GroupsController.cs 921 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using DiffMatchPatch;
  7. using EyeSoft.Collections.Generic;
  8. using EyeSoft.IO;
  9. using Google.Protobuf.WellKnownTypes;
  10. using Microsoft.AspNetCore.SignalR;
  11. using MySqlX.XDevAPI.Relational;
  12. using NetUV.Core.Handles;
  13. using NPOI.HSSF.UserModel;
  14. using NPOI.POIFS.Crypt.Dsig;
  15. using NPOI.POIFS.Properties;
  16. using NPOI.SS.Format;
  17. using NPOI.SS.Formula.Functions;
  18. using NPOI.SS.UserModel;
  19. using NPOI.SS.Util;
  20. using NPOI.XSSF.UserModel;
  21. using OASystem.API.Middlewares;
  22. using OASystem.API.OAMethodLib;
  23. using OASystem.API.OAMethodLib.APNs;
  24. using OASystem.API.OAMethodLib.File;
  25. using OASystem.API.OAMethodLib.Hub.HubClients;
  26. using OASystem.API.OAMethodLib.Hub.Hubs;
  27. using OASystem.API.OAMethodLib.JuHeAPI;
  28. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  29. using OASystem.Domain.AesEncryption;
  30. using OASystem.Domain.Dtos.CRM;
  31. using OASystem.Domain.Dtos.FileDto;
  32. using OASystem.Domain.Dtos.Financial;
  33. using OASystem.Domain.Dtos.Groups;
  34. using OASystem.Domain.Entities.Customer;
  35. using OASystem.Domain.Entities.Financial;
  36. using OASystem.Domain.Entities.Groups;
  37. using OASystem.Domain.ViewModels;
  38. using OASystem.Domain.ViewModels.Financial;
  39. using OASystem.Domain.ViewModels.Groups;
  40. using OASystem.Domain.ViewModels.Statistics;
  41. using OASystem.Infrastructure.Repositories.CRM;
  42. using OASystem.Infrastructure.Repositories.Financial;
  43. using OASystem.Infrastructure.Repositories.Groups;
  44. using OfficeOpenXml;
  45. using Org.BouncyCastle.Asn1.Ocsp;
  46. using Quartz.Util;
  47. using SqlSugar;
  48. using SqlSugar.Extensions;
  49. using System.Collections;
  50. using System.Data;
  51. using System.Data.OleDb;
  52. using System.Diagnostics;
  53. using System.Globalization;
  54. using System.IO;
  55. using System.IO.Compression;
  56. using System.Net.Http;
  57. using System.Reflection.PortableExecutable;
  58. using System.Security.Cryptography;
  59. using Ubiety.Dns.Core;
  60. using static NPOI.POIFS.Crypt.CryptoFunctions;
  61. using static OASystem.API.OAMethodLib.JWTHelper;
  62. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  63. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  64. using Bookmark = Aspose.Words.Bookmark;
  65. using Cell = Aspose.Words.Tables.Cell;
  66. using Table = Aspose.Words.Tables.Table;
  67. namespace OASystem.API.Controllers
  68. {
  69. /// <summary>
  70. /// 团组相关
  71. /// </summary>
  72. //[Authorize]
  73. [Route("api/[controller]/[action]")]
  74. public class GroupsController : ControllerBase
  75. {
  76. private readonly ILogger<GroupsController> _logger;
  77. private readonly GrpScheduleRepository _grpScheduleRep;
  78. private readonly IMapper _mapper;
  79. private readonly DelegationInfoRepository _groupRepository;
  80. private readonly TaskAssignmentRepository _taskAssignmentRep;
  81. private readonly AirTicketResRepository _airTicketResRep;
  82. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  83. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  84. private readonly DelegationEnDataRepository _delegationEnDataRep;
  85. private readonly DelegationVisaRepository _delegationVisaRep;
  86. private readonly VisaPriceRepository _visaPriceRep;
  87. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  88. private readonly HotelPriceRepository _hotelPriceRep;
  89. private readonly CustomersRepository _customersRep;
  90. private readonly MessageRepository _message;
  91. private readonly SqlSugarClient _sqlSugar;
  92. private readonly TourClientListRepository _tourClientListRep;
  93. private readonly TeamRateRepository _teamRateRep;
  94. #region 成本相关
  95. private readonly CheckBoxsRepository _checkBoxs;
  96. private readonly GroupCostRepository _GroupCostRepository;
  97. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  98. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  99. #endregion
  100. private readonly SetDataRepository _setDataRep;
  101. private string url;
  102. private string path;
  103. private readonly EnterExitCostRepository _enterExitCostRep;
  104. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  105. private readonly UsersRepository _usersRep;
  106. private readonly IJuHeApiService _juHeApi;
  107. private readonly InvertedListRepository _invertedListRep;
  108. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  109. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  110. private readonly ThreeCodeRepository _threeCodeRepository;
  111. private readonly HotelInquiryRepository _hotelInquiryRep;
  112. private readonly FeeAuditRepository _feeAuditRep;
  113. private readonly VisaCommissionRepository _visaCommissionRep;
  114. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  115. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  116. private readonly List<CurrencyInfo> _currencyInit;
  117. private readonly List<int> _portTypeData;
  118. private readonly TableOperationRecordRepository _tableorRep;
  119. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  120. /// <summary>
  121. /// 构造函数
  122. /// </summary>
  123. /// <param name="logger"></param>
  124. /// <param name="mapper"></param>
  125. /// <param name="hubContext"></param>
  126. /// <param name="sqlSugar"></param>
  127. /// <param name="grpScheduleRep"></param>
  128. /// <param name="groupRepository"></param>
  129. /// <param name="taskAssignmentRep"></param>
  130. /// <param name="airTicketResRep"></param>
  131. /// <param name="decreasePaymentsRep"></param>
  132. /// <param name="InvitationOfficialActivitiesRep"></param>
  133. /// <param name="delegationEnDataRep"></param>
  134. /// <param name="enterExitCostRep"></param>
  135. /// <param name="delegationVisaRep"></param>
  136. /// <param name="message"></param>
  137. /// <param name="visaPriceRep"></param>
  138. /// <param name="carTouristGuideGroundRep"></param>
  139. /// <param name="checkBoxs"></param>
  140. /// <param name="GroupCostRepository"></param>
  141. /// <param name="CostTypeHotelNumberRepository"></param>
  142. /// <param name="GroupCostParameterRepository"></param>
  143. /// <param name="hotelPriceRep"></param>
  144. /// <param name="customersRep"></param>
  145. /// <param name="setDataRep"></param>
  146. /// <param name="tourClientListRep"></param>
  147. /// <param name="teamRateRep"></param>
  148. /// <param name="usersRep"></param>
  149. /// <param name="juHeApi"></param>
  150. /// <param name="invertedListRep"></param>
  151. /// <param name="visaFeeInfoRep"></param>
  152. /// <param name="ticketBlackCodeRep"></param>
  153. /// <param name="hotelInquiryRep"></param>
  154. /// <param name="threeCodeRepository"></param>
  155. /// <param name="feeAuditRep"></param>
  156. /// <param name="visaCommissionRep"></param>
  157. /// <param name="ffrRep"></param>
  158. /// <param name="opinionaireRep"></param>
  159. /// <param name="tableorRep"></param>
  160. public GroupsController(
  161. ILogger<GroupsController> logger,
  162. IMapper mapper,
  163. IHubContext<ChatHub, IChatClient> hubContext,
  164. SqlSugarClient sqlSugar,
  165. GrpScheduleRepository grpScheduleRep,
  166. DelegationInfoRepository groupRepository,
  167. TaskAssignmentRepository taskAssignmentRep,
  168. AirTicketResRepository airTicketResRep,
  169. DecreasePaymentsRepository decreasePaymentsRep,
  170. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  171. DelegationEnDataRepository delegationEnDataRep,
  172. EnterExitCostRepository enterExitCostRep,
  173. DelegationVisaRepository delegationVisaRep,
  174. MessageRepository message,
  175. VisaPriceRepository visaPriceRep,
  176. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  177. CheckBoxsRepository checkBoxs,
  178. GroupCostRepository GroupCostRepository,
  179. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  180. GroupCostParameterRepository GroupCostParameterRepository,
  181. HotelPriceRepository hotelPriceRep,
  182. CustomersRepository customersRep,
  183. SetDataRepository setDataRep,
  184. TourClientListRepository tourClientListRep,
  185. TeamRateRepository teamRateRep,
  186. UsersRepository usersRep, IJuHeApiService juHeApi,
  187. InvertedListRepository invertedListRep,
  188. VisaFeeInfoRepository visaFeeInfoRep,
  189. TicketBlackCodeRepository ticketBlackCodeRep,
  190. HotelInquiryRepository hotelInquiryRep,
  191. ThreeCodeRepository threeCodeRepository,
  192. FeeAuditRepository feeAuditRep,
  193. VisaCommissionRepository visaCommissionRep,
  194. ForeignReceivablesRepository ffrRep,
  195. OpinionaireRepository opinionaireRep,
  196. TableOperationRecordRepository tableorRep,
  197. EnterExitCostDraftRepository enterExitCostDraftRep
  198. )
  199. {
  200. _logger = logger;
  201. _mapper = mapper;
  202. _grpScheduleRep = grpScheduleRep;
  203. _groupRepository = groupRepository;
  204. _taskAssignmentRep = taskAssignmentRep;
  205. _airTicketResRep = airTicketResRep;
  206. _sqlSugar = sqlSugar;
  207. url = AppSettingsHelper.Get("ExcelBaseUrl");
  208. path = AppSettingsHelper.Get("ExcelBasePath");
  209. if (!System.IO.Directory.Exists(path))
  210. {
  211. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  212. }
  213. _decreasePaymentsRep = decreasePaymentsRep;
  214. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  215. _delegationEnDataRep = delegationEnDataRep;
  216. _enterExitCostRep = enterExitCostRep;
  217. _delegationVisaRep = delegationVisaRep;
  218. _message = message;
  219. _visaPriceRep = visaPriceRep;
  220. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  221. _checkBoxs = checkBoxs;
  222. _GroupCostRepository = GroupCostRepository;
  223. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  224. _GroupCostParameterRepository = GroupCostParameterRepository;
  225. _hotelPriceRep = hotelPriceRep;
  226. _customersRep = customersRep;
  227. _setDataRep = setDataRep;
  228. _tourClientListRep = tourClientListRep;
  229. _teamRateRep = teamRateRep;
  230. _hubContext = hubContext;
  231. _usersRep = usersRep;
  232. _juHeApi = juHeApi;
  233. _invertedListRep = invertedListRep;
  234. _visaFeeInfoRep = visaFeeInfoRep;
  235. _ticketBlackCodeRep = ticketBlackCodeRep;
  236. _hotelInquiryRep = hotelInquiryRep;
  237. _threeCodeRepository = threeCodeRepository;
  238. _feeAuditRep = feeAuditRep;
  239. _visaCommissionRep = visaCommissionRep;
  240. _ffrRep = ffrRep;
  241. _opinionaireRep = opinionaireRep;
  242. _currencyInit = new List<CurrencyInfo>()
  243. {
  244. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  245. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  246. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  247. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  248. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  249. };
  250. _portTypeData = new List<int>() { 2, 3 };
  251. _tableorRep = tableorRep;
  252. _enterExitCostDraftRep = enterExitCostDraftRep;
  253. }
  254. #region 流程管控
  255. /// <summary>
  256. /// 获取团组流程管控信息
  257. /// </summary>
  258. /// <param name="paras">参数Json字符串</param>
  259. /// <returns></returns>
  260. [HttpPost]
  261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  262. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  263. {
  264. if (string.IsNullOrEmpty(_jsonDto.Paras))
  265. {
  266. return Ok(JsonView(false, "参数为空"));
  267. }
  268. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  269. if (_ScheduleDto != null)
  270. {
  271. if (_ScheduleDto.SearchType == 2)//获取列表
  272. {
  273. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  274. return Ok(JsonView(_grpScheduleViewList));
  275. }
  276. else//获取对象
  277. {
  278. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  279. if (_grpScheduleView != null)
  280. {
  281. return Ok(JsonView(_grpScheduleView));
  282. }
  283. }
  284. }
  285. else
  286. {
  287. return Ok(JsonView(false, "参数反序列化失败"));
  288. }
  289. return Ok(JsonView(false, "暂无数据!"));
  290. }
  291. /// <summary>
  292. /// 修改团组流程管控详细表数据
  293. /// </summary>
  294. /// <param name="paras"></param>
  295. /// <returns></returns>
  296. [HttpPost]
  297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  298. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  299. {
  300. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  301. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  302. .SetColumns(it => it.Duty == _detail.Duty)
  303. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  304. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  305. .SetColumns(it => it.JobContent == _detail.JobContent)
  306. .SetColumns(it => it.Remark == _detail.Remark)
  307. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  308. .Where(s => s.Id == dto.Id)
  309. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  310. .ExecuteCommandAsync();
  311. if (result > 0)
  312. {
  313. return Ok(JsonView(true, "保存成功!"));
  314. }
  315. return Ok(JsonView(false, "保存失败!"));
  316. }
  317. /// <summary>
  318. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  319. /// </summary>
  320. /// <param name="dto"></param>
  321. /// <returns></returns>
  322. [HttpPost]
  323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  324. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  325. {
  326. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  327. _detail.IsDel = 1;
  328. _detail.DeleteUserId = dto.Duty;
  329. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  330. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  331. .SetColumns(it => it.IsDel == _detail.IsDel)
  332. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  333. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  334. .Where(it => it.Id == dto.Id)
  335. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  336. //.WhereColumns(s => s.Id == dto.Id)
  337. .ExecuteCommandAsync();
  338. if (result > 0)
  339. {
  340. return Ok(JsonView(true, "删除成功!"));
  341. }
  342. return Ok(JsonView(false, "删除失败!"));
  343. }
  344. /// <summary>
  345. /// 增加团组流程管控详细表数据
  346. /// </summary>
  347. /// <param name="dto"></param>
  348. /// <returns></returns>
  349. [HttpPost]
  350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  351. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  352. {
  353. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  354. if (DateTime.Now < _detail.ExpectBeginDt)
  355. {
  356. _detail.StepStatus = 0;
  357. }
  358. else
  359. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  360. _detail.StepStatus = 1;
  361. }
  362. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  363. if (result > 0)
  364. {
  365. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  366. return Ok(JsonView(true, "添加成功!", _result));
  367. }
  368. return Ok(JsonView(false, "添加失败!"));
  369. }
  370. #endregion
  371. #region 团组基本信息
  372. /// <summary>
  373. /// 接团信息列表
  374. /// </summary>
  375. /// <param name="dto">团组列表请求dto</param>
  376. /// <returns></returns>
  377. [HttpPost]
  378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  379. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  380. {
  381. var groupData = await _groupRepository.GetGroupList(dto);
  382. if (groupData.Code != 0)
  383. {
  384. return Ok(JsonView(false, groupData.Msg));
  385. }
  386. return Ok(JsonView(groupData.Data));
  387. }
  388. /// <summary>
  389. /// 分页查询团组列表
  390. /// </summary>
  391. /// <param name="dto"></param>
  392. /// <returns></returns>
  393. [HttpPost]
  394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  395. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  396. {
  397. var watch = new Stopwatch();
  398. watch.Start();
  399. RefAsync<int> total = 0;
  400. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  401. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  402. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  403. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  404. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  405. .Distinct()
  406. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  407. watch.Stop();
  408. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  409. }
  410. /// <summary>
  411. /// 接团信息列表 Page
  412. /// </summary>
  413. /// <param name="dto">团组列表请求dto</param>
  414. /// <returns></returns>
  415. [HttpPost]
  416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  417. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  418. {
  419. #region 参数验证
  420. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  421. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  422. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  423. #region 页面操作权限验证
  424. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  425. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  426. #endregion
  427. #endregion
  428. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  429. {
  430. string sqlWhere = string.Empty;
  431. if (dto.IsSure == 0) //未完成
  432. {
  433. sqlWhere += string.Format(@" And IsSure = 0");
  434. }
  435. else if (dto.IsSure == 1) //已完成
  436. {
  437. sqlWhere += string.Format(@" And IsSure = 1");
  438. }
  439. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  440. {
  441. string tj = dto.SearchCriteria;
  442. 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}%')",
  443. tj, tj, tj, tj, tj);
  444. }
  445. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  446. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  447. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  448. JietuanOperator,IsSure,CreateTime,IsBid
  449. From (
  450. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  451. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  452. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  453. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  454. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  455. From Grp_DelegationInfo gdi
  456. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  457. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  458. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  459. Where gdi.IsDel = 0 {0}
  460. ) temp", sqlWhere);
  461. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  462. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  463. #region 处理所属部门
  464. /*
  465. * 1.sq 和 gyy 等显示 市场部
  466. * 2.王鸽和主管及张总还有管理员号统一国交部
  467. * 2-1. 4 管理员 ,21 张海麟
  468. */
  469. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  470. List<int> userIds1 = new List<int>() { 4, 21 };
  471. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  472. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  473. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  474. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  475. .ToList();
  476. foreach (var item in _DelegationList)
  477. {
  478. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  479. }
  480. #endregion
  481. var _view = new
  482. {
  483. PageFuncAuth = pageFunAuthView,
  484. Data = _DelegationList
  485. };
  486. return Ok(JsonView(true, "查询成功!", _view, total));
  487. }
  488. else
  489. {
  490. return Ok(JsonView(false, "查询失败"));
  491. }
  492. }
  493. /// <summary>
  494. /// 团组列表
  495. /// </summary>
  496. /// <returns></returns>
  497. [HttpPost]
  498. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  499. {
  500. #region 参数验证
  501. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  502. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  503. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  504. #region 页面操作权限验证
  505. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  506. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  507. #endregion
  508. #endregion
  509. if (dto.PortType != 1 && dto.PortType != 2)
  510. {
  511. return Ok(JsonView(false, "查询失败!"));
  512. }
  513. string orderbyStr = "order by gdi.CreateTime Desc";
  514. string sqlWhere = string.Empty;
  515. if (dto.IsSure == 0) //未完成
  516. {
  517. sqlWhere += string.Format(@" And IsSure = 0");
  518. }
  519. else if (dto.IsSure == 1) //已完成
  520. {
  521. sqlWhere += string.Format(@" And IsSure = 1");
  522. }
  523. //团组类型
  524. if (dto.TeamDid > 0)
  525. {
  526. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  527. }
  528. //团组名称
  529. if (!string.IsNullOrEmpty(dto.TeamName))
  530. {
  531. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  532. }
  533. //客户名称
  534. if (!string.IsNullOrEmpty(dto.ClientName))
  535. {
  536. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  537. }
  538. //客户单位
  539. if (!string.IsNullOrEmpty(dto.ClientUnit))
  540. {
  541. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  542. }
  543. //出访时间
  544. if (!string.IsNullOrEmpty(dto.visitDataTime))
  545. {
  546. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  547. orderbyStr = "order by gdi.VisitDate";
  548. }
  549. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  550. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  551. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  552. JietuanOperator,IsSure,CreateTime
  553. From (
  554. Select row_number() over({0}) as Row_Number,
  555. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  556. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  557. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  558. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  559. From Grp_DelegationInfo gdi
  560. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  561. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  562. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  563. Where gdi.IsDel = 0 {1}
  564. ) temp ", orderbyStr, sqlWhere);
  565. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  566. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  567. #region 处理所属部门
  568. /*
  569. * 1.sq 和 gyy 等显示 市场部
  570. * 2.王鸽和主管及张总还有管理员号统一国交部
  571. * 2-1. 4 管理员 ,21 张海麟
  572. */
  573. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  574. List<int> userIds1 = new List<int>() { 4, 21 };
  575. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  576. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  577. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  578. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  579. .ToList();
  580. foreach (var item in _DelegationList)
  581. {
  582. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  583. }
  584. #endregion
  585. var _view = new
  586. {
  587. PageFuncAuth = pageFunAuthView,
  588. Data = _DelegationList
  589. };
  590. return Ok(JsonView(true, "查询成功!", _view, total));
  591. }
  592. /// <summary>
  593. /// 接团信息详情
  594. /// </summary>
  595. /// <param name="dto">团组info请求dto</param>
  596. /// <returns></returns>
  597. [HttpPost]
  598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  599. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  600. {
  601. var groupData = await _groupRepository.GetGroupInfo(dto);
  602. if (groupData.Code != 0)
  603. {
  604. return Ok(JsonView(false, groupData.Msg));
  605. }
  606. return Ok(JsonView(groupData.Data));
  607. }
  608. /// <summary>
  609. /// 接团信息 编辑添加
  610. /// 基础信息数据源
  611. /// </summary>
  612. /// <param name="dto"></param>
  613. /// <returns></returns>
  614. [HttpPost]
  615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  616. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  617. {
  618. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  619. if (groupData.Code != 0)
  620. {
  621. return Ok(JsonView(false, groupData.Msg));
  622. }
  623. return Ok(JsonView(groupData.Data));
  624. }
  625. /// <summary>
  626. /// 接团信息 操作(增改)
  627. /// </summary>
  628. /// <param name="dto"></param>
  629. /// <returns></returns>
  630. [HttpPost]
  631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  632. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  633. {
  634. // 创建 Stopwatch 实例
  635. Stopwatch stopwatch = Stopwatch.StartNew();
  636. decimal ffrPrice = 0.00M;
  637. DateTime? visitDt = null;
  638. if (dto.Status == 2)
  639. {
  640. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  641. if (groupInfo != null)
  642. {
  643. ffrPrice = groupInfo.PaymentMoney;
  644. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  645. }
  646. }
  647. var groupData = await _groupRepository.GroupOperation(dto);
  648. if (groupData.Code != 0)
  649. {
  650. return Ok(JsonView(false, groupData.Msg));
  651. }
  652. int diId = 0;
  653. try
  654. {
  655. //添加时 默认加入团组汇率
  656. if (dto.Status == 1) //添加
  657. {
  658. diId = groupData.Data;
  659. //添加默认币种
  660. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  661. //默认分配权限
  662. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  663. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  664. var _managerIds = new List<int>() { 22, 32, 21 };
  665. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  666. if (userIds.Count > 0)
  667. {
  668. userIds.Add(208);
  669. //创建团组管控
  670. GroupStepForDelegation.CreateWorkStep(diId);
  671. //发送消息
  672. string groupName = dto.TeamName;
  673. string createGroupUser = string.Empty;
  674. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  675. if (userInfo != null) createGroupUser = userInfo.CnName;
  676. string title = $"系统通知";
  677. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  678. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  679. }
  680. //默认创建倒推表
  681. await _invertedListRep._Create(dto.UserId, diId);
  682. }
  683. else if (dto.Status == 2)
  684. {
  685. diId = dto.Id;
  686. }
  687. #region 签证人员团组时间通知
  688. #region 计算出访起止时间
  689. var startTime = new DateTime();
  690. var endTime = new DateTime();
  691. if (DateTime.TryParse(dto.VisitDate, out startTime))
  692. {
  693. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  694. }
  695. #endregion
  696. #endregion
  697. #region 团组操作默认添加/修改收款账单
  698. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  699. {
  700. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  701. .Where(x => x.IsDel == 0 &&
  702. x.Diid == diId &&
  703. x.Remark.Equals("预付款")
  704. )
  705. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  706. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  707. .FirstAsync();
  708. ffrInfo = new Fin_ForeignReceivables()
  709. {
  710. Diid = diId,
  711. PriceName = dto.ClientUnit,
  712. Price = dto.PaymentMoney,
  713. Count = 1,
  714. Unit = $"元",
  715. ItemSumPrice = dto.PaymentMoney,
  716. Rate = 1.0000M,
  717. Currency = 836,
  718. AddingWay = 0,
  719. CreateUserId = dto.UserId,
  720. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  721. Remark = $"预付款"
  722. };
  723. if (ffrInfo == null) //Add
  724. {
  725. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  726. }
  727. else //修改
  728. {
  729. await _sqlSugar.Updateable(ffrInfo)
  730. .UpdateColumns(x => new
  731. {
  732. x.PriceName,
  733. x.Price,
  734. x.ItemSumPrice,
  735. x.CreateTime,
  736. x.CreateUserId
  737. })
  738. .WhereColumns(x => x.Id)
  739. .ExecuteCommandAsync();
  740. }
  741. }
  742. #endregion
  743. if (diId > 0)
  744. {
  745. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  746. }
  747. // 停止计时
  748. stopwatch.Stop();
  749. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  750. }
  751. catch (Exception ex)
  752. {
  753. // 停止计时
  754. stopwatch.Stop();
  755. Logs("[response]" + JsonConvert.SerializeObject(dto));
  756. Logs(ex.Message);
  757. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  758. }
  759. // 停止计时
  760. stopwatch.Stop();
  761. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  762. }
  763. /// <summary>
  764. /// 接团流程操作(增改)
  765. /// 安卓端使用 建团时添加客户名单
  766. /// </summary>
  767. /// <param name="dto"></param>
  768. /// <returns></returns>
  769. [HttpPost]
  770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  771. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  772. {
  773. #region 参数验证
  774. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  775. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  776. #region 页面操作权限验证
  777. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  778. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  779. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  780. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  781. #endregion
  782. #endregion
  783. try
  784. {
  785. //_sqlSugar.BeginTran();
  786. decimal ffrPrice = 0.00M;
  787. DateTime? visitDt = null;
  788. if (dto.Status == 2)
  789. {
  790. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  791. if (groupInfo != null)
  792. {
  793. ffrPrice = groupInfo.PaymentMoney;
  794. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  795. }
  796. }
  797. var _dto = new GroupOperationDto();
  798. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  799. var groupData = await _groupRepository.GroupOperation(_dto);
  800. if (groupData.Code != 0)
  801. {
  802. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  803. }
  804. int diId = 0;
  805. //添加时 默认加入团组汇率
  806. if (dto.Status == 1) //添加
  807. {
  808. diId = groupData.Data;
  809. //添加默认币种
  810. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  811. //默认分配权限
  812. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  813. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  814. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  815. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  816. if (userIds.Count > 0)
  817. {
  818. userIds.Add(208);
  819. //创建团组管控
  820. GroupStepForDelegation.CreateWorkStep(diId);
  821. //发送消息
  822. string groupName = dto.TeamName;
  823. string createGroupUser = string.Empty;
  824. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  825. if (userInfo != null) createGroupUser = userInfo.CnName;
  826. string title = $"系统通知";
  827. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  828. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  829. }
  830. #region 应用推送
  831. try
  832. {
  833. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  834. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  835. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  836. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  837. {
  838. List<string> userList = new List<string>() { users.QiyeChatUserId };
  839. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  840. }
  841. }
  842. catch (Exception ex)
  843. {
  844. }
  845. #endregion
  846. //默认创建倒推表
  847. await _invertedListRep._Create(dto.UserId, diId);
  848. }
  849. if (dto.Status == 2)
  850. {
  851. diId = dto.Id;
  852. if (diId == 0)
  853. {
  854. //_sqlSugar.RollbackTran();
  855. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  856. }
  857. }
  858. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  859. if (viewData.Code != 0)
  860. {
  861. //_sqlSugar.RollbackTran();
  862. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  863. }
  864. #region 团组操作默认添加/修改收款账单
  865. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  866. {
  867. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  868. .Where(x => x.IsDel == 0 &&
  869. x.Diid == diId &&
  870. x.Remark.Equals("预付款")
  871. )
  872. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  873. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  874. .FirstAsync();
  875. ffrInfo = new Fin_ForeignReceivables()
  876. {
  877. Diid = diId,
  878. PriceName = dto.ClientUnit,
  879. Price = dto.PaymentMoney,
  880. Count = 1,
  881. Unit = $"元",
  882. ItemSumPrice = dto.PaymentMoney,
  883. Rate = 1.0000M,
  884. Currency = 836,
  885. AddingWay = 0,
  886. CreateUserId = dto.UserId,
  887. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  888. Remark = $"预付款"
  889. };
  890. if (ffrInfo == null) //Add
  891. {
  892. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  893. }
  894. else //修改
  895. {
  896. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  897. .UpdateColumns(x => new
  898. {
  899. x.PriceName,
  900. x.Price,
  901. x.ItemSumPrice,
  902. x.CreateTime,
  903. x.CreateUserId
  904. })
  905. .WhereColumns(x => x.Id)
  906. .ExecuteCommandAsync();
  907. }
  908. }
  909. #endregion
  910. #region 签证人员团组时间通知
  911. #region 计算出访起止时间
  912. var startTime = new DateTime();
  913. var endTime = new DateTime();
  914. if (DateTime.TryParse(dto.VisitDate, out startTime))
  915. {
  916. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  917. }
  918. #endregion
  919. if (diId > 0)
  920. {
  921. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  922. }
  923. #endregion
  924. //_sqlSugar.CommitTran();
  925. return Ok(JsonView(true, "添加成功"));
  926. }
  927. catch (Exception ex)
  928. {
  929. _sqlSugar.RollbackTran();
  930. return Ok(JsonView(false, ex.Message));
  931. }
  932. }
  933. /// <summary>
  934. /// 接团流程操作(增改)
  935. /// 安卓端使用 建团时添加客户名单
  936. /// </summary>
  937. /// <param name="dto"></param>
  938. /// <returns></returns>
  939. [HttpPost]
  940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  941. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  942. {
  943. #region 参数验证
  944. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  945. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  946. #region 页面操作权限验证
  947. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  948. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  949. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  950. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  951. #endregion
  952. #endregion
  953. _sqlSugar.BeginTran();
  954. decimal ffrPrice = 0.00M;
  955. DateTime? visitDt = null;
  956. if (dto.Status == 2)
  957. {
  958. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  959. if (groupInfo != null)
  960. {
  961. ffrPrice = groupInfo.PaymentMoney;
  962. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  963. }
  964. }
  965. var _dto = new GroupOperationDto();
  966. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  967. var groupData = await _groupRepository.GroupOperation(_dto);
  968. if (groupData.Code != 0)
  969. {
  970. _sqlSugar.RollbackTran();
  971. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  972. }
  973. try
  974. {
  975. int diId = 0;
  976. //添加时 默认加入团组汇率
  977. if (dto.Status == 1) //添加
  978. {
  979. diId = groupData.Data;
  980. //添加默认币种
  981. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  982. //默认分配权限
  983. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  984. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  985. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  986. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  987. if (userIds.Count > 0)
  988. {
  989. userIds.Add(208);
  990. //创建团组管控
  991. GroupStepForDelegation.CreateWorkStep(diId);
  992. //发送消息
  993. string groupName = dto.TeamName;
  994. string createGroupUser = string.Empty;
  995. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  996. if (userInfo != null) createGroupUser = userInfo.CnName;
  997. string title = $"系统通知";
  998. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  999. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1000. }
  1001. #region 应用推送
  1002. try
  1003. {
  1004. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1005. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1006. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1007. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1008. {
  1009. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1010. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1011. }
  1012. }
  1013. catch (Exception ex)
  1014. {
  1015. _sqlSugar.CommitTran();
  1016. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1017. }
  1018. #endregion
  1019. //默认创建倒推表
  1020. await _invertedListRep._Create(dto.UserId, diId);
  1021. }
  1022. else if (dto.Status == 2)
  1023. {
  1024. diId = dto.Id;
  1025. if (diId == 0)
  1026. {
  1027. _sqlSugar.RollbackTran();
  1028. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1029. }
  1030. }
  1031. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1032. if (viewData.Code != 0)
  1033. {
  1034. _sqlSugar.RollbackTran();
  1035. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1036. }
  1037. #region 团组操作默认添加/修改收款账单
  1038. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1039. {
  1040. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1041. .Where(x => x.IsDel == 0 &&
  1042. x.Diid == diId &&
  1043. x.Remark.Equals("预付款")
  1044. )
  1045. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1046. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1047. .FirstAsync();
  1048. ffrInfo = new Fin_ForeignReceivables()
  1049. {
  1050. Diid = diId,
  1051. PriceName = dto.ClientUnit,
  1052. Price = dto.PaymentMoney,
  1053. Count = 1,
  1054. Unit = $"元",
  1055. ItemSumPrice = dto.PaymentMoney,
  1056. Rate = 1.0000M,
  1057. Currency = 836,
  1058. AddingWay = 0,
  1059. CreateUserId = dto.UserId,
  1060. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1061. Remark = $"预付款"
  1062. };
  1063. if (ffrInfo == null) //Add
  1064. {
  1065. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1066. }
  1067. else //修改
  1068. {
  1069. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1070. .UpdateColumns(x => new
  1071. {
  1072. x.PriceName,
  1073. x.Price,
  1074. x.ItemSumPrice,
  1075. x.CreateTime,
  1076. x.CreateUserId
  1077. })
  1078. .WhereColumns(x => x.Id)
  1079. .ExecuteCommandAsync();
  1080. }
  1081. }
  1082. #endregion
  1083. #region 签证人员团组时间通知
  1084. #region 计算出访起止时间
  1085. var startTime = new DateTime();
  1086. var endTime = new DateTime();
  1087. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1088. {
  1089. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1090. }
  1091. #endregion
  1092. if (diId > 0)
  1093. {
  1094. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1095. }
  1096. #endregion
  1097. _sqlSugar.CommitTran();
  1098. return Ok(JsonView(true));
  1099. }
  1100. catch (Exception ex)
  1101. {
  1102. _sqlSugar.RollbackTran();
  1103. return Ok(JsonView(false, ex.Message));
  1104. }
  1105. }
  1106. /// <summary>
  1107. /// 接团信息 操作(删除)
  1108. /// </summary>
  1109. /// <param name="dto"></param>
  1110. /// <returns></returns>
  1111. [HttpPost]
  1112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1113. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1114. {
  1115. var diId = dto.Id;
  1116. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1117. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1118. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1119. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1120. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1121. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1122. #endregion
  1123. var groupData = await _groupRepository.GroupDel(dto);
  1124. if (groupData.Code != 0)
  1125. {
  1126. return Ok(JsonView(false, groupData.Msg));
  1127. }
  1128. return Ok(JsonView(true));
  1129. }
  1130. /// <summary>
  1131. /// 获取团组销售报价号
  1132. /// 团组添加时 使用
  1133. /// </summary>
  1134. /// <returns></returns>
  1135. [HttpPost]
  1136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1137. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1138. {
  1139. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1140. if (groupData.Code != 0)
  1141. {
  1142. return Ok(JsonView(false, groupData.Msg));
  1143. }
  1144. object salesQuoteNo = new
  1145. {
  1146. SalesQuoteNo = groupData.Data
  1147. };
  1148. return Ok(JsonView(salesQuoteNo));
  1149. }
  1150. /// <summary>
  1151. /// 设置确认出团
  1152. /// </summary>
  1153. /// <param name="dto"></param>
  1154. /// <returns></returns>
  1155. [HttpPost]
  1156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1157. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1158. {
  1159. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1160. if (groupData.Code != 0)
  1161. {
  1162. return Ok(JsonView(false, groupData.Msg));
  1163. }
  1164. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1165. #region OA消息推送
  1166. try
  1167. {
  1168. string groupName = groupInfo.TeamName;
  1169. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1170. string title = $"系统通知";
  1171. string content = $"团组[{groupName}]已确认出团!";
  1172. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1173. }
  1174. catch (Exception ex)
  1175. {
  1176. }
  1177. #endregion
  1178. #region 应用推送
  1179. try
  1180. {
  1181. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1182. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1183. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1184. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1185. {
  1186. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1187. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1188. }
  1189. }
  1190. catch (Exception ex)
  1191. {
  1192. }
  1193. #endregion
  1194. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1195. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1196. }
  1197. /// <summary>
  1198. /// 获取团组名称data And 签证国别Data
  1199. /// </summary>
  1200. /// <param name="dto"></param>
  1201. /// <returns></returns>
  1202. [HttpPost]
  1203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1204. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1205. {
  1206. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1207. if (groupData.Code != 0)
  1208. {
  1209. return Ok(JsonView(false, groupData.Msg));
  1210. }
  1211. return Ok(JsonView(groupData.Data));
  1212. }
  1213. /// <summary>
  1214. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1215. /// </summary>
  1216. /// <returns></returns>
  1217. [HttpPost]
  1218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1219. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1220. {
  1221. try
  1222. {
  1223. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1224. if (groupData.Code != 0)
  1225. {
  1226. return Ok(JsonView(false, groupData.Msg));
  1227. }
  1228. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1229. }
  1230. catch (Exception ex)
  1231. {
  1232. return Ok(JsonView(false, "程序错误!"));
  1233. throw;
  1234. }
  1235. }
  1236. /// <summary>
  1237. /// 团组清单 Excel
  1238. /// </summary>
  1239. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1240. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1241. /// <returns></returns>
  1242. [HttpGet]
  1243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1244. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1245. {
  1246. DateTime _beginDt, _endDt;
  1247. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1248. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1249. if (!beginBool && !endBool)
  1250. {
  1251. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1252. }
  1253. string sql = string.Format(@"
  1254. SELECT
  1255. ROW_NUMBER,
  1256. Id,
  1257. SalesQuoteNo,
  1258. TourCode,
  1259. TeamTypeId,
  1260. TeamType,
  1261. TeamLevId,
  1262. TeamLev,
  1263. TeamName,
  1264. ClientName,
  1265. ClientUnit,
  1266. VisitDate,
  1267. VisitDays,
  1268. VisitPNumber,
  1269. JietuanOperatorId,
  1270. JietuanOperator,
  1271. IsSure,
  1272. CreateUserName,
  1273. IsBid
  1274. FROM
  1275. (
  1276. SELECT
  1277. ROW_NUMBER() OVER(
  1278. ORDER BY
  1279. gdi.CreateTime Desc
  1280. ) AS ROW_NUMBER,
  1281. gdi.Id,
  1282. SalesQuoteNo,
  1283. TourCode,
  1284. ssd.Id TeamTypeId,
  1285. ssd.Name TeamType,
  1286. ssd1.Id TeamLevId,
  1287. ssd1.Name TeamLev,
  1288. TeamName,
  1289. ClientName,
  1290. ClientUnit,
  1291. VisitDate,
  1292. VisitDays,
  1293. VisitPNumber,
  1294. JietuanOperator JietuanOperatorId,
  1295. su.CnName JietuanOperator,
  1296. IsSure,
  1297. gdi.CreateTime,
  1298. su1.CnName As CreateUserName,
  1299. gdi.IsBid
  1300. FROM
  1301. Grp_DelegationInfo gdi
  1302. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1303. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1304. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1305. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1306. WHERE
  1307. gdi.IsDel = 0
  1308. AND gdi.IsBid = 0
  1309. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1310. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1311. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1312. #region 处理所属部门
  1313. /*
  1314. * 1.sq 和 gyy 等显示 市场部
  1315. * 2.王鸽和主管及张总还有管理员号统一国交部
  1316. * 2-1. 4 管理员 ,21 张海麟
  1317. */
  1318. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1319. List<int> userIds1 = new List<int>() { 4, 21 };
  1320. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1321. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1322. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1323. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1324. .ToListAsync();
  1325. var droupIds = groupList.Select(it => it.Id).ToList();
  1326. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1327. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1328. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1329. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1330. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1331. {
  1332. DiId = tcl.DiId,
  1333. LastName = dc.LastName,
  1334. FirstName = dc.FirstName,
  1335. Sex = dc.Sex,
  1336. Birthday = dc.BirthDay,
  1337. Company = cc.CompanyFullName,
  1338. Job = dc.Job,
  1339. CreateTime = tcl.CreateTime,
  1340. })
  1341. .ToList();
  1342. foreach (var item in groupList)
  1343. {
  1344. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1345. string groupFirstName = "";
  1346. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1347. if (currDatas.Any())
  1348. {
  1349. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1350. }
  1351. item.GroupFirst = groupFirstName;
  1352. }
  1353. #endregion
  1354. #region Excel
  1355. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1356. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1357. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1358. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1359. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1360. //载入模板
  1361. WorkbookDesigner designer = new WorkbookDesigner();
  1362. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1363. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1364. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1365. dt.TableName = "GroupList";
  1366. designer.SetDataSource(dt);
  1367. designer.Process();
  1368. if (!Directory.Exists(savePath))
  1369. {
  1370. Directory.CreateDirectory(savePath);
  1371. }
  1372. string serverPath = $"{savePath}{fileName}";
  1373. designer.Workbook.Save(serverPath);
  1374. string rst = $"{servicePath}{ftpPath}{fileName}";
  1375. #endregion
  1376. return Ok(JsonView(true, "操作成功!", rst));
  1377. }
  1378. #endregion
  1379. #region 团组&签证
  1380. /// <summary>
  1381. /// 根据团组Id获取签证客户信息List
  1382. /// </summary>
  1383. /// <param name="dto">请求dto</param>
  1384. /// <returns></returns>
  1385. [HttpPost]
  1386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1387. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1388. {
  1389. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1390. if (groupData.Code != 0)
  1391. {
  1392. return Ok(JsonView(false, groupData.Msg));
  1393. }
  1394. return Ok(JsonView(groupData.Data));
  1395. }
  1396. /// <summary>
  1397. /// IOS获取团组签证拍照上传进度01(团组列表)
  1398. /// </summary>
  1399. /// <param name="dto">请求dto</param>
  1400. /// <returns></returns>
  1401. [HttpPost]
  1402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1403. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1404. {
  1405. if (dto == null)
  1406. {
  1407. return Ok(JsonView(false, "参数为空"));
  1408. }
  1409. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1410. return Ok(JsonView(visaList));
  1411. }
  1412. /// <summary>
  1413. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1414. /// </summary>
  1415. /// <returns></returns>
  1416. [HttpPost]
  1417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1418. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1419. {
  1420. if (dto == null)
  1421. {
  1422. return Ok(JsonView(false, "请求错误:"));
  1423. }
  1424. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1425. return Ok(JsonView(list));
  1426. }
  1427. /// <summary>
  1428. /// IOS获取团组签证拍照上传进度03(相册)
  1429. /// </summary>
  1430. /// <returns></returns>
  1431. [HttpPost]
  1432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1433. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1434. {
  1435. if (dto == null)
  1436. {
  1437. return Ok(JsonView(false, "请求错误:"));
  1438. }
  1439. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1440. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1441. list.ForEach(s => s.url = url);
  1442. return Ok(JsonView(list));
  1443. }
  1444. /// <summary>
  1445. /// IOS获取团组签证拍照上传进度04(图片上传)
  1446. /// </summary>
  1447. /// <param name="dto"></param>
  1448. /// <returns></returns>
  1449. [HttpPost]
  1450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1451. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1452. {
  1453. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1454. //if (!string.IsNullOrEmpty(result))
  1455. //{
  1456. //}
  1457. //else {
  1458. // return Ok(JsonView(false, "上传失败"));
  1459. //}
  1460. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1461. int sucNum = 0;
  1462. try
  1463. {
  1464. foreach (var item in dto.base64DataList)
  1465. {
  1466. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1467. string result = decodeBase64ToImage(item, imageName);
  1468. if (!string.IsNullOrEmpty(result))
  1469. {
  1470. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1471. pic.CreateUserId = dto.CreateUserId;
  1472. pic.PicName = imageName;
  1473. pic.PicPath = result;
  1474. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1475. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1476. if (insertResult > 0)
  1477. {
  1478. sucNum++;
  1479. }
  1480. }
  1481. }
  1482. }
  1483. catch (Exception ex)
  1484. {
  1485. return Ok(JsonView(false, ex.Message));
  1486. }
  1487. string msg = string.Format(@"成功上传{0}张", sucNum);
  1488. return Ok(JsonView(true, msg));
  1489. }
  1490. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1491. {
  1492. string filename = "";//声明一个string类型的相对路径
  1493. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1494. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1495. try//会有异常抛出,try,catch一下
  1496. {
  1497. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1498. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1499. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1500. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1501. //文件名称
  1502. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1503. //上传的文件的路径
  1504. string filePath = "";
  1505. if (!Directory.Exists(fileDir))
  1506. {
  1507. Directory.CreateDirectory(fileDir);
  1508. }
  1509. //上传的文件的路径
  1510. filePath = fileDir + filename;
  1511. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1512. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1513. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1514. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1515. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1516. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1517. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1518. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1519. bitmap.Dispose();
  1520. }
  1521. catch (Exception e)
  1522. {
  1523. string massage = e.Message;
  1524. Logs("IOS图片上传Error:" + massage);
  1525. //filename = e.Message;
  1526. }
  1527. return filename;//返回相对路径
  1528. }
  1529. /// <summary>
  1530. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1531. /// </summary>
  1532. /// <param name="dto"></param>
  1533. /// <returns></returns>
  1534. [HttpPost]
  1535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1536. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1537. {
  1538. if (dto == null)
  1539. {
  1540. return Ok(JsonView(false, "请求错误:"));
  1541. }
  1542. string msg = "参数错误";
  1543. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1544. {
  1545. try
  1546. {
  1547. //_delegationVisaRep.BeginTran();
  1548. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1549. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1550. .Where(s => s.Id == dto.visaProgressCustomerId)
  1551. .ExecuteCommandAsync();
  1552. if (updCount > 0 && dto.publishCode == 1)
  1553. {
  1554. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1555. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1556. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1557. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1558. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1559. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1560. if (groupData == null)
  1561. {
  1562. _delegationVisaRep.RollbackTran();
  1563. }
  1564. string title = string.Format(@"[签证进度更新]");
  1565. string content = string.Format(@"测试文本");
  1566. bool rst = await _message.AddMsg(new MessageDto()
  1567. {
  1568. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1569. IssuerId = dto.publisher,
  1570. Title = title,
  1571. Content = content,
  1572. ReleaseTime = DateTime.Now,
  1573. UIdList = new List<int> {
  1574. 234
  1575. }
  1576. });
  1577. if (rst)
  1578. {
  1579. return Ok(JsonView(true, "发送通知成功"));
  1580. }
  1581. }
  1582. //_delegationVisaRep.CommitTran();
  1583. }
  1584. catch (Exception)
  1585. {
  1586. //_delegationVisaRep.RollbackTran();
  1587. }
  1588. }
  1589. return Ok(JsonView(true, msg));
  1590. }
  1591. #endregion
  1592. #region 团组任务分配
  1593. /// <summary>
  1594. /// 团组任务分配初始化
  1595. /// </summary>
  1596. /// <param name="dto"></param>
  1597. /// <returns></returns>
  1598. [HttpPost]
  1599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1600. public async Task<IActionResult> GetTaskAssignmen()
  1601. {
  1602. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1603. if (groupData.Code != 0)
  1604. {
  1605. return Ok(JsonView(false, groupData.Msg));
  1606. }
  1607. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1608. }
  1609. /// <summary>
  1610. /// 团组任务分配查询
  1611. /// </summary>
  1612. /// <param name="dto"></param>
  1613. /// <returns></returns>
  1614. [HttpPost]
  1615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1616. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1617. {
  1618. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1619. if (groupData.Code != 0)
  1620. {
  1621. return Ok(JsonView(false, groupData.Msg));
  1622. }
  1623. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1624. }
  1625. /// <summary>
  1626. /// 团组任务分配操作
  1627. /// </summary>
  1628. /// <param name="dto"></param>
  1629. /// <returns></returns>
  1630. [HttpPost]
  1631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1632. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1633. {
  1634. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1635. if (groupData.Code != 0)
  1636. {
  1637. return Ok(JsonView(false, groupData.Msg));
  1638. }
  1639. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1640. }
  1641. /// <summary>
  1642. /// 团组任务分配
  1643. /// 批量分配
  1644. /// 查询团组
  1645. /// </summary>
  1646. /// <param name="dto"></param>
  1647. /// <returns></returns>
  1648. [HttpPost]
  1649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1650. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1651. {
  1652. //参数验证
  1653. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1654. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1655. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1656. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1657. }
  1658. /// <summary>
  1659. /// 团组任务分配
  1660. /// 批量分配
  1661. /// </summary>
  1662. /// <param name="dto"></param>
  1663. /// <returns></returns>
  1664. [HttpPost]
  1665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1666. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1667. {
  1668. //参数验证
  1669. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1670. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1671. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1672. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1673. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1674. }
  1675. #endregion
  1676. #region 团组费用审核
  1677. /// <summary>
  1678. /// 费用审核
  1679. /// 团组列表 Page
  1680. /// </summary>
  1681. /// <param name="_dto">团组列表请求dto</param>
  1682. /// <returns></returns>
  1683. [HttpPost]
  1684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1685. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1686. {
  1687. #region 参数验证
  1688. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1689. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1690. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1691. #region 页面操作权限验证
  1692. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1693. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1694. #endregion
  1695. #endregion
  1696. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1697. {
  1698. string sqlWhere = string.Empty;
  1699. if (_dto.IsSure == 0) //未完成
  1700. {
  1701. sqlWhere += string.Format(@" And IsSure = 0");
  1702. }
  1703. else if (_dto.IsSure == 1) //已完成
  1704. {
  1705. sqlWhere += string.Format(@" And IsSure = 1");
  1706. }
  1707. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1708. {
  1709. string tj = _dto.SearchCriteria;
  1710. 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}%')",
  1711. tj, tj, tj, tj, tj);
  1712. }
  1713. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1714. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1715. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1716. From (
  1717. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1718. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1719. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1720. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1721. From Grp_DelegationInfo gdi
  1722. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1723. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1724. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1725. Where gdi.IsDel = 0 {0}
  1726. ) temp ", sqlWhere);
  1727. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1728. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1729. var _view = new
  1730. {
  1731. PageFuncAuth = pageFunAuthView,
  1732. Data = _DelegationList
  1733. };
  1734. return Ok(JsonView(true, "查询成功!", _view, total));
  1735. }
  1736. else
  1737. {
  1738. return Ok(JsonView(false, "查询失败"));
  1739. }
  1740. }
  1741. /// <summary>
  1742. /// 获取团组费用审核
  1743. /// </summary>
  1744. /// <param name="paras">参数Json字符串</param>
  1745. /// <returns></returns>
  1746. [HttpPost]
  1747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1748. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1749. {
  1750. try
  1751. {
  1752. #region 参数验证
  1753. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1754. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1755. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1756. #region 页面操作权限验证
  1757. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1758. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1759. #endregion
  1760. #endregion
  1761. var _view = new Grp_CreditCardPaymentView();
  1762. var clientNameList = getSimplClientList(_dto.DiId);
  1763. #region 费用清单
  1764. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1765. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1766. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1767. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1768. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1769. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1770. /*
  1771. * 76://酒店预订
  1772. */
  1773. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1774. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1775. /*
  1776. * 79://车/导游地接
  1777. */
  1778. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1779. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1780. /*
  1781. * 80: //签证
  1782. */
  1783. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1784. /*
  1785. *81: //邀请/公务活动
  1786. */
  1787. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1788. /*
  1789. * 82: //团组客户保险
  1790. */
  1791. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1792. /*
  1793. * Lable = 85 机票预订
  1794. */
  1795. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1796. /*
  1797. * 85 机票预定
  1798. */
  1799. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1800. /*
  1801. * 98 其他款项
  1802. */
  1803. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1804. /*
  1805. * 285:收款退还
  1806. */
  1807. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1808. /*
  1809. * 1015: //超支费用
  1810. */
  1811. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1812. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1813. /*
  1814. * 币种信息
  1815. */
  1816. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1817. /*
  1818. * 车/导游地接 费用类型
  1819. */
  1820. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1821. /*
  1822. * 车/导游地接 费用类型
  1823. */
  1824. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1825. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1826. /*
  1827. * 用户信息
  1828. */
  1829. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1830. /*
  1831. * 费用模块
  1832. */
  1833. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1834. string priceModule = string.Empty;
  1835. if (sdPriceName != null)
  1836. {
  1837. priceModule = sdPriceName.Name;
  1838. }
  1839. /*
  1840. * 成本信息
  1841. */
  1842. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1843. decimal _groupRate = 0.0000M;
  1844. string _groupCurrencyCode = "-";
  1845. if (groupCost != null)
  1846. {
  1847. _groupRate = groupCost.Rate;
  1848. if (int.TryParse(groupCost.Currency, out int _currency))
  1849. {
  1850. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1851. }
  1852. else _groupCurrencyCode = groupCost.Currency;
  1853. }
  1854. string costContentSql = $"Select * From Grp_GroupCost";
  1855. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1856. //处理日期为空的天数
  1857. for (int i = 0; i < groupCostDetails.Count; i++)
  1858. if (i != 0)
  1859. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1860. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1861. /*
  1862. * 处理详情数据
  1863. */
  1864. foreach (var entity in entityList)
  1865. {
  1866. var _detail = new Grp_CreditCardPaymentDetailView();
  1867. _detail.Id = entity.Id;
  1868. _detail.PriceName = priceModule;
  1869. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1870. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1871. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1872. //处理金额
  1873. if (entity.CTable == 1015)
  1874. {
  1875. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1876. if (czInfo != null)
  1877. {
  1878. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1879. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1880. }
  1881. }
  1882. /*
  1883. * 应付款金额
  1884. */
  1885. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1886. string PaymentCurrency_WaitPay = "Unknown";
  1887. string hotelCurrncyCode = "Unknown";
  1888. string hotelCurrncyName = "Unknown";
  1889. if (sdPaymentCurrency_WaitPay != null)
  1890. {
  1891. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1892. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1893. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1894. if (hotelCurrncyCode.Equals("CNY"))
  1895. {
  1896. entity.DayRate = 1.0000M;
  1897. }
  1898. }
  1899. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1900. /*
  1901. * 此次付款金额
  1902. */
  1903. decimal CurrPayStr = 0.00M,
  1904. OriginalCurrPay = 0.00M;
  1905. if (entity.PayPercentage == 0)
  1906. {
  1907. if (entity.PayThenMoney != 0)
  1908. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1909. }
  1910. else
  1911. {
  1912. if (entity.PayMoney != 0)
  1913. {
  1914. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1915. }
  1916. }
  1917. //if (_dto.Label == 79)
  1918. //{
  1919. // string original = string.Empty;
  1920. // if (hotelCurrncyCode.Equals("CNY"))
  1921. // {
  1922. // OriginalCurrPay = CurrPayStr;
  1923. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1924. // }
  1925. // else
  1926. // {
  1927. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1928. // //760 EUR(7600.00 CNY)
  1929. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1930. // }
  1931. //}
  1932. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1933. string original = string.Empty;
  1934. if (hotelCurrncyCode.Equals("CNY"))
  1935. {
  1936. OriginalCurrPay = CurrPayStr;
  1937. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1938. }
  1939. else
  1940. {
  1941. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1942. //760 EUR(7600.00 CNY)
  1943. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1944. }
  1945. /*
  1946. * 剩余尾款
  1947. */
  1948. decimal BalanceStr = 0;
  1949. if (CurrPayStr != 0)
  1950. {
  1951. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1952. BalanceStr = 0;
  1953. else
  1954. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1955. }
  1956. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1957. /*
  1958. * Bus名称
  1959. */
  1960. _detail.BusName = "待增加";
  1961. /*
  1962. *费用所属
  1963. */
  1964. switch (entity.CTable)
  1965. {
  1966. case 76://酒店预订
  1967. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1968. if (hotelReservations != null)
  1969. {
  1970. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1971. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1972. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1973. string roomFeeStr = "", roomFeestr1 = "";
  1974. //是否比较房型价格
  1975. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1976. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1977. roomFeeStr += $"<br/>";
  1978. var roomTotal = 0.00M;
  1979. if (hotelReservations.SingleRoomPrice > 0)
  1980. {
  1981. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1982. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1983. __isSingle = true;
  1984. roomTotal += fee;
  1985. }
  1986. if (hotelReservations.DoubleRoomPrice > 0)
  1987. {
  1988. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1989. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1990. __isDouble = true;
  1991. roomTotal += fee;
  1992. }
  1993. if (hotelReservations.SuiteRoomPrice > 0)
  1994. {
  1995. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1996. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1997. __isSuite = true;
  1998. roomTotal += fee;
  1999. }
  2000. if (hotelReservations.OtherRoomPrice > 0)
  2001. {
  2002. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2003. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2004. __isOther = true;
  2005. roomTotal += fee;
  2006. }
  2007. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2008. else roomFeeStr += " 0.00 * 0";
  2009. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2010. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2011. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2012. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2013. /*
  2014. * 费用类型
  2015. * 1:房费
  2016. * 2:早餐
  2017. * 3:地税
  2018. * 4:城市税
  2019. * </summary>
  2020. */
  2021. //地税
  2022. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2023. if (governmentRentData != null)
  2024. {
  2025. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2026. governmentRentFee = governmentRentData.Price;
  2027. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2028. if (governmentRentCurrData != null)
  2029. {
  2030. governmentRentCode = governmentRentCurrData.Name;
  2031. governmentRentName = $"({governmentRentCurrData.Remark})";
  2032. }
  2033. }
  2034. //城市税
  2035. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2036. if (cityTaxData != null)
  2037. {
  2038. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2039. cityTaxFee = cityTaxData.Price;
  2040. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2041. if (cityTaxCurrData != null)
  2042. {
  2043. cityTaxCode = cityTaxCurrData.Name;
  2044. cityTaxName = $"({cityTaxCurrData.Remark})";
  2045. }
  2046. }
  2047. //酒店早餐
  2048. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2049. if (breakfastData != null)
  2050. {
  2051. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2052. breakfastFee = breakfastData.Price;
  2053. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2054. if (breakfastCurrData != null)
  2055. {
  2056. breakfastCode = breakfastCurrData.Name;
  2057. breakfastName = $"({breakfastCurrData.Remark})";
  2058. }
  2059. }
  2060. //房间费用
  2061. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2062. if (roomData != null)
  2063. {
  2064. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2065. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2066. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2067. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2068. roomFee = roomData.Price;
  2069. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2070. if (roomCurrData != null)
  2071. {
  2072. roomCode = roomCurrData.Name;
  2073. roomName = $"({roomCurrData.Remark})";
  2074. }
  2075. }
  2076. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2077. string hotelCostStr = "";
  2078. decimal hotelCsotTotal = 0.00M;
  2079. if (groupCost != null)
  2080. {
  2081. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2082. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2083. }
  2084. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2085. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2086. string hotelCost_day = "";
  2087. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2088. foreach (var item in hotelCostDetails1)
  2089. {
  2090. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2091. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2092. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2093. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2094. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2095. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2096. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2097. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2098. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2099. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2100. hotelCost_day += @$"<br/>";
  2101. }
  2102. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2103. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2104. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2105. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2106. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2107. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2108. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2109. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2110. $"房间说明: {hotelReservations.Remark} <br/>" +
  2111. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2112. $"{hotelBreakfastStr}" +
  2113. $"{hotelGovernmentRentStr}" +
  2114. $"{hotelCityTaxStr}";
  2115. _detail.PriceNameContent = hotelReservations.HotelName;
  2116. }
  2117. break;
  2118. case 79://车/导游地接
  2119. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2120. if (touristGuideGroundReservations != null)
  2121. {
  2122. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2123. {
  2124. _detail.BusName = touristGuideGroundReservations.BusName;
  2125. }
  2126. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2127. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2128. //if (isInt)
  2129. //{
  2130. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2131. // if (cityInfo != null)
  2132. // {
  2133. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2134. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2135. // if (carFeeItem != null)
  2136. // {
  2137. // nameContent += $@"({carFeeItem.Name})";
  2138. // }
  2139. // _detail.PriceNameContent = nameContent;
  2140. // }
  2141. //}
  2142. //else
  2143. //{
  2144. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2145. //}
  2146. var touristGuideGroundReservationsContents =
  2147. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2148. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2149. foreach (var item in touristGuideGroundReservationsContents)
  2150. {
  2151. string typeName = "Unknown";
  2152. string carCurrencyCode = "Unknown";
  2153. string carCurrencyName = "Unknown";
  2154. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2155. if (carTypeData != null) typeName = carTypeData.Name;
  2156. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2157. if (currencyData != null)
  2158. {
  2159. carCurrencyCode = currencyData.Name;
  2160. carCurrencyName = currencyData.Remark;
  2161. }
  2162. //op、成本 币种是否一致
  2163. bool IsCurrencyAgreement = false;
  2164. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2165. string opCostStr = string.Empty;
  2166. decimal opCostTypePrice = 0.00M;
  2167. #region 处理成本各项费用
  2168. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2169. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2170. if (opCost.Count > 0)
  2171. {
  2172. switch (item.SId)
  2173. {
  2174. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2175. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2176. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2177. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2178. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2179. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2180. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2181. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2182. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2183. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2184. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2185. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2186. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2187. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2188. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2189. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2190. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2191. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2192. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2193. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2194. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2195. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2197. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2198. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2199. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2200. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2201. }
  2202. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2203. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2204. }
  2205. #endregion
  2206. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2207. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2208. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2209. $"{opTypeStr} {opCostStr}<br/>" +
  2210. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2211. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2212. }
  2213. _detail.PriceMsgContent = priceMsg;
  2214. }
  2215. break;
  2216. case 80: //签证
  2217. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2218. if (visaInfo != null)
  2219. {
  2220. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2221. _detail.PriceNameContent = visaInfo.VisaDescription;
  2222. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2223. }
  2224. break;
  2225. case 81: //邀请/公务活动
  2226. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2227. if (_ioa != null)
  2228. {
  2229. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2230. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2231. sendCurrName = "Unknown", //快递费用币种 Name
  2232. sendCurrCode = "Unknown", //快递费用币种 Code
  2233. eventsCurrName = "Unknown", //公务活动费币种 Name
  2234. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2235. translateCurrName = "Unknown", //公务翻译费 Name
  2236. translateCurrCode = "Unknown"; //公务翻译费 Code
  2237. #region 处理费用币种
  2238. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2239. if (inviteCurrData != null)
  2240. {
  2241. inviteCurrName = inviteCurrData.Remark;
  2242. inviteCurrCode = inviteCurrData.Name;
  2243. }
  2244. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2245. if (sendCurrData != null)
  2246. {
  2247. sendCurrName = sendCurrData.Remark;
  2248. sendCurrCode = sendCurrData.Name;
  2249. }
  2250. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2251. if (eventsCurrData != null)
  2252. {
  2253. eventsCurrName = eventsCurrData.Remark;
  2254. eventsCurrCode = eventsCurrData.Name;
  2255. }
  2256. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2257. if (translateCurrData != null)
  2258. {
  2259. translateCurrName = translateCurrData.Remark;
  2260. translateCurrCode = translateCurrData.Name;
  2261. }
  2262. #endregion
  2263. _detail.PriceNameContent = _ioa.InviterArea;
  2264. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2265. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2266. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2267. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2268. $@"备注:" + _ioa.Remark + "<br/>";
  2269. }
  2270. break;
  2271. case 82: //团组客户保险
  2272. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2273. if (customers != null)
  2274. {
  2275. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2276. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2277. }
  2278. break;
  2279. case 85: //机票预订
  2280. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2281. if (jpRes != null)
  2282. {
  2283. string FlightsDescription = jpRes.FlightsDescription;
  2284. string PriceDescription = jpRes.PriceDescription;
  2285. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2286. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2287. }
  2288. break;
  2289. case 98://其他款项
  2290. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2291. if (gdpRes != null)
  2292. {
  2293. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2294. _detail.PriceNameContent = gdpRes.PriceName;
  2295. }
  2296. break;
  2297. case 285://收款退还
  2298. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2299. if (refundAndOtherMoney != null)
  2300. {
  2301. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2302. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2303. }
  2304. break;
  2305. case 751://酒店早餐
  2306. break;
  2307. case 1015://超支费用
  2308. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2309. if (groupExtraCost != null)
  2310. {
  2311. _detail.PriceNameContent = groupExtraCost.PriceName;
  2312. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2313. }
  2314. break;
  2315. default:
  2316. break;
  2317. }
  2318. /*
  2319. * 申请人
  2320. */
  2321. string operatorName = " - ";
  2322. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2323. if (_opUser != null)
  2324. {
  2325. operatorName = _opUser.CnName;
  2326. }
  2327. _detail.OperatorName = operatorName;
  2328. /*
  2329. * 审核人
  2330. */
  2331. string auditOperatorName = "Unknown";
  2332. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2333. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2334. else
  2335. {
  2336. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2337. if (_adUser != null)
  2338. {
  2339. auditOperatorName = _adUser.CnName;
  2340. }
  2341. }
  2342. _detail.AuditOperatorName = auditOperatorName;
  2343. /*
  2344. * 超预算比例
  2345. */
  2346. string overBudgetStr = "";
  2347. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2348. else if (entity.ExceedBudget == 0)
  2349. {
  2350. if (entity.CTable == 76 || entity.CTable == 79)
  2351. {
  2352. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2353. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2354. }
  2355. else
  2356. {
  2357. overBudgetStr = "未超预算";
  2358. }
  2359. }
  2360. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2361. _detail.OverBudget = overBudgetStr;
  2362. decimal auditFee = 0.00M; //已审核金额 人名币
  2363. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2364. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2365. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2366. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2367. {
  2368. auditedFeeOriginal = entity.PayMoney;
  2369. auditFee = CurrPayStr;
  2370. }
  2371. else if (entity.IsAuditGM == 0)
  2372. {
  2373. unAuditFeeCNY = CurrPayStr;
  2374. unAuditFeeOriginal = OriginalCurrPay;
  2375. OriginalCurrPay = 0.00M;
  2376. }
  2377. /*
  2378. * 费用总计
  2379. */
  2380. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2381. {
  2382. CurrencyId = entity.PaymentCurrency,
  2383. CurrencyName = PaymentCurrency_WaitPay,
  2384. AmountPayable = entity.PayMoney,
  2385. ThisPayment = OriginalCurrPay,
  2386. BalancePayment = BalanceStr,
  2387. AuditedFunds = auditFee,
  2388. AuditedFundsOriginal = auditedFeeOriginal,
  2389. UnAuditFundsCNY = unAuditFeeCNY,
  2390. UnAuditFundsOriginal = unAuditFeeOriginal
  2391. });
  2392. _detail.IsAuditGM = entity.IsAuditGM;
  2393. detailList.Add(_detail);
  2394. }
  2395. #endregion
  2396. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2397. /*
  2398. * 下方描述处理
  2399. */
  2400. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2401. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2402. if (ccpCurrencyPrice != null)
  2403. {
  2404. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2405. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2406. }
  2407. else
  2408. {
  2409. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2410. }
  2411. string amountPayableStr = string.Format(@"应付款总金额: ");
  2412. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2413. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2414. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2415. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2416. foreach (var item in nonDuplicat)
  2417. {
  2418. var currencyName = item.CurrencyName;
  2419. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2420. if (strs.Count > 0)
  2421. {
  2422. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2423. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2424. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2425. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2426. //单独处理此次付款金额
  2427. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2428. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2429. //单独处理已审核费用
  2430. //if (item.CurrencyId == 836) //人民币
  2431. //{
  2432. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2433. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2434. //}
  2435. //else
  2436. //{
  2437. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2438. //}
  2439. if (currencyName.Equals("CNY"))
  2440. {
  2441. //已审核费用
  2442. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2443. //未审核费用
  2444. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2445. }
  2446. else
  2447. {
  2448. //已审核费用
  2449. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2450. //未审核费用
  2451. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  2452. }
  2453. }
  2454. }
  2455. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2456. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2457. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2458. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2459. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2460. var _view1 = new
  2461. {
  2462. PageFuncAuth = pageFunAuthView,
  2463. Data = _view
  2464. };
  2465. return Ok(JsonView(_view1));
  2466. }
  2467. catch (Exception ex)
  2468. {
  2469. return Ok(JsonView(false, ex.Message));
  2470. }
  2471. }
  2472. /// <summary>
  2473. /// 费用审核
  2474. /// 修改团组费用审核状态
  2475. /// </summary>
  2476. /// <param name="_dto">参数Json字符串</param>
  2477. /// <returns></returns>
  2478. [HttpPost]
  2479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2480. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2481. {
  2482. #region 参数验证
  2483. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2484. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2485. #endregion
  2486. #region 页面操作权限验证
  2487. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2488. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2489. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2490. #endregion
  2491. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2492. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2493. DateTime dtNow = DateTime.Now;
  2494. _groupRepository.BeginTran();
  2495. int rst = 0;
  2496. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2497. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2498. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2499. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2500. List<dynamic> msgDatas = new List<dynamic>();
  2501. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2502. foreach (var item in idList)
  2503. {
  2504. int CreditId = int.Parse(item);
  2505. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2506. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2507. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2508. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2509. .Where(s => s.Id == CreditId)
  2510. .ExecuteCommandAsync();
  2511. if (result < 1)
  2512. {
  2513. rst = -1;
  2514. _groupRepository.RollbackTran();
  2515. return Ok(JsonView(false, "操作失败并回滚!"));
  2516. }
  2517. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2518. if (creditData != null)
  2519. {
  2520. #region 应用通知配置
  2521. try
  2522. {
  2523. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2524. }
  2525. catch (Exception ex)
  2526. {
  2527. }
  2528. #endregion
  2529. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2530. string groupNameStr = string.Empty;
  2531. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2532. if (groupData != null) groupNameStr = groupData.TeamName;
  2533. string creditTypeStr = string.Empty;
  2534. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2535. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2536. string creditCurrency = string.Empty;
  2537. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2538. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2539. if (creditCurrency.Equals("CNY"))
  2540. {
  2541. creditData.DayRate = 1.0000M;
  2542. }
  2543. if (creditData.PayPercentage == 0.00M)
  2544. {
  2545. creditData.PayPercentage = 100M;
  2546. }
  2547. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2548. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2549. string msgContent = "";
  2550. if (creditCurrency.Equals("CNY"))
  2551. {
  2552. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2553. }
  2554. else
  2555. {
  2556. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2557. }
  2558. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2559. }
  2560. }
  2561. if (rst == 0)
  2562. {
  2563. _groupRepository.CommitTran();
  2564. foreach (var item in msgDatas)
  2565. {
  2566. //发送消息
  2567. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2568. }
  2569. #region 应用推送
  2570. try
  2571. {
  2572. foreach (var ccpId in dic_ccp_user.Keys)
  2573. {
  2574. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2575. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2576. }
  2577. }
  2578. catch (Exception)
  2579. {
  2580. }
  2581. #endregion
  2582. return Ok(JsonView(true, "操作成功!"));
  2583. }
  2584. return Ok(JsonView(false, "操作失败!"));
  2585. }
  2586. #endregion
  2587. #region 机票费用录入
  2588. /// <summary>
  2589. /// 机票录入当前登录人可操作团组
  2590. /// </summary>
  2591. /// <param name="dto"></param>
  2592. /// <returns></returns>
  2593. [HttpPost]
  2594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2595. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2596. {
  2597. try
  2598. {
  2599. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2600. if (groupData.Code != 0)
  2601. {
  2602. return Ok(JsonView(false, groupData.Msg));
  2603. }
  2604. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2605. }
  2606. catch (Exception ex)
  2607. {
  2608. return Ok(JsonView(false, "程序错误!"));
  2609. throw;
  2610. }
  2611. }
  2612. /// <summary>
  2613. /// 机票费用录入列表
  2614. /// </summary>
  2615. /// <param name="dto"></param>
  2616. /// <returns></returns>
  2617. [HttpPost]
  2618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2619. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2620. {
  2621. try
  2622. {
  2623. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2624. if (groupData.Code != 0)
  2625. {
  2626. return Ok(JsonView(false, groupData.Msg));
  2627. }
  2628. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2629. }
  2630. catch (Exception ex)
  2631. {
  2632. return Ok(JsonView(false, ex.Message));
  2633. throw;
  2634. }
  2635. }
  2636. /// <summary>
  2637. /// 根据id查询费用录入信息
  2638. /// </summary>
  2639. /// <param name="dto"></param>
  2640. /// <returns></returns>
  2641. [HttpPost]
  2642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2643. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2644. {
  2645. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2646. if (groupData.Code != 0)
  2647. {
  2648. return Ok(JsonView(false, groupData.Msg));
  2649. }
  2650. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2651. }
  2652. /// <summary>
  2653. /// 机票费用录入操作(Status:1.新增,2.修改)
  2654. /// </summary>
  2655. /// <param name="dto"></param>
  2656. /// <returns></returns>
  2657. [HttpPost]
  2658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2659. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2660. {
  2661. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2662. if (groupData.Code != 0)
  2663. {
  2664. return Ok(JsonView(false, groupData.Msg));
  2665. }
  2666. #region 应用推送
  2667. try
  2668. {
  2669. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2670. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2671. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2672. //2024-10-21 新增LZ UID
  2673. var userIds = new List<int>() { 21 };
  2674. string title = $"系统通知";
  2675. string content = "";
  2676. var diId = dto.AirTicketResOpData.DiId;
  2677. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2678. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2679. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2680. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2681. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2682. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2683. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2684. }
  2685. catch (Exception ex)
  2686. {
  2687. }
  2688. #endregion
  2689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2690. }
  2691. /// <summary>
  2692. /// 根据舱位类型查询接团客户名单信息
  2693. /// </summary>
  2694. /// <param name="dto"></param>
  2695. /// <returns></returns>
  2696. [HttpPost]
  2697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2698. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2699. {
  2700. try
  2701. {
  2702. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2703. if (crm_Groups.Count != 0)
  2704. {
  2705. List<dynamic> Customer = new List<dynamic>();
  2706. foreach (var item in crm_Groups)
  2707. {
  2708. var data = new
  2709. {
  2710. Id = item.Id,
  2711. Pinyin = item.Pinyin,
  2712. Name = item.LastName + item.FirstName
  2713. };
  2714. Customer.Add(data);
  2715. }
  2716. return Ok(JsonView(true, "查询成功!", Customer));
  2717. }
  2718. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2719. }
  2720. catch (Exception ex)
  2721. {
  2722. return Ok(JsonView(false, "程序错误!"));
  2723. throw;
  2724. }
  2725. }
  2726. /// <summary>
  2727. /// 根据团号获取客户信息
  2728. /// </summary>
  2729. /// <param name="dto"></param>
  2730. /// <returns></returns>
  2731. [HttpPost]
  2732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2733. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2734. {
  2735. var jw = JsonView(false);
  2736. if (dto.DIID < 1)
  2737. {
  2738. jw.Msg += "请输入正确的diid";
  2739. return Ok(jw);
  2740. }
  2741. var arr = getSimplClientList(dto.DIID);
  2742. jw = JsonView(true, "获取成功!", arr);
  2743. return Ok(jw);
  2744. }
  2745. private List<SimplClientInfo> getSimplClientList(int diId)
  2746. {
  2747. 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);
  2748. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2749. foreach (var item in arr)
  2750. {
  2751. EncryptionProcessor.DecryptProperties(item);
  2752. }
  2753. return arr;
  2754. }
  2755. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2756. {
  2757. string result = origin;
  2758. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2759. {
  2760. string[] temparr = origin.Split(',');
  2761. string fistrStr = temparr[0];
  2762. int count = temparr.Count();
  2763. int tempId;
  2764. bool success = int.TryParse(fistrStr, out tempId);
  2765. if (success)
  2766. {
  2767. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2768. if (tempInfo != null)
  2769. {
  2770. if (count > 1)
  2771. {
  2772. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2773. }
  2774. else
  2775. {
  2776. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2777. }
  2778. }
  2779. }
  2780. }
  2781. return result;
  2782. }
  2783. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2784. {
  2785. string result = origin;
  2786. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2787. {
  2788. string[] temparr = origin.Split(',');
  2789. result = "";
  2790. foreach (var item in temparr)
  2791. {
  2792. int tempId;
  2793. bool success = int.TryParse(item, out tempId);
  2794. if (success)
  2795. {
  2796. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2797. if (tempInfo != null)
  2798. {
  2799. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2800. }
  2801. }
  2802. }
  2803. }
  2804. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2805. return result;
  2806. }
  2807. /// <summary>
  2808. /// 机票费用录入,删除
  2809. /// </summary>
  2810. /// <param name="dto"></param>
  2811. /// <returns></returns>
  2812. [HttpPost]
  2813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2814. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2815. {
  2816. try
  2817. {
  2818. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2819. if (res)
  2820. {
  2821. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2822. {
  2823. IsDel = 1,
  2824. DeleteUserId = dto.DeleteUserId,
  2825. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2826. }).ExecuteCommandAsync();
  2827. return Ok(JsonView(true, "删除成功!"));
  2828. }
  2829. return Ok(JsonView(false, "删除失败!"));
  2830. }
  2831. catch (Exception ex)
  2832. {
  2833. return Ok(JsonView(false, "程序错误!"));
  2834. throw;
  2835. }
  2836. }
  2837. /// <summary>
  2838. /// 导出机票录入报表
  2839. /// </summary>
  2840. /// <param name="dto"></param>
  2841. /// <returns></returns>
  2842. [HttpPost]
  2843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2844. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2845. {
  2846. try
  2847. {
  2848. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2849. if (groupData.Code != 0)
  2850. {
  2851. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2852. }
  2853. else
  2854. {
  2855. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2856. if (AirTicketReservations.Count != 0)
  2857. {
  2858. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2859. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2860. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2861. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2862. WorkbookDesigner designer = new WorkbookDesigner();
  2863. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2864. decimal countCost = 0;
  2865. foreach (var item in AirTicketReservations)
  2866. {
  2867. #region 处理客人姓名
  2868. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2869. item.ClientName = clientNames;
  2870. #endregion
  2871. if (item.BankType == "其他")
  2872. {
  2873. item.BankNo = "--";
  2874. }
  2875. else
  2876. {
  2877. if (!string.IsNullOrEmpty(item.BankType))
  2878. {
  2879. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2880. }
  2881. }
  2882. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2883. item.Price = System.Decimal.Round(item.Price, 2);
  2884. countCost += Convert.ToDecimal(item.Price);
  2885. }
  2886. designer.SetDataSource("Export", AirTicketReservations);
  2887. designer.SetDataSource("ExportDiCode", diCode);
  2888. designer.SetDataSource("ExportDiName", diName);
  2889. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2890. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2891. designer.Process();
  2892. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2893. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2894. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2895. return Ok(JsonView(true, "成功", url = rst));
  2896. }
  2897. else
  2898. {
  2899. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2900. }
  2901. }
  2902. }
  2903. catch (Exception ex)
  2904. {
  2905. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2906. throw;
  2907. }
  2908. }
  2909. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2910. /// <summary>
  2911. /// 行程单导出
  2912. /// </summary>
  2913. /// <param name="dto"></param>
  2914. /// <returns></returns>
  2915. [HttpPost]
  2916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2917. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2918. {
  2919. try
  2920. {
  2921. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2922. if (groupData.Code != 0)
  2923. {
  2924. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2925. }
  2926. else
  2927. {
  2928. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2929. if (dto.Language == "CN")
  2930. {
  2931. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2932. DocumentBuilder builder = new DocumentBuilder(doc);
  2933. int tableIndex = 0;//表格索引
  2934. //得到文档中的第一个表格
  2935. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2936. foreach (var item in _AirTicketReservations)
  2937. {
  2938. #region 处理固定数据
  2939. string[] FlightsCode = item.FlightsCode.Split('/');
  2940. if (FlightsCode.Length != 0)
  2941. {
  2942. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2943. if (_AirCompany != null)
  2944. {
  2945. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2946. }
  2947. else
  2948. {
  2949. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2950. }
  2951. }
  2952. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2953. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2954. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2955. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2956. string name = "";
  2957. foreach (string clientName in nameArray)
  2958. {
  2959. if (!name.Contains(clientName))
  2960. {
  2961. name += clientName + ",";
  2962. }
  2963. }
  2964. if (!string.IsNullOrWhiteSpace(name))
  2965. {
  2966. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2967. }
  2968. else
  2969. {
  2970. table.Range.Bookmarks["ClientName"].Text = "--";
  2971. }
  2972. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2973. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2974. table.Range.Bookmarks["JointTicket"].Text = "--";
  2975. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2976. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2977. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2978. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2979. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2980. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2981. #endregion
  2982. #region 循环数据处理
  2983. List<AirInfo> airs = new List<AirInfo>();
  2984. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2985. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2986. for (int i = 0; i < FlightsCode.Length; i++)
  2987. {
  2988. AirInfo air = new AirInfo();
  2989. string[] tempstr = DayArray[i]
  2990. .Replace("\r\n", string.Empty)
  2991. .Replace("\\r\\n", string.Empty)
  2992. .TrimStart().TrimEnd()
  2993. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2994. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2995. string starCity = "";
  2996. if (star_Three != null)
  2997. {
  2998. starCity = star_Three.AirPort;
  2999. }
  3000. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3001. string EndCity = "";
  3002. if (End_Three != null)
  3003. {
  3004. EndCity = End_Three.AirPort;
  3005. }
  3006. air.Destination = starCity + "/" + EndCity;
  3007. air.Flight = FlightsCode[i];
  3008. air.SeatingClass = item.CTypeName;
  3009. string dateTime = tempstr[2];
  3010. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3011. air.FlightDate = DateTemp;
  3012. air.DepartureTime = tempstr[5];
  3013. air.LandingTime = tempstr[6];
  3014. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3015. air.TicketStatus = "--";
  3016. air.Luggage = "--";
  3017. air.DepartureTerminal = "--";
  3018. air.LandingTerminal = "--";
  3019. airs.Add(air);
  3020. }
  3021. int row = 13;
  3022. for (int i = 0; i < airs.Count; i++)
  3023. {
  3024. if (airs.Count > 2)
  3025. {
  3026. for (int j = 0; j < airs.Count - 2; j++)
  3027. {
  3028. var CopyRow = table.Rows[12].Clone(true);
  3029. table.Rows.Add(CopyRow);
  3030. }
  3031. }
  3032. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3033. int index = 0;
  3034. foreach (PropertyInfo property in properties)
  3035. {
  3036. string value = property.GetValue(airs[i]).ToString();
  3037. Cell ishcel0 = table.Rows[row].Cells[index];
  3038. Paragraph p = new Paragraph(doc);
  3039. string s = value;
  3040. p.AppendChild(new Run(doc, s));
  3041. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3042. ishcel0.AppendChild(p);
  3043. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3044. index++;
  3045. }
  3046. row++;
  3047. }
  3048. #endregion
  3049. Paragraph lastParagraph = new Paragraph(doc);
  3050. //第一个表格末尾加段落
  3051. table.ParentNode.InsertAfter(lastParagraph, table);
  3052. //复制第一个表格
  3053. Table cloneTable = (Table)table.Clone(true);
  3054. //在文档末尾段落后面加入复制的表格
  3055. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3056. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3057. {
  3058. int rownewsIndex = 13;
  3059. for (int i = 0; i < 2; i++)
  3060. {
  3061. var CopyRow = table.Rows[12].Clone(true);
  3062. table.Rows.RemoveAt(13);
  3063. table.Rows.Add(CopyRow);
  3064. rownewsIndex++;
  3065. }
  3066. }
  3067. else
  3068. {
  3069. table.Rows.RemoveAt(12);
  3070. }
  3071. cloneTable.Rows.RemoveAt(12);
  3072. }
  3073. if (_AirTicketReservations.Count != 0)
  3074. {
  3075. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3076. if (FlightsCode.Length != 0)
  3077. {
  3078. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3079. if (_AirCompany != null)
  3080. {
  3081. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3082. }
  3083. else
  3084. {
  3085. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3086. }
  3087. }
  3088. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3089. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3090. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3091. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3092. string name = "";
  3093. foreach (string clientName in nameArray)
  3094. {
  3095. if (!name.Contains(clientName))
  3096. {
  3097. name += clientName + ",";
  3098. }
  3099. }
  3100. if (!string.IsNullOrWhiteSpace(name))
  3101. {
  3102. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3103. }
  3104. else
  3105. {
  3106. table.Range.Bookmarks["ClientName"].Text = "--";
  3107. }
  3108. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3109. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3110. table.Range.Bookmarks["JointTicket"].Text = "--";
  3111. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3112. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3113. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3114. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3115. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3116. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3117. }
  3118. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3119. //保存合并后的文档
  3120. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3121. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3122. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3123. return Ok(JsonView(true, "成功!", rst));
  3124. }
  3125. else
  3126. {
  3127. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3128. DocumentBuilder builder = new DocumentBuilder(doc);
  3129. int tableIndex = 0;//表格索引
  3130. //得到文档中的第一个表格
  3131. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3132. List<string> texts = new List<string>();
  3133. foreach (var item in _AirTicketReservations)
  3134. {
  3135. string[] FlightsCode = item.FlightsCode.Split('/');
  3136. if (FlightsCode.Length != 0)
  3137. {
  3138. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3139. if (_AirCompany != null)
  3140. {
  3141. if (!transDic.ContainsKey(_AirCompany.CnName))
  3142. {
  3143. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3144. }
  3145. }
  3146. else
  3147. {
  3148. if (!transDic.ContainsKey("--"))
  3149. {
  3150. transDic.Add("--", "--");
  3151. }
  3152. }
  3153. }
  3154. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3155. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3156. string name = "";
  3157. foreach (string clientName in nameArray)
  3158. {
  3159. name += clientName + ",";
  3160. }
  3161. if (!texts.Contains(name))
  3162. {
  3163. texts.Add(name);
  3164. }
  3165. List<AirInfo> airs = new List<AirInfo>();
  3166. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3167. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3168. for (int i = 0; i < FlightsCode.Length; i++)
  3169. {
  3170. AirInfo air = new AirInfo();
  3171. string[] tempstr = DayArray[i]
  3172. .Replace("\r\n", string.Empty)
  3173. .Replace("\\r\\n", string.Empty)
  3174. .TrimStart().TrimEnd()
  3175. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3176. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3177. if (star_Three != null)
  3178. {
  3179. if (!transDic.ContainsKey(star_Three.AirPort))
  3180. {
  3181. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3182. }
  3183. }
  3184. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3185. if (End_Three != null)
  3186. {
  3187. if (!transDic.ContainsKey(End_Three.AirPort))
  3188. {
  3189. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3190. }
  3191. }
  3192. if (!texts.Contains(item.CTypeName))
  3193. {
  3194. texts.Add(item.CTypeName);
  3195. }
  3196. }
  3197. }
  3198. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3199. if (transData.Count > 0)
  3200. {
  3201. foreach (TranslateResult item in transData)
  3202. {
  3203. if (!transDic.ContainsKey(item.Query))
  3204. {
  3205. transDic.Add(item.Query, item.Translation);
  3206. }
  3207. }
  3208. }
  3209. foreach (var item in _AirTicketReservations)
  3210. {
  3211. #region 处理固定数据
  3212. string[] FlightsCode = item.FlightsCode.Split('/');
  3213. if (FlightsCode.Length != 0)
  3214. {
  3215. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3216. if (_AirCompany != null)
  3217. {
  3218. string str = "--";
  3219. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3220. if (!string.IsNullOrEmpty(translateResult))
  3221. {
  3222. str = translateResult;
  3223. str = _airTicketResRep.Processing(str);
  3224. }
  3225. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3226. }
  3227. else
  3228. {
  3229. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3230. }
  3231. }
  3232. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3233. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3234. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3235. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3236. string names = "";
  3237. foreach (string clientName in nameArray)
  3238. {
  3239. names += clientName + ",";
  3240. }
  3241. if (!string.IsNullOrWhiteSpace(names))
  3242. {
  3243. string str = "--";
  3244. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3245. if (!string.IsNullOrEmpty(translateResult))
  3246. {
  3247. str = translateResult;
  3248. str = _airTicketResRep.Processing(str);
  3249. }
  3250. table.Range.Bookmarks["ClientName"].Text = str;
  3251. }
  3252. else
  3253. {
  3254. table.Range.Bookmarks["ClientName"].Text = "--";
  3255. }
  3256. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3257. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3258. table.Range.Bookmarks["JointTicket"].Text = "--";
  3259. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3260. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3261. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3262. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3263. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3264. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3265. #endregion
  3266. #region 循环数据处理
  3267. List<AirInfo> airs = new List<AirInfo>();
  3268. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3269. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3270. for (int i = 0; i < FlightsCode.Length; i++)
  3271. {
  3272. AirInfo air = new AirInfo();
  3273. string[] tempstr = DayArray[i]
  3274. .Replace("\r\n", string.Empty)
  3275. .Replace("\\r\\n", string.Empty)
  3276. .TrimStart().TrimEnd()
  3277. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3278. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3279. string starCity = "";
  3280. if (star_Three != null)
  3281. {
  3282. string str2 = "--";
  3283. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3284. if (!string.IsNullOrEmpty(translateResult2))
  3285. {
  3286. str2 = translateResult2;
  3287. str2 = _airTicketResRep.Processing(str2);
  3288. }
  3289. starCity = str2;
  3290. }
  3291. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3292. string EndCity = "";
  3293. if (End_Three != null)
  3294. {
  3295. string str1 = "--";
  3296. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3297. if (!string.IsNullOrEmpty(translateResult1))
  3298. {
  3299. str1 = translateResult1;
  3300. str1 = _airTicketResRep.Processing(str1);
  3301. }
  3302. EndCity = str1;
  3303. }
  3304. air.Destination = starCity + "/" + EndCity;
  3305. air.Flight = FlightsCode[i];
  3306. string str = "--";
  3307. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3308. if (!string.IsNullOrEmpty(translateResult))
  3309. {
  3310. str = translateResult;
  3311. str = _airTicketResRep.Processing(str);
  3312. }
  3313. air.SeatingClass = str;
  3314. string dateTime = tempstr[2];
  3315. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3316. air.FlightDate = DateTemp;
  3317. air.DepartureTime = tempstr[5];
  3318. air.LandingTime = tempstr[6];
  3319. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3320. air.TicketStatus = "--";
  3321. air.Luggage = "--";
  3322. air.DepartureTerminal = "--";
  3323. air.LandingTerminal = "--";
  3324. airs.Add(air);
  3325. }
  3326. int row = 13;
  3327. for (int i = 0; i < airs.Count; i++)
  3328. {
  3329. if (airs.Count > 2)
  3330. {
  3331. for (int j = 0; j < airs.Count - 2; j++)
  3332. {
  3333. var CopyRow = table.Rows[12].Clone(true);
  3334. table.Rows.Add(CopyRow);
  3335. }
  3336. }
  3337. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3338. int index = 0;
  3339. foreach (PropertyInfo property in properties)
  3340. {
  3341. string value = property.GetValue(airs[i]).ToString();
  3342. Cell ishcel0 = table.Rows[row].Cells[index];
  3343. Paragraph p = new Paragraph(doc);
  3344. string s = value;
  3345. p.AppendChild(new Run(doc, s));
  3346. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3347. ishcel0.AppendChild(p);
  3348. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3349. //ishcel0.CellFormat.VerticalAlignment=
  3350. index++;
  3351. }
  3352. row++;
  3353. }
  3354. #endregion
  3355. Paragraph lastParagraph = new Paragraph(doc);
  3356. //第一个表格末尾加段落
  3357. table.ParentNode.InsertAfter(lastParagraph, table);
  3358. //复制第一个表格
  3359. Table cloneTable = (Table)table.Clone(true);
  3360. //在文档末尾段落后面加入复制的表格
  3361. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3362. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3363. {
  3364. int rownewsIndex = 13;
  3365. for (int i = 0; i < 2; i++)
  3366. {
  3367. var CopyRow = table.Rows[12].Clone(true);
  3368. table.Rows.RemoveAt(13);
  3369. table.Rows.Add(CopyRow);
  3370. rownewsIndex++;
  3371. }
  3372. }
  3373. else
  3374. {
  3375. table.Rows.RemoveAt(12);
  3376. }
  3377. cloneTable.Rows.RemoveAt(12);
  3378. }
  3379. if (_AirTicketReservations.Count != 0)
  3380. {
  3381. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3382. if (FlightsCode.Length != 0)
  3383. {
  3384. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3385. if (_AirCompany != null)
  3386. {
  3387. string str = "--";
  3388. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3389. if (!string.IsNullOrEmpty(translateResult))
  3390. {
  3391. str = translateResult;
  3392. str = _airTicketResRep.Processing(str);
  3393. }
  3394. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3395. }
  3396. else
  3397. {
  3398. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3399. }
  3400. }
  3401. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3402. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3403. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3404. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3405. string names = "";
  3406. foreach (string clientName in nameArray)
  3407. {
  3408. names += clientName + ",";
  3409. }
  3410. if (!string.IsNullOrWhiteSpace(names))
  3411. {
  3412. string str = "--";
  3413. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3414. if (!string.IsNullOrEmpty(translateResult))
  3415. {
  3416. str = translateResult;
  3417. str = _airTicketResRep.Processing(str);
  3418. }
  3419. table.Range.Bookmarks["ClientName"].Text = str;
  3420. }
  3421. else
  3422. {
  3423. table.Range.Bookmarks["ClientName"].Text = "--";
  3424. }
  3425. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3426. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3427. table.Range.Bookmarks["JointTicket"].Text = "--";
  3428. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3429. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3430. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3431. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3432. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3433. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3434. }
  3435. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3436. //保存合并后的文档
  3437. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3438. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3439. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3440. return Ok(JsonView(true, "成功!", rst));
  3441. }
  3442. }
  3443. }
  3444. catch (Exception ex)
  3445. {
  3446. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3447. throw;
  3448. }
  3449. }
  3450. #endregion
  3451. #region 团组增减款项 --> 其他款项
  3452. /// <summary>
  3453. /// 团组增减款项下拉框绑定
  3454. /// </summary>
  3455. /// <param name="dto"></param>
  3456. /// <returns></returns>
  3457. [HttpPost]
  3458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3459. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3460. {
  3461. #region 参数验证
  3462. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3463. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3464. #endregion
  3465. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3466. }
  3467. /// <summary>
  3468. /// 根据团组Id查询团组增减款项
  3469. /// </summary>
  3470. /// <param name="dto"></param>
  3471. /// <returns></returns>
  3472. [HttpPost]
  3473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3474. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3475. {
  3476. #region 参数验证
  3477. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3478. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3479. #endregion
  3480. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3481. }
  3482. /// <summary>
  3483. /// 团组增减款项操作(Status:1.新增,2.修改)
  3484. /// </summary>
  3485. /// <param name="dto"></param>
  3486. /// <returns></returns>
  3487. [HttpPost]
  3488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3489. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3490. {
  3491. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3492. if (groupData.Code != 200)
  3493. {
  3494. return Ok(JsonView(false, groupData.Msg));
  3495. }
  3496. #region 应用推送
  3497. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3498. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3499. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3500. //自动审核
  3501. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3502. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3503. //2024-10-21 新增LZ UID
  3504. var userIds = new List<int>() { 21 };
  3505. string title = $"系统通知";
  3506. string content = "";
  3507. var diId = dto.DiId;
  3508. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3509. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3510. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3511. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3512. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3513. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3514. #endregion
  3515. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3516. }
  3517. /// <summary>
  3518. /// 团组增减款项操作 删除
  3519. /// </summary>
  3520. /// <param name="dto"></param>
  3521. /// <returns></returns>
  3522. [HttpPost]
  3523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3524. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3525. {
  3526. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3527. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3528. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3529. if (res.Code == 0)
  3530. {
  3531. return Ok(JsonView(true, "删除成功!"));
  3532. }
  3533. return Ok(JsonView(false, "删除失败!"));
  3534. }
  3535. /// <summary>
  3536. /// 根据团组增减款项Id查询
  3537. /// </summary>
  3538. /// <param name="dto"></param>
  3539. /// <returns></returns>
  3540. [HttpPost]
  3541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3542. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3543. {
  3544. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3545. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3546. }
  3547. /// <summary>
  3548. /// 查询供应商名称
  3549. /// </summary>
  3550. /// <param name="dto"></param>
  3551. /// <returns></returns>
  3552. [HttpPost]
  3553. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3554. {
  3555. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3556. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3557. ?? new List<Grp_DecreasePayments>();
  3558. dbResult = dbResult.Distinct(new
  3559. ProductComparer()).ToList();
  3560. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3561. {
  3562. x.Id,
  3563. x.SupplierAddress,
  3564. x.SupplierArea,
  3565. x.SupplierContact,
  3566. x.SupplierContactNumber,
  3567. x.SupplierEmail,
  3568. x.SupplierName,
  3569. x.SupplierSocialAccount,
  3570. x.SupplierTypeId,
  3571. }).ToList());
  3572. return Ok(jw);
  3573. }
  3574. /// <summary>
  3575. /// 团组增减款项 OTA匹配
  3576. /// </summary>
  3577. /// <param name="file"></param>
  3578. /// <returns></returns>
  3579. [HttpPost]
  3580. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3581. {
  3582. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3583. string fileName = file.FileName;
  3584. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3585. {
  3586. return Ok(JsonView(false, "请上传Excel文件!"));
  3587. }
  3588. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3589. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3590. if (!Directory.Exists(path))
  3591. {
  3592. Directory.CreateDirectory(path);
  3593. }
  3594. var filePath = @$"{path}/{fileName}";
  3595. //保存文件
  3596. using (FileStream fs = System.IO.File.Create(filePath))
  3597. {
  3598. file.CopyTo(fs);
  3599. fs.Flush();
  3600. }
  3601. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3602. //读取ExcelFile
  3603. DataTable dt = ConvertExcelToDataTable(filePath);
  3604. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3605. dt.TableName = "TB";
  3606. //修改table列名
  3607. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3608. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3609. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3610. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3611. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3612. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3613. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3614. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3615. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3616. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3617. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3618. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3619. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3620. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3621. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3622. var otaOrderNos = new List<string>();
  3623. foreach (DataRow item in dt.Rows)
  3624. {
  3625. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3626. }
  3627. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3628. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3629. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3630. .Select((dp, di) => new
  3631. {
  3632. dp.PriceName,
  3633. dp.OTAOrderNo,
  3634. dp.FeeTotal,
  3635. di.TeamName,
  3636. })
  3637. .ToListAsync();
  3638. foreach (DataRow item in dt.Rows)
  3639. {
  3640. var otaOrderNo = item["OTAOrderNo"].ToString();
  3641. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3642. if (oaData == null) continue;
  3643. item["GroupName"] = oaData.TeamName;
  3644. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3645. }
  3646. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3647. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3648. List<DataTable> datas = new List<DataTable>();
  3649. datas.Add(dt);
  3650. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3651. return Ok(JsonView(true, "操作成功", new { url = url }));
  3652. }
  3653. #region
  3654. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3655. {
  3656. // 创建Workbook对象
  3657. Workbook workbook = new Workbook(excelFilePath);
  3658. // 获取第一个工作表
  3659. Worksheet worksheet = workbook.Worksheets[0];
  3660. // 将工作表转换为DataTable
  3661. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3662. return dataTable;
  3663. }
  3664. #endregion
  3665. #endregion
  3666. #region 文件上传、删除
  3667. /// <summary>
  3668. /// region 文件上传 可以带参数
  3669. /// </summary>
  3670. /// <param name="file"></param>
  3671. /// <returns></returns>
  3672. [HttpPost]
  3673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3674. public async Task<IActionResult> UploadProject(IFormFile file)
  3675. {
  3676. //var TypeName = Request.Headers["TypeName"].ToString();
  3677. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3678. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3679. ////文件名称
  3680. //string projectFileName = file.FileName;
  3681. ////上传的文件的路径
  3682. //string filePath = $"{fileDir}/{projectFileName}";
  3683. //if (TypeName == "A")//A代表团组增减款项
  3684. //{
  3685. // filePath = fileDir + $@"\团组增减款项相关文件";
  3686. // if (!Directory.Exists(filePath))
  3687. // {
  3688. // Directory.CreateDirectory(filePath);
  3689. // }
  3690. // //上传的文件的路径
  3691. // filePath += $@"\{projectFileName}";
  3692. //}
  3693. //else if (TypeName == "B")//B代表商邀相关文件
  3694. //{
  3695. // //上传的文件的路径
  3696. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3697. // if (!Directory.Exists(filePath))
  3698. // {
  3699. // Directory.CreateDirectory(filePath);
  3700. // }
  3701. // //上传的文件的路径
  3702. // filePath = $@"\{projectFileName}";
  3703. //}
  3704. //try
  3705. //{
  3706. // using (FileStream fs = System.IO.File.Create(filePath))
  3707. // {
  3708. // file.CopyTo(fs);
  3709. // fs.Flush();
  3710. // }
  3711. //}
  3712. //catch (Exception ex)
  3713. //{
  3714. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3715. //}
  3716. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3717. try
  3718. {
  3719. var TypeName = Request.Headers["TypeName"].ToString();
  3720. if (file != null)
  3721. {
  3722. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3723. //文件名称
  3724. string projectFileName = file.FileName;
  3725. //上传的文件的路径
  3726. string filePath = $"{fileDir}/{projectFileName}";
  3727. if (TypeName == "A")//A代表团组增减款项
  3728. {
  3729. if (!Directory.Exists(fileDir))
  3730. {
  3731. Directory.CreateDirectory(fileDir);
  3732. }
  3733. //上传的文件的路径
  3734. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3735. }
  3736. else if (TypeName == "B")//B代表商邀相关文件
  3737. {
  3738. if (!Directory.Exists(fileDir))
  3739. {
  3740. Directory.CreateDirectory(fileDir);
  3741. }
  3742. //上传的文件的路径
  3743. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3744. }
  3745. using (FileStream fs = System.IO.File.Create(filePath))
  3746. {
  3747. file.CopyTo(fs);
  3748. fs.Flush();
  3749. }
  3750. return Ok(JsonView(true, "上传成功!", projectFileName));
  3751. }
  3752. else
  3753. {
  3754. return Ok(JsonView(false, "上传失败!"));
  3755. }
  3756. }
  3757. catch (Exception ex)
  3758. {
  3759. return Ok(JsonView(false, "程序错误!"));
  3760. }
  3761. }
  3762. /// <summary>
  3763. /// 删除指定文件
  3764. /// </summary>
  3765. /// <param name="dto"></param>
  3766. /// <returns></returns>
  3767. [HttpPost]
  3768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3769. public async Task<IActionResult> DelFile(DelFileDto dto)
  3770. {
  3771. try
  3772. {
  3773. var TypeName = Request.Headers["TypeName"].ToString();
  3774. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3775. string filePath = "";
  3776. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3777. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3778. int id = 0;
  3779. if (TypeName == "A")
  3780. {
  3781. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3782. // 删除该文件
  3783. System.IO.File.Delete(filePath);
  3784. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3785. .Where(a => a.Id == dto.Id)
  3786. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3787. .ExecuteCommandAsync();
  3788. }
  3789. else if (TypeName == "B")
  3790. {
  3791. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3792. // 删除该文件
  3793. System.IO.File.Delete(filePath);
  3794. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3795. if (info != null)
  3796. {
  3797. string[] files = new string[] { };
  3798. if (!string.IsNullOrEmpty(info.Attachment))
  3799. {
  3800. try
  3801. {
  3802. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3803. }
  3804. catch (Exception)
  3805. {
  3806. files = new List<string>() { info.Attachment }.ToArray();
  3807. }
  3808. }
  3809. if (files.Length > 0)
  3810. {
  3811. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3812. string filePath2 = string.Empty;
  3813. if (files1.Length > 0)
  3814. {
  3815. filePath2 = JsonConvert.SerializeObject(files1);
  3816. }
  3817. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3818. .Where(a => a.Id == dto.Id)
  3819. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3820. .ExecuteCommandAsync();
  3821. }
  3822. }
  3823. }
  3824. if (id != 0)
  3825. {
  3826. return Ok(JsonView(true, "成功!"));
  3827. }
  3828. else
  3829. {
  3830. return Ok(JsonView(false, "失败!"));
  3831. }
  3832. }
  3833. catch (Exception ex)
  3834. {
  3835. return Ok(JsonView(false, "程序错误!"));
  3836. throw;
  3837. }
  3838. }
  3839. /// <summary>
  3840. /// 文件上传多个文件 可以带参数
  3841. /// </summary>
  3842. /// <param name="file"></param>
  3843. /// <returns></returns>
  3844. [HttpPost]
  3845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3846. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3847. {
  3848. try
  3849. {
  3850. var TypeName = Request.Headers["TypeName"].ToString();
  3851. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3852. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3853. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3854. var filePahts = new List<string>();
  3855. foreach (var file in files)
  3856. {
  3857. //文件名称
  3858. string projectFileName = file.FileName;
  3859. //上传的文件的路径
  3860. string filePath = $"{fileDir}/{projectFileName}";
  3861. if (TypeName == "A")//A代表团组增减款项
  3862. {
  3863. if (!Directory.Exists(fileDir))
  3864. {
  3865. Directory.CreateDirectory(fileDir);
  3866. }
  3867. //上传的文件的路径
  3868. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3869. }
  3870. else if (TypeName == "B")//B代表商邀相关文件
  3871. {
  3872. if (!Directory.Exists(fileDir))
  3873. {
  3874. Directory.CreateDirectory(fileDir);
  3875. }
  3876. //上传的文件的路径
  3877. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3878. }
  3879. using (FileStream fs = System.IO.File.Create(filePath))
  3880. {
  3881. file.CopyTo(fs);
  3882. fs.Flush();
  3883. }
  3884. filePahts.Add(projectFileName);
  3885. }
  3886. return Ok(JsonView(true, "上传成功!", filePahts));
  3887. }
  3888. catch (Exception ex)
  3889. {
  3890. return Ok(JsonView(false, "程序错误!"));
  3891. }
  3892. }
  3893. #endregion
  3894. #region 商邀费用录入
  3895. /// <summary>
  3896. /// 根据团组Id查询商邀费用列表
  3897. /// </summary>
  3898. /// <param name="dto"></param>
  3899. /// <returns></returns>
  3900. [HttpPost]
  3901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3902. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3903. {
  3904. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3905. if (groupData.Code != 0)
  3906. {
  3907. return Ok(JsonView(false, groupData.Msg));
  3908. }
  3909. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3910. }
  3911. /// <summary>
  3912. /// 商邀费用列表
  3913. /// 下载文件
  3914. /// </summary>
  3915. /// <param name="dto"></param>
  3916. /// <returns></returns>
  3917. [HttpGet("{id}")]
  3918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3919. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3920. {
  3921. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3922. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3923. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3924. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3925. var filePaths = new List<string>();
  3926. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3927. try
  3928. {
  3929. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3930. }
  3931. catch (Exception ex)
  3932. {
  3933. filePaths.Add(info.Attachment);
  3934. }
  3935. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3936. for (int i = 0; i < filePaths.Count; i++)
  3937. {
  3938. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3939. }
  3940. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3941. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3942. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3943. {
  3944. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3945. {
  3946. foreach (string filePath in filePaths)
  3947. {
  3948. if (System.IO.File.Exists(filePath))
  3949. {
  3950. // 获取文件名
  3951. string fileName = Path.GetFileName(filePath);
  3952. // 将文件添加到ZIP归档中
  3953. zipArchive.CreateEntryFromFile(filePath, fileName);
  3954. }
  3955. }
  3956. }
  3957. }
  3958. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3959. }
  3960. /// <summary>
  3961. /// 商邀费用 Info Page 基础数据源
  3962. /// </summary>
  3963. /// <param name="dto"></param>
  3964. /// <returns></returns>
  3965. [HttpPost]
  3966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3967. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3968. {
  3969. try
  3970. {
  3971. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3972. if (groupData.Code != 0)
  3973. {
  3974. return Ok(JsonView(false, groupData.Msg));
  3975. }
  3976. return Ok(JsonView(true, "操作成功", groupData.Data));
  3977. }
  3978. catch (Exception ex)
  3979. {
  3980. return Ok(JsonView(false, ex.Message));
  3981. throw;
  3982. }
  3983. }
  3984. /// <summary>
  3985. /// 根据商邀费用ID查询C表和商邀费用数据
  3986. /// </summary>
  3987. /// <param name="dto"></param>
  3988. /// <returns></returns>
  3989. [HttpPost]
  3990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3991. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3992. {
  3993. try
  3994. {
  3995. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3996. if (groupData.Code != 0)
  3997. {
  3998. return Ok(JsonView(false, groupData.Msg));
  3999. }
  4000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4001. }
  4002. catch (Exception ex)
  4003. {
  4004. return Ok(JsonView(false, ex.Message));
  4005. throw;
  4006. }
  4007. }
  4008. /// <summary>
  4009. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4010. /// </summary>
  4011. /// <param name="dto"></param>
  4012. /// <returns></returns>
  4013. [HttpPost]
  4014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4015. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4016. {
  4017. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4018. if (groupData.Code != 0)
  4019. {
  4020. return Ok(JsonView(false, groupData.Msg));
  4021. }
  4022. #region 应用推送
  4023. try
  4024. {
  4025. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4026. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4027. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4028. //2024-10-21 新增LZ UID
  4029. var userIds = new List<int>() { 21 };
  4030. string title = $"系统通知";
  4031. string content = "";
  4032. var diId = dto.DiId;
  4033. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4034. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4035. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4036. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4037. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4038. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4039. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4040. }
  4041. catch (Exception ex)
  4042. {
  4043. }
  4044. #endregion
  4045. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4046. }
  4047. /// <summary>
  4048. /// 商邀删除
  4049. /// </summary>
  4050. /// <param name="dto"></param>
  4051. /// <returns></returns>
  4052. [HttpPost]
  4053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4054. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4055. {
  4056. try
  4057. {
  4058. _sqlSugar.BeginTran();
  4059. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4060. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4061. {
  4062. IsDel = 1,
  4063. DeleteUserId = dto.DeleteUserId,
  4064. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4065. })
  4066. .Where(it => it.Id == dto.Id)
  4067. .ExecuteCommand();
  4068. if (res1 > 0)
  4069. {
  4070. int _diId = 0;
  4071. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4072. if (_ioaInfo != null)
  4073. {
  4074. _diId = _ioaInfo.DiId;
  4075. }
  4076. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4077. .SetColumns(a => new Grp_CreditCardPayment()
  4078. {
  4079. IsDel = 1,
  4080. DeleteUserId = dto.DeleteUserId,
  4081. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4082. })
  4083. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4084. .ExecuteCommand();
  4085. if (res2 > 0)
  4086. {
  4087. _sqlSugar.CommitTran();
  4088. return Ok(JsonView(true, "删除成功!"));
  4089. }
  4090. }
  4091. _sqlSugar.RollbackTran();
  4092. return Ok(JsonView(false, "删除失败"));
  4093. }
  4094. catch (Exception ex)
  4095. {
  4096. _sqlSugar.RollbackTran();
  4097. return Ok(JsonView(false, ex.Message));
  4098. }
  4099. }
  4100. /// <summary>
  4101. /// 团组模块文件上传
  4102. /// </summary>
  4103. /// <param name="dto"></param>
  4104. /// <returns></returns>
  4105. [HttpPost]
  4106. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4107. {
  4108. var jw = JsonView(false);
  4109. long M = 1024 * 1024;
  4110. if (dto.Files == null || dto.Files.Count == 0)
  4111. {
  4112. jw.Msg = "无文件信息!";
  4113. return Ok(jw);
  4114. }
  4115. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4116. {
  4117. jw.Msg = "文件大小超过20M!";
  4118. return Ok(jw);
  4119. }
  4120. //var nameSp = dto.File.FileName.Split(".");
  4121. //if (nameSp.Length < 2)
  4122. //{
  4123. // jw.Msg = "拓展名称有误!";
  4124. // return Ok(jw);
  4125. //}
  4126. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4127. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4128. //{
  4129. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4130. // return Ok(jw);
  4131. //}
  4132. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4133. if (Ctable == null)
  4134. {
  4135. jw.Msg = "Ctable指向有误!";
  4136. return Ok(jw);
  4137. }
  4138. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4139. if (groupInfo == null)
  4140. {
  4141. jw.Msg = "团组信息不存在!";
  4142. return Ok(jw);
  4143. }
  4144. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4145. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4146. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4147. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4148. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4149. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4150. try
  4151. {
  4152. if (!Directory.Exists(fileBase))
  4153. {
  4154. Directory.CreateDirectory(fileBase);
  4155. }
  4156. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4157. foreach (var fileStream in dto.Files)
  4158. {
  4159. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4160. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4161. {
  4162. Cid = dto.Cid,
  4163. CreateTime = DateTime.Now,
  4164. CreateUserId = dto.Userid,
  4165. Ctable = dto.Ctable,
  4166. Diid = dto.Diid,
  4167. IsDel = 0,
  4168. FilePath = saveFilePath,
  4169. FileName = fileStream.FileName
  4170. };
  4171. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4172. {
  4173. fileStream.CopyTo(fs);
  4174. fs.Flush();
  4175. }
  4176. saveArr.Add(file);
  4177. }
  4178. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4179. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4180. jw = JsonView(true, "保存成功!", new
  4181. {
  4182. count = addResult,
  4183. filesName = saveArr.Select(x => x.FileName)
  4184. });
  4185. }
  4186. catch (Exception ex)
  4187. {
  4188. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4189. {
  4190. count = 0,
  4191. filesName = new string[0],
  4192. });
  4193. }
  4194. return Ok(jw);
  4195. }
  4196. /// <summary>
  4197. /// 查询各模块已保存文件
  4198. /// </summary>
  4199. /// <param name="dto"></param>
  4200. /// <returns></returns>
  4201. [HttpPost]
  4202. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4203. {
  4204. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4205. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4206. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4207. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4208. {
  4209. expression = Expressionable.Create<Grp_GroupModelFile>()
  4210. .And(x => visaIds.Contains(x.CreateUserId));
  4211. }
  4212. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4213. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4214. .Where(expression.ToExpression())
  4215. .ToList();
  4216. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4217. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4218. {
  4219. x.FileName,
  4220. x.Id,
  4221. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4222. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4223. })));
  4224. }
  4225. /// <summary>
  4226. /// 下载该团组下的所有文件
  4227. /// </summary>
  4228. /// <param name="dto"></param>
  4229. /// <returns></returns>
  4230. [HttpPost]
  4231. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4232. {
  4233. var jw = JsonView(false);
  4234. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4235. if (groupInfo == null)
  4236. {
  4237. jw.Msg = "团组信息不存在!";
  4238. return Ok(jw);
  4239. }
  4240. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4241. var isModule = Convert.ToBoolean(dto.isModule);
  4242. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4243. IOOperatorHelper io = new IOOperatorHelper();
  4244. if (isModule)
  4245. {
  4246. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4247. foreach (var moduleArr in moduleGroup)
  4248. {
  4249. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4250. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4251. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4252. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4253. foreach (var item in moduleArr)
  4254. {
  4255. if (System.IO.File.Exists(item.FilePath))
  4256. {
  4257. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4258. {
  4259. byte[] bytes = new byte[fileStream.Length];
  4260. fileStream.Read(bytes, 0, bytes.Length);
  4261. fileStream.Close();
  4262. Stream stream = new MemoryStream(bytes);
  4263. chiZips.Add(item.FileName, stream);
  4264. }
  4265. }
  4266. }
  4267. if (chiZips.Count > 0)
  4268. {
  4269. var byts = io.ConvertZipStream(chiZips);
  4270. Stream stream = new MemoryStream(byts);
  4271. Zips.Add(key.Name + "_.zip", stream);
  4272. }
  4273. }
  4274. }
  4275. else
  4276. {
  4277. foreach (var item in dbQuery)
  4278. {
  4279. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4280. {
  4281. byte[] bytes = new byte[fileStream.Length];
  4282. fileStream.Read(bytes, 0, bytes.Length);
  4283. fileStream.Close();
  4284. Stream stream = new MemoryStream(bytes);
  4285. while (Zips.Keys.Contains(item.FileName))
  4286. {
  4287. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4288. }
  4289. Zips.Add(item.FileName, stream);
  4290. }
  4291. }
  4292. }
  4293. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4294. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4295. if (Zips.Count > 0)
  4296. {
  4297. var byts = io.ConvertZipStream(Zips);
  4298. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4299. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4300. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4301. }
  4302. else
  4303. {
  4304. jw.Msg = "暂无生成文件!";
  4305. }
  4306. return Ok(jw);
  4307. }
  4308. /// <summary>
  4309. /// 下载该团组下此模块的所有文件
  4310. /// </summary>
  4311. /// <param name="dto"></param>
  4312. /// <returns></returns>
  4313. [HttpPost]
  4314. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4315. {
  4316. var jw = JsonView(false);
  4317. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4318. if (groupInfo == null)
  4319. {
  4320. jw.Msg = "团组信息不存在!";
  4321. return Ok(jw);
  4322. }
  4323. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4324. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4325. && x.IsDel == 0);
  4326. if (key == null)
  4327. {
  4328. jw.Msg = "Ctable指向错误!";
  4329. return Ok(jw);
  4330. }
  4331. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4332. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4333. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4334. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4335. IOOperatorHelper io = new IOOperatorHelper();
  4336. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4337. foreach (var item in dbQuery)
  4338. {
  4339. if (System.IO.File.Exists(item.FilePath))
  4340. {
  4341. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4342. {
  4343. byte[] bytes = new byte[fileStream.Length];
  4344. fileStream.Read(bytes, 0, bytes.Length);
  4345. fileStream.Close();
  4346. Stream stream = new MemoryStream(bytes);
  4347. while (Zips.Keys.Contains(item.FileName))
  4348. {
  4349. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4350. }
  4351. Zips.Add(item.FileName, stream);
  4352. }
  4353. }
  4354. }
  4355. if (Zips.Count > 0)
  4356. {
  4357. var byts = io.ConvertZipStream(Zips);
  4358. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4359. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4360. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4361. }
  4362. else
  4363. {
  4364. jw.Msg = "暂无生成文件!";
  4365. }
  4366. return Ok(jw);
  4367. }
  4368. /// <summary>
  4369. /// 删除该团组下的指定文件
  4370. /// </summary>
  4371. /// <param name="dto"></param>
  4372. /// <returns></returns>
  4373. [HttpPost]
  4374. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4375. {
  4376. var jw = JsonView(false);
  4377. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4378. if (sing == null)
  4379. {
  4380. jw.Msg = "暂无";
  4381. return Ok(jw);
  4382. }
  4383. if (System.IO.File.Exists(sing.FilePath))
  4384. {
  4385. try
  4386. {
  4387. System.IO.File.Delete(sing.FilePath);
  4388. }
  4389. catch (Exception ex)
  4390. {
  4391. jw.Msg = "删除失败!" + ex.Message;
  4392. return Ok(jw);
  4393. }
  4394. }
  4395. sing.IsDel = 1;
  4396. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4397. sing.DeleteUserId = dto.UserId;
  4398. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4399. jw = JsonView(true, "删除成功!");
  4400. return Ok(jw);
  4401. }
  4402. #endregion
  4403. #region 团组英文资料
  4404. /// <summary>
  4405. /// 查询团组英文所有资料
  4406. /// </summary>
  4407. /// <param name="dto"></param>
  4408. /// <returns></returns>
  4409. [HttpPost]
  4410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4411. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4412. {
  4413. try
  4414. {
  4415. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4416. if (groupData.Code != 0)
  4417. {
  4418. return Ok(JsonView(false, groupData.Msg));
  4419. }
  4420. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4421. }
  4422. catch (Exception ex)
  4423. {
  4424. return Ok(JsonView(false, "程序错误!"));
  4425. throw;
  4426. }
  4427. }
  4428. /// <summary>
  4429. /// 团组英文资料操作(Status:1.新增,2.修改)
  4430. /// </summary>
  4431. /// <param name="dto"></param>
  4432. /// <returns></returns>
  4433. [HttpPost]
  4434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4435. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4436. {
  4437. try
  4438. {
  4439. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4440. if (groupData.Code != 0)
  4441. {
  4442. return Ok(JsonView(false, groupData.Msg));
  4443. }
  4444. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4445. }
  4446. catch (Exception ex)
  4447. {
  4448. return Ok(JsonView(false, "程序错误!"));
  4449. throw;
  4450. }
  4451. }
  4452. /// <summary>
  4453. /// 团组英文资料Id查询数据
  4454. /// </summary>
  4455. /// <param name="dto"></param>
  4456. /// <returns></returns>
  4457. [HttpPost]
  4458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4459. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4460. {
  4461. try
  4462. {
  4463. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4464. if (_DelegationEnData != null)
  4465. {
  4466. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4467. }
  4468. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4469. }
  4470. catch (Exception ex)
  4471. {
  4472. return Ok(JsonView(false, "程序错误!"));
  4473. throw;
  4474. }
  4475. }
  4476. /// <summary>
  4477. /// 团组英文资料删除
  4478. /// </summary>
  4479. /// <param name="dto"></param>
  4480. /// <returns></returns>
  4481. [HttpPost]
  4482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4483. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4484. {
  4485. try
  4486. {
  4487. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4488. if (!res)
  4489. {
  4490. return Ok(JsonView(false, "删除失败"));
  4491. }
  4492. return Ok(JsonView(true, "删除成功!"));
  4493. }
  4494. catch (Exception ex)
  4495. {
  4496. return Ok(JsonView(false, "程序错误!"));
  4497. throw;
  4498. }
  4499. }
  4500. #endregion
  4501. #region 导出邀请函
  4502. /// <summary>
  4503. /// 导出邀请函页面初始化
  4504. /// </summary>
  4505. /// <param name="dto"></param>
  4506. /// <returns></returns>
  4507. [HttpPost]
  4508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4509. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4510. {
  4511. try
  4512. {
  4513. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4514. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4515. if (dto.DiId == 0)
  4516. {
  4517. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4518. }
  4519. else
  4520. {
  4521. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4522. }
  4523. return Ok(JsonView(true, "查询成功!", new
  4524. {
  4525. deleClient = crm_Deles,
  4526. delegations = grp_Delegations
  4527. }));
  4528. }
  4529. catch (Exception ex)
  4530. {
  4531. return Ok(JsonView(false, "程序错误!"));
  4532. throw;
  4533. }
  4534. }
  4535. /// <summary>
  4536. /// 导出邀请函
  4537. /// </summary>
  4538. /// <param name="dto"></param>
  4539. /// <returns></returns>
  4540. [HttpPost]
  4541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4542. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4543. {
  4544. #region 参数验证
  4545. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4546. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4547. #endregion
  4548. try
  4549. {
  4550. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4551. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4552. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4553. From Grp_TourClientList tcl
  4554. Left Join
  4555. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4556. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4557. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4558. From Crm_DeleClient dc
  4559. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4560. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4561. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4562. Where dc.IsDel = 0) temp
  4563. On temp.DcId =tcl.ClientId
  4564. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4565. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4566. List<string> texts = new List<string>();
  4567. if (datas.Count != 0)
  4568. {
  4569. foreach (TourClientListDetailsView item in datas)
  4570. {
  4571. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4572. {
  4573. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4574. }
  4575. else
  4576. {
  4577. string name = item.LastName + item.FirstName;
  4578. texts.Add(name);
  4579. }
  4580. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4581. {
  4582. if (!transDic.ContainsKey(item.Job))
  4583. {
  4584. texts.Add(item.Job);
  4585. }
  4586. }
  4587. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4588. {
  4589. texts.Add(item.CompanyFullName);
  4590. }
  4591. }
  4592. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4593. if (transData.Count > 0)
  4594. {
  4595. foreach (TranslateResult item in transData)
  4596. {
  4597. if (!transDic.ContainsKey(item.Query))
  4598. {
  4599. transDic.Add(item.Query, item.Translation);
  4600. }
  4601. }
  4602. }
  4603. List<GuestList> list = new List<GuestList>();
  4604. foreach (TourClientListDetailsView dele in datas)
  4605. {
  4606. GuestList guestList = new GuestList();
  4607. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4608. {
  4609. guestList.Name = dele.Pinyin;
  4610. }
  4611. else
  4612. {
  4613. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4614. guestList.Name = Name;
  4615. }
  4616. if (dele.Sex == 0)
  4617. {
  4618. guestList.Sex = "Male";
  4619. }
  4620. else if (dele.Sex == 1)
  4621. {
  4622. guestList.Sex = "Female";
  4623. }
  4624. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4625. if (!string.IsNullOrEmpty(dele.Job))
  4626. {
  4627. guestList.Job = dele.Job;
  4628. }
  4629. list.Add(guestList);
  4630. }
  4631. //载入模板
  4632. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4633. DocumentBuilder builder = new DocumentBuilder(doc);
  4634. //获取word里所有表格
  4635. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4636. //获取所填表格的序数
  4637. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4638. var rowStart = tableOne.Rows[0]; //获取第1行
  4639. //循环赋值
  4640. for (int i = 0; i < list.Count; i++)
  4641. {
  4642. builder.MoveToCell(0, i + 1, 0, 0);
  4643. builder.Write(list[i].Name.ToString());
  4644. builder.MoveToCell(0, i + 1, 1, 0);
  4645. builder.Write(list[i].Sex.ToString());
  4646. builder.MoveToCell(0, i + 1, 2, 0);
  4647. builder.Write(list[i].DOB.ToString());
  4648. builder.MoveToCell(0, i + 1, 3, 0);
  4649. builder.Write(list[i].Job.ToString());
  4650. }
  4651. //删除多余行
  4652. while (tableOne.Rows.Count > list.Count + 1)
  4653. {
  4654. tableOne.Rows.RemoveAt(list.Count + 1);
  4655. }
  4656. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4657. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4658. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4659. doc.Save(filePath);
  4660. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4661. return Ok(JsonView(true, "操作成功!", Url));
  4662. }
  4663. else
  4664. {
  4665. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4666. }
  4667. }
  4668. catch (Exception ex)
  4669. {
  4670. return Ok(JsonView(false, ex.Message));
  4671. throw;
  4672. }
  4673. }
  4674. #endregion
  4675. #region 团组经理模块 出入境费用
  4676. /// <summary>
  4677. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4678. /// </summary>
  4679. /// <returns></returns>
  4680. [HttpPost]
  4681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4682. public async Task<IActionResult> SetDayAndCostAreaChange()
  4683. {
  4684. try
  4685. {
  4686. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4687. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4688. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4689. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4690. foreach (var item in unite) //处理交集数据
  4691. {
  4692. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4693. }
  4694. foreach (var item in merge) //处理差集数据
  4695. {
  4696. int nationalTravelFeeId = 0;
  4697. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4698. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4699. else
  4700. {
  4701. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4702. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4703. }
  4704. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4705. }
  4706. //只更新dayAndCost 的 nationalTravelFeeId;
  4707. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4708. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4709. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4710. }
  4711. catch (Exception ex)
  4712. {
  4713. return Ok(JsonView(false, ex.Message));
  4714. throw;
  4715. }
  4716. }
  4717. /// <summary>
  4718. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4719. /// </summary>
  4720. /// <returns></returns>
  4721. [HttpPost]
  4722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4723. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4724. {
  4725. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4726. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4727. //SetDataInfoView
  4728. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4729. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4730. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4731. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4732. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4733. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4734. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4735. //默认币种显示
  4736. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4737. {
  4738. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4739. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4740. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4741. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4742. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4743. };
  4744. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4745. if (_currencyRate.Count > 0)
  4746. {
  4747. foreach (var item in _currencyInfos)
  4748. {
  4749. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4750. if (rateInfo != null)
  4751. {
  4752. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4753. rate1 *= 1.035M;
  4754. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4755. }
  4756. }
  4757. }
  4758. return Ok(JsonView(true, "查询成功!", new
  4759. {
  4760. GroupNameData = groupNameData.Data,
  4761. CurrencyData = _CurrencyData,
  4762. WordTypeData = _WordTypeData,
  4763. ExcelTypeData = _ExcelTypeData,
  4764. CurrencyInit = _currencyInfos
  4765. }));
  4766. }
  4767. /// <summary>
  4768. /// 团组模块 - 出入境费用
  4769. /// 实时汇率 tips
  4770. /// 签证费用 tips
  4771. /// 机票费用 tips
  4772. /// </summary>
  4773. /// <returns></returns>
  4774. [HttpPost]
  4775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4776. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4777. {
  4778. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4779. //默认币种显示
  4780. var _currencyInfos = _currencyInit;
  4781. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4782. List<dynamic> reteInfos = new List<dynamic>();
  4783. if (_currencyRate.Count > 0)
  4784. {
  4785. foreach (var item in _currencyInfos)
  4786. {
  4787. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4788. if (rateInfo != null)
  4789. {
  4790. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4791. decimal rate1 = item.Rate;
  4792. rate1 *= 1.03M;
  4793. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4794. reteInfos.Add(new
  4795. {
  4796. currCode = item.CurrencyCode,
  4797. currName = item.CurrencyName,
  4798. rate = rate2,
  4799. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4800. });
  4801. }
  4802. }
  4803. }
  4804. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4805. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4806. return Ok(JsonView(true, "查询成功!", new
  4807. {
  4808. //GroupNameData = groupNameData.Data,
  4809. visaData = visaData.Data,
  4810. airData = airData.Data,
  4811. reteInfos = reteInfos
  4812. }));
  4813. }
  4814. /// <summary>
  4815. /// 团组模块 - 出入境费用 - Info
  4816. /// </summary>
  4817. /// <returns></returns>
  4818. [HttpPost]
  4819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4820. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4821. {
  4822. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4823. }
  4824. /// <summary>
  4825. /// 团组模块 - 出入境费用 - Add And Update
  4826. /// </summary>
  4827. /// <returns></returns>
  4828. [HttpPost]
  4829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4830. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4831. {
  4832. try
  4833. {
  4834. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4835. if (dto.DayOtherPriceData.Any())
  4836. {
  4837. var inserList = dto.DayOtherPriceData
  4838. .Where(x => x.Id == 0)
  4839. .Select(x => new Grp_DayOtherPrice
  4840. {
  4841. Cost = x.Cost,
  4842. Id = x.Id,
  4843. CreateTime = DateTime.Now,
  4844. CreateUserId = dto.UserId,
  4845. Currency = x.Currency,
  4846. Diid = x.DiId,
  4847. Index = x.Index,
  4848. IsDel = 0,
  4849. SetDataId = x.SetDataId,
  4850. SubTotal = x.SubTotal,
  4851. Remark = x.Remark
  4852. })
  4853. .ToList();
  4854. var updateList = dto.DayOtherPriceData
  4855. .Where(x => x.Id != 0)
  4856. .Select(x => new Grp_DayOtherPrice
  4857. {
  4858. Cost = x.Cost,
  4859. Id = x.Id,
  4860. CreateTime = DateTime.Now,
  4861. CreateUserId = dto.UserId,
  4862. Currency = x.Currency,
  4863. Diid = x.DiId,
  4864. Index = x.Index,
  4865. IsDel = 0,
  4866. SetDataId = x.SetDataId,
  4867. SubTotal = x.SubTotal,
  4868. Remark = x.Remark
  4869. })
  4870. .ToList();
  4871. //添加
  4872. _sqlSugar.BeginTran();
  4873. if (inserList.Any())
  4874. {
  4875. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4876. }
  4877. if (updateList.Any())
  4878. {
  4879. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4880. }
  4881. _sqlSugar.CommitTran();
  4882. }
  4883. if (data.Code != 0)
  4884. {
  4885. return Ok(JsonView(false, data.Msg));
  4886. }
  4887. //生成默认文件pdf并且通知人员
  4888. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4889. {
  4890. DiId = dto.DiId,
  4891. ExportType = 1,
  4892. SubTypeId = 1005
  4893. }, "pdf");
  4894. //发送通知
  4895. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4896. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4897. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4898. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4899. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4900. //汇率信息记录
  4901. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4902. return Ok(JsonView(true, data.Msg, data.Data));
  4903. }
  4904. catch (Exception ex)
  4905. {
  4906. return Ok(JsonView(false, ex.Message));
  4907. }
  4908. }
  4909. /// <summary>
  4910. /// 团组模块 - 出入境费用 - Confirm 费用
  4911. /// </summary>
  4912. /// <returns></returns>
  4913. [HttpPost]
  4914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4915. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4916. {
  4917. //TODO:测试完毕需把对应的用户ID更改
  4918. //1、数据表添加字段
  4919. //2、更改字段接口()
  4920. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4921. //3、确认成功 给财务发送消息
  4922. if (_view.Code == 200)
  4923. {
  4924. if (dto.Type == 1)
  4925. {
  4926. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4927. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4928. }
  4929. }
  4930. return Ok(_view);
  4931. }
  4932. /// <summary>
  4933. /// 团组模块 - 出入境费用 - File downlaod
  4934. /// </summary>
  4935. /// <param name="dto"></param>
  4936. /// <returns></returns>
  4937. [HttpPost]
  4938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4939. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4940. {
  4941. try
  4942. {
  4943. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4944. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4945. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4946. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4947. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4948. 3 团组成员名单 1 团组成员名单", ""));
  4949. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4950. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4951. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4952. //数据源
  4953. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4954. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4955. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4956. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4957. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4958. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4959. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4960. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4961. .Select((x, a, b) => new
  4962. {
  4963. x.Index,
  4964. itemName = a.Name,
  4965. CurrencyStr = b.Name,
  4966. x.Cost,
  4967. x.SubTotal,
  4968. x.Remark
  4969. })
  4970. .OrderBy((x) => x.Index)
  4971. .ToList(); //其他款项费用
  4972. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4973. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4974. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4975. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4976. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4977. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4978. .Select((tcl, dc, cc) => new ClientInfo
  4979. {
  4980. LastName = dc.LastName,
  4981. FirstName = dc.FirstName,
  4982. Sex = dc.Sex,
  4983. Birthday = dc.BirthDay,
  4984. Company = cc.CompanyFullName,
  4985. Job = dc.Job
  4986. })
  4987. .ToList();
  4988. foreach (var item in DeleClientList)
  4989. {
  4990. EncryptionProcessor.DecryptProperties(item);
  4991. }
  4992. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4993. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4994. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4995. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4996. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4997. if (dto.ExportType == 1) //明细表
  4998. {
  4999. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5000. {
  5001. //获取模板
  5002. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5003. //载入模板
  5004. Document doc = new Document(tempPath);
  5005. DocumentBuilder builder = new DocumentBuilder(doc);
  5006. //利用键值对存放数据
  5007. Dictionary<string, string> dic = new Dictionary<string, string>();
  5008. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5009. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5010. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5011. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5012. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5013. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5014. //境内费用(其他费用)
  5015. if (_EnterExitCosts.ChoiceOne == 1)
  5016. {
  5017. string row1_1 = "";
  5018. if (_EnterExitCosts.Visa > 0)
  5019. {
  5020. //insidePayTotal += _EnterExitCosts.Visa;
  5021. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5022. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5023. {
  5024. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5025. }
  5026. }
  5027. string row1_2 = "";
  5028. if (_EnterExitCosts.YiMiao > 0)
  5029. {
  5030. //insidePayTotal += _EnterExitCosts.YiMiao;
  5031. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5032. }
  5033. if (_EnterExitCosts.HeSuan > 0)
  5034. {
  5035. //insidePayTotal += _EnterExitCosts.HeSuan;
  5036. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5037. }
  5038. if (_EnterExitCosts.Service > 0)
  5039. {
  5040. //insidePayTotal += _EnterExitCosts.Service;
  5041. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5042. }
  5043. string row1_3 = "";
  5044. if (_EnterExitCosts.Safe > 0)
  5045. {
  5046. //insidePayTotal += _EnterExitCosts.Safe;
  5047. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5048. }
  5049. if (_EnterExitCosts.Ticket > 0)
  5050. {
  5051. //insidePayTotal += _EnterExitCosts.Ticket;
  5052. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5053. }
  5054. string row1 = "";
  5055. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5056. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5057. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5058. row1 += $"备注:{_EnterExitCosts.Remark}";
  5059. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5060. dic.Add("Row1Str", row1);
  5061. }
  5062. string airTotalStr = string.Empty,
  5063. airPriceStr = string.Empty;
  5064. //经济舱
  5065. if (_EnterExitCosts.SumJJC == 1)
  5066. {
  5067. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5068. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5069. }
  5070. //公务舱
  5071. if (_EnterExitCosts.SumGWC == 1)
  5072. {
  5073. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5074. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5075. }
  5076. //头等舱
  5077. if (_EnterExitCosts.SumTDC == 1)
  5078. {
  5079. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5080. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5081. }
  5082. string twoItemRemark = "备注:";
  5083. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5084. {
  5085. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5086. }
  5087. dic.Add("AirTotalStr", airTotalStr);
  5088. dic.Add("AirPriceStr", airPriceStr);
  5089. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5090. dic.Add("TwoItemRemark", twoItemRemark);
  5091. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5092. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5093. int table1Row = 0,
  5094. table2Row = 0,
  5095. table3Row = 0,
  5096. table4Row = 0,
  5097. table5Row = 0;
  5098. //住宿费
  5099. if (_EnterExitCosts.ChoiceThree == 1)
  5100. {
  5101. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5102. table1Row = dac1.Count;
  5103. #region 填充word表格内容
  5104. for (int i = 0; i < dac1.Count; i++)
  5105. {
  5106. Grp_DayAndCost dac = dac1[i];
  5107. if (dac == null) continue;
  5108. builder.MoveToCell(0, i, 0, 0);
  5109. builder.Write("第" + dac.Days.ToString() + "晚:");
  5110. builder.MoveToCell(0, i, 1, 0);
  5111. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5112. //builder.Write(dac.Place == null ? "" : dac.Place);
  5113. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5114. builder.MoveToCell(0, i, 2, 0);
  5115. builder.Write("费用标准:");
  5116. string curr = "";
  5117. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5118. if (currData != null)
  5119. {
  5120. curr = currData.Name;
  5121. }
  5122. builder.MoveToCell(0, i, 3, 0);
  5123. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5124. builder.MoveToCell(0, i, 4, 0);
  5125. builder.Write("费用小计:");
  5126. builder.MoveToCell(0, i, 5, 0);
  5127. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5128. }
  5129. #endregion
  5130. }
  5131. else dic.Add("SubZS", "0.00");
  5132. //删除多余行
  5133. while (table1.Rows.Count > table1Row)
  5134. {
  5135. table1.Rows.RemoveAt(table1Row);
  5136. }
  5137. //伙食费
  5138. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5139. if (_EnterExitCosts.ChoiceFour == 1)
  5140. {
  5141. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5142. table2Row = dac2.Count;
  5143. #region 填充word表格内容
  5144. for (int i = 0; i < dac2.Count; i++)
  5145. {
  5146. Grp_DayAndCost dac = dac2[i];
  5147. if (dac == null) continue;
  5148. builder.MoveToCell(1, i, 0, 0);
  5149. builder.Write("第" + dac.Days.ToString() + "天:");
  5150. builder.MoveToCell(1, i, 1, 0);
  5151. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5152. builder.MoveToCell(1, i, 2, 0);
  5153. builder.Write("费用标准:");
  5154. string curr = "";
  5155. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5156. if (currData != null)
  5157. {
  5158. curr = currData.Name;
  5159. }
  5160. builder.MoveToCell(1, i, 3, 0);
  5161. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5162. builder.MoveToCell(1, i, 4, 0);
  5163. builder.Write("费用小计:");
  5164. builder.MoveToCell(1, i, 5, 0);
  5165. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5166. }
  5167. #endregion
  5168. }
  5169. else dic.Add("SubHS", "0.00");
  5170. //删除多余行
  5171. while (table2.Rows.Count > table2Row)
  5172. {
  5173. table2.Rows.RemoveAt(table2Row);
  5174. }
  5175. //公杂费
  5176. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5177. if (_EnterExitCosts.ChoiceFive == 1)
  5178. {
  5179. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5180. table3Row = dac3.Count;
  5181. #region 填充word表格内容
  5182. for (int i = 0; i < dac3.Count; i++)
  5183. {
  5184. Grp_DayAndCost dac = dac3[i];
  5185. if (dac == null) continue;
  5186. builder.MoveToCell(2, i, 0, 0);
  5187. builder.Write("第" + dac.Days.ToString() + "天:");
  5188. builder.MoveToCell(2, i, 1, 0);
  5189. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5190. builder.MoveToCell(2, i, 2, 0);
  5191. builder.Write("费用标准:");
  5192. string curr = "";
  5193. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5194. if (currData != null)
  5195. {
  5196. curr = currData.Name;
  5197. }
  5198. builder.MoveToCell(2, i, 3, 0);
  5199. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5200. builder.MoveToCell(2, i, 4, 0);
  5201. builder.Write("费用小计:");
  5202. builder.MoveToCell(2, i, 5, 0);
  5203. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5204. }
  5205. //删除多余行
  5206. while (table3.Rows.Count > table3Row)
  5207. {
  5208. table3.Rows.RemoveAt(table3Row);
  5209. }
  5210. #endregion
  5211. }
  5212. else dic.Add("SubGZF", "0.00");
  5213. //删除多余行
  5214. while (table3.Rows.Count > table3Row)
  5215. {
  5216. table3.Rows.RemoveAt(table3Row);
  5217. }
  5218. //培训费
  5219. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5220. if (_EnterExitCosts.ChoiceSix == 1)
  5221. {
  5222. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5223. dic.Add("SubPX", pxStr);
  5224. table4Row = dac4.Count;
  5225. #region 填充word表格内容
  5226. for (int i = 0; i < dac4.Count; i++)
  5227. {
  5228. Grp_DayAndCost dac = dac4[i];
  5229. if (dac == null) continue;
  5230. builder.MoveToCell(3, i, 0, 0);
  5231. builder.Write("第" + dac.Days.ToString() + "天:");
  5232. builder.MoveToCell(3, i, 1, 0);
  5233. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5234. builder.MoveToCell(3, i, 2, 0);
  5235. builder.Write("费用标准:");
  5236. string curr = "";
  5237. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5238. if (currData != null)
  5239. {
  5240. curr = currData.Name;
  5241. }
  5242. builder.MoveToCell(3, i, 3, 0);
  5243. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5244. builder.MoveToCell(3, i, 4, 0);
  5245. builder.Write("费用小计:");
  5246. builder.MoveToCell(3, i, 5, 0);
  5247. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5248. }
  5249. #endregion
  5250. }
  5251. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5252. //删除多余行
  5253. while (table4.Rows.Count > table4Row)
  5254. {
  5255. table4.Rows.RemoveAt(table4Row);
  5256. }
  5257. //其他费用
  5258. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5259. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5260. {
  5261. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5262. dic.Add("titleQi", qtStr);
  5263. table5Row = dac5.Count;
  5264. #region 填充word表格内容
  5265. for (int i = 0; i < dac5.Count; i++)
  5266. {
  5267. var dac = dac5[i];
  5268. if (dac == null) continue;
  5269. builder.MoveToCell(4, i, 0, 0);
  5270. builder.Write("第" + dac.Index.ToString() + "项:");
  5271. builder.MoveToCell(4, i, 1, 0);
  5272. builder.Write(dac.itemName);
  5273. builder.MoveToCell(4, i, 2, 0);
  5274. builder.Write("费用标准:");
  5275. builder.MoveToCell(4, i, 3, 0);
  5276. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5277. builder.MoveToCell(4, i, 4, 0);
  5278. builder.Write("费用小计:");
  5279. builder.MoveToCell(4, i, 5, 0);
  5280. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5281. builder.MoveToCell(4, i, 6, 0);
  5282. builder.Write("备注:");
  5283. builder.MoveToCell(4, i, 7, 0);
  5284. builder.Write(dac.Remark);
  5285. }
  5286. #endregion
  5287. }
  5288. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5289. //删除多余行
  5290. while (table5.Rows.Count > table5Row)
  5291. {
  5292. table5.Rows.RemoveAt(table5Row);
  5293. }
  5294. //加上其他费用
  5295. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5296. decimal subJJC = 0.00M,
  5297. subGWC = 0.00M,
  5298. subTDC = 0.00M;
  5299. //经济舱
  5300. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5301. //公务舱
  5302. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5303. //头等舱
  5304. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5305. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5306. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5307. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5308. #region 填充word模板书签内容
  5309. foreach (var key in dic.Keys)
  5310. {
  5311. Bookmark bookmark = doc.Range.Bookmarks[key];
  5312. if (bookmark != null)
  5313. {
  5314. builder.MoveToBookmark(key);
  5315. builder.Write(dic[key]);
  5316. }
  5317. }
  5318. #endregion
  5319. //文件名
  5320. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5321. AsposeHelper.removewatermark_v2180();
  5322. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5323. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5324. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5325. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5326. }
  5327. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5328. {
  5329. //获取模板
  5330. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5331. //载入模板
  5332. Document doc = new Document(tempPath);
  5333. DocumentBuilder builder = new DocumentBuilder(doc);
  5334. Dictionary<string, string> dic = new Dictionary<string, string>();
  5335. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5336. {
  5337. List<string> list = new List<string>();
  5338. try
  5339. {
  5340. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5341. foreach (var item in spilitArr)
  5342. {
  5343. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5344. var depCode = spDotandEmpty[2].Substring(0, 3);
  5345. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5346. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5347. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5348. list.Add(depName);
  5349. list.Add(arrName);
  5350. }
  5351. list = list.Distinct().ToList();
  5352. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5353. }
  5354. catch (Exception)
  5355. {
  5356. dic.Add("ReturnCode", "行程录入不正确!");
  5357. }
  5358. }
  5359. else
  5360. {
  5361. dic.Add("ReturnCode", "未录入行程!");
  5362. }
  5363. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5364. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5365. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5366. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5367. {
  5368. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5369. dic.Add("Day", sp.Days.ToString());
  5370. }
  5371. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5372. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5373. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5374. //dic.Add("Names", Names);
  5375. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5376. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5377. decimal dac1totalPrice = 0.00M;
  5378. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5379. foreach (var dac in dac1)
  5380. {
  5381. if (dac.SubTotal == 0.00M)
  5382. {
  5383. continue;
  5384. }
  5385. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5386. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5387. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5388. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5389. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5390. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5391. builder.Write(currency);//币种
  5392. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5393. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5394. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5395. builder.Write("");//人数
  5396. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5397. builder.Write("");//天数
  5398. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5399. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5400. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5401. decimal rate = 0.00M;
  5402. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5403. builder.Write(rate.ToString("#0.0000"));//汇率
  5404. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5405. decimal rbmPrice = dac.SubTotal;
  5406. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5407. accommodationStartIndex++;
  5408. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5409. }
  5410. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5411. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5412. {
  5413. table1.Rows.RemoveAt(i - 1);
  5414. foodandotherStartIndex--;
  5415. }
  5416. if (dac2.Count == dac3.Count)//国家 币种 金额
  5417. {
  5418. for (int i = 0; i < dac2.Count; i++)
  5419. {
  5420. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5421. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5422. }
  5423. }
  5424. decimal dac2totalPrice = 0.00M;
  5425. foreach (var dac in dac2)
  5426. {
  5427. if (dac.SubTotal == 0)
  5428. {
  5429. continue;
  5430. }
  5431. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5432. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5433. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5434. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5435. builder.Write(currency);//币种
  5436. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5437. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5438. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5439. builder.Write("");//人数
  5440. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5441. builder.Write("");//天数
  5442. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5443. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5444. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5445. decimal rate = 0.00M;
  5446. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5447. builder.Write(rate.ToString("#0.0000"));//汇率
  5448. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5449. decimal rbmPrice = dac.SubTotal;
  5450. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5451. foodandotherStartIndex++;
  5452. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5453. }
  5454. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5455. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5456. {
  5457. table1.Rows.RemoveAt(i - 1);
  5458. }
  5459. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5460. string otherFeeStr = "";
  5461. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5462. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5463. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5464. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5465. foreach (var otherInfo in dac5)
  5466. {
  5467. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5468. }
  5469. #endregion
  5470. if (otherFeeStr.Length > 0)
  5471. {
  5472. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5473. otherFeeStr = $"({otherFeeStr})";
  5474. dic.Add("OtherFeeStr", otherFeeStr);
  5475. }
  5476. //总计
  5477. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5478. //国际旅费
  5479. string outsideAir = string.Empty;
  5480. string allPriceAir = string.Empty;
  5481. if (_EnterExitCosts.SumJJC == 1)
  5482. {
  5483. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5484. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5485. }
  5486. if (_EnterExitCosts.SumGWC == 1)
  5487. {
  5488. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5489. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5490. }
  5491. if (_EnterExitCosts.SumTDC == 1)
  5492. {
  5493. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5494. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5495. }
  5496. dic.Add("InTravelPrice", $"({outsideAir})");
  5497. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5498. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5499. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5500. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5501. foreach (var key in dic.Keys)
  5502. {
  5503. builder.MoveToBookmark(key);
  5504. builder.Write(dic[key]);
  5505. }
  5506. //模板文件名
  5507. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5508. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5509. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5510. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5511. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5512. }
  5513. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5514. {
  5515. //获取模板
  5516. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5517. //载入模板
  5518. WorkbookDesigner designer = new WorkbookDesigner();
  5519. designer.Workbook = new Workbook(tempPath);
  5520. Dictionary<string, string> dic = new Dictionary<string, string>();
  5521. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5522. {
  5523. List<string> list = new List<string>();
  5524. try
  5525. {
  5526. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5527. foreach (var item in spilitArr)
  5528. {
  5529. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5530. var depCode = spDotandEmpty[2].Substring(0, 3);
  5531. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5532. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5533. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5534. list.Add(depName);
  5535. list.Add(arrName);
  5536. }
  5537. list = list.Distinct().ToList();
  5538. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5539. }
  5540. catch (Exception)
  5541. {
  5542. dic.Add("ReturnCode", "行程录入不正确!");
  5543. }
  5544. }
  5545. else
  5546. {
  5547. dic.Add("ReturnCode", "未录入行程!");
  5548. }
  5549. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5550. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5551. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5552. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5553. {
  5554. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5555. dic.Add("Day", sp.Days.ToString());
  5556. }
  5557. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5558. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5559. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5560. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5561. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5562. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5563. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5564. designer.SetDataSource("Name", Names);
  5565. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5566. designer.SetDataSource("Day", dic["Day"] + "天");
  5567. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5568. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5569. int startIndex = 10;
  5570. const int startIndexcopy = 10;
  5571. if (dac2.Count == dac3.Count)//国家 币种 金额
  5572. {
  5573. for (int i = 0; i < dac2.Count; i++)
  5574. {
  5575. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5576. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5577. }
  5578. }
  5579. DataTable dtdac1 = new DataTable();
  5580. List<string> place = new List<string>();
  5581. dtdac1.Columns.AddRange(new DataColumn[] {
  5582. new DataColumn(){ ColumnName = "city"},
  5583. new DataColumn(){ ColumnName = "curr"},
  5584. new DataColumn(){ ColumnName = "criterion"},
  5585. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5586. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5587. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5588. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5589. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5590. });
  5591. DataTable dtdac2 = new DataTable();
  5592. dtdac2.Columns.AddRange(new DataColumn[] {
  5593. new DataColumn(){ ColumnName = "city"},
  5594. new DataColumn(){ ColumnName = "curr"},
  5595. new DataColumn(){ ColumnName = "criterion"},
  5596. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5597. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5598. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5599. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5600. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5601. });
  5602. dtdac1.TableName = "tb1";
  5603. dtdac2.TableName = "tb2";
  5604. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5605. foreach (var item in dac1)
  5606. {
  5607. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5608. if (place.Contains(item.Place))
  5609. {
  5610. continue;
  5611. }
  5612. DataRow row = dtdac1.NewRow();
  5613. row["city"] = item.Place;
  5614. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5615. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5616. row["curr"] = currency;
  5617. row["rate"] = rate.ToString("#0.0000");
  5618. row["criterion"] = item.Cost.ToString("#0.00");
  5619. row["number"] = 1;
  5620. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5621. //row["costRMB"] = rbmPrice;
  5622. dtdac1.Rows.Add(row);
  5623. place.Add(item.Place);
  5624. }
  5625. place = new List<string>();
  5626. foreach (var item in dac2)
  5627. {
  5628. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5629. if (place.Contains(item.Place))
  5630. {
  5631. continue;
  5632. }
  5633. DataRow row = dtdac2.NewRow();
  5634. row["city"] = item.Place;
  5635. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5636. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5637. row["curr"] = currency;
  5638. row["rate"] = rate.ToString("#0.0000");
  5639. row["criterion"] = item.Cost.ToString("#0.00");
  5640. row["number"] = 1;
  5641. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5642. //row["cost"] = item.SubTotal;
  5643. //row["costRMB"] = rbmPrice;
  5644. dtdac2.Rows.Add(row);
  5645. place.Add(item.Place);
  5646. //dac2totalPrice += rbmPrice;
  5647. }
  5648. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5649. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5650. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5651. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5652. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5653. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5654. string cell4Str1 = string.Empty;
  5655. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5656. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5657. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5658. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5659. string cellStr = $" 5.其他费用(";
  5660. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5661. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5662. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5663. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5664. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5665. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5666. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5667. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5668. foreach (var otherInfo in dac5)
  5669. {
  5670. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5671. }
  5672. #endregion
  5673. if (cellStr.Length > 8)
  5674. {
  5675. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5676. }
  5677. cellStr += ")";
  5678. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5679. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5680. decimal pxFee = dac4.Sum(it => it.Cost);
  5681. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5682. string celllastStr1 = "";
  5683. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5684. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5685. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5686. celllastStr1 += $",国际旅费 元";
  5687. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5688. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5689. designer.SetDataSource("cell4Str", cell4Str);
  5690. designer.SetDataSource("cellStr", cellStr);
  5691. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5692. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5693. designer.SetDataSource("celllastStr", celllastStr);
  5694. Workbook wb = designer.Workbook;
  5695. var sheet = wb.Worksheets[0];
  5696. //绑定datatable数据集
  5697. designer.SetDataSource(dtdac1);
  5698. designer.SetDataSource(dtdac2);
  5699. designer.Process();
  5700. var rowStart = dtdac1.Rows.Count;
  5701. while (rowStart > 0)
  5702. {
  5703. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5704. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5705. startIndex++;
  5706. rowStart--;
  5707. }
  5708. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5709. startIndex += 1; //总计行
  5710. rowStart = dtdac2.Rows.Count;
  5711. while (rowStart > 0)
  5712. {
  5713. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5714. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5715. startIndex++;
  5716. rowStart--;
  5717. }
  5718. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5719. wb.CalculateFormula(true);
  5720. //模板文件名
  5721. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5722. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5723. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5724. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5725. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5726. }
  5727. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5728. {
  5729. //获取模板
  5730. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5731. //载入模板
  5732. Document doc = new Document(tempPath);
  5733. DocumentBuilder builder = new DocumentBuilder(doc);
  5734. Dictionary<string, string> dic = new Dictionary<string, string>();
  5735. dic.Add("GroupName", _DelegationInfo.TeamName);
  5736. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5737. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5738. string missionLeaderJob = "";//负责人job
  5739. int groupNumber = 0; //团人数
  5740. if (DeleClientList.Count > 0)
  5741. {
  5742. missionLeader = DeleClientList[0]?.Name ?? "";
  5743. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5744. }
  5745. dic.Add("MissionLeader", missionLeader); //团负责人
  5746. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5747. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5748. #region MyRegion
  5749. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5750. //{
  5751. // List<string> list = new List<string>();
  5752. // try
  5753. // {
  5754. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5755. // foreach (var item in spilitArr)
  5756. // {
  5757. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5758. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5759. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5760. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5761. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5762. // list.Add(depName);
  5763. // list.Add(arrName);
  5764. // }
  5765. // list = list.Distinct().ToList();
  5766. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5767. // }
  5768. // catch (Exception)
  5769. // {
  5770. // dic.Add("ReturnCode", "行程录入不正确!");
  5771. // }
  5772. //}
  5773. //else
  5774. //{
  5775. // dic.Add("ReturnCode", "未录入行程!");
  5776. //}
  5777. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5778. dic.Add("ReturnCode", string.Join("、", countrys));
  5779. #endregion
  5780. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5781. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5782. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5783. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5784. //{
  5785. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5786. // dic.Add("Day", sp.Days.ToString());
  5787. //}
  5788. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5789. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5790. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5791. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5792. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5793. //培训人员名单
  5794. int cultivateRowIndex = 7;
  5795. foreach (var item in DeleClientList)
  5796. {
  5797. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5798. builder.Write(item.Name);
  5799. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5800. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5801. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5802. string birthDay = "";
  5803. if (item.Birthday != null)
  5804. {
  5805. DateTime dt = Convert.ToDateTime(item.Birthday);
  5806. birthDay = $"{dt.Year}.{dt.Month}";
  5807. }
  5808. builder.Write(birthDay);
  5809. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5810. builder.Write(item.Company);
  5811. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5812. builder.Write(item.Job);
  5813. cultivateRowIndex++;
  5814. }
  5815. //删除多余行
  5816. //cultivateRowIndex -= 2;
  5817. int delRows = 10 + 7 - cultivateRowIndex;
  5818. if (delRows > 0)
  5819. {
  5820. for (int i = 0; i < delRows; i++)
  5821. {
  5822. table1.Rows.RemoveAt(cultivateRowIndex);
  5823. //cultivateRowIndex++;
  5824. }
  5825. }
  5826. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5827. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5828. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5829. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5830. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5831. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5832. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5833. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5834. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5835. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5836. //其他费用
  5837. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5838. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5839. //其他费用合计
  5840. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5841. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5842. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5843. //公务舱合计
  5844. //国际旅费
  5845. string outsideJJ = "";
  5846. string allPriceJJ = "";
  5847. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5848. {
  5849. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5850. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5851. }
  5852. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5853. {
  5854. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5855. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5856. }
  5857. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5858. {
  5859. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5860. dic.Add("AirFeeTotal", airFeeTotalStr);
  5861. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5862. dic.Add("FeeTotal", feeTotalStr);
  5863. }
  5864. foreach (var key in dic.Keys)
  5865. {
  5866. builder.MoveToBookmark(key);
  5867. builder.Write(dic[key]);
  5868. }
  5869. //模板文件名
  5870. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5871. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5872. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5873. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5874. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5875. }
  5876. }
  5877. else if (dto.ExportType == 2) //表格
  5878. {
  5879. //利用键值对存放数据
  5880. Dictionary<string, string> dic = new Dictionary<string, string>();
  5881. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5882. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5883. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5884. dic.Add("Day", sp.Days.ToString());
  5885. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5886. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5887. {
  5888. //获取模板
  5889. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5890. //载入模板
  5891. Document doc = new Document(tempPath);
  5892. DocumentBuilder builder = new DocumentBuilder(doc);
  5893. dic.Add("TeamName", _DelegationInfo.TeamName);
  5894. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5895. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5896. string missionLeaderName = "",
  5897. missionLeaderJob = "";
  5898. if (DeleClientList.Count > 0)
  5899. {
  5900. missionLeaderName = DeleClientList[0].Name;
  5901. missionLeaderJob = DeleClientList[0].Job;
  5902. }
  5903. dic.Add("MissionLeaderName", missionLeaderName);
  5904. dic.Add("MissionLeaderJob", missionLeaderJob);
  5905. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5906. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5907. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5908. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5909. int rowCount = 10;//总人数行
  5910. int startRowIndex = 7; //起始行
  5911. for (int i = 0; i < DeleClientList.Count; i++)
  5912. {
  5913. builder.MoveToCell(0, startRowIndex, 0, 0);
  5914. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5915. builder.MoveToCell(0, startRowIndex, 1, 0);
  5916. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5917. builder.Write(sex);//性别
  5918. builder.MoveToCell(0, startRowIndex, 2, 0);
  5919. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5920. builder.MoveToCell(0, startRowIndex, 3, 0);
  5921. builder.Write(DeleClientList[i].Company);//工作单位
  5922. builder.MoveToCell(0, startRowIndex, 4, 0);
  5923. builder.Write(DeleClientList[i].Job);//职务及级别
  5924. builder.MoveToCell(0, startRowIndex, 5, 0);
  5925. builder.Write("");//人员属性
  5926. builder.MoveToCell(0, startRowIndex, 6, 0);
  5927. builder.Write("");//上次出国时间
  5928. startRowIndex++;
  5929. }
  5930. int nullRow = rowCount - DeleClientList.Count;//空行
  5931. for (int i = 0; i < nullRow; i++)
  5932. {
  5933. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5934. }
  5935. foreach (var key in dic.Keys)
  5936. {
  5937. builder.MoveToBookmark(key);
  5938. builder.Write(dic[key]);
  5939. }
  5940. //模板文件名
  5941. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5942. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5943. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5944. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5945. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5946. }
  5947. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5948. {
  5949. //获取模板
  5950. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5951. //载入模板
  5952. Document doc = new Document(tempPath);
  5953. DocumentBuilder builder = new DocumentBuilder(doc);
  5954. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5955. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5956. dic.Add("Names", Names);
  5957. int accommodationRows = 12, foodandotherRows = 12;
  5958. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5959. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5960. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5961. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5962. int accommodationStartIndex = 6;
  5963. decimal dac1totalPrice = 0.00M;
  5964. foreach (var dac in dac1)
  5965. {
  5966. if (dac.SubTotal == 0)
  5967. {
  5968. continue;
  5969. }
  5970. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5971. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5972. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5973. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5974. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5975. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5976. builder.Write(currency);//币种
  5977. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5978. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5979. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5980. builder.Write("");//人数
  5981. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5982. builder.Write("");//天数
  5983. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5984. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5985. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5986. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5987. builder.Write(rate.ToString("#0.0000"));//汇率
  5988. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5989. decimal rbmPrice = rate * dac.SubTotal;
  5990. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5991. accommodationStartIndex++;
  5992. dac1totalPrice += rbmPrice;
  5993. }
  5994. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5995. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5996. builder.Write("小计");
  5997. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5998. builder.Write(dac1totalPrice.ToString("#0.00"));
  5999. accommodationStartIndex++;
  6000. int nullRow = accommodationRows - dac1.Count;
  6001. //删除空行
  6002. //if (nullRow > 0)
  6003. //{
  6004. // int rowIndex = accommodationStartIndex;
  6005. // for (int i = 0; i < nullRow; i++)
  6006. // {
  6007. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6008. // row.Remove();
  6009. // rowIndex++;
  6010. // }
  6011. //}
  6012. if (dac2.Count == dac3.Count)//国家 币种 金额
  6013. {
  6014. for (int i = 0; i < dac2.Count; i++)
  6015. {
  6016. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6017. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6018. }
  6019. }
  6020. int foodandotherStartIndex = 19;//
  6021. decimal dac2totalPrice = 0.00M;
  6022. foreach (var dac in dac2)
  6023. {
  6024. if (dac.SubTotal == 0)
  6025. {
  6026. continue;
  6027. }
  6028. //foodandotherStartIndex = 12;
  6029. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6030. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6031. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6032. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6033. builder.Write(currency);//币种
  6034. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6035. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6036. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6037. builder.Write("");//人数
  6038. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6039. builder.Write("");//天数
  6040. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6041. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6042. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6043. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6044. builder.Write(rate.ToString("#0.0000"));//汇率
  6045. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6046. decimal rbmPrice = rate * dac.SubTotal;
  6047. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6048. foodandotherStartIndex++;
  6049. dac2totalPrice += rbmPrice;
  6050. }
  6051. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6052. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6053. //删除空行
  6054. //if (dac2.Count < foodandotherRows)
  6055. //{
  6056. // while (table2.Rows.Count > dac2.Count)
  6057. // {
  6058. // table2.Rows.RemoveAt(dac2.Count);
  6059. // }
  6060. //}
  6061. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6062. string otherFeeStr = "";
  6063. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6064. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6065. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6066. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6067. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6068. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6069. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6070. foreach (var otherInfo in dac5)
  6071. {
  6072. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6073. }
  6074. #endregion
  6075. if (otherFeeStr.Length > 0)
  6076. {
  6077. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6078. otherFeeStr = $"({otherFeeStr})";
  6079. dic.Add("OtherFeeStr", otherFeeStr);
  6080. }
  6081. foreach (var key in dic.Keys)
  6082. {
  6083. builder.MoveToBookmark(key);
  6084. builder.Write(dic[key]);
  6085. }
  6086. //模板文件名
  6087. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6088. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6089. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6090. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6091. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6092. }
  6093. }
  6094. else if (dto.ExportType == 3)
  6095. {
  6096. if (dto.SubTypeId == 1) //团组成员名单
  6097. {
  6098. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6099. //获取模板
  6100. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6101. //载入模板
  6102. Document doc = new Document(tempPath);
  6103. DocumentBuilder builder = new DocumentBuilder(doc);
  6104. //获取word里所有表格
  6105. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6106. //获取所填表格的序数
  6107. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6108. var rowStart = tableOne.Rows[0]; //获取第1行
  6109. //循环赋值
  6110. for (int i = 0; i < DeleClientList.Count; i++)
  6111. {
  6112. builder.MoveToCell(0, i + 1, 0, 0);
  6113. builder.Write(DeleClientList[i].Name);
  6114. builder.MoveToCell(0, i + 1, 1, 0);
  6115. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6116. builder.Write(sex);
  6117. builder.MoveToCell(0, i + 1, 2, 0);
  6118. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6119. builder.MoveToCell(0, i + 1, 3, 0);
  6120. builder.Write(DeleClientList[i].Company);
  6121. builder.MoveToCell(0, i + 1, 4, 0);
  6122. builder.Write(DeleClientList[i].Job);
  6123. }
  6124. //删除多余行
  6125. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6126. {
  6127. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6128. }
  6129. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6130. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6131. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6132. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6133. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6134. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6135. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6136. }
  6137. }
  6138. return Ok(JsonView(400, "操作失败!", ""));
  6139. }
  6140. catch (Exception ex)
  6141. {
  6142. return Ok(JsonView(400, ex.Message, ""));
  6143. }
  6144. }
  6145. /// <summary>
  6146. /// 获取三公费用标准city
  6147. /// </summary>
  6148. /// <param name="placeData"></param>
  6149. /// <param name="nationalTravelFeeId"></param>
  6150. /// <returns></returns>
  6151. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6152. {
  6153. string _city = string.Empty;
  6154. if (placeData.Count < 1) return _city;
  6155. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6156. if (data == null) return _city;
  6157. string country = data.Country;
  6158. string city = data.City;
  6159. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6160. else _city = city;
  6161. return _city;
  6162. }
  6163. /// <summary>
  6164. /// 团组模块 - 出入境费用 - 明细表导出
  6165. /// </summary>
  6166. /// <returns></returns>
  6167. [HttpPost]
  6168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6169. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6170. {
  6171. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6172. if (data.Code != 0)
  6173. {
  6174. return Ok(JsonView(false, data.Msg));
  6175. }
  6176. return Ok(JsonView(true, data.Msg, data.Data));
  6177. }
  6178. /// <summary>
  6179. /// 团组模块 - 出入境费用 - 一键清空
  6180. /// </summary>
  6181. /// <returns></returns>
  6182. [HttpPost]
  6183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6184. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6185. {
  6186. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6187. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6188. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6189. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6190. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6191. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6192. .SetColumns(x => new Grp_DayOtherPrice
  6193. {
  6194. IsDel = 1,
  6195. DeleteUserId = dto.UserId,
  6196. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6197. })
  6198. .ExecuteCommandAsync();
  6199. if (_view.Code == 0)
  6200. {
  6201. return Ok(JsonView(true, "操作成功"));
  6202. }
  6203. return Ok(JsonView(false, "操作失败"));
  6204. }
  6205. /// <summary>
  6206. /// 团组模块 - 出入境费用 - 子项删除
  6207. /// </summary>
  6208. /// <returns></returns>
  6209. [HttpPost]
  6210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6211. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6212. {
  6213. try
  6214. {
  6215. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6216. if (data.Code != 0)
  6217. {
  6218. return Ok(JsonView(false, data.Msg));
  6219. }
  6220. return Ok(JsonView(true, "操作成功!", data.Data));
  6221. }
  6222. catch (Exception ex)
  6223. {
  6224. return Ok(JsonView(false, ex.Message));
  6225. }
  6226. }
  6227. /// <summary>
  6228. /// 删除三公其他费用
  6229. /// </summary>
  6230. /// <param name="dto"></param>
  6231. /// <returns></returns>
  6232. [HttpPost]
  6233. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6234. {
  6235. var jw = JsonView(false,"删除失败!");
  6236. var data = new Grp_DayOtherPrice()
  6237. {
  6238. Id = dto.Id,
  6239. IsDel = 1,
  6240. DeleteUserId = dto.DeleteUserId,
  6241. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6242. };
  6243. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6244. if (del > 0)
  6245. {
  6246. jw.Code = 200;
  6247. jw.Msg = "删除成功!";
  6248. }
  6249. return Ok(jw);
  6250. }
  6251. /// <summary>
  6252. /// 团组模块 - 出入境国家费用标准 List
  6253. /// </summary>
  6254. /// <returns></returns>
  6255. [HttpPost]
  6256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6257. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6258. {
  6259. try
  6260. {
  6261. Stopwatch sw = new Stopwatch();
  6262. sw.Start();
  6263. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6264. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6265. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6266. Where gntf.Isdel = 0");
  6267. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6268. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6269. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6270. //foreach (var item in nationalTravel)
  6271. //{
  6272. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6273. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6274. // if (otherData != null)
  6275. // {
  6276. // cityData.Remove(otherData);
  6277. // cityData.Add(otherData);
  6278. // }
  6279. // nationalTravelFeeData1.Add(new
  6280. // {
  6281. // Country = item.Country,
  6282. // CityData = cityData
  6283. // });
  6284. //}
  6285. sw.Stop();
  6286. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6287. }
  6288. catch (Exception ex)
  6289. {
  6290. return Ok(JsonView(false, ex.Message));
  6291. throw;
  6292. }
  6293. }
  6294. /// <summary>
  6295. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6296. /// </summary>
  6297. /// <returns></returns>
  6298. [HttpPost]
  6299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6300. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6301. {
  6302. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6303. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6304. List<string> countryData = new List<string>();
  6305. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6306. countryData = countryData.Distinct().ToList();
  6307. List<dynamic> dataSource = new List<dynamic>();
  6308. foreach (var item in countryData)
  6309. {
  6310. List<string> cityData1 = new List<string>();
  6311. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6312. var countryData2 = new
  6313. {
  6314. CountryName = item,
  6315. CityData = cityData1
  6316. };
  6317. dataSource.Add(countryData2);
  6318. }
  6319. return Ok(JsonView(true, "查询成功!", dataSource));
  6320. }
  6321. /// <summary>
  6322. /// 团组模块 - 出入境国家费用标准 Page List
  6323. /// </summary>
  6324. /// <returns></returns>
  6325. [HttpPost]
  6326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6327. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6328. {
  6329. int portId = dto.PortType;
  6330. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6331. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6332. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6333. string whereSql = string.Empty;
  6334. if (!string.IsNullOrEmpty(dto.Country))
  6335. {
  6336. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6337. }
  6338. if (!string.IsNullOrEmpty(dto.City))
  6339. {
  6340. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6341. }
  6342. string pageSql = string.Format(@"Select * From (
  6343. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6344. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6345. From Grp_NationalTravelFee gntf
  6346. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6347. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6348. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6349. RefAsync<int> total = 0;
  6350. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6351. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6352. }
  6353. /// <summary>
  6354. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6355. /// </summary>
  6356. /// <returns></returns>
  6357. [HttpPost]
  6358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6359. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6360. {
  6361. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6362. int portId = dto.PortType;
  6363. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6364. string whereSql = string.Empty;
  6365. if (!string.IsNullOrEmpty(dto.Country))
  6366. {
  6367. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6368. }
  6369. if (!string.IsNullOrEmpty(dto.City))
  6370. {
  6371. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6372. }
  6373. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6374. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6375. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6376. From Grp_NationalTravelFee gntf
  6377. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6378. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6379. Where gntf.Isdel = 0 {0} ", whereSql);
  6380. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6381. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6382. }
  6383. /// <summary>
  6384. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6385. /// </summary>
  6386. /// <returns></returns>
  6387. [HttpPost]
  6388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6389. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6390. {
  6391. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6392. if (data.Code != 0)
  6393. {
  6394. return Ok(JsonView(false, data.Msg));
  6395. }
  6396. return Ok(JsonView(true, "操作成功!", data.Data));
  6397. }
  6398. /// <summary>
  6399. /// 团组模块 - 出入境国家费用标准 - Del
  6400. /// </summary>
  6401. /// <returns></returns>
  6402. [HttpPost]
  6403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6404. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6405. {
  6406. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6407. {
  6408. Id = dto.Id,
  6409. DeleteUserId = dto.DeleteUserId,
  6410. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6411. IsDel = 1
  6412. };
  6413. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6414. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6415. .WhereColumns(it => new { it.Id })
  6416. .ExecuteCommandAsync();
  6417. if (delStatus <= 0)
  6418. {
  6419. return Ok(JsonView(false, "删除失败!"));
  6420. }
  6421. return Ok(JsonView(true, "操作成功!"));
  6422. }
  6423. /// <summary>
  6424. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6425. /// 注:Get 请求Headers 加 Token
  6426. /// </summary>
  6427. /// <param name="groupId"></param>
  6428. /// <returns></returns>
  6429. [HttpGet("{groupId}")]
  6430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6431. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6432. {
  6433. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6434. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6435. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6436. data.ForEach(x =>
  6437. {
  6438. x.CreateUserId = _currUserInfo.UserId;
  6439. });
  6440. if (data.Any())
  6441. {
  6442. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6443. if (add > 0)
  6444. {
  6445. return Ok(JsonView(true, "操作成功!"));
  6446. }
  6447. }
  6448. return Ok(JsonView(false, "未操作!"));
  6449. }
  6450. #endregion
  6451. #region 团组经理模块 出入境费用-草稿
  6452. /// <summary>
  6453. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6454. /// </summary>
  6455. /// <returns></returns>
  6456. [HttpPost]
  6457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6458. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6459. {
  6460. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6461. .Where(x => x.IsDel == 0)
  6462. .OrderByDescending(x => x.CreateTime)
  6463. .Select(x => new { x.Id, x.DraftName })
  6464. .ToListAsync();
  6465. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6466. //SetDataInfoView
  6467. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6468. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6469. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6470. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6471. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6472. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6473. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6474. //默认币种显示
  6475. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6476. {
  6477. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6478. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6479. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6480. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6481. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6482. };
  6483. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6484. if (_currencyRate.Count > 0)
  6485. {
  6486. foreach (var item in _currencyInfos)
  6487. {
  6488. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6489. if (rateInfo != null)
  6490. {
  6491. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6492. rate1 *= 1.035M;
  6493. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6494. }
  6495. }
  6496. }
  6497. return Ok(JsonView(true, "查询成功!", new
  6498. {
  6499. DraftNameDatas = draftNameDatas,
  6500. CurrencyData = _CurrencyData,
  6501. WordTypeData = _WordTypeData,
  6502. ExcelTypeData = _ExcelTypeData,
  6503. CurrencyInit = _currencyInfos
  6504. }));
  6505. }
  6506. /// <summary>
  6507. /// 团组模块 - 出入境费用-草稿
  6508. /// 实时汇率 tips
  6509. /// 签证费用 tips
  6510. /// 机票费用 tips
  6511. /// </summary>
  6512. /// <returns></returns>
  6513. [HttpPost]
  6514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6515. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6516. {
  6517. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6518. //默认币种显示
  6519. var _currencyInfos = _currencyInit;
  6520. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6521. List<dynamic> reteInfos = new List<dynamic>();
  6522. if (_currencyRate.Count > 0)
  6523. {
  6524. foreach (var item in _currencyInfos)
  6525. {
  6526. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6527. if (rateInfo != null)
  6528. {
  6529. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6530. decimal rate1 = item.Rate;
  6531. rate1 *= 1.03M;
  6532. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6533. reteInfos.Add(new
  6534. {
  6535. currCode = item.CurrencyCode,
  6536. currName = item.CurrencyName,
  6537. rate = rate2,
  6538. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6539. });
  6540. }
  6541. }
  6542. }
  6543. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6544. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6545. return Ok(JsonView(true, "查询成功!", new
  6546. {
  6547. //GroupNameData = groupNameData.Data,
  6548. //visaData = visaData.Data,
  6549. //airData = airData.Data,
  6550. reteInfos = reteInfos
  6551. }));
  6552. }
  6553. /// <summary>
  6554. /// 团组模块 - 出入境费用-草稿 - Info
  6555. /// </summary>
  6556. /// <returns></returns>
  6557. [HttpPost]
  6558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6559. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6560. {
  6561. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6562. }
  6563. /// <summary>
  6564. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6565. /// </summary>
  6566. /// <returns></returns>
  6567. [HttpPost]
  6568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6569. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6570. {
  6571. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6572. if (data.Code != 0)
  6573. {
  6574. return Ok(JsonView(false, data.Msg));
  6575. }
  6576. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6577. //汇率信息记录
  6578. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6579. return Ok(JsonView(true, data.Msg, data.Data));
  6580. }
  6581. /// <summary>
  6582. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6583. /// </summary>
  6584. /// <param name="dto"></param>
  6585. /// <returns></returns>
  6586. [HttpPost]
  6587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6588. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6589. {
  6590. try
  6591. {
  6592. var id = dto.Id;
  6593. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6594. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6595. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6596. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6597. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6598. 3 团组成员名单 1 团组成员名单", ""));
  6599. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6600. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6601. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6602. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6603. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6604. //数据源
  6605. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6606. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6607. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6608. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6609. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6610. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6611. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6612. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6613. .Select((x, a, b) => new
  6614. {
  6615. x.Index,
  6616. itemName = a.Name,
  6617. CurrencyStr = b.Name,
  6618. x.Cost,
  6619. x.SubTotal,
  6620. x.Remark
  6621. })
  6622. .OrderBy((x) => x.Index)
  6623. .ToList(); //其他款项费用
  6624. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6625. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6626. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6627. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6628. if (dto.ExportType == 1) //明细表
  6629. {
  6630. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6631. {
  6632. //获取模板
  6633. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6634. //载入模板
  6635. Document doc = new Document(tempPath);
  6636. DocumentBuilder builder = new DocumentBuilder(doc);
  6637. //利用键值对存放数据
  6638. Dictionary<string, string> dic = new Dictionary<string, string>();
  6639. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6640. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6641. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6642. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6643. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6644. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6645. //境内费用(其他费用)
  6646. if (_EnterExitCosts.ChoiceOne == 1)
  6647. {
  6648. string row1_1 = "";
  6649. if (_EnterExitCosts.Visa > 0)
  6650. {
  6651. //insidePayTotal += _EnterExitCosts.Visa;
  6652. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6653. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6654. {
  6655. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6656. }
  6657. }
  6658. string row1_2 = "";
  6659. if (_EnterExitCosts.YiMiao > 0)
  6660. {
  6661. //insidePayTotal += _EnterExitCosts.YiMiao;
  6662. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6663. }
  6664. if (_EnterExitCosts.HeSuan > 0)
  6665. {
  6666. //insidePayTotal += _EnterExitCosts.HeSuan;
  6667. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6668. }
  6669. if (_EnterExitCosts.Service > 0)
  6670. {
  6671. //insidePayTotal += _EnterExitCosts.Service;
  6672. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6673. }
  6674. string row1_3 = "";
  6675. if (_EnterExitCosts.Safe > 0)
  6676. {
  6677. //insidePayTotal += _EnterExitCosts.Safe;
  6678. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6679. }
  6680. if (_EnterExitCosts.Ticket > 0)
  6681. {
  6682. //insidePayTotal += _EnterExitCosts.Ticket;
  6683. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6684. }
  6685. string row1 = "";
  6686. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6687. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6688. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6689. row1 += $"备注:{_EnterExitCosts.Remark}";
  6690. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6691. dic.Add("Row1Str", row1);
  6692. }
  6693. string airTotalStr = string.Empty,
  6694. airPriceStr = string.Empty;
  6695. //经济舱
  6696. if (_EnterExitCosts.SumJJC == 1)
  6697. {
  6698. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6699. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6700. }
  6701. //公务舱
  6702. if (_EnterExitCosts.SumGWC == 1)
  6703. {
  6704. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6705. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6706. }
  6707. //头等舱
  6708. if (_EnterExitCosts.SumTDC == 1)
  6709. {
  6710. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6711. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6712. }
  6713. dic.Add("AirTotalStr", airTotalStr);
  6714. dic.Add("AirPriceStr", airPriceStr);
  6715. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6716. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6717. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6718. int table1Row = 0,
  6719. table2Row = 0,
  6720. table3Row = 0,
  6721. table4Row = 0,
  6722. table5Row = 0;
  6723. //住宿费
  6724. if (_EnterExitCosts.ChoiceThree == 1)
  6725. {
  6726. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6727. table1Row = dac1.Count;
  6728. #region 填充word表格内容
  6729. for (int i = 0; i < dac1.Count; i++)
  6730. {
  6731. var dac = dac1[i];
  6732. if (dac == null) continue;
  6733. builder.MoveToCell(0, i, 0, 0);
  6734. builder.Write("第" + dac.Days.ToString() + "晚:");
  6735. builder.MoveToCell(0, i, 1, 0);
  6736. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6737. //builder.Write(dac.Place == null ? "" : dac.Place);
  6738. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6739. builder.MoveToCell(0, i, 2, 0);
  6740. builder.Write("费用标准:");
  6741. string curr = "";
  6742. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6743. if (currData != null)
  6744. {
  6745. curr = currData.Name;
  6746. }
  6747. builder.MoveToCell(0, i, 3, 0);
  6748. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6749. builder.MoveToCell(0, i, 4, 0);
  6750. builder.Write("费用小计:");
  6751. builder.MoveToCell(0, i, 5, 0);
  6752. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6753. }
  6754. #endregion
  6755. }
  6756. else dic.Add("SubZS", "0.00");
  6757. //删除多余行
  6758. while (table1.Rows.Count > table1Row)
  6759. {
  6760. table1.Rows.RemoveAt(table1Row);
  6761. }
  6762. //伙食费
  6763. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6764. if (_EnterExitCosts.ChoiceFour == 1)
  6765. {
  6766. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6767. table2Row = dac2.Count;
  6768. #region 填充word表格内容
  6769. for (int i = 0; i < dac2.Count; i++)
  6770. {
  6771. var dac = dac2[i];
  6772. if (dac == null) continue;
  6773. builder.MoveToCell(1, i, 0, 0);
  6774. builder.Write("第" + dac.Days.ToString() + "天:");
  6775. builder.MoveToCell(1, i, 1, 0);
  6776. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6777. builder.MoveToCell(1, i, 2, 0);
  6778. builder.Write("费用标准:");
  6779. string curr = "";
  6780. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6781. if (currData != null)
  6782. {
  6783. curr = currData.Name;
  6784. }
  6785. builder.MoveToCell(1, i, 3, 0);
  6786. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6787. builder.MoveToCell(1, i, 4, 0);
  6788. builder.Write("费用小计:");
  6789. builder.MoveToCell(1, i, 5, 0);
  6790. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6791. }
  6792. #endregion
  6793. }
  6794. else dic.Add("SubHS", "0.00");
  6795. //删除多余行
  6796. while (table2.Rows.Count > table2Row)
  6797. {
  6798. table2.Rows.RemoveAt(table2Row);
  6799. }
  6800. //公杂费
  6801. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6802. if (_EnterExitCosts.ChoiceFive == 1)
  6803. {
  6804. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6805. table3Row = dac3.Count;
  6806. #region 填充word表格内容
  6807. for (int i = 0; i < dac3.Count; i++)
  6808. {
  6809. var dac = dac3[i];
  6810. if (dac == null) continue;
  6811. builder.MoveToCell(2, i, 0, 0);
  6812. builder.Write("第" + dac.Days.ToString() + "天:");
  6813. builder.MoveToCell(2, i, 1, 0);
  6814. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6815. builder.MoveToCell(2, i, 2, 0);
  6816. builder.Write("费用标准:");
  6817. string curr = "";
  6818. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6819. if (currData != null)
  6820. {
  6821. curr = currData.Name;
  6822. }
  6823. builder.MoveToCell(2, i, 3, 0);
  6824. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6825. builder.MoveToCell(2, i, 4, 0);
  6826. builder.Write("费用小计:");
  6827. builder.MoveToCell(2, i, 5, 0);
  6828. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6829. }
  6830. //删除多余行
  6831. while (table3.Rows.Count > table3Row)
  6832. {
  6833. table3.Rows.RemoveAt(table3Row);
  6834. }
  6835. #endregion
  6836. }
  6837. else dic.Add("SubGZF", "0.00");
  6838. //删除多余行
  6839. while (table3.Rows.Count > table3Row)
  6840. {
  6841. table3.Rows.RemoveAt(table3Row);
  6842. }
  6843. //培训费
  6844. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6845. if (_EnterExitCosts.ChoiceSix == 1)
  6846. {
  6847. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6848. dic.Add("SubPX", pxStr);
  6849. table4Row = dac4.Count;
  6850. #region 填充word表格内容
  6851. for (int i = 0; i < dac4.Count; i++)
  6852. {
  6853. var dac = dac4[i];
  6854. if (dac == null) continue;
  6855. builder.MoveToCell(3, i, 0, 0);
  6856. builder.Write("第" + dac.Days.ToString() + "天:");
  6857. builder.MoveToCell(3, i, 1, 0);
  6858. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6859. builder.MoveToCell(3, i, 2, 0);
  6860. builder.Write("费用标准:");
  6861. string curr = "";
  6862. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6863. if (currData != null)
  6864. {
  6865. curr = currData.Name;
  6866. }
  6867. builder.MoveToCell(3, i, 3, 0);
  6868. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6869. builder.MoveToCell(3, i, 4, 0);
  6870. builder.Write("费用小计:");
  6871. builder.MoveToCell(3, i, 5, 0);
  6872. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6873. }
  6874. #endregion
  6875. }
  6876. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6877. //删除多余行
  6878. while (table4.Rows.Count > table4Row)
  6879. {
  6880. table4.Rows.RemoveAt(table4Row);
  6881. }
  6882. //其他费用
  6883. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6884. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6885. {
  6886. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6887. dic.Add("titleQi", qtStr);
  6888. table5Row = dac5.Count;
  6889. #region 填充word表格内容
  6890. for (int i = 0; i < dac5.Count; i++)
  6891. {
  6892. var dac = dac5[i];
  6893. if (dac == null) continue;
  6894. builder.MoveToCell(4, i, 0, 0);
  6895. builder.Write("第" + dac.Index.ToString() + "项:");
  6896. builder.MoveToCell(4, i, 1, 0);
  6897. builder.Write(dac.itemName);
  6898. builder.MoveToCell(4, i, 2, 0);
  6899. builder.Write("费用标准:");
  6900. builder.MoveToCell(4, i, 3, 0);
  6901. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6902. builder.MoveToCell(4, i, 4, 0);
  6903. builder.Write("费用小计:");
  6904. builder.MoveToCell(4, i, 5, 0);
  6905. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6906. builder.MoveToCell(4, i, 6, 0);
  6907. builder.Write("备注:");
  6908. builder.MoveToCell(4, i, 7, 0);
  6909. builder.Write(dac.Remark);
  6910. }
  6911. #endregion
  6912. }
  6913. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6914. //删除多余行
  6915. while (table5.Rows.Count > table5Row)
  6916. {
  6917. table5.Rows.RemoveAt(table5Row);
  6918. }
  6919. //加上其他费用
  6920. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6921. decimal subJJC = 0.00M,
  6922. subGWC = 0.00M,
  6923. subTDC = 0.00M;
  6924. //经济舱
  6925. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6926. //公务舱
  6927. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6928. //头等舱
  6929. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6930. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6931. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6932. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6933. #region 填充word模板书签内容
  6934. foreach (var key in dic.Keys)
  6935. {
  6936. Bookmark bookmark = doc.Range.Bookmarks[key];
  6937. if (bookmark != null)
  6938. {
  6939. builder.MoveToBookmark(key);
  6940. builder.Write(dic[key]);
  6941. }
  6942. }
  6943. #endregion
  6944. //文件名
  6945. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  6946. strFileName = CommonFun.ValidFileName(strFileName);
  6947. AsposeHelper.removewatermark_v2180();
  6948. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6949. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6950. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6951. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6952. }
  6953. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6954. {
  6955. //获取模板
  6956. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6957. //载入模板
  6958. Document doc = new Document(tempPath);
  6959. DocumentBuilder builder = new DocumentBuilder(doc);
  6960. Dictionary<string, string> dic = new Dictionary<string, string>();
  6961. string returnCodeLabel = string.Empty;
  6962. if (nationalTravelFeeData.Any())
  6963. {
  6964. List<string> list = new List<string>();
  6965. foreach (var item in nationalTravelFeeData)
  6966. {
  6967. list.Add($"{item.Country}({item.City})");
  6968. }
  6969. list = list.Distinct().ToList();
  6970. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  6971. }
  6972. var countryLabel = string.Empty;
  6973. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  6974. if (countryData.Any())
  6975. {
  6976. countryLabel = string.Join("、", countryData);
  6977. }
  6978. dic.Add("ReturnCodeAir", returnCodeLabel);
  6979. dic.Add("VisitStartDate", "-");
  6980. dic.Add("VisitEndDate", "-");
  6981. dic.Add("Day", "-");
  6982. dic.Add("VisitCountry", countryLabel);
  6983. dic.Add("ClientUnit", "-");
  6984. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6985. //dic.Add("Names", Names);
  6986. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6987. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6988. decimal dac1totalPrice = 0.00M;
  6989. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6990. foreach (var dac in dac1)
  6991. {
  6992. if (dac.SubTotal == 0.00M)
  6993. {
  6994. continue;
  6995. }
  6996. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6997. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6998. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6999. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7000. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7001. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7002. builder.Write(currency);//币种
  7003. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7004. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7005. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7006. builder.Write("");//人数
  7007. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7008. builder.Write("");//天数
  7009. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7010. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7011. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7012. decimal rate = 0.00M;
  7013. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7014. builder.Write(rate.ToString("#0.0000"));//汇率
  7015. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7016. decimal rbmPrice = dac.SubTotal;
  7017. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7018. accommodationStartIndex++;
  7019. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7020. }
  7021. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7022. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7023. {
  7024. table1.Rows.RemoveAt(i - 1);
  7025. foodandotherStartIndex--;
  7026. }
  7027. if (dac2.Count == dac3.Count)//国家 币种 金额
  7028. {
  7029. for (int i = 0; i < dac2.Count; i++)
  7030. {
  7031. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7032. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7033. }
  7034. }
  7035. decimal dac2totalPrice = 0.00M;
  7036. foreach (var dac in dac2)
  7037. {
  7038. if (dac.SubTotal == 0)
  7039. {
  7040. continue;
  7041. }
  7042. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7043. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7044. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7045. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7046. builder.Write(currency);//币种
  7047. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7048. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7049. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7050. builder.Write("");//人数
  7051. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7052. builder.Write("");//天数
  7053. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7054. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7055. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7056. decimal rate = 0.00M;
  7057. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7058. builder.Write(rate.ToString("#0.0000"));//汇率
  7059. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7060. decimal rbmPrice = dac.SubTotal;
  7061. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7062. foodandotherStartIndex++;
  7063. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7064. }
  7065. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7066. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7067. {
  7068. table1.Rows.RemoveAt(i - 1);
  7069. }
  7070. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7071. string otherFeeStr = "";
  7072. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7073. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7074. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7075. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7076. foreach (var otherInfo in dac5)
  7077. {
  7078. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7079. }
  7080. #endregion
  7081. if (otherFeeStr.Length > 0)
  7082. {
  7083. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7084. otherFeeStr = $"({otherFeeStr})";
  7085. dic.Add("OtherFeeStr", otherFeeStr);
  7086. }
  7087. //总计
  7088. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7089. //国际旅费
  7090. string outsideAir = string.Empty;
  7091. string allPriceAir = string.Empty;
  7092. if (_EnterExitCosts.SumJJC == 1)
  7093. {
  7094. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7095. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7096. }
  7097. if (_EnterExitCosts.SumGWC == 1)
  7098. {
  7099. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7100. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7101. }
  7102. if (_EnterExitCosts.SumTDC == 1)
  7103. {
  7104. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7105. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7106. }
  7107. dic.Add("InTravelPrice", $"({outsideAir})");
  7108. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7109. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7110. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7111. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7112. foreach (var key in dic.Keys)
  7113. {
  7114. builder.MoveToBookmark(key);
  7115. builder.Write(dic[key]);
  7116. }
  7117. //模板文件名
  7118. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7119. strFileName = CommonFun.ValidFileName(strFileName);
  7120. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7121. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7122. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7123. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7124. }
  7125. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7126. {
  7127. //获取模板
  7128. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7129. //载入模板
  7130. WorkbookDesigner designer = new WorkbookDesigner();
  7131. designer.Workbook = new Workbook(tempPath);
  7132. Dictionary<string, string> dic = new Dictionary<string, string>();
  7133. string returnCodeLabel = string.Empty;
  7134. if (nationalTravelFeeData.Any())
  7135. {
  7136. List<string> list = new List<string>();
  7137. foreach (var item in nationalTravelFeeData)
  7138. {
  7139. list.Add($"{item.Country}({item.City})");
  7140. }
  7141. list = list.Distinct().ToList();
  7142. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7143. }
  7144. var countryLabel = string.Empty;
  7145. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7146. if (countryData.Any())
  7147. {
  7148. countryLabel = string.Join("、", countryData);
  7149. }
  7150. dic.Add("ReturnCodeAir", returnCodeLabel);
  7151. dic.Add("VisitStartDate", "-");
  7152. dic.Add("VisitEndDate", "-");
  7153. dic.Add("Day", "0");
  7154. dic.Add("VisitCountry", countryLabel);
  7155. dic.Add("ClientUnit", "-");
  7156. designer.SetDataSource("ClientUnit", "-");
  7157. designer.SetDataSource("VisitCountry", countryLabel);
  7158. designer.SetDataSource("Group", "-");
  7159. designer.SetDataSource("ClientUnitTitle", "-");
  7160. designer.SetDataSource("Name", "-");
  7161. designer.SetDataSource("VisitStartDate", "-" );
  7162. designer.SetDataSource("Day", "0");
  7163. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7164. designer.SetDataSource("ReturnCodeAir", "-");
  7165. int startIndex = 10;
  7166. const int startIndexcopy = 10;
  7167. if (dac2.Count == dac3.Count)//国家 币种 金额
  7168. {
  7169. for (int i = 0; i < dac2.Count; i++)
  7170. {
  7171. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7172. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7173. }
  7174. }
  7175. DataTable dtdac1 = new DataTable();
  7176. List<string> place = new List<string>();
  7177. dtdac1.Columns.AddRange(new DataColumn[] {
  7178. new DataColumn(){ ColumnName = "city"},
  7179. new DataColumn(){ ColumnName = "curr"},
  7180. new DataColumn(){ ColumnName = "criterion"},
  7181. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7182. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7183. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7184. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7185. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7186. });
  7187. DataTable dtdac2 = new DataTable();
  7188. dtdac2.Columns.AddRange(new DataColumn[] {
  7189. new DataColumn(){ ColumnName = "city"},
  7190. new DataColumn(){ ColumnName = "curr"},
  7191. new DataColumn(){ ColumnName = "criterion"},
  7192. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7193. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7194. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7195. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7196. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7197. });
  7198. dtdac1.TableName = "tb1";
  7199. dtdac2.TableName = "tb2";
  7200. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7201. foreach (var item in dac1)
  7202. {
  7203. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7204. if (place.Contains(item.Place))
  7205. {
  7206. continue;
  7207. }
  7208. DataRow row = dtdac1.NewRow();
  7209. row["city"] = item.Place;
  7210. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7211. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7212. row["curr"] = currency;
  7213. row["rate"] = rate.ToString("#0.0000");
  7214. row["criterion"] = item.Cost.ToString("#0.00");
  7215. row["number"] = 1;
  7216. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7217. //row["costRMB"] = rbmPrice;
  7218. dtdac1.Rows.Add(row);
  7219. place.Add(item.Place);
  7220. }
  7221. place = new List<string>();
  7222. foreach (var item in dac2)
  7223. {
  7224. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7225. if (place.Contains(item.Place))
  7226. {
  7227. continue;
  7228. }
  7229. DataRow row = dtdac2.NewRow();
  7230. row["city"] = item.Place;
  7231. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7232. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7233. row["curr"] = currency;
  7234. row["rate"] = rate.ToString("#0.0000");
  7235. row["criterion"] = item.Cost.ToString("#0.00");
  7236. row["number"] = 1;
  7237. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7238. //row["cost"] = item.SubTotal;
  7239. //row["costRMB"] = rbmPrice;
  7240. dtdac2.Rows.Add(row);
  7241. place.Add(item.Place);
  7242. //dac2totalPrice += rbmPrice;
  7243. }
  7244. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7245. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7246. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7247. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7248. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7249. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7250. string cell4Str1 = string.Empty;
  7251. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7252. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7253. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7254. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7255. string cellStr = $" 5.其他费用(";
  7256. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7257. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7258. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7259. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7260. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7261. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7262. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7263. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7264. foreach (var otherInfo in dac5)
  7265. {
  7266. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7267. }
  7268. #endregion
  7269. if (cellStr.Length > 8)
  7270. {
  7271. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7272. }
  7273. cellStr += ")";
  7274. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7275. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7276. decimal pxFee = dac4.Sum(it => it.Cost);
  7277. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7278. string celllastStr1 = "";
  7279. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7280. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7281. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7282. celllastStr1 += $",国际旅费 元";
  7283. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7284. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7285. designer.SetDataSource("cell4Str", cell4Str);
  7286. designer.SetDataSource("cellStr", cellStr);
  7287. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7288. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7289. designer.SetDataSource("celllastStr", celllastStr);
  7290. Workbook wb = designer.Workbook;
  7291. var sheet = wb.Worksheets[0];
  7292. //绑定datatable数据集
  7293. designer.SetDataSource(dtdac1);
  7294. designer.SetDataSource(dtdac2);
  7295. designer.Process();
  7296. var rowStart = dtdac1.Rows.Count;
  7297. while (rowStart > 0)
  7298. {
  7299. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7300. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7301. startIndex++;
  7302. rowStart--;
  7303. }
  7304. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7305. startIndex += 1; //总计行
  7306. rowStart = dtdac2.Rows.Count;
  7307. while (rowStart > 0)
  7308. {
  7309. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7310. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7311. startIndex++;
  7312. rowStart--;
  7313. }
  7314. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7315. wb.CalculateFormula(true);
  7316. //模板文件名
  7317. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7318. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7319. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7320. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7321. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7322. }
  7323. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7324. {
  7325. //获取模板
  7326. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7327. //载入模板
  7328. Document doc = new Document(tempPath);
  7329. DocumentBuilder builder = new DocumentBuilder(doc);
  7330. Dictionary<string, string> dic = new Dictionary<string, string>();
  7331. dic.Add("GroupName", "-");
  7332. dic.Add("ClientUnit", "-");
  7333. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7334. string missionLeaderJob = "";//负责人job
  7335. int groupNumber = 0; //团人数
  7336. dic.Add("MissionLeader", "-"); //团负责人
  7337. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7338. dic.Add("GroupNumber", "0"); //团人数
  7339. dic.Add("Day", "0");
  7340. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7341. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7342. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7343. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7344. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7345. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7346. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7347. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7348. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7349. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7350. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7351. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7352. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7353. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7354. //其他费用
  7355. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7356. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7357. //其他费用合计
  7358. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7359. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7360. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7361. //公务舱合计
  7362. //国际旅费
  7363. string outsideJJ = "";
  7364. string allPriceJJ = "";
  7365. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7366. {
  7367. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7368. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7369. }
  7370. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7371. {
  7372. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7373. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7374. }
  7375. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7376. {
  7377. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7378. dic.Add("AirFeeTotal", airFeeTotalStr);
  7379. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7380. dic.Add("FeeTotal", feeTotalStr);
  7381. }
  7382. foreach (var key in dic.Keys)
  7383. {
  7384. builder.MoveToBookmark(key);
  7385. builder.Write(dic[key]);
  7386. }
  7387. //模板文件名
  7388. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7389. strFileName = CommonFun.ValidFileName(strFileName);
  7390. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7391. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7392. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7393. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7394. }
  7395. }
  7396. else if (dto.ExportType == 2) //表格
  7397. {
  7398. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7399. }
  7400. else if (dto.ExportType == 3)
  7401. {
  7402. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7403. }
  7404. return Ok(JsonView(400, "只可导出明细表!", ""));
  7405. }
  7406. catch (Exception ex)
  7407. {
  7408. return Ok(JsonView(400, ex.Message, ""));
  7409. }
  7410. }
  7411. /// <summary>
  7412. /// 获取三公费用标准city
  7413. /// </summary>
  7414. /// <param name="placeData"></param>
  7415. /// <param name="nationalTravelFeeId"></param>
  7416. /// <returns></returns>
  7417. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7418. {
  7419. string _city = string.Empty;
  7420. if (!placeData.Any()) return _city;
  7421. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7422. if (data == null) return _city;
  7423. string country = data.Country;
  7424. string city = data.City;
  7425. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7426. else _city = city;
  7427. return _city;
  7428. }
  7429. /// <summary>
  7430. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7431. /// </summary>
  7432. /// <returns></returns>
  7433. [HttpPost]
  7434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7435. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7436. {
  7437. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7438. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7439. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7440. if (_view.Code == 0)
  7441. {
  7442. return Ok(JsonView(true, "操作成功"));
  7443. }
  7444. return Ok(JsonView(false, "操作失败"));
  7445. }
  7446. /// <summary>
  7447. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7448. /// </summary>
  7449. /// <returns></returns>
  7450. [HttpPost]
  7451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7452. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7453. {
  7454. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7455. if (data.Code != 0)
  7456. {
  7457. return Ok(JsonView(false, data.Msg));
  7458. }
  7459. return Ok(JsonView(true, "操作成功!", data.Data));
  7460. }
  7461. /// <summary>
  7462. /// 三公其他费用草稿 删除
  7463. /// </summary>
  7464. /// <param name="dto"></param>
  7465. /// <returns></returns>
  7466. [HttpPost]
  7467. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7468. {
  7469. var jw = JsonView(false, "删除失败!");
  7470. var data = new Grp_DayOtherPriceDraft()
  7471. {
  7472. Id = dto.Id,
  7473. IsDel = 1,
  7474. DeleteUserId = dto.DeleteUserId,
  7475. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7476. };
  7477. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7478. if (del > 0)
  7479. {
  7480. jw.Code = 200;
  7481. jw.Msg = "删除成功!";
  7482. }
  7483. return Ok(jw);
  7484. }
  7485. /// <summary>
  7486. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7487. /// </summary>
  7488. /// <param name="dto"></param>
  7489. /// <returns></returns>
  7490. [HttpPost]
  7491. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7492. {
  7493. var jw = JsonView(false);
  7494. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7495. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7496. jw.Code = StatusCodes.Status200OK;
  7497. jw.Msg = "操作成功!";
  7498. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7499. return Ok(jw);
  7500. }
  7501. /// <summary>
  7502. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7503. /// </summary>
  7504. /// <param name="dto"></param>
  7505. /// <returns></returns>
  7506. [HttpPost]
  7507. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7508. {
  7509. int userId = dto.UserId,
  7510. portId = dto.PortType,
  7511. groupId = dto.GroupId,
  7512. draftId = dto.DraftId;
  7513. _portTypeData.Add(1);
  7514. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7515. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7516. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7517. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7518. _sqlSugar.BeginTran();
  7519. try
  7520. {
  7521. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7522. if (draftDatas == null)
  7523. {
  7524. _sqlSugar.RollbackTran();
  7525. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7526. }
  7527. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7528. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7529. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7530. newExterData.DiId = groupId;
  7531. newExterData.CreateUserId = userId;
  7532. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7533. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7534. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7535. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7536. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7537. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7538. //数据如果存在执行删除
  7539. if (enterExitCostInfo != null)
  7540. {
  7541. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7542. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7543. .Where(x => x.Id == enterExitCostInfo.Id)
  7544. .ExecuteCommand();
  7545. _sqlSugar.Updateable<Grp_DayAndCost>()
  7546. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7547. .Where(x => x.DiId == groupId)
  7548. .ExecuteCommand();
  7549. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7550. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7551. .Where(x => x.Diid == groupId)
  7552. .ExecuteCommand();
  7553. }
  7554. //执行insert
  7555. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7556. if (insertId < 1)
  7557. {
  7558. _sqlSugar.RollbackTran();
  7559. return Ok(JsonView(false, "草稿数据导入失败!"));
  7560. }
  7561. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7562. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7563. _sqlSugar.CommitTran();
  7564. //执行操作之后
  7565. //生成默认文件pdf并且通知人员
  7566. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7567. {
  7568. DiId = groupId,
  7569. ExportType = 1,
  7570. SubTypeId = 1005
  7571. }, "pdf");
  7572. //发送通知
  7573. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7574. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7575. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7576. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7577. //汇率信息记录
  7578. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7579. return Ok(JsonView(true));
  7580. }
  7581. catch (Exception ex)
  7582. {
  7583. _sqlSugar.RollbackTran();
  7584. return Ok(JsonView(false,ex.Message));
  7585. }
  7586. }
  7587. #endregion
  7588. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7589. /// <summary>
  7590. /// 获取币种基础数据(含逻辑处理)
  7591. /// </summary>
  7592. /// <returns></returns>
  7593. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7594. {
  7595. //默认币种显示
  7596. var _currencyInfos = _currencyInit;
  7597. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7598. if (_currencyRate.Count > 0)
  7599. {
  7600. foreach (var item in _currencyInfos)
  7601. {
  7602. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7603. if (rateInfo != null)
  7604. {
  7605. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7606. rate1 *= 1.035M;
  7607. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7608. }
  7609. }
  7610. }
  7611. return _currencyInfos;
  7612. }
  7613. /// <summary>
  7614. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7615. /// </summary>
  7616. /// <returns></returns>
  7617. [HttpPost]
  7618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7619. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7620. {
  7621. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7622. //SetDataInfoView
  7623. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7624. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7625. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7626. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7627. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7628. //默认币种显示
  7629. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7630. return Ok(JsonView(true, "查询成功!", new
  7631. {
  7632. WordTypeData = _WordTypeData,
  7633. ExcelTypeData = _ExcelTypeData,
  7634. CurrencyInit = _currencyInfos
  7635. }));
  7636. }
  7637. /// <summary>
  7638. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7639. /// </summary>
  7640. /// <returns></returns>
  7641. [HttpPost]
  7642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7643. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7644. {
  7645. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7646. RefAsync<int> total = 0;
  7647. int diId = 0;
  7648. var status = int.TryParse(dto.GroupName, out diId);
  7649. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7650. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7651. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7652. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7653. .Select(x => new
  7654. {
  7655. Id = x.Id,
  7656. GroupName = x.TeamName
  7657. })
  7658. .OrderByDescending(x => x.Id)
  7659. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7660. return Ok(JsonView(true, "查询成功!", data, total));
  7661. }
  7662. /// <summary>
  7663. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7664. /// </summary>
  7665. /// <returns></returns>
  7666. [HttpPost]
  7667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7668. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7669. {
  7670. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7671. RefAsync<int> total = 0;
  7672. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7673. .Where(x => x.IsDel == 0 && x.STid == 66)
  7674. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7675. .Select(x => new
  7676. {
  7677. id = x.Id,
  7678. name = x.Name,
  7679. remark = x.Remark,
  7680. })
  7681. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7682. return Ok(JsonView(true, "查询成功!", data, total));
  7683. }
  7684. /// <summary>
  7685. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7686. /// </summary>
  7687. /// <returns></returns>
  7688. [HttpPost]
  7689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7690. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7691. {
  7692. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7693. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7694. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7695. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7696. var groupOtherRateData = groupRateData.TeamRates;
  7697. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7698. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7699. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7700. groupOtherRateData = groupOtherRateData
  7701. .Select(x => new TeamRateDescAddCurrencyIdView {
  7702. CurrencyId = x.CurrencyId,
  7703. CurrencyName = x.CurrencyName,
  7704. CurrencyCode = x.CurrencyCode,
  7705. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7706. }).ToList();
  7707. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7708. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7709. }
  7710. /// <summary>
  7711. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7712. /// </summary>
  7713. /// <returns></returns>
  7714. [HttpPost]
  7715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7716. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7717. {
  7718. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7719. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7720. var tipsData = new List<int>() {1,2,3 };
  7721. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7722. if (dto.TipsType == 1)
  7723. {
  7724. //默认币种显示
  7725. var _currencyInfos = _currencyInit;
  7726. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7727. List<dynamic> reteInfos = new List<dynamic>();
  7728. if (_currencyRate.Count > 0)
  7729. {
  7730. foreach (var item in _currencyInfos)
  7731. {
  7732. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7733. if (rateInfo != null)
  7734. {
  7735. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7736. decimal rate1 = item.Rate;
  7737. rate1 *= 1.03M;
  7738. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7739. reteInfos.Add(new
  7740. {
  7741. currCode = item.CurrencyCode,
  7742. currName = item.CurrencyName,
  7743. rate = rate2,
  7744. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7745. });
  7746. }
  7747. }
  7748. }
  7749. return Ok(JsonView(true, "查询成功!", reteInfos));
  7750. }
  7751. else if (dto.TipsType == 2)
  7752. {
  7753. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7754. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7755. }
  7756. else if (dto.TipsType == 3)
  7757. {
  7758. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7759. return Ok(JsonView(true, "查询成功!", airData.Data));
  7760. }
  7761. return Ok(JsonView(false));
  7762. }
  7763. /// <summary>
  7764. /// 团组模块 - 出入境国家费用标准-移动端 List
  7765. /// </summary>
  7766. /// <returns></returns>
  7767. [HttpPost]
  7768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7769. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7770. {
  7771. Stopwatch sw = new Stopwatch();
  7772. sw.Start();
  7773. RefAsync<int> total = 0;
  7774. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7775. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7776. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7777. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7778. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7779. .Select((ntf, sd, u) => new
  7780. {
  7781. Id = ntf.Id,
  7782. Area = $"{ntf.Country}-{ntf.City}",
  7783. Currency = ntf.Currency,
  7784. CurrencyCode = sd.Name,
  7785. CurrencyName = sd.Remark,
  7786. RoomCost = ntf.RoomCost,
  7787. FoodCost = ntf.FoodCost,
  7788. PublicCost = ntf.PublicCost,
  7789. LastUpdateUserId = ntf.LastUpdateUserId,
  7790. LastUpdateUserName = u.CnName,
  7791. LastUpdateTime = ntf.LastUpdateTime,
  7792. })
  7793. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7794. sw.Stop();
  7795. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7796. }
  7797. /// <summary>
  7798. /// 团组模块 - 出入境费用-移动端 - Info
  7799. /// </summary>
  7800. /// <returns></returns>
  7801. [HttpPost]
  7802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7803. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7804. {
  7805. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7806. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7807. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7808. return Ok(data);
  7809. }
  7810. /// <summary>
  7811. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7812. /// </summary>
  7813. /// <returns></returns>
  7814. [HttpPost]
  7815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7816. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7817. {
  7818. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7819. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7820. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7821. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7822. mobileInfo.DiId = dto.DiId;
  7823. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  7824. if (eecInfo == null) return Ok(mobileInfo);
  7825. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  7826. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  7827. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7828. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7829. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  7830. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7831. {
  7832. SubId = dac.Id,
  7833. DiId = dac.DiId,
  7834. Type = dac.Type,
  7835. Days = dac.Days,
  7836. NationalTravelFeeId = dac.NationalTravelFeeId,
  7837. Arae = $"{ntf.Country}-{ntf.City}",
  7838. Cost = dac.Cost,
  7839. Currency = dac.Currency,
  7840. CurrencyName = sd.Name,
  7841. SubTotal = dac.SubTotal,
  7842. })
  7843. .ToList();
  7844. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  7845. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  7846. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  7847. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  7848. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  7849. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  7850. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  7851. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  7852. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  7853. //其他款项
  7854. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7855. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  7856. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  7857. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  7858. .OrderBy((dop, sd1, sd2) => dop.Index)
  7859. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  7860. {
  7861. SubId = dop.Id,
  7862. DiId = dop.Diid,
  7863. Index = dop.Index,
  7864. SetDataId = dop.SetDataId,
  7865. SetDataName = sd1.Name,
  7866. Cost = dop.Cost,
  7867. Currency = dop.Currency,
  7868. CurrencyName = sd2.Remark,
  7869. SubTotal = dop.SubTotal,
  7870. Remark = dop.Remark,
  7871. })
  7872. .ToArray();
  7873. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  7874. return Ok(mobileInfo);
  7875. }
  7876. /// <summary>
  7877. /// 团组模块 - 出入境费用-移动端 - SubInfo
  7878. /// </summary>
  7879. /// <returns></returns>
  7880. [HttpPost]
  7881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7882. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  7883. {
  7884. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7885. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7886. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  7887. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  7888. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7889. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  7890. var subType = dto.SubType;
  7891. if (subType == 1) //1:境内费用
  7892. {
  7893. var oneData = new ChoiceOneMobileSubInfoView()
  7894. {
  7895. Id = eecInfo.Id,
  7896. ChoiceOne = eecInfo.ChoiceOne,
  7897. ChoiceOneTotalCost = eecInfo.InsidePay,
  7898. Visa = eecInfo.Visa,
  7899. VisaRemark = eecInfo.VisaRemark,
  7900. YiMiao = eecInfo.YiMiao,
  7901. HeSuan = eecInfo.HeSuan,
  7902. Service = eecInfo.Service,
  7903. Ticket = eecInfo.Ticket,
  7904. Safe = eecInfo.Safe,
  7905. FirstItemRemark = eecInfo.FirstItemRemark
  7906. };
  7907. return Ok(JsonView(oneData));
  7908. }
  7909. else if (subType == 2) //2:国际旅费
  7910. {
  7911. var twoData = new ChoiceTwoMobileSubInfoView() {
  7912. Id = eecInfo.Id,
  7913. ChoiceTwoJJ = eecInfo.SumJJC,
  7914. OutsideJJPay = eecInfo.OutsideJJPay,
  7915. ChoiceTwoGW = eecInfo.SumGWC,
  7916. OutsideGWPay = eecInfo.OutsideGWPay,
  7917. ChoiceTwoTD = eecInfo.SumTDC,
  7918. OutsideTDPay = eecInfo.OutsideTDPay,
  7919. AirJJ = eecInfo.AirJJ,
  7920. AirGW = eecInfo.AirGW,
  7921. AirTD = eecInfo.AirTD,
  7922. CityTranffic = eecInfo.CityTranffic,
  7923. TwoItemRemark = eecInfo.TwoItemRemark
  7924. };
  7925. return Ok(JsonView(twoData));
  7926. }
  7927. else if (subType == 3) //3:住宿费
  7928. {
  7929. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  7930. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7931. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7932. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  7933. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7934. {
  7935. SubId = dac.Id,
  7936. DiId = dac.DiId,
  7937. Type = dac.Type,
  7938. Days = dac.Days,
  7939. NationalTravelFeeId = dac.NationalTravelFeeId,
  7940. Arae = $"{ntf.Country}-{ntf.City}",
  7941. Cost = dac.Cost,
  7942. Currency = dac.Currency,
  7943. CurrencyName = sd.Name,
  7944. SubTotal = dac.SubTotal,
  7945. })
  7946. .ToArray();
  7947. var data = new ChoiceMobileSubInfo3To6View() {
  7948. ParentId = eecInfo.Id,
  7949. Choice = eecInfo.ChoiceThree,
  7950. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  7951. Details = dayAndCostDatas
  7952. };
  7953. return Ok(JsonView(data));
  7954. }
  7955. else if (subType == 4) //4:伙食费
  7956. {
  7957. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  7958. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7959. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7960. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  7961. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7962. {
  7963. SubId = dac.Id,
  7964. DiId = dac.DiId,
  7965. Type = dac.Type,
  7966. Days = dac.Days,
  7967. NationalTravelFeeId = dac.NationalTravelFeeId,
  7968. Arae = $"{ntf.Country}-{ntf.City}",
  7969. Cost = dac.Cost,
  7970. Currency = dac.Currency,
  7971. CurrencyName = sd.Name,
  7972. SubTotal = dac.SubTotal,
  7973. })
  7974. .ToArray();
  7975. var data = new ChoiceMobileSubInfo3To6View()
  7976. {
  7977. ParentId = eecInfo.Id,
  7978. Choice = eecInfo.ChoiceFour,
  7979. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  7980. Details = dayAndCostDatas
  7981. };
  7982. return Ok(JsonView(data));
  7983. }
  7984. else if (subType == 5) //5:公杂费
  7985. {
  7986. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  7987. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7988. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7989. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  7990. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7991. {
  7992. SubId = dac.Id,
  7993. DiId = dac.DiId,
  7994. Type = dac.Type,
  7995. Days = dac.Days,
  7996. NationalTravelFeeId = dac.NationalTravelFeeId,
  7997. Arae = $"{ntf.Country}-{ntf.City}",
  7998. Cost = dac.Cost,
  7999. Currency = dac.Currency,
  8000. CurrencyName = sd.Name,
  8001. SubTotal = dac.SubTotal,
  8002. })
  8003. .ToArray();
  8004. var data = new ChoiceMobileSubInfo3To6View()
  8005. {
  8006. ParentId = eecInfo.Id,
  8007. Choice = eecInfo.ChoiceFive,
  8008. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8009. Details = dayAndCostDatas
  8010. };
  8011. return Ok(JsonView(data));
  8012. }
  8013. else if (subType == 6) //6:培训费
  8014. {
  8015. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8016. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8017. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8018. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8019. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8020. {
  8021. SubId = dac.Id,
  8022. DiId = dac.DiId,
  8023. Type = dac.Type,
  8024. Days = dac.Days,
  8025. NationalTravelFeeId = dac.NationalTravelFeeId,
  8026. Arae = $"{ntf.Country}-{ntf.City}",
  8027. Cost = dac.Cost,
  8028. Currency = dac.Currency,
  8029. CurrencyName = sd.Name,
  8030. SubTotal = dac.SubTotal,
  8031. })
  8032. .ToArray();
  8033. var data = new ChoiceMobileSubInfo3To6View()
  8034. {
  8035. ParentId = eecInfo.Id,
  8036. Choice = eecInfo.ChoiceSix,
  8037. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8038. Details = dayAndCostDatas
  8039. };
  8040. return Ok(JsonView(data));
  8041. }
  8042. else if (subType == 7) //7:其他
  8043. {
  8044. //其他款项
  8045. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8046. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8047. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8048. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8049. .OrderBy((dop, sd1, sd2) => dop.Index)
  8050. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8051. {
  8052. SubId = dop.Id,
  8053. DiId = dop.Diid,
  8054. Index = dop.Index,
  8055. SetDataId = dop.SetDataId,
  8056. SetDataName = sd1.Name,
  8057. Cost = dop.Cost,
  8058. Currency = dop.Currency,
  8059. CurrencyName = sd2.Name,
  8060. SubTotal = dop.SubTotal,
  8061. Remark = dop.Remark,
  8062. })
  8063. .ToArray();
  8064. var data = new ChoiceSevenMobileSubInfoView()
  8065. {
  8066. ParentId = eecInfo.Id,
  8067. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8068. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8069. Details = otherData
  8070. };
  8071. return Ok(JsonView(data));
  8072. }
  8073. return Ok(JsonView(false));
  8074. }
  8075. #region op
  8076. /// <summary>
  8077. /// 移动端更新费用消息通知
  8078. /// </summary>
  8079. /// <param name="diid"></param>
  8080. /// <param name="id"></param>
  8081. /// <param name="currUserId"></param>
  8082. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8083. {
  8084. try
  8085. {
  8086. ////生成默认文件pdf并且通知人员
  8087. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8088. //{
  8089. // DiId = diid,
  8090. // ExportType = 1,
  8091. // SubTypeId = 1005
  8092. //}, "pdf");
  8093. ////发送通知
  8094. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8095. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8096. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8097. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8098. ////汇率信息记录
  8099. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8100. }
  8101. catch (Exception ex)
  8102. {
  8103. //记录日志
  8104. throw;
  8105. }
  8106. }
  8107. /// <summary>
  8108. /// 验证出入境费用数据是否存在
  8109. /// 不存在添加
  8110. /// </summary>
  8111. /// <param name="diId"></param>
  8112. /// <param name="currUserId"></param>
  8113. /// <returns></returns>
  8114. /// <exception cref="CustomException"></exception>
  8115. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8116. {
  8117. var parentId = 0;
  8118. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8119. if (info != null) parentId = info.Id;
  8120. else
  8121. {
  8122. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8123. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8124. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8125. parentId = addId;
  8126. }
  8127. return parentId;
  8128. }
  8129. /// <summary>
  8130. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8131. /// </summary>
  8132. /// <returns></returns>
  8133. [HttpPost]
  8134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8135. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8136. {
  8137. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8138. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8139. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8140. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8141. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8142. int id = dto.Id;
  8143. if (id <= 0) //add
  8144. {
  8145. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8146. if (add < 1) return Ok(JsonView(false));
  8147. id = add;
  8148. }
  8149. else //update
  8150. {
  8151. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8152. if (upd < 1) return Ok(JsonView(false));
  8153. }
  8154. #region 汇率变更时更改币种相关费用
  8155. var opDayCosts = new List<Grp_DayAndCost>();
  8156. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8157. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8158. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8159. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8160. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8161. .Select((dac, sd) => new {
  8162. dac.Id,
  8163. dac.DiId,
  8164. CurrencyCode = sd.Name,
  8165. dac.Cost
  8166. })
  8167. .ToList();
  8168. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8169. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8170. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8171. .Select((dop, sd) => new {
  8172. dop.Id,
  8173. dop.Diid,
  8174. CurrencyCode = sd.Name,
  8175. dop.Cost
  8176. })
  8177. .ToList();
  8178. if (dayCosts.Count > 0)
  8179. {
  8180. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8181. foreach (var dc in new_dayCosts)
  8182. {
  8183. var thisCurrency = dc.Key.ToUpper();
  8184. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8185. if (thisRate == 0.00M) continue;
  8186. foreach (var dcSub in dc)
  8187. {
  8188. opDayCosts.Add(new Grp_DayAndCost() {
  8189. Id = dcSub.Id,
  8190. DiId = dcSub.DiId,
  8191. Cost = dcSub.Cost,
  8192. SubTotal = dcSub.Cost * thisRate,
  8193. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8194. });
  8195. }
  8196. }
  8197. if (opDayCosts.Count > 0)
  8198. {
  8199. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8200. }
  8201. }
  8202. if (dayOtherCosts.Count > 0)
  8203. {
  8204. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8205. foreach (var dc in new_dayOtherCosts)
  8206. {
  8207. var thisCurrency = dc.Key.ToUpper();
  8208. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8209. if (thisRate == 0.00M) continue;
  8210. foreach (var dcSub in dc)
  8211. {
  8212. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8213. {
  8214. Id = dcSub.Id,
  8215. Diid = dcSub.Diid,
  8216. Cost = dcSub.Cost,
  8217. SubTotal = dcSub.Cost * thisRate,
  8218. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8219. });
  8220. }
  8221. }
  8222. if (opDayOtherCosts.Count > 0)
  8223. {
  8224. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8225. }
  8226. }
  8227. #endregion
  8228. //消息通知
  8229. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8230. //汇率信息记录
  8231. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8232. return Ok(JsonView(new { parentId = id }));
  8233. }
  8234. /// <summary>
  8235. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8236. /// </summary>
  8237. /// <returns></returns>
  8238. [HttpPost]
  8239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8240. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8241. {
  8242. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8243. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8244. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8245. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8246. int id = dto.Id;
  8247. if (id <= 0) //add
  8248. {
  8249. checkboxInfo.CreateUserId = dto.CurrUserId;
  8250. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8251. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8252. if (add < 1) return Ok(JsonView(false));
  8253. }
  8254. else //update
  8255. {
  8256. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8257. .UpdateColumns(x => new {
  8258. x.ChoiceOne,
  8259. x.ChoiceTwo,
  8260. x.SumJJC,
  8261. x.SumGWC,
  8262. x.SumTDC,
  8263. x.ChoiceThree,
  8264. x.ChoiceFour,
  8265. x.ChoiceFive,
  8266. x.ChoiceSix,
  8267. x.OtherExpenses_Checked
  8268. })
  8269. .Where(x => x.Id == id)
  8270. .ExecuteCommandAsync();
  8271. if (upd < 1) return Ok(JsonView(false));
  8272. }
  8273. return Ok(JsonView(new { parentId = id }));
  8274. }
  8275. /// <summary>
  8276. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8277. /// </summary>
  8278. /// <returns></returns>
  8279. [HttpPost]
  8280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8281. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8282. {
  8283. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8284. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8285. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8286. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8287. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8288. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8289. var checkboxInfo = new Grp_EnterExitCost() {
  8290. Id = id,
  8291. DiId = diId,
  8292. CreateUserId = currUserId
  8293. };
  8294. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8295. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8296. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8297. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8298. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8299. if (id <= 0) //add
  8300. {
  8301. checkboxInfo.CreateUserId = dto.CurrUserId;
  8302. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8303. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8304. if (add < 1) return Ok(JsonView(false));
  8305. }
  8306. else //update
  8307. {
  8308. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8309. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8310. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8311. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8312. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8313. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8314. .Where(x => x.Id == id)
  8315. .ExecuteCommandAsync();
  8316. if (upd < 1) return Ok(JsonView(false));
  8317. }
  8318. return Ok(JsonView(new { parentId = id }));
  8319. }
  8320. /// <summary>
  8321. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8322. /// </summary>
  8323. /// <returns></returns>
  8324. [HttpPost]
  8325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8326. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8327. {
  8328. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8329. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8330. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8331. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8332. info.FirstItemRemark = dto.FirstItemRemark;
  8333. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8334. int id = dto.Id;
  8335. if (id <= 0) //add
  8336. {
  8337. info.CreateUserId = dto.CurrUserId;
  8338. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8339. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8340. if (add < 1) return Ok(JsonView(false));
  8341. id = add;
  8342. }
  8343. else //update
  8344. {
  8345. var upd = await _sqlSugar.Updateable(info)
  8346. .UpdateColumns(x => new {
  8347. x.ChoiceOne,
  8348. x.InsidePay,
  8349. x.VisaRemark,
  8350. x.Visa,
  8351. x.Service,
  8352. x.Safe,
  8353. x.Ticket,
  8354. x.HeSuan,
  8355. x.YiMiao,
  8356. x.FirstItemRemark
  8357. })
  8358. .Where(x => x.Id == id)
  8359. .ExecuteCommandAsync();
  8360. if (upd < 1) return Ok(JsonView(false));
  8361. }
  8362. //消息通知
  8363. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8364. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8365. }
  8366. /// <summary>
  8367. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8368. /// </summary>
  8369. /// <returns></returns>
  8370. [HttpPost]
  8371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8372. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8373. {
  8374. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8375. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8376. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8377. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8378. info.OutsideJJPay = dto.OutsideJJPay;
  8379. info.OutsideGWPay = dto.OutsideGWPay;
  8380. info.OutsideTDPay = dto.OutsideTDPay;
  8381. info.AirJJ = dto.AirJJ;
  8382. info.AirGW = dto.AirGW;
  8383. info.AirTD = dto.AirTD;
  8384. info.CityTranffic = dto.CityTranffic;
  8385. info.TwoItemRemark = dto.TwoItemRemark;
  8386. info.SumJJC = dto.ChoiceTwoJJ;
  8387. info.SumGWC = dto.ChoiceTwoGW;
  8388. info.SumTDC = dto.ChoiceTwoTD;
  8389. int id = dto.Id;
  8390. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8391. if (id <= 0) //add
  8392. {
  8393. info.CreateUserId = dto.CurrUserId;
  8394. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8395. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8396. if (addId <= 0) return Ok(JsonView(false));
  8397. id = addId;
  8398. }
  8399. else //update
  8400. {
  8401. var upd = await _sqlSugar.Updateable(info)
  8402. .UpdateColumns(x => new {
  8403. x.SumJJC,
  8404. x.OutsideJJPay,
  8405. x.SumGWC,
  8406. x.OutsideGWPay,
  8407. x.SumTDC,
  8408. x.OutsideTDPay,
  8409. x.AirJJ,
  8410. x.AirGW,
  8411. x.AirTD,
  8412. x.CityTranffic,
  8413. x.TwoItemRemark
  8414. })
  8415. .Where(x => x.Id == id)
  8416. .ExecuteCommandAsync();
  8417. if (upd <1) return Ok(JsonView(false));
  8418. }
  8419. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8420. gwcItemTotal = info.AirGW + info.CityTranffic;
  8421. tdcItemTotal = info.AirTD + info.CityTranffic;
  8422. //消息通知
  8423. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8424. return Ok(JsonView(new
  8425. {
  8426. parentId = id,
  8427. choiceTwoJJ = dto.ChoiceTwoJJ,
  8428. jjcItemTotal = jjcItemTotal,
  8429. choiceTwoGW = dto.ChoiceTwoGW,
  8430. gwcItemTotal = gwcItemTotal,
  8431. choiceTwoTD = dto.ChoiceTwoTD,
  8432. tdcItemTotal = tdcItemTotal
  8433. }));
  8434. }
  8435. /// <summary>
  8436. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8437. /// </summary>
  8438. /// <returns></returns>
  8439. [HttpPost]
  8440. [ApiExplorerSettings(IgnoreApi = true)]
  8441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8442. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8443. {
  8444. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8445. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8446. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8447. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8448. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8449. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8450. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8451. var infos = infos1.Select(x => new Grp_DayAndCost
  8452. {
  8453. Id = x.Id,
  8454. DiId = dto.DiId,
  8455. Type = dto.FeeType,
  8456. Days = x.Days,
  8457. NationalTravelFeeId = x.NationalTravelFeeId,
  8458. Cost = x.Cost,
  8459. Currency = x.Currency,
  8460. SubTotal = x.SubTotal,
  8461. CreateUserId = dto.CurrUserId
  8462. })
  8463. .ToList();
  8464. var adds = infos.Where(x => x.Id <= 0).ToList();
  8465. var upds = infos.Where(x => x.Id > 0).ToList();
  8466. if (adds.Count > 0)
  8467. {
  8468. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8469. if (add < 1) return Ok(JsonView(false));
  8470. }
  8471. if (upds.Count > 0)
  8472. {
  8473. var upd = await _sqlSugar.Updateable(adds)
  8474. .UpdateColumns(x => new
  8475. {
  8476. x.Days,
  8477. x.NationalTravelFeeId,
  8478. x.Cost,
  8479. x.Currency,
  8480. x.SubTotal
  8481. })
  8482. .WhereColumns(x => new { x.Id })
  8483. .ExecuteCommandAsync();
  8484. if (upd < 1) return Ok(JsonView(false));
  8485. }
  8486. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8487. //消息通知
  8488. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8489. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8490. return Ok(JsonView(new { itemTotal = itemTotal }));
  8491. }
  8492. /// <summary>
  8493. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8494. /// </summary>
  8495. /// <returns></returns>
  8496. [HttpPost]
  8497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8498. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8499. {
  8500. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8501. int subId = dto.SubId, feeType = dto.FeeType;
  8502. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8503. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8504. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8505. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8506. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8507. subInfo.Id = subId;
  8508. subInfo.DiId = dto.DiId;
  8509. if (feeType == 3) subInfo.Type = 1;
  8510. else if (feeType == 4) subInfo.Type = 2;
  8511. else if (feeType == 5) subInfo.Type = 3;
  8512. else if (feeType == 6) subInfo.Type = 4;
  8513. subInfo.CreateUserId = dto.CurrUserId;
  8514. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8515. if (parentId < 1) return Ok(JsonView(false));
  8516. //子表op
  8517. if (subId < 1)
  8518. {
  8519. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8520. if (subAdd < 1) return Ok(JsonView(false));
  8521. }
  8522. else
  8523. {
  8524. var subUpd = await _sqlSugar.Updateable(subInfo)
  8525. .UpdateColumns(x => new
  8526. {
  8527. x.Days,
  8528. x.NationalTravelFeeId,
  8529. x.Cost,
  8530. x.Currency,
  8531. x.SubTotal
  8532. })
  8533. .WhereColumns(x => new { x.Id })
  8534. .ExecuteCommandAsync();
  8535. if (subUpd < 1) return Ok(JsonView(false));
  8536. }
  8537. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8538. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8539. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8540. }
  8541. /// <summary>
  8542. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8543. /// </summary>
  8544. /// <returns></returns>
  8545. [HttpPost]
  8546. [ApiExplorerSettings(IgnoreApi = true)]
  8547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8548. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8549. {
  8550. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8551. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8552. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8553. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8554. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8555. {
  8556. Id = x.Id,
  8557. Diid = dto.DiId,
  8558. SetDataId = x.SetDataId,
  8559. Index = x.Index,
  8560. Cost = x.Cost,
  8561. Currency = x.Currency,
  8562. SubTotal = x.SubTotal,
  8563. CreateUserId = dto.CurrUserId,
  8564. Remark = x.Remark
  8565. }).ToList();
  8566. var adds = infos.Where(x => x.Id <= 0).ToList();
  8567. var upds = infos.Where(x => x.Id > 0).ToList();
  8568. if (adds.Count > 0)
  8569. {
  8570. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8571. if (add < 1) return Ok(JsonView(false));
  8572. }
  8573. if (upds.Count > 0)
  8574. {
  8575. var upd = await _sqlSugar.Updateable(adds)
  8576. .UpdateColumns(x => new
  8577. {
  8578. x.Index,
  8579. x.SetDataId,
  8580. x.Cost,
  8581. x.Currency,
  8582. x.SubTotal,
  8583. x.Remark
  8584. })
  8585. .WhereColumns(x => new { x.Id })
  8586. .ExecuteCommandAsync();
  8587. if (upd < 1) return Ok(JsonView(false));
  8588. }
  8589. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8590. //消息通知
  8591. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8592. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8593. return Ok(JsonView(new { itemTotal = itemTotal }));
  8594. }
  8595. /// <summary>
  8596. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8597. /// </summary>
  8598. /// <returns></returns>
  8599. [HttpPost]
  8600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8601. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8602. {
  8603. int subId = dto.SubId;
  8604. int diId = dto.Diid;
  8605. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8606. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8607. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8608. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8609. subInfo.Id = subId;
  8610. subInfo.Diid = dto.Diid;
  8611. subInfo.CreateUserId = dto.CurrUserId;
  8612. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8613. if (parentId < 1) return Ok(JsonView(false));
  8614. #region 子表op
  8615. if (subId < 1)//add
  8616. {
  8617. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8618. if (subAdd < 1) return Ok(JsonView(false));
  8619. }
  8620. else //upd
  8621. {
  8622. var subUpd = await _sqlSugar.Updateable(subInfo)
  8623. .UpdateColumns(x => new
  8624. {
  8625. x.Index,
  8626. x.SetDataId,
  8627. x.Cost,
  8628. x.Currency,
  8629. x.SubTotal,
  8630. x.Remark
  8631. })
  8632. .WhereColumns(x => new { x.Id })
  8633. .ExecuteCommandAsync();
  8634. if (subUpd < 1) return Ok(JsonView(false));
  8635. }
  8636. #endregion
  8637. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8638. //消息通知
  8639. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8640. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8641. }
  8642. /// <summary>
  8643. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8644. /// </summary>
  8645. /// <returns></returns>
  8646. [HttpPost]
  8647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8648. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8649. {
  8650. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8651. if (data.Code != 0)
  8652. {
  8653. return Ok(JsonView(false, data.Msg));
  8654. }
  8655. return Ok(JsonView(true, "操作成功!", data.Data));
  8656. }
  8657. /// <summary>
  8658. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8659. /// </summary>
  8660. /// <param name="dto"></param>
  8661. /// <returns></returns>
  8662. [HttpPost]
  8663. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8664. {
  8665. var data = new Grp_DayOtherPrice()
  8666. {
  8667. Id = dto.Id,
  8668. IsDel = 1,
  8669. DeleteUserId = dto.DeleteUserId,
  8670. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8671. };
  8672. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8673. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8674. return Ok(JsonView(false,"删除失败!"));
  8675. }
  8676. #endregion
  8677. #endregion
  8678. #region 签证费用录入
  8679. /// <summary>
  8680. /// 根据diid查询签证费用列表
  8681. /// </summary>
  8682. /// <param name="dto"></param>
  8683. /// <returns></returns>
  8684. [HttpPost]
  8685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8686. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  8687. {
  8688. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  8689. if (groupData.Code != 0)
  8690. {
  8691. return Ok(JsonView(false, groupData.Msg));
  8692. }
  8693. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8694. }
  8695. /// <summary>
  8696. /// 根据签证费用Id查询单条数据及c表数据
  8697. /// </summary>
  8698. /// <param name="dto"></param>
  8699. /// <returns></returns>
  8700. [HttpPost]
  8701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8702. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  8703. {
  8704. Result groupData = await _visaPriceRep.PostVisaById(dto);
  8705. if (groupData.Code != 0)
  8706. {
  8707. return Ok(JsonView(false, groupData.Msg));
  8708. }
  8709. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8710. }
  8711. /// <summary>
  8712. /// 签证费用删除
  8713. /// </summary>
  8714. /// <param name="dto"></param>
  8715. /// <returns></returns>
  8716. [HttpPost]
  8717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8718. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  8719. {
  8720. _sqlSugar.BeginTran();
  8721. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  8722. if (!res)
  8723. {
  8724. _sqlSugar.RollbackTran();
  8725. return Ok(JsonView(false, "删除失败"));
  8726. }
  8727. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  8728. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  8729. .SetColumns(a => new Grp_CreditCardPayment()
  8730. {
  8731. IsDel = 1,
  8732. DeleteUserId = dto.DeleteUserId,
  8733. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8734. })
  8735. .ExecuteCommand();
  8736. if (resSub < 1)
  8737. {
  8738. _sqlSugar.RollbackTran();
  8739. return Ok(JsonView(false, "删除失败"));
  8740. }
  8741. _sqlSugar.CommitTran();
  8742. return Ok(JsonView(true, "删除成功!"));
  8743. }
  8744. /// <summary>
  8745. /// 签证费用录入下拉框初始化
  8746. /// </summary>
  8747. /// <returns></returns>
  8748. [HttpPost]
  8749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8750. public async Task<IActionResult> VisaPriceAddSelect()
  8751. {
  8752. //支付方式
  8753. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  8754. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  8755. //币种
  8756. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  8757. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  8758. //乘客类型
  8759. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  8760. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  8761. //卡类型
  8762. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  8763. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  8764. //代办费类型
  8765. var agencyFeeTypeData = new List<dynamic>() {
  8766. new { id = 0 , Text = "未选择" },
  8767. new { id = 1 , Text = "小公务" },
  8768. new { id = 2 , Text = "大公务" },
  8769. };
  8770. //签证费用标准国家Data
  8771. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  8772. var data = new
  8773. {
  8774. Payment = _Payment,
  8775. CurrencyList = _CurrencyList,
  8776. PassengerType = _PassengerType,
  8777. BankCard = _BankCard,
  8778. AgencyFeeType = agencyFeeTypeData,
  8779. CountryFeeData = visaCountryFeeData
  8780. };
  8781. return Ok(JsonView(true, "查询成功!", data));
  8782. }
  8783. /// <summary>
  8784. /// 签证费用录入操作(Status:1.新增,2.修改)
  8785. /// </summary>
  8786. /// <param name="dto"></param>
  8787. /// <returns></returns>
  8788. [HttpPost]
  8789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8790. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  8791. {
  8792. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  8793. if (groupData.Code != 0)
  8794. {
  8795. return Ok(JsonView(false, groupData.Msg));
  8796. }
  8797. #region 应用推送
  8798. try
  8799. {
  8800. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  8801. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  8802. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8803. //2024-10-21 新增LZ UID
  8804. var userIds = new List<int>() { 21 };
  8805. string title = $"系统通知";
  8806. string content = "";
  8807. var diId = dto.DiId;
  8808. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  8809. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  8810. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8811. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8812. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  8813. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  8814. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  8815. }
  8816. catch (Exception ex)
  8817. {
  8818. }
  8819. #endregion
  8820. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8821. }
  8822. #endregion
  8823. #region 签证提成录入
  8824. /// <summary>
  8825. /// 签证提成录入
  8826. /// 基础数据
  8827. /// </summary>
  8828. /// <param name="_dto"></param>
  8829. /// <returns></returns>
  8830. [HttpGet]
  8831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8832. public async Task<IActionResult> VisaCommissionInit()
  8833. {
  8834. return Ok(await _visaCommissionRep.Init());
  8835. }
  8836. /// <summary>
  8837. /// 签证提成录入
  8838. /// Item
  8839. /// </summary>
  8840. /// <param name="_dto"></param>
  8841. /// <returns></returns>
  8842. [HttpPost]
  8843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8844. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  8845. {
  8846. var validator = new VisaCommissionItemDtoValidator();
  8847. var validatorRes = await validator.ValidateAsync(_dto);
  8848. if (!validatorRes.IsValid)
  8849. {
  8850. StringBuilder sb = new StringBuilder();
  8851. foreach (var item in validatorRes.Errors)
  8852. {
  8853. sb.AppendLine(item.ErrorMessage);
  8854. }
  8855. return Ok(JsonView(false, sb.ToString()));
  8856. }
  8857. return Ok(await _visaCommissionRep.Item(_dto));
  8858. }
  8859. /// <summary>
  8860. /// 签证提成录入
  8861. /// Save
  8862. /// </summary>
  8863. /// <param name="_dto"></param>
  8864. /// <returns></returns>
  8865. [HttpPost]
  8866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8867. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  8868. {
  8869. //参数验证
  8870. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  8871. foreach (var item in _dto.Items)
  8872. {
  8873. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  8874. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  8875. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  8876. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  8877. }
  8878. return Ok(await _visaCommissionRep.Save(_dto));
  8879. }
  8880. /// <summary>
  8881. /// 签证提成录入
  8882. /// Create
  8883. /// </summary>
  8884. /// <param name="_dto"></param>
  8885. /// <returns></returns>
  8886. [HttpPost]
  8887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8888. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  8889. {
  8890. var validator = new VisaCommissionCreateDtoValidator();
  8891. var validatorRes = await validator.ValidateAsync(_dto);
  8892. if (!validatorRes.IsValid)
  8893. {
  8894. StringBuilder sb = new StringBuilder();
  8895. foreach (var item in validatorRes.Errors)
  8896. {
  8897. sb.AppendLine(item.ErrorMessage);
  8898. }
  8899. return Ok(JsonView(false, sb.ToString()));
  8900. }
  8901. return Ok(await _visaCommissionRep.Create(_dto));
  8902. }
  8903. /// <summary>
  8904. /// 签证提成录入
  8905. /// Put(编辑)
  8906. /// </summary>
  8907. /// <param name="id"></param>
  8908. /// <param name="_dto"></param>
  8909. /// <returns></returns>
  8910. [HttpPut]
  8911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8912. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  8913. {
  8914. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  8915. var validator = new VisaCommissionCreateDtoValidator();
  8916. var validatorRes = await validator.ValidateAsync(_dto);
  8917. if (!validatorRes.IsValid)
  8918. {
  8919. StringBuilder sb = new StringBuilder();
  8920. foreach (var item in validatorRes.Errors)
  8921. {
  8922. sb.AppendLine(item.ErrorMessage);
  8923. }
  8924. return Ok(JsonView(false, sb.ToString()));
  8925. }
  8926. return Ok(await _visaCommissionRep.Edit(id, _dto));
  8927. }
  8928. /// <summary>
  8929. /// 签证提成录入
  8930. /// Del
  8931. /// </summary>
  8932. /// <param name="id"></param>
  8933. /// <param name="currUserId"></param>
  8934. /// <returns></returns>
  8935. [HttpPost]
  8936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8937. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  8938. {
  8939. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  8940. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  8941. return Ok(await _visaCommissionRep.Del(id, currUserId));
  8942. }
  8943. #endregion
  8944. #region op费用录入
  8945. /// <summary>
  8946. /// 根据diid查询op费用列表
  8947. /// </summary>
  8948. /// <param name="dto"></param>
  8949. /// <returns></returns>
  8950. [HttpPost]
  8951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8952. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  8953. {
  8954. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  8955. if (groupData.Code != 0)
  8956. {
  8957. return Ok(JsonView(false, groupData.Msg));
  8958. }
  8959. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8960. }
  8961. /// <summary>
  8962. /// 根据op费用Id查询单条数据及c表数据
  8963. /// </summary>
  8964. /// <param name="dto"></param>
  8965. /// <returns></returns>
  8966. [HttpPost]
  8967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8968. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  8969. {
  8970. try
  8971. {
  8972. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  8973. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  8974. var data = new
  8975. {
  8976. CarTouristGuideGround = _groupData,
  8977. CreditCardPayment = _creditCardPayment
  8978. };
  8979. return Ok(JsonView(true, "查询成功!", data));
  8980. }
  8981. catch (Exception ex)
  8982. {
  8983. return Ok(JsonView(false, "程序错误!"));
  8984. }
  8985. }
  8986. /// <summary>
  8987. /// op费用删除
  8988. /// </summary>
  8989. /// <param name="dto"></param>
  8990. /// <returns></returns>
  8991. [HttpPost]
  8992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8993. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  8994. {
  8995. try
  8996. {
  8997. _sqlSugar.BeginTran();
  8998. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  8999. if (!res)
  9000. {
  9001. return Ok(JsonView(false, "删除失败"));
  9002. }
  9003. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  9004. {
  9005. IsDel = 1,
  9006. DeleteUserId = dto.DeleteUserId,
  9007. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9008. }).ExecuteCommandAsync();
  9009. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  9010. {
  9011. IsDel = 1,
  9012. DeleteUserId = dto.DeleteUserId,
  9013. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9014. }).ExecuteCommandAsync();
  9015. #region 删除超支相关数据
  9016. //删除导入的超支数据
  9017. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  9018. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  9019. {
  9020. IsDel = 1,
  9021. DeleteUserId = dto.DeleteUserId,
  9022. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9023. }).ExecuteCommand();
  9024. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  9025. {
  9026. IsDel = 1,
  9027. DeleteUserId = dto.DeleteUserId,
  9028. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9029. }).ExecuteCommand();
  9030. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  9031. {
  9032. IsDel = 1,
  9033. DeleteUserId = dto.DeleteUserId,
  9034. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9035. }).ExecuteCommand();
  9036. #endregion
  9037. _sqlSugar.CommitTran();
  9038. return Ok(JsonView(true, "删除成功!"));
  9039. }
  9040. catch (Exception ex)
  9041. {
  9042. _sqlSugar.RollbackTran();
  9043. return Ok(JsonView(false, "程序错误!" + ex.Message));
  9044. }
  9045. }
  9046. /// <summary>
  9047. /// op费用录入操作(Status:1.新增,2.修改)
  9048. /// </summary>
  9049. /// <param name="dto"></param>
  9050. /// <returns></returns>
  9051. [HttpPost]
  9052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9053. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  9054. {
  9055. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  9056. if (groupData.Code != 0)
  9057. {
  9058. return Ok(JsonView(false, groupData.Msg));
  9059. }
  9060. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9061. }
  9062. /// <summary>
  9063. /// 填写费用详细页面初始化绑定
  9064. /// </summary>
  9065. /// <param name="dto"></param>
  9066. /// <returns></returns>
  9067. [HttpPost]
  9068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9069. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  9070. {
  9071. try
  9072. {
  9073. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  9074. if (groupData.Code != 0)
  9075. {
  9076. return Ok(JsonView(false, groupData.Msg));
  9077. }
  9078. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9079. }
  9080. catch (Exception ex)
  9081. {
  9082. return Ok(JsonView(false, ex.Message));
  9083. }
  9084. }
  9085. /// <summary>
  9086. /// 根据op费用Id查询详细数据
  9087. /// </summary>
  9088. /// <param name="dto"></param>
  9089. /// <returns></returns>
  9090. [HttpPost]
  9091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9092. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  9093. {
  9094. try
  9095. {
  9096. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  9097. if (groupData.Code != 0)
  9098. {
  9099. return Ok(JsonView(false, groupData.Msg));
  9100. }
  9101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9102. }
  9103. catch (Exception ex)
  9104. {
  9105. return Ok(JsonView(false, ex.Message));
  9106. }
  9107. }
  9108. /// <summary>
  9109. /// OP费用录入填写详情
  9110. /// </summary>
  9111. /// <param name="dto"></param>
  9112. /// <returns></returns>
  9113. [HttpPost]
  9114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9115. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  9116. {
  9117. try
  9118. {
  9119. #region 参数校验
  9120. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  9121. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  9122. if (di == null) return Ok(JsonView(false, "团组错误!"));
  9123. #endregion
  9124. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  9125. if (groupData.Code != 0)
  9126. {
  9127. return Ok(JsonView(false, groupData.Msg));
  9128. }
  9129. //自动审核
  9130. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  9131. #region 应用推送
  9132. try
  9133. {
  9134. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9135. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9136. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9137. //2024-10-21 新增LZ UID
  9138. var userIds = new List<int>() { 21 };
  9139. string title = $"系统通知";
  9140. var diId = dto.DiId;
  9141. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9142. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9143. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  9144. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9145. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  9146. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  9147. }
  9148. catch (Exception ex)
  9149. {
  9150. }
  9151. #endregion
  9152. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9153. }
  9154. catch (Exception ex)
  9155. {
  9156. return Ok(JsonView(false, ex.Message));
  9157. }
  9158. }
  9159. /// <summary>
  9160. /// 获取三公详细所有城市
  9161. /// </summary>
  9162. /// <returns></returns>
  9163. [HttpGet]
  9164. public IActionResult OpCarCityResult()
  9165. {
  9166. var jw = JsonView(false);
  9167. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  9168. {
  9169. x.Id,
  9170. x.Country,
  9171. x.City,
  9172. }).ToList();
  9173. if (data.Count > 0)
  9174. {
  9175. jw = JsonView(true, "获取成功!", data);
  9176. }
  9177. else
  9178. {
  9179. jw.Msg = "城市数据为空!";
  9180. jw.Data = new string[0];
  9181. }
  9182. return Ok(jw);
  9183. }
  9184. /// <summary>
  9185. /// 导出地接费用明细
  9186. /// </summary>
  9187. /// <param name="dto"></param>
  9188. /// <returns></returns>
  9189. [HttpPost]
  9190. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  9191. {
  9192. var jw = JsonView(false);
  9193. if (dto.Diid < 1)
  9194. {
  9195. jw.Msg = "请输入正确的diid!";
  9196. return Ok(jw);
  9197. }
  9198. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  9199. if (group == null)
  9200. {
  9201. jw.Msg = "未找到团组信息!";
  9202. return Ok(jw);
  9203. }
  9204. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  9205. if (localGuideArr.Count == 0)
  9206. {
  9207. jw.Msg = "该团组暂无地接信息!";
  9208. return Ok(jw);
  9209. }
  9210. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  9211. var overspendSoure = new Dictionary<int, int>
  9212. {
  9213. { 91, 982 }, //车
  9214. { 92 , 1059} ,//导游
  9215. { 994 , 1073}, //翻译
  9216. { 988 , 1074 }, //早餐
  9217. { 93 , 1075 }, //午餐
  9218. { 989 , 1076 }, //晚餐
  9219. };
  9220. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  9221. foreach (var groupArr in localGroup)
  9222. {
  9223. var keyValue = groupArr.Key;
  9224. if (int.TryParse(keyValue, out int cityid))
  9225. {
  9226. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  9227. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  9228. }
  9229. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  9230. foreach (var item in groupArr)
  9231. {
  9232. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  9233. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  9234. new Grp_CarTouristGuideGroundReservationsContentExtend
  9235. {
  9236. Count = a.Count,
  9237. CreateTime = a.CreateTime,
  9238. CreateUserId = a.CreateUserId,
  9239. CTGGRId = a.CTGGRId,
  9240. Currency = a.Currency,
  9241. DatePrice = a.DatePrice,
  9242. DeleteTime = a.DeleteTime,
  9243. DeleteUserId = a.DeleteUserId,
  9244. DiId = a.DiId,
  9245. Id = a.Id,
  9246. IsDel = a.IsDel,
  9247. Price = a.Price,
  9248. PriceContent = a.PriceContent,
  9249. Remark = a.Remark,
  9250. SId = a.SId,
  9251. SidName = b.Name,
  9252. Units = a.Units,
  9253. }
  9254. ).ToList();
  9255. if (content.Count > 0)
  9256. {
  9257. contentArr.Add(content);
  9258. }
  9259. }
  9260. //open excel
  9261. //set excel
  9262. //save excel
  9263. try
  9264. {
  9265. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  9266. IWorkbook workbook;
  9267. if (Path.GetExtension(filePath).ToLower() == ".xls")
  9268. {
  9269. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9270. }
  9271. else
  9272. {
  9273. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9274. }
  9275. ISheet sheet = workbook.GetSheetAt(0);
  9276. var rowStartIndex = 2;
  9277. var clounmCount = 10;
  9278. var initStyleRow = sheet.GetRow(2);
  9279. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  9280. //var overspendArrDetail =
  9281. var existsId = new List<CarCompare>();
  9282. var lastElem = arr.Last();
  9283. var thisSid = -1;
  9284. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  9285. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  9286. {
  9287. Name = "未知币种!",
  9288. Remark = "未知币种!",
  9289. };
  9290. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  9291. Action cloneRowFn = () =>
  9292. {
  9293. rowStartIndex++;
  9294. var cloneRow = sheet.CreateRow(rowStartIndex);
  9295. // 复制样式
  9296. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  9297. {
  9298. ICell sourceCell = initStyleRow.GetCell(i);
  9299. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  9300. // 确保单元格存在样式
  9301. if (sourceCell.CellStyle != null)
  9302. {
  9303. targetCell.CellStyle = sourceCell.CellStyle;
  9304. }
  9305. }
  9306. };
  9307. var mergeRow = () =>
  9308. {
  9309. for (int i = 2; i < sheet.LastRowNum; i++)
  9310. {
  9311. var row = sheet.GetRow(i);
  9312. var cellFirst = row.GetCell(0);
  9313. var thisIndex = i + 1;
  9314. while (thisIndex < sheet.LastRowNum)
  9315. {
  9316. var nextRow = sheet.GetRow(thisIndex);
  9317. var nextCellFirst = nextRow.GetCell(0);
  9318. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  9319. {
  9320. thisIndex++;
  9321. }
  9322. else
  9323. {
  9324. break;
  9325. }
  9326. }
  9327. thisIndex--;
  9328. if (thisIndex != i)
  9329. {
  9330. //合并row
  9331. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9332. i, // 起始行索引(0-based)
  9333. thisIndex, // 结束行索引(0-based)
  9334. 0, // 起始列索引(0-based)
  9335. 0 // 结束列索引(0-based)
  9336. );
  9337. sheet.AddMergedRegion(cellRangeAddress);
  9338. i = thisIndex;
  9339. }
  9340. }
  9341. };
  9342. var chaoshiNumber = 0;
  9343. var totalNumber = 0.00M;
  9344. string lastStr = "";
  9345. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  9346. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  9347. {
  9348. b.IsAuditGM,
  9349. x.Id,
  9350. x.Area,
  9351. b.PayPercentage,
  9352. b.PayMoney,
  9353. }).ToList();
  9354. string yesPayment = "", noPayment = "";
  9355. foreach (var item in queryCarArrByCityAndDiid)
  9356. {
  9357. if (item.IsAuditGM == 1)
  9358. {
  9359. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9360. }
  9361. else
  9362. {
  9363. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9364. }
  9365. }
  9366. lastStr = yesPayment + noPayment;
  9367. foreach (var item in arr)
  9368. {
  9369. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  9370. {
  9371. if (thisSid != item.SId)
  9372. {
  9373. if (thisSid == -1)
  9374. {
  9375. thisSid = item.SId;
  9376. }
  9377. else
  9378. {
  9379. //合并小计行
  9380. //创建合并区域的实例
  9381. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9382. rowStartIndex, // 起始行索引(0-based)
  9383. rowStartIndex, // 结束行索引(0-based)
  9384. 0, // 起始列索引(0-based)
  9385. 3 // 结束列索引(0-based)
  9386. );
  9387. sheet.AddMergedRegion(cellRangeAddress);
  9388. var CellStyle = workbook.CreateCellStyle();
  9389. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9390. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9391. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9392. for (int i = 0; i <= clounmCount; i++)
  9393. {
  9394. if (i > 6)
  9395. {
  9396. var CellStyle1 = workbook.CreateCellStyle();
  9397. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9398. IFont Font = workbook.CreateFont(); // 创建字体
  9399. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9400. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9401. CellStyle1.SetFont(Font);
  9402. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9403. }
  9404. else
  9405. {
  9406. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9407. }
  9408. }
  9409. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9410. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9411. //超时合计
  9412. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9413. //超时数
  9414. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9415. //超时合计费用
  9416. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9417. thisSid = item.SId;
  9418. cloneRowFn();
  9419. chaoshiNumber = 0;
  9420. totalNumber = 0;
  9421. }
  9422. }
  9423. IRow row = sheet.GetRow(rowStartIndex);
  9424. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9425. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  9426. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  9427. if (isOpenOverspendSoure)
  9428. {
  9429. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9430. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  9431. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  9432. }
  9433. for (int i = 0; i <= clounmCount; i++)
  9434. {
  9435. var cell = row.GetCell(i);
  9436. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  9437. if (cell == null)
  9438. {
  9439. cell = row.CreateCell(i);
  9440. }
  9441. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  9442. fontRed.CloneStyleFrom(cell.CellStyle);
  9443. IFont Font = workbook.CreateFont(); // 创建字体
  9444. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  9445. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9446. fontRed.SetFont(Font);
  9447. byte[] rgb = new byte[3] { 255, 242, 204 };
  9448. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  9449. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  9450. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  9451. if (workbook is XSSFWorkbook)
  9452. {
  9453. BackgroundColor255_242_204.FillForegroundColor = 0;
  9454. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  9455. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  9456. }
  9457. else
  9458. {
  9459. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  9460. }
  9461. if (i == 1 || i > 6)
  9462. {
  9463. if (i > 6)
  9464. {
  9465. fontRed.FillForegroundColor = 0;
  9466. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  9467. fontRed.FillPattern = FillPattern.SolidForeground;
  9468. }
  9469. cell.CellStyle = fontRed;
  9470. }
  9471. if (i > 2 && i < 7)
  9472. {
  9473. cell.CellStyle = BackgroundColor255_242_204;
  9474. }
  9475. cell.SetCellValue(setCellValue); //写入单元格
  9476. }
  9477. if (overspendSoure.ContainsKey(thisSid))
  9478. {
  9479. var overspendId = overspendSoure[thisSid];
  9480. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9481. }
  9482. cloneRowFn();
  9483. existsId.Add(new CarCompare
  9484. {
  9485. DataPrice = item.DatePrice.ObjToDate(),
  9486. Sid = item.SId
  9487. });
  9488. }
  9489. if (item.Equals(lastElem))
  9490. {
  9491. //合并小计行
  9492. //创建合并区域的实例
  9493. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9494. rowStartIndex, // 起始行索引(0-based)
  9495. rowStartIndex, // 结束行索引(0-based)
  9496. 0, // 起始列索引(0-based)
  9497. 3 // 结束列索引(0-based)
  9498. );
  9499. sheet.AddMergedRegion(cellRangeAddress);
  9500. var CellStyle = workbook.CreateCellStyle();
  9501. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9502. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9503. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9504. for (int i = 0; i <= clounmCount; i++)
  9505. {
  9506. if (i > 6)
  9507. {
  9508. var CellStyle1 = workbook.CreateCellStyle();
  9509. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9510. IFont Font = workbook.CreateFont(); // 创建字体
  9511. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9512. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9513. CellStyle1.SetFont(Font);
  9514. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9515. }
  9516. else
  9517. {
  9518. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9519. }
  9520. }
  9521. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9522. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9523. //超时合计
  9524. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9525. //超时数
  9526. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9527. //超时合计费用
  9528. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9529. cloneRowFn();
  9530. // 创建合并区域的实例
  9531. cellRangeAddress = new CellRangeAddress(
  9532. rowStartIndex, // 起始行索引(0-based)
  9533. rowStartIndex, // 结束行索引(0-based)
  9534. 0, // 起始列索引(0-based)
  9535. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  9536. );
  9537. // 添加合并区域
  9538. sheet.AddMergedRegion(cellRangeAddress);
  9539. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  9540. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  9541. }
  9542. }
  9543. mergeRow();
  9544. // 保存修改后的Excel文件到新文件
  9545. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  9546. // new FileStream(newFilePath, FileMode.CreateNew)
  9547. using (var stream = new MemoryStream())
  9548. {
  9549. workbook.Write(stream, true);
  9550. stream.Flush();
  9551. stream.Seek(0, SeekOrigin.Begin);
  9552. MemoryStream memoryStream = new MemoryStream();
  9553. stream.CopyTo(memoryStream);
  9554. memoryStream.Seek(0, SeekOrigin.Begin);
  9555. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  9556. }
  9557. workbook.Close();
  9558. workbook.Dispose();
  9559. }
  9560. catch (Exception ex)
  9561. {
  9562. jw.Msg = "出现异常!" + ex.Message;
  9563. return Ok(jw);
  9564. }
  9565. }
  9566. if (Zips.Count > 0)
  9567. {
  9568. IOOperatorHelper io = new IOOperatorHelper();
  9569. var byts = io.ConvertZipStream(Zips);
  9570. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  9571. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  9572. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  9573. }
  9574. else
  9575. {
  9576. jw.Msg = "暂无生成文件!";
  9577. }
  9578. return Ok(jw);
  9579. }
  9580. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  9581. {
  9582. string outStr = string.Empty;
  9583. switch (i)
  9584. {
  9585. case 0:
  9586. outStr = arr[0].SidName;
  9587. break;
  9588. case 1:
  9589. outStr = arr[0].DataPriceStr;
  9590. break;
  9591. case 2:
  9592. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  9593. break;
  9594. case 4:
  9595. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  9596. break;
  9597. case 7:
  9598. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9599. {
  9600. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  9601. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  9602. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  9603. }
  9604. break;
  9605. case 8:
  9606. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9607. {
  9608. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  9609. }
  9610. break;
  9611. case 9:
  9612. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9613. {
  9614. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  9615. }
  9616. break;
  9617. case 10:
  9618. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9619. {
  9620. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  9621. }
  9622. break;
  9623. }
  9624. return outStr;
  9625. }
  9626. #region OP行程单
  9627. /// <summary>
  9628. /// OP行程单初始化
  9629. /// </summary>
  9630. /// <param name="dto"></param>
  9631. /// <returns></returns>
  9632. [HttpPost]
  9633. public IActionResult InitOpTravel(InitOpTravelDto dto)
  9634. {
  9635. var jw = JsonView(false);
  9636. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  9637. var group = groupList.First();
  9638. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  9639. if (group == null)
  9640. {
  9641. jw.Msg = "暂无团组!";
  9642. return Ok(jw);
  9643. }
  9644. group = groupList.Find(x => x.Id == diid);
  9645. if (group == null)
  9646. {
  9647. jw.Msg = "请输入正确的团组ID!";
  9648. return Ok(jw);
  9649. }
  9650. string city = string.Empty;
  9651. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  9652. if (blackCode.Count > 0)
  9653. {
  9654. var black = blackCode.First();
  9655. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  9656. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  9657. if (blackSp.Length > 0)
  9658. {
  9659. try
  9660. {
  9661. var cityArrCode = new List<string>(20);
  9662. foreach (var item in blackSp)
  9663. {
  9664. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  9665. var IndexSelect = itemSp[2];
  9666. var cityArrCodeLength = cityArrCode.Count - 1;
  9667. var startCity = IndexSelect.Substring(0, 3);
  9668. if (cityArrCodeLength > 0)
  9669. {
  9670. var arrEndCity = cityArrCode[cityArrCodeLength];
  9671. if (arrEndCity != startCity)
  9672. {
  9673. cityArrCode.Add(startCity.ToUpper());
  9674. }
  9675. }
  9676. else
  9677. {
  9678. cityArrCode.Add(startCity.ToUpper());
  9679. }
  9680. var endCity = IndexSelect.Substring(3, 3);
  9681. cityArrCode.Add(endCity.ToUpper());
  9682. }
  9683. var cityThree = string.Empty;
  9684. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  9685. cityThree = cityThree.TrimEnd(',');
  9686. if (string.IsNullOrWhiteSpace(cityThree))
  9687. {
  9688. throw new
  9689. Exception("error");
  9690. }
  9691. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  9692. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  9693. foreach (var item in cityArrCode)
  9694. {
  9695. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  9696. if (find != null)
  9697. {
  9698. city += find.City + "/";
  9699. }
  9700. else
  9701. {
  9702. city += item + "三字码未收入/";
  9703. }
  9704. }
  9705. city = city.TrimEnd('/');
  9706. }
  9707. catch (Exception e)
  9708. {
  9709. city = "黑屏代码格式不正确!";
  9710. }
  9711. }
  9712. }
  9713. else
  9714. {
  9715. city = "未录入黑屏代码";
  9716. }
  9717. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  9718. {
  9719. Date = x.Date,
  9720. Days = x.Days,
  9721. Diffgroup = x.Diffgroup,
  9722. Diid = x.Diid,
  9723. Traffic_First = x.Traffic_First,
  9724. Traffic_Second = x.Traffic_Second,
  9725. Trip = x.Trip,
  9726. WeekDay = x.WeekDay,
  9727. Id = x.Id
  9728. }).ToList();
  9729. jw.Data = new
  9730. {
  9731. groupList = groupList.Select(x => new
  9732. {
  9733. x.Id,
  9734. x.TeamName,
  9735. x.TourCode
  9736. }).ToList(),
  9737. groupInfo = new
  9738. {
  9739. group.VisitDays,
  9740. group.TourCode,
  9741. group.VisitPNumber,
  9742. group.TeamName,
  9743. city
  9744. },
  9745. OpTravelList
  9746. };
  9747. jw.Code = 200;
  9748. jw.Msg = "操作成功!";
  9749. return Ok(jw);
  9750. }
  9751. /// <summary>
  9752. /// 删除团组行程单
  9753. /// </summary>
  9754. /// <returns></returns>
  9755. [HttpPost]
  9756. public IActionResult DelTravel(DelOpTravelDto dto)
  9757. {
  9758. var jw = JsonView(false);
  9759. if (dto.UserId <= 0 || dto.Diid <= 0)
  9760. {
  9761. jw.Msg = "请输入正确的参数!";
  9762. return Ok(jw);
  9763. }
  9764. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  9765. .SetColumns(x => new Grp_TravelList
  9766. {
  9767. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9768. DeleteUserId = dto.UserId,
  9769. IsDel = 1,
  9770. }).ExecuteCommand();
  9771. jw = JsonView(true);
  9772. return Ok(jw);
  9773. }
  9774. /// <summary>
  9775. /// 行程单保存
  9776. /// </summary>
  9777. /// <returns></returns>
  9778. [HttpPost]
  9779. public IActionResult TravelSave(TravelSaveDto dto)
  9780. {
  9781. var jw = JsonView(false);
  9782. if (dto.Arr.Count > 0)
  9783. {
  9784. try
  9785. {
  9786. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  9787. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  9788. .ToList();
  9789. _sqlSugar.BeginTran();
  9790. foreach (var item in dto.Arr)
  9791. {
  9792. if (item.Id == 0)
  9793. {
  9794. throw new Exception("请传入正确的Id");
  9795. }
  9796. //比较上一次的差异
  9797. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  9798. if (findTravel != null)
  9799. {
  9800. item.Trip = item.Trip.Replace("[++]", string.Empty);
  9801. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  9802. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  9803. }
  9804. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  9805. .SetColumns(x => new Grp_TravelList
  9806. {
  9807. Trip = item.Trip
  9808. }).ExecuteCommand();
  9809. }
  9810. _sqlSugar.CommitTran();
  9811. jw = JsonView(true);
  9812. }
  9813. catch (Exception ex)
  9814. {
  9815. _sqlSugar.RollbackTran();
  9816. jw.Msg = "程序异常!" + ex.Message;
  9817. }
  9818. }
  9819. else
  9820. {
  9821. jw.Msg = "请传入正确的参数!";
  9822. }
  9823. return Ok(jw);
  9824. }
  9825. private string CheckStr(string original, string changed)
  9826. {
  9827. // 创建diff_match_patch对象
  9828. var dmp = new diff_match_patch();
  9829. // 计算差异
  9830. List<Diff> diffs = dmp.diff_main(original, changed);
  9831. // 清理和合并差异
  9832. dmp.diff_cleanupSemantic(diffs);
  9833. // 使用StringBuilder构建最终的字符串
  9834. StringBuilder finalString = new StringBuilder();
  9835. // 输出差异结果,并构建变动后的字符串
  9836. foreach (Diff diff in diffs)
  9837. {
  9838. switch (diff.operation)
  9839. {
  9840. case Operation.EQUAL:
  9841. // 相等的部分,直接添加到最终字符串
  9842. finalString.Append(diff.text);
  9843. break;
  9844. case Operation.INSERT:
  9845. // 插入的部分,添加标记并添加到最终字符串
  9846. finalString.Append("[++]" + diff.text + "[++]");
  9847. break;
  9848. case Operation.DELETE:
  9849. // 删除的部分,不添加到最终字符串
  9850. //finalString.Append("[++]" + diff.text + "[++]");
  9851. break;
  9852. }
  9853. }
  9854. // 输出变动后的字符串
  9855. return finalString.ToString();
  9856. }
  9857. public class tagContent
  9858. {
  9859. public DateTime Date { get; set; }
  9860. public string StartTag { get; set; }
  9861. public string EndTag { get; set; }
  9862. public string Content { get; set; }
  9863. public static int tagLength { get { return 3; } }
  9864. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  9865. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  9866. public bool IsFinally { get; set; }
  9867. }
  9868. /// <summary>
  9869. /// 导出行程单
  9870. /// </summary>
  9871. /// <param name="dto"></param>
  9872. /// <returns></returns>
  9873. [HttpPost]
  9874. public IActionResult ExportTravel(ExportTravelDto dto)
  9875. {
  9876. var jw = JsonView(false);
  9877. jw.Data = "";
  9878. int diid = 0;
  9879. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  9880. if (Find == null)
  9881. {
  9882. jw.Msg = "请选择正确的团组!";
  9883. return Ok(jw);
  9884. }
  9885. else
  9886. {
  9887. diid = Find.Id;
  9888. }
  9889. //数据源
  9890. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  9891. DataTable dtBlack = null;
  9892. try
  9893. {
  9894. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  9895. }
  9896. catch (Exception)
  9897. {
  9898. jw.Msg = "机票黑屏代码有误!";
  9899. return Ok(jw);
  9900. }
  9901. string CityStr = string.Empty;
  9902. if (dtBlack.Rows.Count == 0)
  9903. {
  9904. jw.Msg = "机票黑屏代码有误!";
  9905. return Ok(jw);
  9906. }
  9907. else
  9908. {
  9909. foreach (DataRow row in dtBlack.Rows)
  9910. {
  9911. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  9912. {
  9913. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  9914. return Ok(jw);
  9915. }
  9916. }
  9917. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  9918. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  9919. }
  9920. //创建数据源Table
  9921. DataTable dtSource = new DataTable();
  9922. dtSource.Columns.Add("Days", typeof(string));
  9923. dtSource.Columns.Add("Date", typeof(string));
  9924. dtSource.Columns.Add("Week", typeof(string));
  9925. dtSource.Columns.Add("Traffic", typeof(string));
  9926. dtSource.Columns.Add("Trip", typeof(string));
  9927. //获取数据,放到datatable
  9928. foreach (var item in _travelList)
  9929. {
  9930. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty).Replace(tagContent.TagFormat.Item2, string.Empty);
  9931. DataRow dr = dtSource.NewRow();
  9932. dr["Days"] = item.Days;
  9933. dr["Date"] = item.Date;
  9934. dr["Week"] = item.WeekDay;
  9935. dr["Traffic"] = item.Traffic_First
  9936. + "\r\n"
  9937. + item.Traffic_Second;
  9938. dr["Trip"] = item.Trip;
  9939. dtSource.Rows.Add(dr);
  9940. }
  9941. Dictionary<string, string> dic = new Dictionary<string, string>();
  9942. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  9943. dic.Add("City", CityStr);
  9944. dic.Add("Days", Find.VisitDays.ToString());
  9945. dic.Add("DeleCode", Find.TourCode);
  9946. dic.Add("Pnum", Find.VisitPNumber.ToString());
  9947. //模板路径
  9948. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  9949. //载入模板
  9950. Document doc = null;
  9951. DocumentBuilder builder = null;
  9952. try
  9953. {
  9954. //载入模板
  9955. doc = new Document(tempPath);
  9956. builder = new DocumentBuilder(doc);
  9957. }
  9958. catch (Exception)
  9959. {
  9960. jw.Msg = "模板位置不存在!";
  9961. return Ok(jw);
  9962. }
  9963. foreach (var key in dic.Keys)
  9964. {
  9965. Bookmark bookmark = doc.Range.Bookmarks[key];
  9966. if (bookmark != null)
  9967. {
  9968. builder.MoveToBookmark(key);
  9969. builder.Write(dic[key]);
  9970. }
  9971. }
  9972. //获取word里所有表格
  9973. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9974. //获取所填表格的序数
  9975. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9976. try
  9977. {
  9978. //循环赋值
  9979. for (int i = 0; i < dtSource.Rows.Count; i++)
  9980. {
  9981. builder.MoveToCell(0, i + 1, 0, 0);
  9982. builder.Write(dtSource.Rows[i]["Days"].ToString());
  9983. builder.MoveToCell(0, i + 1, 1, 0);
  9984. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  9985. builder.MoveToCell(0, i + 1, 2, 0);
  9986. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  9987. var trip = dtSource.Rows[i]["Trip"].ToString();
  9988. builder.MoveToCell(0, i + 1, 3, 0);
  9989. builder.Write(trip);
  9990. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  9991. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  9992. // 获取特定索引的段落
  9993. Paragraph paragraph = (Paragraph)paragraphs[0];
  9994. Run run = paragraph.Runs[0];
  9995. Aspose.Words.Font font = run.Font;
  9996. font.Name = "黑体";
  9997. //设置双休红色
  9998. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  9999. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  10000. paragraph = (Paragraph)paragraphs[1];
  10001. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  10002. {
  10003. run = paragraph.Runs[0];
  10004. font = run.Font;
  10005. font.Color = Color.Red;
  10006. }
  10007. }
  10008. }
  10009. catch (Exception ex)
  10010. {
  10011. }
  10012. //删除多余行
  10013. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  10014. {
  10015. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  10016. }
  10017. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  10018. if (!Directory.Exists(savePath))
  10019. {
  10020. try
  10021. {
  10022. Directory.CreateDirectory(savePath);
  10023. }
  10024. catch
  10025. {
  10026. }
  10027. }
  10028. string path = savePath + Find.TeamName + "出访日程";
  10029. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  10030. try
  10031. {
  10032. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  10033. string postfix = ".docx";
  10034. if (dto.IsPDF == 1)
  10035. {
  10036. saveFormat = Aspose.Words.SaveFormat.Pdf;
  10037. postfix = ".pdf";
  10038. }
  10039. doc.Save(path + postfix, saveFormat);
  10040. jw = JsonView(true, "导出成功", ftpPath + postfix);
  10041. }
  10042. catch (Exception)
  10043. {
  10044. jw = JsonView(false);
  10045. }
  10046. return Ok(jw);
  10047. }
  10048. /// <summary>
  10049. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  10050. /// </summary>
  10051. /// <param name="num"></param>
  10052. /// <returns></returns>
  10053. string GetNum(string num)
  10054. {
  10055. string str = "";
  10056. switch (num)
  10057. {
  10058. case "1":
  10059. str = "一";
  10060. break;
  10061. case "2":
  10062. str = "二";
  10063. break;
  10064. case "3":
  10065. str = "三";
  10066. break;
  10067. case "4":
  10068. str = "四";
  10069. break;
  10070. case "5":
  10071. str = "五";
  10072. break;
  10073. case "6":
  10074. str = "六";
  10075. break;
  10076. case "7":
  10077. str = "七";
  10078. break;
  10079. case "8":
  10080. str = "八";
  10081. break;
  10082. case "9":
  10083. str = "九";
  10084. break;
  10085. case "10":
  10086. str = "十";
  10087. break;
  10088. case "11":
  10089. str = "十一";
  10090. break;
  10091. case "12":
  10092. str = "十二";
  10093. break;
  10094. case "一":
  10095. str = "1";
  10096. break;
  10097. case "二":
  10098. str = "2";
  10099. break;
  10100. case "三":
  10101. str = "3";
  10102. break;
  10103. case "四":
  10104. str = "4";
  10105. break;
  10106. case "五":
  10107. str = "5";
  10108. break;
  10109. case "六":
  10110. str = "6";
  10111. break;
  10112. case "七":
  10113. str = "7";
  10114. break;
  10115. case "八":
  10116. str = "8";
  10117. break;
  10118. case "九":
  10119. str = "9";
  10120. break;
  10121. case "十":
  10122. str = "10";
  10123. break;
  10124. case "十一":
  10125. str = "11";
  10126. break;
  10127. case "十二":
  10128. str = "12";
  10129. break;
  10130. }
  10131. return str;
  10132. }
  10133. #endregion
  10134. #endregion
  10135. #region 团组成本
  10136. /// <summary>
  10137. /// 团组成本数据初始化
  10138. /// </summary>
  10139. /// <param name="dto"></param>
  10140. /// <returns></returns>
  10141. [HttpPost]
  10142. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  10143. {
  10144. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  10145. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  10146. WHEN COUNT(*) >= 0 THEN 'True'
  10147. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  10148. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  10149. ").ToList(); //团组列表
  10150. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  10151. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  10152. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  10153. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  10154. if (groupinfoValue != null)
  10155. {
  10156. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  10157. var spArr = new string[1] { countryArr };
  10158. if (countryArr.Contains("|"))
  10159. {
  10160. spArr = countryArr.Split("|");
  10161. }
  10162. else if (countryArr.Contains("、"))
  10163. {
  10164. spArr = countryArr.Split("、");
  10165. }
  10166. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  10167. {
  10168. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  10169. if (dbQueryCountry != null)
  10170. {
  10171. visaCountryInfoArr.Add(dbQueryCountry);
  10172. }
  10173. }
  10174. }
  10175. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  10176. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  10177. var create = _GroupCostRepository.
  10178. CreateGroupCostByBlackCode(dto.Diid);
  10179. if (groupCost.Count == 0 && create.Code == 0)
  10180. {
  10181. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  10182. }
  10183. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  10184. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  10185. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  10186. groupCostMap = groupCostMap.Select(x =>
  10187. {
  10188. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  10189. {
  10190. x.Date = dataForamt.ToString("yyyy-MM-dd");
  10191. }
  10192. return x;
  10193. }).ToList();
  10194. //GroupCostParameter.Add(new
  10195. // Grp_GroupCostParameter());
  10196. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  10197. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  10198. return Ok(JsonView(new
  10199. {
  10200. groupList,
  10201. groupInfo,
  10202. groupChecks,
  10203. groupCost = groupCostMap,
  10204. hotelNumber,
  10205. GroupCostParameter = GroupCostParameterMap,
  10206. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  10207. {
  10208. x.VisaCountry,
  10209. x.VisaPrice,
  10210. x.Id,
  10211. }).ToList(),
  10212. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  10213. blackCodeIsTrue = create.Code == 0 ? true : false,
  10214. hotelIsTrue = hotelIsTrue,
  10215. }));
  10216. }
  10217. /// <summary>
  10218. /// 团组成本信息保存
  10219. /// </summary>
  10220. /// <param name="dto"></param>
  10221. /// <returns></returns>
  10222. [HttpPost]
  10223. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  10224. {
  10225. if (dto.Diid <= 0 || dto.Userid <= 0)
  10226. {
  10227. return Ok(JsonView(false));
  10228. }
  10229. JsonView jw = null;
  10230. bool isTrue = false;
  10231. #region 复制团组成本
  10232. //if (dto.Diid == 2581)
  10233. //{
  10234. // dto.Diid = 2599;
  10235. // dto.CheckBoxs.ForEach(x =>
  10236. // {
  10237. // x.Diid = 2599;
  10238. // });
  10239. // dto.GroupCosts.ForEach(x =>
  10240. // {
  10241. // x.Diid = 2599;
  10242. // });
  10243. // dto.CostTypeHotelNumbers.ForEach(x =>
  10244. // {
  10245. // x.Diid = 2599;
  10246. // });
  10247. // dto.GroupCostParameters.ForEach(x =>
  10248. // {
  10249. // x.DiId = 2599;
  10250. // });
  10251. //}
  10252. #endregion
  10253. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  10254. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  10255. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  10256. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  10257. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  10258. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  10259. try
  10260. {
  10261. _sqlSugar.BeginTran();
  10262. isTrue = await _GroupCostRepository.
  10263. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  10264. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  10265. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  10266. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  10267. _sqlSugar.CommitTran();
  10268. jw = JsonView(true, "保存成功!", isTrue);
  10269. }
  10270. catch (Exception)
  10271. {
  10272. _sqlSugar.RollbackTran();
  10273. jw = JsonView(false);
  10274. }
  10275. return Ok(jw);
  10276. }
  10277. /// <summary>
  10278. /// 司兼导数据
  10279. /// </summary>
  10280. /// <param name="dto"></param>
  10281. /// <returns></returns>
  10282. [HttpPost]
  10283. public IActionResult GetCarGuides(CarGuidesDto dto)
  10284. {
  10285. JsonView jw = null;
  10286. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  10287. jw = JsonView(true, "获取成功!", Data);
  10288. return Ok(jw);
  10289. }
  10290. /// <summary>
  10291. /// 导游数据
  10292. /// </summary>
  10293. /// <param name="dto"></param>
  10294. /// <returns></returns>
  10295. [HttpPost]
  10296. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  10297. {
  10298. JsonView jw = null;
  10299. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  10300. // 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
  10301. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  10302. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  10303. jw = JsonView(true, "获取成功!", Data);
  10304. return Ok(jw);
  10305. }
  10306. /// <summary>
  10307. /// 成本车数据
  10308. /// </summary>
  10309. /// <param name="dto"></param>
  10310. /// <returns></returns>
  10311. [HttpPost]
  10312. public IActionResult GetCarInfo(CarGuidesDto dto)
  10313. {
  10314. JsonView jw = null;
  10315. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  10316. jw = JsonView(true, "获取成功!", Data);
  10317. return Ok(jw);
  10318. }
  10319. /// <summary>
  10320. /// 景点数据
  10321. /// </summary>
  10322. /// <param name="dto"></param>
  10323. /// <returns></returns>
  10324. [HttpPost]
  10325. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  10326. {
  10327. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  10328. return Ok(JsonView(true, "获取成功!", Data));
  10329. }
  10330. /// <summary>
  10331. /// 成本通知
  10332. /// </summary>
  10333. /// <param name="dto"></param>
  10334. /// <returns></returns>
  10335. [HttpPost]
  10336. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  10337. {
  10338. if (dto.Diid < 0)
  10339. {
  10340. return Ok(JsonView(false));
  10341. }
  10342. JsonView jw = null;
  10343. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  10344. if (GroupCostParameter != null)
  10345. {
  10346. int IsShare = 0;
  10347. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  10348. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  10349. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  10350. string msg = string.Empty;
  10351. if (isTrue)
  10352. {
  10353. if (IsShare == 0)
  10354. {
  10355. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  10356. }
  10357. else
  10358. {
  10359. #region 企微通知对应岗位用户
  10360. try
  10361. {
  10362. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  10363. }
  10364. catch (Exception ex)
  10365. {
  10366. }
  10367. #endregion
  10368. msg = "通知成功,其他模块操作人员可见此成本信息!";
  10369. }
  10370. jw = JsonView(isTrue, msg, new { IsShare });
  10371. }
  10372. else
  10373. {
  10374. msg = "修改失败!";
  10375. jw = JsonView(isTrue, msg);
  10376. }
  10377. }
  10378. else
  10379. {
  10380. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  10381. }
  10382. return Ok(jw);
  10383. }
  10384. /// <summary>
  10385. /// 导出报价单
  10386. /// </summary>
  10387. /// <param name="dto"></param>
  10388. /// <returns></returns>
  10389. [HttpPost]
  10390. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  10391. {
  10392. if (dto.Diid == 0)
  10393. {
  10394. return Ok(JsonView(false, "请传递团组id"));
  10395. }
  10396. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10397. if (deleInfo.Code != 0)
  10398. {
  10399. return Ok(JsonView(false, "团组信息查询失败!"));
  10400. }
  10401. var di = deleInfo.Data as DelegationInfoWebView;
  10402. if (di != null)
  10403. {
  10404. di.TeamName = di.TeamName.Replace("|", "、");
  10405. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  10406. //文件名
  10407. string strFileName = di.TeamName + "-收款账单.doc";
  10408. //获取模板
  10409. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  10410. //载入模板
  10411. Document doc = new Document(tmppath);
  10412. decimal TotalPrice = 0.00M;
  10413. string itemStr = string.Empty;
  10414. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  10415. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10416. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10417. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  10418. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  10419. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  10420. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  10421. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  10422. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  10423. foreach (var cost in groupCostType)
  10424. {
  10425. var List = cost.ToList();
  10426. if (cost.Key == "A")
  10427. {
  10428. foreach (var ListItem in List)
  10429. {
  10430. if (ListItem.number > 0)
  10431. {
  10432. if (ListItem.code.Contains("TBR"))
  10433. {
  10434. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10435. }
  10436. else
  10437. {
  10438. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10439. }
  10440. TotalPrice += (ListItem.number * ListItem.price);
  10441. }
  10442. }
  10443. }
  10444. else
  10445. {
  10446. itemStr = itemStr.Insert(0, "A段\r\n");
  10447. itemStr += "B段\r\n";
  10448. foreach (var ListItem in List)
  10449. {
  10450. if (ListItem.number > 0)
  10451. {
  10452. if (ListItem.code.Contains("TBR"))
  10453. {
  10454. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10455. }
  10456. else
  10457. {
  10458. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10459. }
  10460. TotalPrice += (ListItem.number * ListItem.price);
  10461. }
  10462. }
  10463. }
  10464. }
  10465. #region 替换Word模板书签内容
  10466. Dictionary<string, string> marks = new Dictionary<string, string>();
  10467. marks.Add("To", di.ClientUnit);//付款方
  10468. marks.Add("ToTel", di.TellPhone);//付款方电话
  10469. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  10470. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  10471. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  10472. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  10473. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  10474. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  10475. marks.Add("PayItemContent", itemStr);//详细信息
  10476. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  10477. #endregion
  10478. ////注
  10479. //if (doc.Range.Bookmarks["Attention"] != null)
  10480. //{
  10481. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  10482. // mark.Text = frList[0].Attention;
  10483. //}
  10484. foreach (var item in marks.Keys)
  10485. {
  10486. if (doc.Range.Bookmarks[item] != null)
  10487. {
  10488. Bookmark mark = doc.Range.Bookmarks[item];
  10489. mark.Text = marks[item];
  10490. }
  10491. }
  10492. byte[] bytes = null;
  10493. using (MemoryStream stream = new MemoryStream())
  10494. {
  10495. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10496. bytes = stream.ToArray();
  10497. }
  10498. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  10499. return Ok(JsonView(true, "", new
  10500. {
  10501. Data = bytes,
  10502. strFileName,
  10503. }));
  10504. }
  10505. else
  10506. {
  10507. return Ok(JsonView(false, "团组信息不存在!"));
  10508. }
  10509. }
  10510. /// <summary>
  10511. /// 导出团组成本
  10512. /// </summary>
  10513. /// <param name="dto"></param>
  10514. /// <returns></returns>
  10515. [HttpPost]
  10516. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  10517. {
  10518. var jw = JsonView(false);
  10519. if (dto.Diid == 0)
  10520. {
  10521. return Ok(JsonView(false, "请传递团组id"));
  10522. }
  10523. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10524. if (deleInfo.Code != 0)
  10525. {
  10526. return Ok(JsonView(false, "团组信息查询失败!"));
  10527. }
  10528. var di = deleInfo.Data as DelegationInfoWebView;
  10529. if (di == null)
  10530. {
  10531. return Ok(JsonView(false, "团组信息查询失败!"));
  10532. }
  10533. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  10534. WorkbookDesigner designer = new WorkbookDesigner();
  10535. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  10536. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  10537. for (int i = 0; i < List_GC.Count; i++)
  10538. {
  10539. GroupCost_Excel gc = new GroupCost_Excel();
  10540. gc.Id = List_GC[i].Id;
  10541. gc.Diid = List_GC[i].Diid.ToString();
  10542. gc.DAY = List_GC[i].DAY;
  10543. string week = "";
  10544. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  10545. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  10546. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  10547. gc.ITIN = List_GC[i].ITIN;
  10548. gc.CarType = List_GC[i].CarType;
  10549. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  10550. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  10551. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  10552. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  10553. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  10554. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  10555. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  10556. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  10557. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  10558. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  10559. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  10560. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  10561. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10562. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10563. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  10564. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  10565. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  10566. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  10567. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  10568. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  10569. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  10570. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  10571. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  10572. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  10573. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  10574. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  10575. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  10576. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  10577. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  10578. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  10579. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  10580. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  10581. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  10582. List_GC1.Add(gc);
  10583. }
  10584. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  10585. dt.TableName = "TB";
  10586. //报表标题等不用dt的值
  10587. designer.SetDataSource("TeamName", dto.title.TeamName);
  10588. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  10589. designer.SetDataSource("Tax", dto.title.Tax);
  10590. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  10591. designer.SetDataSource("Currency", dto.title.Currency);
  10592. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  10593. designer.SetDataSource("Rate", dto.title.Rate);
  10594. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  10595. var Aparams = hotels.Find(x => x.Type == "Default");
  10596. if (Aparams == null)
  10597. {
  10598. return Ok(jw);
  10599. }
  10600. //酒店数量
  10601. var txtSGRNumber = Aparams.SGR.ToString();
  10602. var txtTBRNumber = Aparams.TBR.ToString();
  10603. var txtJSESNumber = Aparams.JSES.ToString();
  10604. var txtSUITENumbe = Aparams.SUITE.ToString();
  10605. if (dto.costType == "B")
  10606. {
  10607. Aparams = hotels.Find(x => x.Type == "A");
  10608. var Bparams = hotels.Find(x => x.Type == "B");
  10609. if (Aparams == null || Bparams == null)
  10610. {
  10611. return Ok(jw);
  10612. }
  10613. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  10614. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  10615. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  10616. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  10617. }
  10618. designer.SetDataSource("SGRNumber", txtSGRNumber);
  10619. designer.SetDataSource("TBRNumber", txtTBRNumber);
  10620. designer.SetDataSource("JSESNumber", txtJSESNumber);
  10621. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  10622. var ws = designer.Workbook.Worksheets[0];
  10623. int Row = List_GC.Count;
  10624. int startIndex = 11;
  10625. int HideRows = 0;
  10626. List<int> hideRowsList = new List<int>();
  10627. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  10628. #region A段left数据
  10629. var left = dto.leftInfo.Find(x => x.Type == "A");
  10630. if (left == null)
  10631. {
  10632. return Ok(jw);
  10633. }
  10634. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  10635. if (leftBindData != null)
  10636. {
  10637. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  10638. designer.SetDataSource("VisaRS", leftBindData.rs);
  10639. designer.SetDataSource("VisaXS", leftBindData.xs);
  10640. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10641. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10642. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10643. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10644. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10645. }
  10646. else
  10647. {
  10648. hideRowsList.Add(Row + startIndex + HideRows);
  10649. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10650. }
  10651. HideRows += 2;
  10652. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  10653. if (leftBindData != null)
  10654. {
  10655. designer.SetDataSource("BXDRCB", leftBindData.cb);
  10656. designer.SetDataSource("BXRS", leftBindData.rs);
  10657. designer.SetDataSource("BXXS", leftBindData.xs);
  10658. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10659. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10660. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10661. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10662. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10663. }
  10664. else
  10665. {
  10666. hideRowsList.Add(Row + startIndex + HideRows);
  10667. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10668. }
  10669. HideRows += 2;
  10670. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  10671. if (leftBindData != null)
  10672. {
  10673. designer.SetDataSource("HSDRCB", leftBindData.cb);
  10674. designer.SetDataSource("HSRS", leftBindData.rs);
  10675. designer.SetDataSource("HSXS", leftBindData.xs);
  10676. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10677. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10678. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10679. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10680. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10681. }
  10682. else
  10683. {
  10684. hideRowsList.Add(Row + startIndex + HideRows);
  10685. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10686. }
  10687. HideRows += 2;
  10688. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  10689. if (leftBindData != null)
  10690. {
  10691. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  10692. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  10693. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  10694. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10695. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10696. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10697. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10698. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10699. }
  10700. else
  10701. {
  10702. hideRowsList.Add(Row + startIndex + HideRows);
  10703. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10704. }
  10705. HideRows += 2;
  10706. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  10707. if (leftBindData != null)
  10708. {
  10709. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  10710. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  10711. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  10712. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10713. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10714. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10715. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10716. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10717. }
  10718. else
  10719. {
  10720. hideRowsList.Add(Row + startIndex + HideRows);
  10721. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10722. }
  10723. HideRows += 2;
  10724. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  10725. if (leftBindData != null)
  10726. {
  10727. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  10728. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  10729. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  10730. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10731. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10732. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10733. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10734. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10735. }
  10736. else
  10737. {
  10738. hideRowsList.Add(Row + startIndex + HideRows);
  10739. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10740. }
  10741. HideRows += 2;
  10742. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  10743. if (leftBindData != null)
  10744. {
  10745. ////TBR
  10746. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  10747. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  10748. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  10749. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10750. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10751. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10752. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10753. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10754. }
  10755. else
  10756. {
  10757. hideRowsList.Add(Row + startIndex + HideRows);
  10758. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10759. }
  10760. HideRows += 2;
  10761. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  10762. if (leftBindData != null)
  10763. {
  10764. ////SGR
  10765. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  10766. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  10767. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  10768. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10769. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10770. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10771. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10772. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10773. }
  10774. else
  10775. {
  10776. hideRowsList.Add(Row + startIndex + HideRows);
  10777. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10778. }
  10779. HideRows += 2;
  10780. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  10781. if (leftBindData != null)
  10782. {
  10783. ////JS/ES
  10784. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  10785. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  10786. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  10787. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10788. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10789. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10790. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10791. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10792. }
  10793. else
  10794. {
  10795. hideRowsList.Add(Row + startIndex + HideRows);
  10796. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10797. }
  10798. HideRows += 2;
  10799. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  10800. if (leftBindData != null)
  10801. {
  10802. ////SUITE
  10803. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  10804. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  10805. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  10806. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10807. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10808. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10809. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10810. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10811. }
  10812. else
  10813. {
  10814. hideRowsList.Add(Row + startIndex + HideRows);
  10815. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10816. }
  10817. HideRows += 2;
  10818. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  10819. if (leftBindData != null)
  10820. {
  10821. designer.SetDataSource("DJDRCB", leftBindData.cb);
  10822. designer.SetDataSource("DJRS", leftBindData.rs);
  10823. designer.SetDataSource("DJXS", leftBindData.xs);
  10824. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10825. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10826. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10827. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10828. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10829. }
  10830. else
  10831. {
  10832. hideRowsList.Add(Row + startIndex + HideRows);
  10833. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10834. }
  10835. HideRows += 2;
  10836. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  10837. if (leftBindData != null)
  10838. {
  10839. designer.SetDataSource("HCPCB", leftBindData.cb);
  10840. designer.SetDataSource("HCPRS", leftBindData.rs);
  10841. designer.SetDataSource("HCPXS", leftBindData.xs);
  10842. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10843. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10844. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10845. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10846. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10847. }
  10848. else
  10849. {
  10850. hideRowsList.Add(Row + startIndex + HideRows);
  10851. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10852. }
  10853. HideRows += 2;
  10854. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  10855. if (leftBindData != null)
  10856. {
  10857. designer.SetDataSource("CPCB", leftBindData.cb);
  10858. designer.SetDataSource("CPRS", leftBindData.rs);
  10859. designer.SetDataSource("CPXS", leftBindData.xs);
  10860. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10861. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10862. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10863. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10864. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10865. }
  10866. else
  10867. {
  10868. hideRowsList.Add(Row + startIndex + HideRows);
  10869. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10870. }
  10871. HideRows += 2;
  10872. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  10873. if (leftBindData != null)
  10874. {
  10875. designer.SetDataSource("GWDRCD", leftBindData.cb);
  10876. designer.SetDataSource("GWRS", leftBindData.rs);
  10877. designer.SetDataSource("GWXS", leftBindData.xs);
  10878. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10879. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10880. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10881. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10882. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10883. }
  10884. else
  10885. {
  10886. hideRowsList.Add(Row + startIndex + HideRows);
  10887. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10888. }
  10889. HideRows += 2;
  10890. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  10891. if (leftBindData != null)
  10892. {
  10893. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  10894. designer.SetDataSource("LYJRS", leftBindData.rs);
  10895. designer.SetDataSource("LYJXS", leftBindData.xs);
  10896. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10897. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10898. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10899. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10900. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10901. }
  10902. else
  10903. {
  10904. hideRowsList.Add(Row + startIndex + HideRows);
  10905. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10906. }
  10907. #endregion
  10908. #region A段Right信息
  10909. var right = dto.rightInfo.Find(x => x.Type == "A");
  10910. if (right == null)
  10911. {
  10912. return Ok(jw);
  10913. }
  10914. HideRows += 4;
  10915. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  10916. if (rightBindData != null)
  10917. {
  10918. //经济舱 + 双人间 TBR
  10919. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  10920. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  10921. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10922. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  10923. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10924. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10925. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10926. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10927. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10928. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10929. }
  10930. else
  10931. {
  10932. hideRowsList.Add(Row + startIndex + HideRows);
  10933. }
  10934. HideRows += 2;
  10935. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  10936. if (rightBindData != null)
  10937. {
  10938. //经济舱 + 单人间 SGR
  10939. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  10940. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  10941. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10942. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  10943. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10944. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10945. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10946. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10947. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10948. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10949. }
  10950. else
  10951. {
  10952. hideRowsList.Add(Row + startIndex + HideRows);
  10953. }
  10954. HideRows += 2;
  10955. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  10956. if (rightBindData != null)
  10957. {
  10958. //公务舱 + 单人间 SGR
  10959. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  10960. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  10961. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10962. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  10963. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10964. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10965. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10966. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10967. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10968. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10969. }
  10970. else
  10971. {
  10972. hideRowsList.Add(Row + startIndex + HideRows);
  10973. }
  10974. HideRows += 2;
  10975. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  10976. if (rightBindData != null)
  10977. {
  10978. //公务舱 + 小套房 JSES
  10979. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  10980. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  10981. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10982. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  10983. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10984. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10985. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10986. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10987. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10988. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10989. }
  10990. else
  10991. {
  10992. hideRowsList.Add(Row + startIndex + HideRows);
  10993. }
  10994. HideRows += 2;
  10995. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  10996. if (rightBindData != null)
  10997. {
  10998. //公务舱 + 小套房 JSES
  10999. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  11000. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  11001. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11002. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  11003. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11004. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11005. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11006. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11007. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11008. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11009. }
  11010. else
  11011. {
  11012. hideRowsList.Add(Row + startIndex + HideRows);
  11013. }
  11014. HideRows += 2;
  11015. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11016. if (rightBindData != null)
  11017. {
  11018. //经济舱 + 大套房
  11019. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  11020. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  11021. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11022. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  11023. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11024. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11025. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11026. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11027. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11028. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11029. }
  11030. else
  11031. {
  11032. hideRowsList.Add(Row + startIndex + HideRows);
  11033. }
  11034. HideRows += 2;
  11035. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11036. if (rightBindData != null)
  11037. {
  11038. //头等舱 + 小套房 JSES
  11039. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  11040. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  11041. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11042. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  11043. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11044. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11045. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11046. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11047. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11048. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11049. }
  11050. else
  11051. {
  11052. hideRowsList.Add(Row + startIndex + HideRows);
  11053. }
  11054. HideRows += 2;
  11055. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11056. if (rightBindData != null)
  11057. {
  11058. //头等舱 + 大套房
  11059. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  11060. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  11061. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11062. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  11063. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11064. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11065. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11066. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11067. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11068. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11069. }
  11070. else
  11071. {
  11072. hideRowsList.Add(Row + startIndex + HideRows);
  11073. }
  11074. #endregion
  11075. #region B段标题清空
  11076. designer.SetDataSource("CostBDRCB", "");
  11077. designer.SetDataSource("CostBRS", "");
  11078. designer.SetDataSource("CostBXS", "");
  11079. designer.SetDataSource("CostBZCB", "");
  11080. designer.SetDataSource("CostBDRBJ", "");
  11081. designer.SetDataSource("CostBZBJ", "");
  11082. designer.SetDataSource("CostBDRLR", "");
  11083. designer.SetDataSource("CostBZLR", "");
  11084. designer.SetDataSource("CostBDRCBOM", "");
  11085. designer.SetDataSource("CostBRSOM", "");
  11086. designer.SetDataSource("CostBZCBOM", "");
  11087. designer.SetDataSource("CostBDRBJOM", "");
  11088. designer.SetDataSource("CostBZBJOM", "");
  11089. designer.SetDataSource("CostBDRLROM", "");
  11090. designer.SetDataSource("CostBZLROM", "");
  11091. #endregion
  11092. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  11093. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  11094. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  11095. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  11096. designer.SetDataSource("DJName", "地接(CNY)");
  11097. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  11098. designer.SetDataSource("CPName", "地接-船票(CNY)");
  11099. designer.SetDataSource("GWName", "公务(CNY)");
  11100. designer.SetDataSource("YQHName", "邀请函(CNY)");
  11101. designer.SetDataSource("LYJName", "零用金(CNY)");
  11102. designer.SetDataSource("HSName", "核酸检测(CNY)");
  11103. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  11104. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  11105. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  11106. designer.SetDataSource("BXName", "保险(CNY)");
  11107. designer.SetDataSource("VisaName", "签证(CNY)");
  11108. #region B段基本数据
  11109. if (dto.costType == "B")
  11110. {
  11111. left = dto.leftInfo.Find(x => x.Type == "B");
  11112. if (left == null)
  11113. {
  11114. return Ok(jw);
  11115. }
  11116. #region B段left数据
  11117. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  11118. if (leftBindData != null)
  11119. {
  11120. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  11121. designer.SetDataSource("BHSRS", leftBindData.rs);
  11122. designer.SetDataSource("BHSXS", leftBindData.xs);
  11123. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11124. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11125. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11126. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11127. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11128. }
  11129. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  11130. if (leftBindData != null)
  11131. {
  11132. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  11133. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  11134. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  11135. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11136. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11137. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11138. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11139. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11140. }
  11141. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  11142. if (leftBindData != null)
  11143. {
  11144. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  11145. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  11146. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  11147. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11148. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11149. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11150. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11151. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11152. }
  11153. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  11154. if (leftBindData != null)
  11155. {
  11156. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  11157. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  11158. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  11159. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11160. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11161. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11162. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11163. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11164. }
  11165. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  11166. if (leftBindData != null)
  11167. {
  11168. designer.SetDataSource("BHCPCB", leftBindData.cb);
  11169. designer.SetDataSource("BHCPRS", leftBindData.rs);
  11170. designer.SetDataSource("BHCPXS", leftBindData.xs);
  11171. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11172. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11173. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11174. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11175. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11176. }
  11177. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  11178. if (leftBindData != null)
  11179. {
  11180. designer.SetDataSource("BCPCB", leftBindData.cb);
  11181. designer.SetDataSource("BCPRS", leftBindData.rs);
  11182. designer.SetDataSource("BCPXS", leftBindData.xs);
  11183. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11184. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11185. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11186. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11187. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11188. }
  11189. //TBR
  11190. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  11191. if (leftBindData != null)
  11192. {
  11193. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  11194. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  11195. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  11196. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11197. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11198. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11199. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11200. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11201. }
  11202. //SGR
  11203. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  11204. if (leftBindData != null)
  11205. {
  11206. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  11207. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  11208. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  11209. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11210. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11211. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11212. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11213. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11214. }
  11215. //JS/ES
  11216. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  11217. if (leftBindData != null)
  11218. {
  11219. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  11220. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  11221. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  11222. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11223. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11224. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11225. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11226. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11227. }
  11228. //SUITE
  11229. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  11230. if (leftBindData != null)
  11231. {
  11232. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  11233. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  11234. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  11235. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11236. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11237. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11238. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11239. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11240. }
  11241. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  11242. if (leftBindData != null)
  11243. {
  11244. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  11245. designer.SetDataSource("BDJRS", leftBindData.rs);
  11246. designer.SetDataSource("BDJXS", leftBindData.xs);
  11247. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11248. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11249. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11250. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11251. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11252. }
  11253. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  11254. if (leftBindData != null)
  11255. {
  11256. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  11257. designer.SetDataSource("BGWRS", leftBindData.rs);
  11258. designer.SetDataSource("BGWXS", leftBindData.xs);
  11259. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11260. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11261. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11262. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11263. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11264. }
  11265. #region 优化方案
  11266. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  11267. //excelBind.Add("零用金", new {
  11268. //cb="",
  11269. //rs="",
  11270. //xs ="",
  11271. //zcb = "",
  11272. //});
  11273. #endregion
  11274. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  11275. if (leftBindData != null)
  11276. {
  11277. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  11278. designer.SetDataSource("BLYJRS", leftBindData.rs);
  11279. designer.SetDataSource("BLYJXS", leftBindData.xs);
  11280. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11281. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11282. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11283. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11284. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11285. }
  11286. #endregion
  11287. #region B段Right信息
  11288. right = dto.rightInfo.Find(x => x.Type == "B");
  11289. if (right == null)
  11290. {
  11291. return Ok(jw);
  11292. }
  11293. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  11294. if (rightBindData != null)
  11295. {
  11296. //经济舱 + 双人间 TBR
  11297. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  11298. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  11299. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11300. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  11301. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11302. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11303. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11304. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11305. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11306. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11307. }
  11308. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  11309. if (rightBindData != null)
  11310. {
  11311. //经济舱 + 单人间 SGR
  11312. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  11313. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  11314. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11315. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  11316. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11317. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11318. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11319. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11320. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11321. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11322. }
  11323. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  11324. if (rightBindData != null)
  11325. {
  11326. //公务舱 + 单人间 SGR
  11327. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  11328. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  11329. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11330. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  11331. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11332. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11333. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11334. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11335. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11336. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11337. }
  11338. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  11339. if (rightBindData != null)
  11340. {
  11341. //公务舱 + 小套房 JSES
  11342. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  11343. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  11344. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11345. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  11346. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11347. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11348. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11349. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11350. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11351. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11352. }
  11353. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  11354. if (rightBindData != null)
  11355. {
  11356. //公务舱 + 小套房 JSES
  11357. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  11358. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  11359. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11360. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  11361. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11362. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11363. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11364. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11365. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11366. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11367. }
  11368. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11369. if (rightBindData != null)
  11370. {
  11371. //经济舱 + 大套房
  11372. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  11373. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  11374. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11375. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  11376. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11377. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11378. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11379. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11380. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11381. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11382. }
  11383. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11384. if (rightBindData != null)
  11385. {
  11386. //头等舱 + 小套房 JSES
  11387. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  11388. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  11389. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11390. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  11391. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11392. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11393. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11394. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11395. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11396. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11397. }
  11398. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11399. if (rightBindData != null)
  11400. {
  11401. //头等舱 + 大套房
  11402. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  11403. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  11404. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11405. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  11406. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11407. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11408. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11409. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11410. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11411. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11412. }
  11413. #endregion
  11414. #region 标题
  11415. designer.SetDataSource("CostBDRCB", "单人成本");
  11416. designer.SetDataSource("CostBRS", "人数");
  11417. designer.SetDataSource("CostBXS", "系数");
  11418. designer.SetDataSource("CostBZCB", "总成本");
  11419. designer.SetDataSource("CostBDRBJ", "单人报价");
  11420. designer.SetDataSource("CostBZBJ", "总报价");
  11421. designer.SetDataSource("CostBDRLR", "单人利润");
  11422. designer.SetDataSource("CostBZLR", "总利润");
  11423. designer.SetDataSource("CostBDRCBOM", "单人成本");
  11424. designer.SetDataSource("CostBRSOM", "人数");
  11425. designer.SetDataSource("CostBZCBOM", "总成本");
  11426. designer.SetDataSource("CostBDRBJOM", "单人报价");
  11427. designer.SetDataSource("CostBZBJOM", "总报价");
  11428. designer.SetDataSource("CostBDRLROM", "单人利润");
  11429. designer.SetDataSource("CostBZLROM", "总利润");
  11430. #endregion
  11431. }
  11432. #endregion
  11433. designer.SetDataSource("TzZCB2", TzZCB2);
  11434. designer.SetDataSource("TzZBJ2", TzZBJ2);
  11435. designer.SetDataSource("TzZLR2", TzZLR2);
  11436. string[] dataSourceKeys = new string[]
  11437. {
  11438. "VF",
  11439. "TGS",
  11440. "TGOF",
  11441. "TGM",
  11442. "TGA",
  11443. "TGTF",
  11444. "TGEF",
  11445. "CFM",
  11446. "CFOF",
  11447. "B",
  11448. "L",
  11449. "D",
  11450. "TBR",
  11451. "SGR",
  11452. "JSES",
  11453. "Suite",
  11454. "TV",
  11455. "1L",
  11456. "IF",
  11457. "EF",
  11458. "BRF",
  11459. "TE",
  11460. "TGT",
  11461. "DRVT",
  11462. "PC",
  11463. "TLF",
  11464. "ECT"
  11465. };
  11466. foreach (var item in dataSourceKeys)
  11467. {
  11468. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  11469. if (find != null)
  11470. {
  11471. designer.SetDataSource(item, find.text);
  11472. }
  11473. else
  11474. {
  11475. designer.SetDataSource(item, 0);
  11476. }
  11477. }
  11478. designer.SetDataSource(dt);
  11479. //根据数据源处理生成报表内容
  11480. designer.Process();
  11481. designer.Workbook.Worksheets[0].Name = "清单";
  11482. Worksheet sheet = designer.Workbook.Worksheets[0];
  11483. foreach (var Rowindex in hideRowsList)
  11484. {
  11485. ws.Cells.HideRows(Rowindex, 2);
  11486. }
  11487. byte[] bytes = null;
  11488. string strFileName = di.TeamName + "-团组-成本.xls";
  11489. using (MemoryStream stream = new MemoryStream())
  11490. {
  11491. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  11492. bytes = stream.ToArray();
  11493. }
  11494. return Ok(JsonView(true, "", new
  11495. {
  11496. Data = bytes,
  11497. strFileName,
  11498. }));
  11499. }
  11500. /// <summary>
  11501. /// 导出客户报表
  11502. /// </summary>
  11503. /// <returns></returns>
  11504. [HttpPost]
  11505. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  11506. {
  11507. var jw = JsonView(false);
  11508. if (dto.Diid == 0)
  11509. {
  11510. return Ok(JsonView(false, "请传递团组id"));
  11511. }
  11512. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11513. if (deleInfo.Code != 0)
  11514. {
  11515. return Ok(JsonView(false, "团组信息查询失败!"));
  11516. }
  11517. var di = deleInfo.Data as DelegationInfoWebView;
  11518. if (di == null)
  11519. {
  11520. return Ok(JsonView(false, "团组信息查询失败!"));
  11521. }
  11522. //文件名
  11523. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  11524. //获取模板
  11525. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  11526. //载入模板
  11527. Document doc = new Document(tmppath);
  11528. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  11529. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  11530. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  11531. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  11532. var AParameter = ParameterList.Find(x => x.CostType == "A");
  11533. var BParameter = ParameterList.Find(x => x.CostType == "B");
  11534. if (AParameter == null)
  11535. {
  11536. return Ok(JsonView(false, "系数不存在!"));
  11537. }
  11538. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  11539. , TzAirDesc, TzZCost;
  11540. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  11541. = TzAirDesc = TzZCost = string.Empty;
  11542. TzNumber = AParameter.CostTypenumber.ToString();
  11543. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  11544. CarGuides1 = dto.CarGuides1;
  11545. Meal = dto.Meal;
  11546. SubsidizedMeals = dto.SubsidizedMeals;
  11547. NightRepair = dto.NightRepair;
  11548. AttractionsTickets = dto.AttractionsTickets;
  11549. MiscellaneousFees = dto.MiscellaneousFees;
  11550. ATip = dto.ATip;
  11551. TzHotelDesc = "";
  11552. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  11553. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  11554. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  11555. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  11556. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  11557. TzAirDesc = "";
  11558. TzZCost = dto.TzZCost;
  11559. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  11560. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  11561. var index = 1;
  11562. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  11563. foreach (var item in TzHotelDescArr)
  11564. {
  11565. if (AinfoArr != null)
  11566. {
  11567. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11568. if (Ainfo != null)
  11569. {
  11570. if (int.Parse(Ainfo.rs) <= 0)
  11571. {
  11572. continue;
  11573. }
  11574. var hotelText = string.Empty;
  11575. switch (item)
  11576. {
  11577. case "SGR":
  11578. hotelText = "单人间";
  11579. break;
  11580. case "JSES":
  11581. hotelText = "小套房";
  11582. break;
  11583. case "SUITE":
  11584. hotelText = "套房";
  11585. break;
  11586. case "TBR":
  11587. hotelText = "双人间";
  11588. break;
  11589. }
  11590. if (item != "TBR")
  11591. {
  11592. 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";
  11593. }
  11594. else
  11595. {
  11596. 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";
  11597. }
  11598. index++;
  11599. }
  11600. }
  11601. }
  11602. index = 1;
  11603. foreach (var item in TzAirDescArr)
  11604. {
  11605. if (AinfoArr != null)
  11606. {
  11607. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11608. if (Ainfo != null)
  11609. {
  11610. if (int.Parse(Ainfo.rs) <= 0)
  11611. {
  11612. continue;
  11613. }
  11614. 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";
  11615. index++;
  11616. }
  11617. }
  11618. }
  11619. if (dto.costType == "B")
  11620. {
  11621. if (BParameter == null)
  11622. {
  11623. return Ok(JsonView(false, "B段系数不存在!"));
  11624. }
  11625. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  11626. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  11627. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  11628. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  11629. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  11630. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  11631. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  11632. foreach (var item in TzHotelDescArr)
  11633. {
  11634. if (AinfoArr != null)
  11635. {
  11636. TzHotelDesc += "B段信息 \r\n";
  11637. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11638. if (Ainfo != null)
  11639. {
  11640. if (int.Parse(Ainfo.rs) <= 0)
  11641. {
  11642. continue;
  11643. }
  11644. var hotelText = string.Empty;
  11645. switch (item)
  11646. {
  11647. case "SGR":
  11648. hotelText = "单人间";
  11649. break;
  11650. case "JSES":
  11651. hotelText = "小套房";
  11652. break;
  11653. case "SUITE":
  11654. hotelText = "套房";
  11655. break;
  11656. case "TBR":
  11657. hotelText = "双人间";
  11658. break;
  11659. }
  11660. if (item != "TBR")
  11661. {
  11662. 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";
  11663. }
  11664. else
  11665. {
  11666. 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";
  11667. }
  11668. index++;
  11669. }
  11670. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  11671. }
  11672. }
  11673. index = 1;
  11674. foreach (var item in TzAirDescArr)
  11675. {
  11676. if (AinfoArr != null)
  11677. {
  11678. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11679. if (Ainfo != null)
  11680. {
  11681. if (int.Parse(Ainfo.rs) <= 0)
  11682. {
  11683. continue;
  11684. }
  11685. 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";
  11686. index++;
  11687. }
  11688. }
  11689. }
  11690. }
  11691. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  11692. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  11693. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  11694. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  11695. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  11696. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  11697. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  11698. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  11699. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  11700. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  11701. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  11702. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  11703. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  11704. DickeyValue.Add("Visa", Visa); // 签证单人报价
  11705. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  11706. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  11707. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  11708. DickeyValue.Add("TzZCost", TzZCost);
  11709. foreach (var key in DickeyValue.Keys)
  11710. {
  11711. if (doc.Range.Bookmarks[key] != null)
  11712. {
  11713. Bookmark mark = doc.Range.Bookmarks[key];
  11714. mark.Text = DickeyValue[key];
  11715. }
  11716. }
  11717. byte[] bytes = null;
  11718. string strFileName = di.TeamName + "-客户报价.doc";
  11719. using (MemoryStream stream = new MemoryStream())
  11720. {
  11721. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11722. bytes = stream.ToArray();
  11723. }
  11724. return Ok(JsonView(true, "", new
  11725. {
  11726. Data = bytes,
  11727. strFileName,
  11728. }));
  11729. }
  11730. /// <summary>
  11731. /// 团组成本 各模块(酒店,地接,机票)成本提示
  11732. /// </summary>
  11733. /// <param name="dto"></param>
  11734. /// <returns></returns>
  11735. [HttpPost]
  11736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11737. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  11738. {
  11739. try
  11740. {
  11741. #region 参数验证
  11742. if (dto.DiId < 0)
  11743. {
  11744. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  11745. }
  11746. List<int> cTableIds = new List<int>() {
  11747. 76 ,//酒店预订
  11748. 77 ,//行程
  11749. 79 ,//车/导游地接
  11750. 80 ,//签证
  11751. 81 ,//邀请/公务活
  11752. 82 ,//团组客户保险
  11753. 85 ,//机票预订
  11754. 98 ,//其他款项
  11755. 285 ,//收款退还
  11756. 751 ,//酒店早餐
  11757. 1015 // 超支费用
  11758. };
  11759. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  11760. {
  11761. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  11762. }
  11763. #endregion
  11764. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  11765. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  11766. if (_GroupCostParameters.Count <= 0)
  11767. {
  11768. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  11769. }
  11770. if (_GroupCostParameters[0].IsShare == 0)
  11771. {
  11772. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  11773. }
  11774. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  11775. //处理date为空问题
  11776. if (_GroupCosts.Count > 0)
  11777. {
  11778. for (int i = 0; i < _GroupCosts.Count; i++)
  11779. {
  11780. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  11781. {
  11782. if (i > 0)
  11783. {
  11784. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  11785. }
  11786. }
  11787. }
  11788. }
  11789. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  11790. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  11791. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  11792. string currCode = "";
  11793. #region currCode 验证
  11794. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  11795. if (isInt)
  11796. {
  11797. var currData = currDatas.Find(it => it.Id == intCurrency);
  11798. if (currData != null)
  11799. {
  11800. currCode = currData.Name;
  11801. }
  11802. }
  11803. else
  11804. {
  11805. currCode = _GroupCostParameters[0].Currency.Trim();
  11806. }
  11807. #endregion
  11808. //op,酒店单段模式存储
  11809. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  11810. {
  11811. CurrencyCode = currCode,
  11812. Rate = _GroupCostParameters[0].Rate,
  11813. CostType = _GroupCostParameters[0].CostType,
  11814. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  11815. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  11816. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  11817. };
  11818. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  11819. if (_GroupCostParameters.Count == 2)
  11820. {
  11821. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  11822. }
  11823. foreach (var item in _GroupCostParameters)
  11824. {
  11825. decimal _rate = 1;
  11826. decimal _rate1 = item.Rate;
  11827. decimal _scale = 1;
  11828. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  11829. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  11830. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  11831. //if (userInfo != null)
  11832. //{
  11833. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  11834. // {
  11835. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  11836. // {
  11837. // _scale = 1.00M;
  11838. // }
  11839. // }
  11840. //}
  11841. #endregion
  11842. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  11843. {
  11844. CurrencyCode = currCode,
  11845. Rate = _rate1,
  11846. CostType = item.CostType,
  11847. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  11848. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  11849. CostTypeNumber = item.CostTypenumber
  11850. };
  11851. if (_GroupCostParameters.Count > 1)
  11852. {
  11853. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  11854. }
  11855. else
  11856. {
  11857. modulePromptInfo.CostTypeNumber = item.LYJRS;
  11858. }
  11859. if (dto.CTable == 79)//
  11860. {
  11861. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  11862. modulePromptInfo.TotalCost = item.DJCB;
  11863. }
  11864. List<string> costTypes = new List<string>() { "A", "B" };
  11865. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  11866. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  11867. if (_GroupCostsDuplicates.Count() == 1)
  11868. {
  11869. _GroupCostsTypeData = _GroupCosts;
  11870. }
  11871. else
  11872. {
  11873. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  11874. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  11875. }
  11876. /*
  11877. * 76 酒店预订
  11878. * 77 行程
  11879. * 79 车/导游地接
  11880. * 80 签证
  11881. * 81 邀请/公务活动
  11882. * 82 团组客户保险
  11883. * 85 机票预订
  11884. * 98 其他款项
  11885. * 285 收款退还
  11886. * 751 酒店早餐
  11887. * 1015 超支费用
  11888. */
  11889. switch (dto.CTable)
  11890. {
  11891. case 76: // 酒店预订
  11892. _ModuleSubPromptInfo.AddRange(
  11893. _GroupCostsTypeData.Select(it => new
  11894. {
  11895. it.DAY,
  11896. it.Date,
  11897. it.ACCON,
  11898. it.ITIN,
  11899. it.SGR,
  11900. it.TBR,
  11901. it.JS_ES,
  11902. it.Suite
  11903. })
  11904. );
  11905. break;
  11906. case 79: // 车/导游地接
  11907. _ModuleSubPromptInfo.AddRange(
  11908. _GroupCostsTypeData.Select(it => new
  11909. {
  11910. Date = it.Date, //日期
  11911. CarFee = it.CarCost * _rate * _scale, //车费用
  11912. CarType = it.CarType, //车型
  11913. DriverFee = it.CFS * _rate * _scale, //司机工资
  11914. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  11915. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  11916. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  11917. GuideFee = it.TGS * _rate * _scale, //导游费用
  11918. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  11919. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  11920. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  11921. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  11922. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  11923. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  11924. Breakfast = it.B * _rate * _scale, //早餐费
  11925. Lunch = it.L * _rate * _scale, //午餐费
  11926. Dinner = it.D * _rate * _scale, //晚餐费
  11927. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  11928. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  11929. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  11930. TicketFee = it.EF * _rate * _scale, //门票费
  11931. TicketRemark = it.EFR, //门票费描述
  11932. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  11933. TravelSupplies = it.TE * _rate * _scale, //出行物资
  11934. SpentCash = it.PC * _rate * _scale, //零用金
  11935. LeadersFee = it.TLF * _rate * _scale, //领队费
  11936. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  11937. })
  11938. );
  11939. break;
  11940. case 85: // 机票
  11941. List<dynamic> datas = new List<dynamic>();
  11942. datas.Add(
  11943. new
  11944. {
  11945. AirType = "经济舱",
  11946. AirNum = item.JJCRS,
  11947. AirDRCB = item.JJCCB,
  11948. AirZCB = (item.JJCRS * item.JJCCB)
  11949. }
  11950. );
  11951. datas.Add(
  11952. new
  11953. {
  11954. AirType = "公务舱",
  11955. AirNum = item.GWCRS,
  11956. AirDRCB = item.GWCCB,
  11957. AirZCB = (item.GWCRS * item.GWCCB)
  11958. }
  11959. );
  11960. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  11961. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  11962. modulePromptInfo.Data = new
  11963. {
  11964. airFeeData = datas,
  11965. airInitData = initDatas
  11966. };
  11967. _ModulePromptInfos.Add(modulePromptInfo);
  11968. break;
  11969. default:
  11970. break;
  11971. }
  11972. }
  11973. if (dto.CTable != 85)
  11974. {
  11975. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  11976. _ModulePromptInfos.Add(_ModulePromptInfo);
  11977. }
  11978. _view.ModulePromptInfos = _ModulePromptInfos;
  11979. return Ok(JsonView(true, "操作成功!", _view));
  11980. }
  11981. catch (Exception ex)
  11982. {
  11983. return Ok(JsonView(false, ex.Message));
  11984. }
  11985. }
  11986. /// <summary>
  11987. /// 根据黑屏代码重新生成行程
  11988. /// </summary>
  11989. /// <param name="dto"></param>
  11990. /// <returns></returns>
  11991. [HttpPost]
  11992. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  11993. {
  11994. var jw = JsonView(false);
  11995. var Create = _GroupCostRepository.
  11996. CreateGroupCostByBlackCode(dto.Diid);
  11997. jw.Msg = Create.Msg;
  11998. if (Create.Code == 0)
  11999. {
  12000. jw.Code = 200;
  12001. jw.Data = new
  12002. {
  12003. groupCost = Create.Data,
  12004. blackCodeIsTrue = true
  12005. };
  12006. }
  12007. else
  12008. {
  12009. jw.Code = 400;
  12010. jw.Data = new
  12011. {
  12012. groupCost = Create.Data,
  12013. blackCodeIsTrue = false,
  12014. };
  12015. }
  12016. return Ok(jw);
  12017. }
  12018. /// <summary>
  12019. /// 成本获取OP历史车费用
  12020. /// </summary>
  12021. /// <param name="dto"></param>
  12022. /// <returns></returns>
  12023. [HttpPost]
  12024. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  12025. {
  12026. var jw = JsonView(false);
  12027. try
  12028. {
  12029. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  12030. //获取现有所有车的数据
  12031. if (!dto.Param.IsNullOrWhiteSpace())
  12032. {
  12033. string sql = $@"
  12034. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  12035. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  12036. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  12037. 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
  12038. AND gctggr.ServiceEndTime is not NULL
  12039. ORDER by gctggrc.id DESC
  12040. ";
  12041. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  12042. var numeberResult = await Task.Run(() =>
  12043. {
  12044. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  12045. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  12046. return numberArr;
  12047. });
  12048. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  12049. foreach (var item in numeberResult)
  12050. {
  12051. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  12052. {
  12053. Country = "数据异常!",
  12054. City = string.Empty,
  12055. };
  12056. item.Area = find.Country + " " + find.City;
  12057. }
  12058. dbResult.AddRange(numeberResult);
  12059. if (dto.Param.Contains("、"))
  12060. {
  12061. var sp = dto.Param.Split("、");
  12062. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12063. .Where(x =>
  12064. {
  12065. return System.Array.Exists(sp, e =>
  12066. {
  12067. bool where = false;
  12068. if (x.Area != null)
  12069. {
  12070. where = x.Area.Contains(e);
  12071. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12072. {
  12073. return false;
  12074. }
  12075. }
  12076. if (x.PriceName != null && !where)
  12077. {
  12078. where = x.PriceName.Contains(e);
  12079. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12080. {
  12081. return false;
  12082. }
  12083. }
  12084. return where;
  12085. });
  12086. }).ToList();
  12087. }
  12088. else
  12089. {
  12090. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12091. .Where(x =>
  12092. {
  12093. bool where = false;
  12094. if (x.Area != null)
  12095. {
  12096. where = x.Area.Contains(dto.Param);
  12097. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12098. {
  12099. return false;
  12100. }
  12101. }
  12102. if (x.PriceName != null && !where)
  12103. {
  12104. where = x.PriceName.Contains(dto.Param);
  12105. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12106. {
  12107. return false;
  12108. }
  12109. }
  12110. return where;
  12111. }
  12112. )
  12113. .ToList();
  12114. }
  12115. }
  12116. var view = dbResult.Select(x =>
  12117. {
  12118. decimal dp = 0.00M;
  12119. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  12120. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  12121. if (string.IsNullOrWhiteSpace(x.DatePrice))
  12122. {
  12123. if (startB && endB)
  12124. {
  12125. var timesp = endD.Subtract(startD);
  12126. if ((timesp.Days + 1) != 0)
  12127. {
  12128. dp = x.Price / (timesp.Days + 1);
  12129. }
  12130. }
  12131. }
  12132. else
  12133. {
  12134. dp = x.Price;
  12135. }
  12136. return new
  12137. {
  12138. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  12139. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  12140. x.Area,
  12141. x.id,
  12142. price = x.Price.ToString("F2"),
  12143. x.PriceName,
  12144. x.PriceContent,
  12145. x.TeamName,
  12146. x.DatePrice,
  12147. dayPrice = dp.ToString("F2"),
  12148. };
  12149. }).OrderByDescending(x => x.id).ToList();
  12150. jw = JsonView(true, "获取成功!", view);
  12151. }
  12152. catch (Exception e)
  12153. {
  12154. jw = JsonView(false, e.Message);
  12155. }
  12156. return Ok(jw);
  12157. }
  12158. #endregion
  12159. #region 酒店预订 新 雷怡 2023-12-28 17:45
  12160. /// <summary>
  12161. /// 酒店预订
  12162. /// 酒店费用列表 根据团组Id查询
  12163. /// </summary>
  12164. /// <param name="_dto"></param>
  12165. /// <returns></returns>
  12166. [HttpPost]
  12167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12168. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  12169. {
  12170. #region 参数验证
  12171. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12172. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12173. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12174. #region 团组操作权限验证 76 酒店预定模块
  12175. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12176. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12177. #endregion
  12178. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12179. #region 页面操作权限验证
  12180. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12181. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12182. #endregion
  12183. #endregion
  12184. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  12185. }
  12186. /// <summary>
  12187. /// 酒店预订
  12188. /// 基础数据
  12189. /// </summary>
  12190. /// <param name="_dto"></param>
  12191. /// <returns></returns>
  12192. [HttpPost]
  12193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12194. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  12195. {
  12196. #region 参数验证
  12197. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12198. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12199. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12201. #region 页面操作权限验证
  12202. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12203. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12204. #endregion
  12205. #region 团组操作权限验证 76 酒店预定模块
  12206. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12207. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12208. #endregion
  12209. #endregion
  12210. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  12211. }
  12212. /// <summary>
  12213. /// 酒店预订
  12214. /// 创建 入住卷号码
  12215. /// </summary>
  12216. /// <param name="_dto"></param>
  12217. /// <returns></returns>
  12218. [HttpPost]
  12219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12220. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  12221. {
  12222. #region 参数验证
  12223. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12224. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12225. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12226. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12227. #region 页面操作权限验证
  12228. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12229. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12230. #endregion
  12231. #region 团组操作权限验证 76 酒店预定模块
  12232. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12233. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12234. #endregion
  12235. #endregion
  12236. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  12237. if (data.Code != 0)
  12238. {
  12239. return Ok(JsonView(false, data.Msg));
  12240. }
  12241. return Ok(JsonView(true, data.Msg, data.Data));
  12242. }
  12243. /// <summary>
  12244. /// 酒店预订
  12245. /// 详情
  12246. /// </summary>
  12247. /// <param name="_dto"></param>
  12248. /// <returns></returns>
  12249. [HttpPost]
  12250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12251. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  12252. {
  12253. #region 参数验证
  12254. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  12255. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12256. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  12257. #region 团组操作权限验证 76 酒店预定模块
  12258. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12259. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12260. #endregion
  12261. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12262. #region 页面操作权限验证
  12263. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12264. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12265. #endregion
  12266. #endregion
  12267. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  12268. }
  12269. /// <summary>
  12270. /// 酒店预订
  12271. /// Add Or Edit
  12272. /// </summary>
  12273. /// <param name="_dto"></param>
  12274. /// <returns></returns>
  12275. [HttpPost]
  12276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12277. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  12278. {
  12279. #region 参数验证
  12280. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12281. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12282. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12283. #region 团组操作权限验证 76 酒店预定模块
  12284. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12285. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12286. #endregion
  12287. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12288. #region 页面操作权限验证
  12289. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12290. if (_dto.Id == 0) // Add
  12291. {
  12292. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12293. }
  12294. else if (_dto.Id > 1) // Edit
  12295. {
  12296. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  12297. }
  12298. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  12299. #endregion
  12300. #endregion
  12301. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  12302. if (_view.Code != 200)
  12303. {
  12304. return Ok(_view);
  12305. }
  12306. #region 成本无酒店价格数据进入超支
  12307. _sqlSugar.BeginTran();
  12308. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  12309. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  12310. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  12311. for (int i = 0; i < groupCost.Count; i++)
  12312. {
  12313. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  12314. {
  12315. groupCost[i].Date = groupCost[i - 1].Date;
  12316. }
  12317. }
  12318. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  12319. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  12320. List<Fin_GroupExtraCostDto_OP>();
  12321. if (start_Bool && end_Bool)
  12322. {
  12323. while (start_Time < end_Time)
  12324. {
  12325. foreach (var item in groupCost_Grp)
  12326. {
  12327. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  12328. {
  12329. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  12330. {
  12331. extraCostList.Add(new
  12332. Fin_GroupExtraCostDto_OP
  12333. {
  12334. Area = _dto.AreaId,
  12335. coefficient = 1.5M,
  12336. createUser = _dto.UserId,
  12337. currency = _dto.CardPriceCurrency,
  12338. diId = _dto.DiId,
  12339. ManagerConfirm = 0,
  12340. SupervisorConfirm = 0,
  12341. SYsupervisorConfirm = 0,
  12342. editType = 1,
  12343. PortType = 1,
  12344. price = _dto.CardPrice,
  12345. PriceCount = 1,
  12346. priceType = 1027,
  12347. priceDetailType = 1044,
  12348. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  12349. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  12350. });
  12351. }
  12352. }
  12353. }
  12354. start_Time = start_Time.AddDays(1);
  12355. }
  12356. }
  12357. if (extraCostList.Any())
  12358. {
  12359. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  12360. }
  12361. _sqlSugar.CommitTran();
  12362. #endregion
  12363. #region 应用推送
  12364. try
  12365. {
  12366. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12367. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12368. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12369. var diId = _dto.DiId;
  12370. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12371. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12372. #region 操作记录
  12373. var opInfo = new Crm_TableOperationRecord() {
  12374. TableName = "Grp_HotelReservations",
  12375. PortType = _dto.PortType,
  12376. DataId = hotelId,
  12377. CreateUserId = _dto.UserId
  12378. };
  12379. var opStatus = OperationEnum.NoOperation;
  12380. if (_dto.Id<1) //添加操作
  12381. {
  12382. opInfo.OperationItem = OperationEnum.Add;
  12383. }
  12384. else if (_dto.Id > 0)
  12385. {
  12386. opInfo.OperationItem = OperationEnum.Edit;
  12387. }
  12388. string opRemark = string.Empty;
  12389. if (ccpInfo != null)
  12390. {
  12391. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  12392. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  12393. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  12394. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  12395. }
  12396. opInfo.Remark = opRemark;
  12397. await _tableorRep.AddAsync(opInfo);
  12398. #endregion
  12399. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  12400. //2024-10-21 新增LZ UID
  12401. var userIds = new List<int>() { 21 };
  12402. string title = $"费用审核";
  12403. string content = "";
  12404. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12405. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12406. try
  12407. {
  12408. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12409. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  12410. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  12411. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  12412. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  12413. }
  12414. catch (Exception ex )
  12415. {
  12416. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  12417. }
  12418. }
  12419. catch (Exception ex)
  12420. {
  12421. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  12422. }
  12423. try
  12424. {
  12425. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12426. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12427. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12428. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12429. //自动审核
  12430. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  12431. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  12432. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  12433. //2024-10-21 新增LZ UID
  12434. var userIds = new List<int>() { 21 };
  12435. string title = $"系统通知";
  12436. var diId = _dto.DiId;
  12437. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12438. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12439. string content = "";
  12440. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12441. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12442. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12443. }
  12444. catch (Exception ex)
  12445. {
  12446. }
  12447. #endregion
  12448. return Ok(_view);
  12449. }
  12450. /// <summary>
  12451. /// 酒店自动审核测试
  12452. /// Add Or Edit
  12453. /// </summary>
  12454. /// <param name="_dto"></param>
  12455. /// <returns></returns>
  12456. [HttpPost]
  12457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12458. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  12459. {
  12460. #region 应用推送
  12461. try
  12462. {
  12463. //自动审核
  12464. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  12465. }
  12466. catch (Exception ex)
  12467. {
  12468. return Ok(JsonView(false, "操作失败"));
  12469. }
  12470. #endregion
  12471. return Ok(JsonView(false, "操作成功"));
  12472. }
  12473. /// <summary>
  12474. /// 酒店预订
  12475. /// Del
  12476. /// </summary>
  12477. /// <param name="_dto"></param>
  12478. /// <returns></returns>
  12479. [HttpPost]
  12480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12481. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  12482. {
  12483. #region 参数验证
  12484. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12485. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12486. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12487. #region 团组操作权限验证 76 酒店预定模块
  12488. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12489. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12490. #endregion
  12491. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12492. #region 页面操作权限验证
  12493. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12494. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12495. #endregion
  12496. #endregion
  12497. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  12498. #region 操作记录
  12499. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  12500. {
  12501. TableName = "Grp_HotelReservations",
  12502. PortType = _dto.PortType,
  12503. OperationItem = OperationEnum.Del,
  12504. DataId = _dto.Id,
  12505. CreateUserId = _dto.UserId
  12506. });
  12507. #endregion
  12508. return Ok(data);
  12509. }
  12510. /// <summary>
  12511. /// 酒店预订
  12512. /// 生成VOUCHER
  12513. /// 2024.05.06 之前版本
  12514. /// </summary>
  12515. /// <param name="_dto"></param>
  12516. /// <returns></returns>
  12517. [HttpPost]
  12518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12519. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  12520. {
  12521. try
  12522. {
  12523. #region 参数验证
  12524. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12525. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12526. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12527. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  12528. #region 团组操作权限验证 76 酒店预定模块
  12529. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12530. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12531. #endregion
  12532. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12533. #region 页面操作权限验证
  12534. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12535. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12536. #endregion
  12537. #endregion
  12538. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  12539. //判断数据是否完整
  12540. if (hr != null)
  12541. {
  12542. if (!string.IsNullOrEmpty(hr.DetermineNo))
  12543. {
  12544. string strFileName = "HotelStatement/";
  12545. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  12546. if (dele != null)
  12547. strFileName += dele.TourCode;
  12548. //载入模板
  12549. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  12550. Document doc = new Document(sss);
  12551. DocumentBuilder builder = new DocumentBuilder(doc);
  12552. #region 替换Word模板书签内容
  12553. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  12554. //入住卷预定号码
  12555. if (doc.Range.Bookmarks["VNO"] != null)
  12556. {
  12557. Bookmark mark = doc.Range.Bookmarks["VNO"];
  12558. mark.Text = hr.CheckNumber;
  12559. }
  12560. //酒店时间
  12561. if (doc.Range.Bookmarks["Date"] != null)
  12562. {
  12563. Bookmark mark = doc.Range.Bookmarks["Date"];
  12564. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12565. }
  12566. //团号
  12567. if (doc.Range.Bookmarks["TNo"] != null)
  12568. {
  12569. Bookmark mark = doc.Range.Bookmarks["TNo"];
  12570. mark.Text = dele.TourCode;
  12571. }
  12572. //预定号码
  12573. if (doc.Range.Bookmarks["BookingId"] != null)
  12574. {
  12575. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  12576. mark.Text = hr.ReservationsNo;
  12577. }
  12578. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  12579. {
  12580. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  12581. mark.Text = hr.DetermineNo;
  12582. }
  12583. //酒店城市
  12584. if (doc.Range.Bookmarks["City"] != null)
  12585. {
  12586. Bookmark mark = doc.Range.Bookmarks["City"];
  12587. mark.Text = hr.City;
  12588. }
  12589. //酒店名称
  12590. if (doc.Range.Bookmarks["HName"] != null)
  12591. {
  12592. Bookmark mark = doc.Range.Bookmarks["HName"];
  12593. mark.Text = hr.HotelName;
  12594. }
  12595. //酒店地址
  12596. if (doc.Range.Bookmarks["Address"] != null)
  12597. {
  12598. Bookmark mark = doc.Range.Bookmarks["Address"];
  12599. mark.Text = hr.HotelAddress;
  12600. }
  12601. //酒店电话
  12602. if (doc.Range.Bookmarks["Tel"] != null)
  12603. {
  12604. Bookmark mark = doc.Range.Bookmarks["Tel"];
  12605. mark.Text = hr.HotelTel;
  12606. }
  12607. //酒店传真
  12608. if (doc.Range.Bookmarks["Fax"] != null)
  12609. {
  12610. Bookmark mark = doc.Range.Bookmarks["Fax"];
  12611. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  12612. {
  12613. mark.Text = hr.HotelFax;
  12614. }
  12615. }
  12616. //入住时间
  12617. if (doc.Range.Bookmarks["CIn"] != null)
  12618. {
  12619. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12620. Bookmark mark = doc.Range.Bookmarks["CIn"];
  12621. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  12622. }
  12623. //退房时间
  12624. if (doc.Range.Bookmarks["COut"] != null)
  12625. {
  12626. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12627. Bookmark mark = doc.Range.Bookmarks["COut"];
  12628. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12629. }
  12630. //客户名称
  12631. if (doc.Range.Bookmarks["GName"] != null)
  12632. {
  12633. string guestName = "";
  12634. string[] clients = new string[] { };
  12635. if (hr.GuestName.Contains(","))
  12636. {
  12637. clients = hr.GuestName.Split(",");
  12638. }
  12639. else
  12640. {
  12641. clients = new string[] { hr.GuestName };
  12642. }
  12643. List<int> clientIds_int = new List<int>();
  12644. if (clients.Length > 0)
  12645. {
  12646. foreach (var item in clients)
  12647. {
  12648. if (item.IsNumeric())
  12649. {
  12650. clientIds_int.Add(int.Parse(item));
  12651. }
  12652. }
  12653. }
  12654. if (clientIds_int.Count > 0)
  12655. {
  12656. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  12657. foreach (var client in _clientDatas)
  12658. {
  12659. //男
  12660. if (client.Sex == 0) guestName += $"Mr.";
  12661. //女
  12662. else if (client.Sex == 1) guestName += $"Ms.";
  12663. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  12664. {
  12665. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  12666. }
  12667. //guestName += $"{client.Pinyin},";
  12668. }
  12669. if (guestName.Length > 0)
  12670. {
  12671. guestName = guestName.Substring(0, guestName.Length - 1);
  12672. }
  12673. }
  12674. else
  12675. {
  12676. guestName = hr.GuestName;
  12677. }
  12678. Bookmark mark = doc.Range.Bookmarks["GName"];
  12679. mark.Text = guestName;
  12680. }
  12681. //房间介绍
  12682. if (doc.Range.Bookmarks["ROOM"] != null)
  12683. {
  12684. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  12685. mark.Text = hr.RoomExplanation;
  12686. }
  12687. //报价描述
  12688. if (doc.Range.Bookmarks["NOTE"] != null)
  12689. {
  12690. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  12691. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  12692. if (ss != null)
  12693. mark.Text = ss.Name;
  12694. }
  12695. //入住时间
  12696. if (doc.Range.Bookmarks["CheckIn"] != null)
  12697. {
  12698. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12699. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  12700. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  12701. }
  12702. //退房时间
  12703. if (doc.Range.Bookmarks["CheckOut"] != null)
  12704. {
  12705. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12706. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  12707. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12708. }
  12709. //日期
  12710. if (doc.Range.Bookmarks["DT"] != null)
  12711. {
  12712. Bookmark mark = doc.Range.Bookmarks["DT"];
  12713. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12714. }
  12715. //名称
  12716. if (doc.Range.Bookmarks["VName"] != null)
  12717. {
  12718. Bookmark mark = doc.Range.Bookmarks["VName"];
  12719. mark.Text = hr.HotelName;
  12720. }
  12721. //号码
  12722. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  12723. {
  12724. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  12725. mark.Text = hr.CheckNumber;
  12726. }
  12727. #endregion
  12728. strFileName += "VOUCHER.doc";
  12729. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12730. doc.Save(fileDir);
  12731. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12732. return Ok(JsonView(true, "操作成功!", Url));
  12733. }
  12734. else
  12735. {
  12736. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  12737. }
  12738. }
  12739. else
  12740. {
  12741. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  12742. }
  12743. }
  12744. catch (Exception ex)
  12745. {
  12746. return Ok(JsonView(false, ex.Message));
  12747. }
  12748. }
  12749. /// <summary>
  12750. /// 酒店预订
  12751. /// 生成VOUCHER
  12752. /// 2024.05.06 之后版本
  12753. /// </summary>
  12754. /// <param name="_dto"></param>
  12755. /// <returns></returns>
  12756. [HttpPost]
  12757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12758. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  12759. {
  12760. #region 参数验证
  12761. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12762. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12763. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12764. #region 团组操作权限验证 76 酒店预定模块
  12765. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12766. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12767. #endregion
  12768. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12769. #region 页面操作权限验证
  12770. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12771. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12772. #endregion
  12773. #endregion
  12774. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  12775. //判断数据是否完整
  12776. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  12777. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12778. string strFileName = "HotelStatement/";
  12779. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12780. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  12781. #region 数据处理
  12782. List<int> guestIds = new List<int>();
  12783. int index = 0;
  12784. foreach (var item in hrDtas)
  12785. {
  12786. if (item.GuestName.Contains(","))
  12787. {
  12788. string[] guestIdArr = item.GuestName.Split(',');
  12789. foreach (var guestIdStr in guestIdArr)
  12790. {
  12791. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  12792. if (guestBool)
  12793. {
  12794. guestIds.Add(guestId);
  12795. }
  12796. }
  12797. }
  12798. else guestNames += item.GuestName;
  12799. var voucherInfo = new HotelVoucherInfoView()
  12800. {
  12801. HotelName = item.HotelName,
  12802. CheckInDate = item.CheckInDate,
  12803. CheckOutDate = item.CheckOutDate,
  12804. ConfirmationNumber = item.DetermineNo.Trim(),
  12805. RoomType = item.RoomExplanation
  12806. };
  12807. vouchers.Add(voucherInfo);
  12808. }
  12809. if (guestIds.Count > 0)
  12810. {
  12811. guestIds = guestIds.Distinct().ToList();
  12812. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  12813. if (guestDatas.Count > 0)
  12814. {
  12815. guestNames = "";
  12816. foreach (var guest in guestDatas)
  12817. {
  12818. string guestName = "";
  12819. if (guest.Sex == 0) guestName += @"MR.";
  12820. else if (guest.Sex == 1) guestName += @"MS.";
  12821. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  12822. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  12823. guestNames += @$"{guestName.Trim()}、";
  12824. }
  12825. if (guestNames.Length > 0)
  12826. {
  12827. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  12828. }
  12829. }
  12830. }
  12831. #endregion
  12832. //载入模板
  12833. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  12834. Document doc = new Document(sss);
  12835. DocumentBuilder builder = new DocumentBuilder(doc);
  12836. if (doc.Range.Bookmarks["GuestName"] != null)
  12837. {
  12838. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  12839. mark.Text = guestNames;
  12840. }
  12841. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12842. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  12843. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  12844. for (int i = 1; i <= vouchers.Count; i++)
  12845. {
  12846. HotelVoucherInfoView hviv = vouchers[i - 1];
  12847. builder.MoveToCell(0, i, 0, 0);
  12848. builder.Write(hviv.HotelName);
  12849. builder.MoveToCell(0, i, 1, 0);
  12850. builder.Write(hviv.CheckInDate);
  12851. builder.MoveToCell(0, i, 2, 0);
  12852. builder.Write(hviv.CheckOutDate);
  12853. builder.MoveToCell(0, i, 3, 0);
  12854. builder.Write(hviv.RoomType);
  12855. builder.MoveToCell(0, i, 4, 0);
  12856. builder.Write(hviv.ConfirmationNumber);
  12857. }
  12858. //删除多余行
  12859. int currRowIndex = vouchers.Count + 1;
  12860. int delRows = 21 - currRowIndex;
  12861. if (delRows > 0)
  12862. {
  12863. for (int i = 0; i < delRows; i++)
  12864. {
  12865. table.Rows.RemoveAt(currRowIndex);
  12866. //cultivateRowIndex++;
  12867. }
  12868. }
  12869. strFileName += "VOUCHER.docx";
  12870. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12871. doc.Save(fileDir);
  12872. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12873. return Ok(JsonView(true, "操作成功!", Url));
  12874. }
  12875. /// <summary>
  12876. /// 酒店预订
  12877. /// 生成VOUCHER 批量生成
  12878. /// New
  12879. /// </summary>
  12880. /// <param name="_dto"></param>
  12881. /// <returns></returns>
  12882. [HttpPost]
  12883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12884. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  12885. {
  12886. #region 参数验证
  12887. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12888. if (_dto.PageId < 1) _dto.PageId = 28;
  12889. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12890. #region 团组操作权限验证 76 酒店预定模块
  12891. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12892. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12893. #endregion
  12894. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12895. #region 页面操作权限验证
  12896. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12897. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12898. #endregion
  12899. #endregion
  12900. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  12901. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  12902. .OrderBy(x => x.CheckInDate)
  12903. .ToListAsync();
  12904. //判断数据是否完整
  12905. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  12906. string strFileName = "HotelStatement/";
  12907. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  12908. if (dele != null)
  12909. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  12910. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  12911. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  12912. .Where(it => it.IsDel == 0)
  12913. .ToListAsync();
  12914. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  12915. for (int i = 0; i < hrDtas.Count; i++)
  12916. {
  12917. string guestNames = string.Empty;
  12918. List<int> guestIds = new List<int>();
  12919. var item = hrDtas[i];
  12920. //处理客户姓名
  12921. if (item.GuestName.Contains(","))
  12922. {
  12923. string[] guestIdArr = item.GuestName.Split(',');
  12924. foreach (var guestIdStr in guestIdArr)
  12925. if (int.TryParse(guestIdStr, out int guestId))
  12926. guestIds.Add(guestId);
  12927. }
  12928. else
  12929. {
  12930. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  12931. if (guestIdBool)
  12932. {
  12933. guestIds.Add(guestId);
  12934. }
  12935. //NaN
  12936. if (item.GuestName.Contains("NaN"))
  12937. {
  12938. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  12939. }
  12940. }
  12941. if (guestIds.Count > 0)
  12942. {
  12943. guestIds = guestIds.Distinct().ToList();
  12944. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  12945. if (guestDatas1.Count > 0)
  12946. {
  12947. guestNames = "";
  12948. foreach (var guest in guestDatas1)
  12949. {
  12950. string guestName = "";
  12951. if (guest.Sex == 0) guestName += @"MR.";
  12952. else if (guest.Sex == 1) guestName += @"MS.";
  12953. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  12954. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  12955. guestNames += @$"{guestName.Trim()}、";
  12956. }
  12957. if (guestNames.Length > 0)
  12958. {
  12959. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  12960. }
  12961. }
  12962. }
  12963. //if (!string.IsNullOrEmpty(guestNames))
  12964. //{
  12965. hrDtas[i].GuestName = guestNames;
  12966. //}
  12967. }
  12968. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  12969. Document doc = new Document();
  12970. DocumentBuilder builder = new DocumentBuilder(doc);
  12971. try
  12972. {
  12973. builder.MoveToDocumentStart();
  12974. foreach (var item in hrDtas)
  12975. {
  12976. //标题
  12977. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  12978. builder.ParagraphFormat.LineSpacing = 1;
  12979. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12980. builder.ParagraphFormat.Style.Font.Size = 9;
  12981. builder.ParagraphFormat.Style.Font.Bold = true;
  12982. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  12983. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  12984. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  12985. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  12986. builder.ParagraphFormat.LineSpacing = 1;
  12987. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12988. builder.ParagraphFormat.Style.Font.Size = 9;
  12989. builder.ParagraphFormat.Style.Font.Bold = true;
  12990. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  12991. builder.StartTable();
  12992. // 设置边框颜色
  12993. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  12994. //设置边框样式
  12995. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  12996. //表格
  12997. #region 第一行
  12998. builder.InsertCell();
  12999. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13000. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13001. //builder.CellFormat.AllowAutoFit = false;
  13002. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13003. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13004. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13005. builder.CellFormat.WrapText = true; //自动换行
  13006. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13007. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  13008. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13009. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13010. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13011. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13012. builder.Write("TOUR NO:");
  13013. builder.InsertCell();
  13014. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13015. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13016. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13017. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13018. builder.ParagraphFormat.Style.Font.Bold = false;
  13019. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13020. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13021. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13022. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13023. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13024. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13025. builder.Write($"{dele?.TourCode ?? "-"}");
  13026. builder.InsertCell();
  13027. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13028. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13029. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13030. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13031. builder.ParagraphFormat.Style.Font.Bold = false;
  13032. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13033. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13034. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13035. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13036. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13037. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13038. builder.Write($"CITY:");
  13039. builder.InsertCell();
  13040. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13041. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13042. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13043. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13044. builder.ParagraphFormat.Style.Font.Bold = false;
  13045. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13046. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13047. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13048. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13049. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13050. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13051. builder.Write($"{item.City}");
  13052. builder.EndRow();
  13053. #endregion
  13054. #region 第二行
  13055. builder.InsertCell();
  13056. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13057. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13058. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13059. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13060. builder.ParagraphFormat.Style.Font.Bold = false;
  13061. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13062. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13063. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13064. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13065. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13066. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13067. builder.Write("CONFIRMATION NO:");
  13068. builder.InsertCell();
  13069. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13070. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13071. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13072. builder.ParagraphFormat.Style.Font.Bold = false;
  13073. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13074. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13075. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13076. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13077. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13078. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13079. builder.CellFormat.VerticalMerge = CellMerge.None;
  13080. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13081. builder.Write($"{item.DetermineNo}");
  13082. builder.InsertCell();
  13083. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13084. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13085. builder.InsertCell();
  13086. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13087. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13088. builder.EndRow();
  13089. #endregion
  13090. #region 第三行
  13091. builder.InsertCell();
  13092. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13093. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13094. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13095. builder.ParagraphFormat.Style.Font.Bold = false;
  13096. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13097. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13098. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13099. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13100. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13101. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13102. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13103. builder.Write($"HOTEL NAME:");
  13104. builder.InsertCell();
  13105. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13106. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13107. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13108. builder.ParagraphFormat.Style.Font.Bold = false;
  13109. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13110. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13111. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13112. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13113. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13114. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13115. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13116. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13117. builder.Write($"{item.HotelName}");
  13118. builder.InsertCell();
  13119. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13120. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13121. builder.InsertCell();
  13122. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13123. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13124. builder.EndRow();
  13125. #endregion
  13126. #region 第四行
  13127. builder.InsertCell();
  13128. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13129. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13130. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13131. builder.ParagraphFormat.Style.Font.Bold = false;
  13132. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13133. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13134. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13135. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13136. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13137. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13138. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13139. builder.Write($"HOTEL ADDRESS:");
  13140. builder.InsertCell();
  13141. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13142. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13143. builder.ParagraphFormat.Style.Font.Size = 8;
  13144. builder.ParagraphFormat.Style.Font.Bold = false;
  13145. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13146. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13147. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13148. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13149. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13150. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13151. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13152. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13153. builder.Write($"{item.HotelAddress}");
  13154. builder.InsertCell();
  13155. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13156. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13157. builder.InsertCell();
  13158. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13159. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13160. builder.EndRow();
  13161. #endregion
  13162. #region 第五行
  13163. builder.InsertCell();
  13164. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13165. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13166. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13167. builder.ParagraphFormat.Style.Font.Bold = false;
  13168. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13169. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13170. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13171. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13172. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13173. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13174. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13175. builder.Write("TEL:");
  13176. builder.InsertCell();
  13177. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13178. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13179. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13180. builder.ParagraphFormat.Style.Font.Bold = false;
  13181. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13182. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13183. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13184. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13185. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13186. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13187. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13188. builder.Write($"{item.HotelTel}");
  13189. builder.InsertCell();
  13190. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13191. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13192. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13193. builder.ParagraphFormat.Style.Font.Bold = false;
  13194. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13195. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13196. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13197. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13198. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13199. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13200. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13201. builder.Write($"FAX:");
  13202. builder.InsertCell();
  13203. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13204. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13205. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13206. builder.ParagraphFormat.Style.Font.Bold = false;
  13207. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13208. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13209. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13210. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13211. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13212. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13213. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13214. builder.Write($"{item.HotelFax}");
  13215. builder.EndRow();
  13216. #endregion
  13217. #region 第六行
  13218. builder.InsertCell();
  13219. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13220. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13221. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13222. builder.ParagraphFormat.Style.Font.Bold = false;
  13223. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13224. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13225. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13226. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13227. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13228. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13229. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13230. builder.Write("CHECK IN:");
  13231. builder.InsertCell();
  13232. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13233. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13234. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13235. builder.ParagraphFormat.Style.Font.Bold = false;
  13236. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13237. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13238. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13239. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13240. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13241. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13242. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13243. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  13244. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  13245. builder.Write($"{checkInStr}");
  13246. builder.InsertCell();
  13247. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13248. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13249. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13250. builder.ParagraphFormat.Style.Font.Bold = false;
  13251. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13252. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13253. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13254. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13255. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13256. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13257. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13258. builder.Write($"CHECK OUT:");
  13259. builder.InsertCell();
  13260. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13261. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13262. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13263. builder.ParagraphFormat.Style.Font.Bold = false;
  13264. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13265. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13266. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13267. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13268. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13269. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13270. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13271. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  13272. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  13273. builder.Write($"{checkOutStr}");
  13274. builder.EndRow();
  13275. #endregion
  13276. #region 第七行
  13277. builder.InsertCell();
  13278. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13279. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13280. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13281. builder.ParagraphFormat.Style.Font.Bold = false;
  13282. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13283. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13284. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13285. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13286. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13287. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13288. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13289. builder.Write($"GUEST NAME:");
  13290. builder.InsertCell();
  13291. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13292. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13293. builder.ParagraphFormat.Style.Font.Size = 8;
  13294. builder.ParagraphFormat.Style.Font.Bold = false;
  13295. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13296. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13297. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13298. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13299. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13300. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13301. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13302. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13303. builder.Write($"{item.GuestName}");
  13304. builder.InsertCell();
  13305. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13306. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13307. builder.InsertCell();
  13308. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13309. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13310. builder.EndRow();
  13311. #endregion
  13312. #region 第八行
  13313. builder.InsertCell();
  13314. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13315. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13316. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13317. builder.ParagraphFormat.Style.Font.Bold = false;
  13318. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13319. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13320. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13321. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13322. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13323. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13324. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13325. builder.Write($"ROOM TYPE:");
  13326. builder.InsertCell();
  13327. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13328. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13329. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13330. builder.ParagraphFormat.Style.Font.Bold = false;
  13331. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13332. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13333. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13334. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13335. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13336. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13337. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13338. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13339. builder.Write($"{item.RoomExplanation}");
  13340. builder.InsertCell();
  13341. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13342. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13343. builder.InsertCell();
  13344. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13345. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13346. builder.EndRow();
  13347. #endregion
  13348. #region 第九行
  13349. builder.InsertCell();
  13350. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13351. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13352. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13353. builder.ParagraphFormat.Style.Font.Bold = false;
  13354. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13355. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13356. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13357. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13358. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13359. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13360. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13361. builder.Write($"NOTE:");
  13362. builder.InsertCell();
  13363. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13364. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13365. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13366. builder.ParagraphFormat.Style.Font.Bold = false;
  13367. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13368. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13369. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13370. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13371. 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.");
  13372. builder.InsertCell();
  13373. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13374. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13375. builder.InsertCell();
  13376. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13377. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13378. builder.EndRow();
  13379. #endregion
  13380. builder.EndTable();
  13381. //换行
  13382. builder.Writeln("");
  13383. builder.Writeln("");
  13384. }
  13385. #region 获取文档中的所有表格 设置文字自适应
  13386. // 获取文档中的所有表格。
  13387. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13388. {
  13389. // 遍历表格中的所有行。
  13390. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13391. {
  13392. foreach (Cell cell in row.Cells)
  13393. {
  13394. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  13395. cellFormat.Width = 0;
  13396. }
  13397. }
  13398. }
  13399. #endregion
  13400. #region 设置页眉
  13401. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  13402. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  13403. if (System.IO.File.Exists(voucherHeaderPath))
  13404. {
  13405. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  13406. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  13407. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  13408. Shape shape = builder.InsertImage(imageBytes);
  13409. // 调整图片位置
  13410. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  13411. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  13412. shape.Top = 50; // 将图片距离页眉上边缘的距离
  13413. shape.Left = 0; // 将图片距离页面左边缘的距离
  13414. shape.Width = 81; // 设置图片宽度
  13415. shape.Height = 36; // 设置图片高度
  13416. }
  13417. //靠右
  13418. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  13419. //// 设置页脚上下边距
  13420. //builder.PageSetup.HeaderDistance = 42;
  13421. // 添加页眉线
  13422. Aspose.Words.Border borderHeader = null;
  13423. try
  13424. {
  13425. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  13426. }
  13427. catch (Exception e)
  13428. {
  13429. // TODO Auto-generated catch block
  13430. //e.printStackTrace();
  13431. }
  13432. borderHeader.Shadow = true;
  13433. borderHeader.DistanceFromText = 2;
  13434. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  13435. #endregion
  13436. }
  13437. catch (Exception ex)
  13438. {
  13439. }
  13440. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  13441. doc.Save(fileDir);
  13442. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  13443. return Ok(JsonView(true, "操作成功!", Url));
  13444. }
  13445. /// <summary>
  13446. /// 酒店预订
  13447. /// 生成 预定成本 Excel
  13448. /// </summary>
  13449. /// <param name="_dto"></param>
  13450. /// <returns></returns>
  13451. [HttpPost]
  13452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13453. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  13454. {
  13455. #region 参数验证
  13456. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  13457. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  13458. if (!vadalitorRes.IsValid)
  13459. {
  13460. var errors = new StringBuilder();
  13461. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  13462. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  13463. }
  13464. #region 团组操作权限验证 76 酒店预定模块
  13465. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13466. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13467. #endregion
  13468. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13469. #region 页面操作权限验证
  13470. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13471. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13472. #endregion
  13473. #endregion
  13474. decimal _rate = 1.00M;
  13475. string _currency = string.Empty;
  13476. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  13477. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13478. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  13479. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13480. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  13481. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  13482. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  13483. if (_GroupCostParameter == null)
  13484. {
  13485. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  13486. bool isIntType = int.TryParse(_currency, out int currId);
  13487. if (isIntType)
  13488. {
  13489. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13490. }
  13491. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13492. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13493. if (currInfo == null)
  13494. {
  13495. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13496. }
  13497. else _rate = currInfo.Rate;
  13498. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  13499. {
  13500. _rate = _GroupCostParameter.Rate;
  13501. }
  13502. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13503. string strFileName = "HotelStatement/";
  13504. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13505. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13506. var rateDatas = new List<dynamic>();
  13507. #region 数据处理
  13508. foreach (var item in hrDtas)
  13509. {
  13510. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13511. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13512. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13513. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13514. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13515. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  13516. {
  13517. continue;
  13518. }
  13519. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13520. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  13521. string singleRoomFeeStr = string.Empty,
  13522. doubleRoomFeeStr = string.Empty,
  13523. suiteRoomFeeStr = string.Empty,
  13524. otherRoomFeeStr = string.Empty,
  13525. payMoneyStr = string.Empty,
  13526. cardPriceStr = string.Empty;
  13527. if (roomCurr.Equals("CNY"))
  13528. {
  13529. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  13530. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13531. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13532. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13533. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13534. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  13535. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  13536. }
  13537. else
  13538. {
  13539. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13540. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13541. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13542. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13543. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13544. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13545. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13546. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13547. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13548. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13549. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  13550. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  13551. if (ccpPaymentCurrency.Equals("CNY"))
  13552. {
  13553. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  13554. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13555. }
  13556. else
  13557. {
  13558. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  13559. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  13560. }
  13561. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  13562. if (hotelcardPriceCurrency.Equals("CNY"))
  13563. {
  13564. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13565. }
  13566. else
  13567. {
  13568. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  13569. }
  13570. }
  13571. string breakfastPriceStr = string.Empty,
  13572. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13573. governmentRentStr = string.Empty,
  13574. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13575. cityTaxStr = string.Empty,
  13576. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13577. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  13578. if (!string.IsNullOrEmpty(breakfastCurrency1))
  13579. {
  13580. if (breakfastCurrency1.Equals("CNY"))
  13581. {
  13582. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13583. }
  13584. else
  13585. {
  13586. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  13587. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  13588. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  13589. }
  13590. }
  13591. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13592. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  13593. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  13594. {
  13595. if (governmentRentCurrency.Equals("CNY"))
  13596. {
  13597. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13598. }
  13599. else
  13600. {
  13601. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  13602. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  13603. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  13604. }
  13605. }
  13606. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13607. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  13608. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  13609. {
  13610. if (cityTaxStrCurrency1.Equals("CNY"))
  13611. {
  13612. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13613. }
  13614. else
  13615. {
  13616. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  13617. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  13618. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  13619. }
  13620. }
  13621. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13622. int payDId = roomInfo?.PayDId ?? 0;
  13623. pcfds.Add(new HotelReservations_PCFD_View()
  13624. {
  13625. City = item.City,
  13626. HotelName = item.HotelName,
  13627. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13628. // SingleRoomCount = item.SingleRoomCount,
  13629. SingleRoomPrice = singleRoomFeeStr,
  13630. // DoubleRoomCount = item.DoubleRoomCount,
  13631. DoubleRoomPrice = doubleRoomFeeStr,
  13632. //SuiteRoomCount = item.SuiteRoomCount,
  13633. SuiteRoomPrice = suiteRoomFeeStr,
  13634. OtherRoomPrice = otherRoomFeeStr,
  13635. //OtherRoomCount = item.OtherRoomCount,
  13636. BreakfastPrice = breakfastPriceStr,
  13637. GovernmentRent = governmentRentStr,
  13638. CityTax = cityTaxStr,
  13639. RoomExplanation = item.RoomExplanation,
  13640. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13641. PayTime = roomInfo?.ConsumptionDate,
  13642. BankNo = roomInfo?.BankNo,
  13643. PayMoney = payMoneyStr,
  13644. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13645. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13646. CardPrice = cardPriceStr,
  13647. Remark = ccpInfo.Remark
  13648. });
  13649. }
  13650. #endregion
  13651. //载入模板
  13652. WorkbookDesigner designer = new WorkbookDesigner();
  13653. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13654. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13655. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13656. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13657. var rateDatas1 = rateDatas.Distinct();
  13658. var rateStr = string.Empty;
  13659. foreach (var item in rateDatas1)
  13660. {
  13661. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  13662. }
  13663. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  13664. designer.SetDataSource("Opertor", userInfo.CnName);
  13665. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13666. dt.TableName = "ViewMyHotelReservations";
  13667. designer.SetDataSource(dt);
  13668. designer.Process();
  13669. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13670. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13671. designer.Workbook.Save(serverPath);
  13672. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13673. #region 删除指定行
  13674. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13675. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13676. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13677. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13678. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13679. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13680. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13681. cssIndex = dt.Columns["CityTax"].Ordinal,
  13682. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13683. remarkIndex = dt.Columns["Remark"].Ordinal;
  13684. //删除指定列
  13685. foreach (DataRow item in dt.Rows)
  13686. {
  13687. string singleStr = item["SingleRoomPrice"].ToString();
  13688. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13689. if (containsDigitButNotZero1) singleDel = false;
  13690. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13691. string doubleStr = item["DoubleRoomPrice"].ToString();
  13692. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13693. if (containsDigitButNotZero2) doubleDel = false;
  13694. string suiteStr = item["SuiteRoomPrice"].ToString();
  13695. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13696. if (containsDigitButNotZero3) suiteDel = false;
  13697. string otherStr = item["OtherRoomPrice"].ToString();
  13698. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13699. if (containsDigitButNotZero4) otherDel = false;
  13700. string zcStr = item["BreakfastPrice"].ToString();
  13701. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13702. if (containsDigitButNotZero5) zcDel = false;
  13703. string dsStr = item["GovernmentRent"].ToString();
  13704. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13705. if (containsDigitButNotZero6) dsDel = false;
  13706. string cssStr = item["CityTax"].ToString();
  13707. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13708. if (containsDigitButNotZero7) cssDel = false;
  13709. string cpStr = item["ConsumptionPatterns"].ToString();
  13710. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13711. string remarkStr = item["Remark"].ToString();
  13712. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13713. }
  13714. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13715. DeleteColumn(serverPath, cpIndex, cpDel);
  13716. DeleteColumn(serverPath, dsIndex, dsDel);
  13717. DeleteColumn(serverPath, cssIndex, cssDel);
  13718. DeleteColumn(serverPath, zcIndex, zcDel);
  13719. DeleteColumn(serverPath, otherIndex, otherDel);
  13720. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13721. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13722. DeleteColumn(serverPath, singleIndex, singleDel);
  13723. #endregion
  13724. //只保留第一个表格
  13725. DeleteSheet(serverPath);
  13726. return Ok(JsonView(true, "操作成功", url = rst));
  13727. }
  13728. else
  13729. {
  13730. _currency = _GroupCostParameter.Currency;
  13731. bool isIntType = int.TryParse(_currency, out int currId);
  13732. if (isIntType)
  13733. {
  13734. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13735. }
  13736. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13737. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13738. if (currInfo == null)
  13739. {
  13740. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13741. }
  13742. if (!_currency.ToUpper().Equals("CNY"))
  13743. {
  13744. _rate = _GroupCostParameter.Rate;
  13745. }
  13746. _rate = currInfo.Rate;
  13747. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13748. string strFileName = "HotelStatement/";
  13749. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13750. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13751. #region 数据处理
  13752. foreach (var item in hrDtas)
  13753. {
  13754. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13755. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13756. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13757. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13758. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13759. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13760. string singleRoomFeeStr = string.Empty,
  13761. doubleRoomFeeStr = string.Empty,
  13762. suiteRoomFeeStr = string.Empty,
  13763. otherRoomFeeStr = string.Empty,
  13764. payMoneyStr = string.Empty,
  13765. cardPriceStr = string.Empty;
  13766. if (roomCurr.Equals(_currency))
  13767. {
  13768. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  13769. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  13770. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  13771. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  13772. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  13773. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  13774. }
  13775. else
  13776. {
  13777. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13778. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13779. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13780. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13781. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13782. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13783. }
  13784. string breakfastPriceStr = string.Empty,
  13785. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13786. governmentRentStr = string.Empty,
  13787. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13788. cityTaxStrStr = string.Empty,
  13789. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13790. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  13791. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  13792. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  13793. int payDId = roomInfo?.PayDId ?? 0;
  13794. pcfds.Add(new HotelReservations_PCFD_View()
  13795. {
  13796. City = item.City,
  13797. HotelName = item.HotelName,
  13798. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13799. // SingleRoomCount = item.SingleRoomCount,
  13800. SingleRoomPrice = singleRoomFeeStr,
  13801. // DoubleRoomCount = item.DoubleRoomCount,
  13802. DoubleRoomPrice = doubleRoomFeeStr,
  13803. //SuiteRoomCount = item.SuiteRoomCount,
  13804. SuiteRoomPrice = suiteRoomFeeStr,
  13805. OtherRoomPrice = otherRoomFeeStr,
  13806. //OtherRoomCount = item.OtherRoomCount,
  13807. BreakfastPrice = breakfastPriceStr,
  13808. GovernmentRent = governmentRentStr,
  13809. CityTax = cityTaxStrStr,
  13810. RoomExplanation = item.RoomExplanation,
  13811. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13812. PayTime = roomInfo?.ConsumptionDate,
  13813. BankNo = roomInfo?.BankNo,
  13814. PayMoney = payMoneyStr,
  13815. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13816. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13817. CardPrice = cardPriceStr,
  13818. Remark = ccpInfo.Remark
  13819. });
  13820. }
  13821. #endregion
  13822. //载入模板
  13823. WorkbookDesigner designer = new WorkbookDesigner();
  13824. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13825. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13826. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13827. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13828. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  13829. designer.SetDataSource("Opertor", userInfo.CnName);
  13830. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13831. dt.TableName = "ViewMyHotelReservations";
  13832. designer.SetDataSource(dt);
  13833. designer.Process();
  13834. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13835. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13836. designer.Workbook.Save(serverPath);
  13837. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13838. #region 删除指定行
  13839. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13840. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13841. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13842. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13843. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13844. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13845. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13846. cssIndex = dt.Columns["CityTax"].Ordinal,
  13847. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13848. remarkIndex = dt.Columns["Remark"].Ordinal;
  13849. //删除指定列
  13850. foreach (DataRow item in dt.Rows)
  13851. {
  13852. string singleStr = item["SingleRoomPrice"].ToString();
  13853. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13854. if (containsDigitButNotZero1) singleDel = false;
  13855. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13856. string doubleStr = item["DoubleRoomPrice"].ToString();
  13857. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13858. if (containsDigitButNotZero2) doubleDel = false;
  13859. string suiteStr = item["SuiteRoomPrice"].ToString();
  13860. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13861. if (containsDigitButNotZero3) suiteDel = false;
  13862. string otherStr = item["OtherRoomPrice"].ToString();
  13863. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13864. if (containsDigitButNotZero4) otherDel = false;
  13865. string zcStr = item["BreakfastPrice"].ToString();
  13866. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13867. if (containsDigitButNotZero5) zcDel = false;
  13868. string dsStr = item["GovernmentRent"].ToString();
  13869. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13870. if (containsDigitButNotZero6) dsDel = false;
  13871. string cssStr = item["CityTax"].ToString();
  13872. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13873. if (containsDigitButNotZero7) cssDel = false;
  13874. string cpStr = item["ConsumptionPatterns"].ToString();
  13875. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13876. string remarkStr = item["Remark"].ToString();
  13877. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13878. }
  13879. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13880. DeleteColumn(serverPath, cpIndex, cpDel);
  13881. DeleteColumn(serverPath, dsIndex, dsDel);
  13882. DeleteColumn(serverPath, cssIndex, cssDel);
  13883. DeleteColumn(serverPath, zcIndex, zcDel);
  13884. DeleteColumn(serverPath, otherIndex, otherDel);
  13885. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13886. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13887. DeleteColumn(serverPath, singleIndex, singleDel);
  13888. #endregion
  13889. //只保留第一个表格
  13890. DeleteSheet(serverPath);
  13891. return Ok(JsonView(true, "操作成功", url = rst));
  13892. }
  13893. return Ok(JsonView(false));
  13894. }
  13895. /// <summary>
  13896. /// 删除指定列
  13897. /// </summary>
  13898. /// <param name="file"></param>
  13899. /// <param name="columnIndex"></param>
  13900. /// <param name="isDel"></param>
  13901. private void DeleteColumn(string file, int columnIndex, bool isDel)
  13902. {
  13903. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  13904. //wb.Save(file);
  13905. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  13906. if (sheet1 != null)
  13907. {
  13908. if (isDel)
  13909. {
  13910. Cells cells = sheet1.Cells;
  13911. cells.DeleteColumn(columnIndex);
  13912. }
  13913. }
  13914. wb.Save(file);
  13915. }
  13916. /// <summary>
  13917. /// 删除sheet
  13918. /// </summary>
  13919. /// <param name="file"></param>
  13920. /// <param name="sheetName"></param>
  13921. private void DeleteSheet(string file, string sheetName = "")
  13922. {
  13923. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  13924. //wb.Save(file);
  13925. List<string> sheets = new List<string>();
  13926. foreach (var item in wb.Worksheets)
  13927. {
  13928. sheets.Add(item.Name);
  13929. }
  13930. if (sheets.Count > 0)
  13931. {
  13932. sheets.RemoveAt(0);//不删除第一个sheet
  13933. foreach (var item in sheets)
  13934. {
  13935. wb.Worksheets.RemoveAt(item);
  13936. }
  13937. }
  13938. wb.Save(file);
  13939. }
  13940. /// <summary>
  13941. /// 酒店预订
  13942. /// 确认单
  13943. /// </summary>
  13944. /// <param name="_dto"></param>
  13945. /// <returns></returns>
  13946. [HttpPost]
  13947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13948. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  13949. {
  13950. try
  13951. {
  13952. #region 参数验证
  13953. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  13954. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13955. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  13956. #region 团组操作权限验证 76 酒店预定模块
  13957. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13958. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  13959. #endregion
  13960. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13961. #region 页面操作权限验证
  13962. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13963. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13964. #endregion
  13965. #endregion
  13966. //团组信息
  13967. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  13968. //酒店数据
  13969. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  13970. if (listhoteldata.Count < 0)
  13971. {
  13972. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  13973. }
  13974. //利datatable存储
  13975. DataTable dt = new DataTable();
  13976. dt.Columns.Add("CheckInDate", typeof(string));
  13977. dt.Columns.Add("City", typeof(string));
  13978. dt.Columns.Add("Hotel", typeof(string));
  13979. dt.Columns.Add("Room", typeof(string));
  13980. for (int i = 0; i < listhoteldata.Count; i++)
  13981. {
  13982. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  13983. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  13984. while (dayStart < dayEnd)
  13985. {
  13986. string temp = "";
  13987. DataRow row = dt.NewRow();
  13988. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  13989. row["City"] = listhoteldata[i].City;
  13990. row["Hotel"] = listhoteldata[i].HotelName;
  13991. if (listhoteldata[i].SingleRoomCount > 0)
  13992. {
  13993. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  13994. }
  13995. if (listhoteldata[i].DoubleRoomCount > 0)
  13996. {
  13997. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  13998. }
  13999. if (listhoteldata[i].SuiteRoomCount > 0)
  14000. {
  14001. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  14002. }
  14003. if (listhoteldata[i].OtherRoomCount > 0)
  14004. {
  14005. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  14006. }
  14007. row["Room"] = temp;
  14008. dt.Rows.Add(row);
  14009. dayStart = dayStart.AddDays(1);
  14010. }
  14011. }
  14012. Dictionary<string, string> dic = new Dictionary<string, string>();
  14013. dic.Add("Dele", di.TeamName);
  14014. dic.Add("City", di.VisitCountry);
  14015. //模板路径
  14016. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  14017. //载入模板
  14018. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  14019. DocumentBuilder builder = new DocumentBuilder(doc);
  14020. foreach (var key in dic.Keys)
  14021. {
  14022. builder.MoveToBookmark(key);
  14023. builder.Write(dic[key]);
  14024. }
  14025. //获取word里所有表格
  14026. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14027. //获取所填表格的序数
  14028. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14029. var rowStart = tableOne.Rows[0]; //获取第1行
  14030. //循环赋值
  14031. for (int i = 0; i < dt.Rows.Count; i++)
  14032. {
  14033. builder.MoveToCell(0, i + 1, 0, 0);
  14034. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  14035. builder.MoveToCell(0, i + 1, 1, 0);
  14036. builder.Write(dt.Rows[i]["City"].ToString());
  14037. builder.MoveToCell(0, i + 1, 2, 0);
  14038. builder.Write(dt.Rows[i]["Hotel"].ToString());
  14039. builder.MoveToCell(0, i + 1, 3, 0);
  14040. builder.Write(dt.Rows[i]["Room"].ToString());
  14041. }
  14042. //删除多余行
  14043. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  14044. {
  14045. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  14046. }
  14047. string strFileName = di.TeamName + "酒店确认单.doc";
  14048. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  14049. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  14050. return Ok(JsonView(true, "成功", url));
  14051. }
  14052. catch (Exception ex)
  14053. {
  14054. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  14055. }
  14056. }
  14057. #endregion
  14058. #region 团组状态
  14059. /// <summary>
  14060. /// 团组状态列表 Page
  14061. /// </summary>
  14062. /// <param name="dto">团组列表请求dto</param>
  14063. /// <returns></returns>
  14064. [HttpPost]
  14065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14066. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  14067. {
  14068. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14069. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  14070. {
  14071. string sqlWhere = string.Empty;
  14072. if (dto.IsSure == 0) //未完成
  14073. {
  14074. sqlWhere += string.Format(@" And IsSure = 0");
  14075. }
  14076. else if (dto.IsSure == 1) //已完成
  14077. {
  14078. sqlWhere += string.Format(@" And IsSure = 1");
  14079. }
  14080. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  14081. {
  14082. string tj = dto.SearchCriteria;
  14083. 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}%')",
  14084. tj, tj, tj, tj, tj);
  14085. }
  14086. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  14087. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  14088. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  14089. From (
  14090. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  14091. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  14092. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  14093. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  14094. From Grp_DelegationInfo gdi
  14095. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  14096. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  14097. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  14098. Where gdi.IsDel = 0 {0}
  14099. ) temp ", sqlWhere);
  14100. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  14101. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  14102. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  14103. }
  14104. else
  14105. {
  14106. return Ok(JsonView(false, "查询失败"));
  14107. }
  14108. }
  14109. /// <summary>
  14110. /// 团组状态
  14111. /// 设置操作完成
  14112. /// </summary>
  14113. /// <param name="dto">团组列表请求dto</param>
  14114. /// <returns></returns>
  14115. [HttpPost]
  14116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14117. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  14118. {
  14119. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14120. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  14121. {
  14122. Id = dto.Id,
  14123. IsSure = 1
  14124. };
  14125. var result = await _sqlSugar.Updateable(_DelegationInfo)
  14126. .UpdateColumns(it => new { it.IsSure })
  14127. .WhereColumns(it => new { it.Id })
  14128. .ExecuteCommandAsync();
  14129. if (result > 0)
  14130. {
  14131. return Ok(JsonView(true, "操作完成!"));
  14132. }
  14133. return Ok(JsonView(false, "操作失败!"));
  14134. }
  14135. #endregion
  14136. #region 保险费用录入
  14137. /// <summary>
  14138. /// 根据团组Id查询保险费用列表
  14139. /// </summary>
  14140. /// <param name="dto"></param>
  14141. /// <returns></returns>
  14142. [HttpPost]
  14143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14144. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  14145. {
  14146. Result groupData = await _customersRep.CustomersByDiId(dto);
  14147. if (groupData.Code != 0)
  14148. {
  14149. return Ok(JsonView(false, groupData.Msg));
  14150. }
  14151. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14152. }
  14153. /// <summary>
  14154. /// 根据保险费用Id查询保险费用详细
  14155. /// </summary>
  14156. /// <param name="dto"></param>
  14157. /// <returns></returns>
  14158. [HttpPost]
  14159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14160. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  14161. {
  14162. try
  14163. {
  14164. Result groupData = await _customersRep.CustomersById(dto);
  14165. if (groupData.Code != 0)
  14166. {
  14167. return Ok(JsonView(false, groupData.Msg));
  14168. }
  14169. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14170. }
  14171. catch (Exception ex)
  14172. {
  14173. return Ok(JsonView(false, ex.Message));
  14174. }
  14175. }
  14176. /// <summary>
  14177. /// 保险费用录入页面初始化绑定
  14178. /// </summary>
  14179. /// <param name="dto"></param>
  14180. /// <returns></returns>
  14181. [HttpPost]
  14182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14183. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  14184. {
  14185. try
  14186. {
  14187. Result groupData = await _customersRep.CustomersInitialize(dto);
  14188. if (groupData.Code != 0)
  14189. {
  14190. return Ok(JsonView(false, groupData.Msg));
  14191. }
  14192. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14193. }
  14194. catch (Exception ex)
  14195. {
  14196. return Ok(JsonView(false, ex.Message));
  14197. }
  14198. }
  14199. /// <summary>
  14200. /// 保险费用操作(Status:1.新增,2.修改)
  14201. /// </summary>
  14202. /// <param name="dto"></param>
  14203. /// <returns></returns>
  14204. [HttpPost]
  14205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14206. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  14207. {
  14208. Result groupData = await _customersRep.OpCustomers(dto);
  14209. if (groupData.Code != 0)
  14210. {
  14211. return Ok(JsonView(false, groupData.Msg));
  14212. }
  14213. #region 应用推送
  14214. try
  14215. {
  14216. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14217. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14218. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  14219. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14220. //自动审核
  14221. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  14222. //2024-10-21 新增LZ UID
  14223. var userIds = new List<int>() { 21 };
  14224. string title = $"系统通知";
  14225. var diId = dto.DiId;
  14226. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14227. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14228. string content = "";
  14229. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14230. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14231. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14232. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14233. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14234. }
  14235. catch (Exception ex)
  14236. {
  14237. }
  14238. #endregion
  14239. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14240. }
  14241. /// <summary>
  14242. /// 保险文件上传
  14243. /// </summary>
  14244. /// <param name="file"></param>
  14245. /// <returns></returns>
  14246. [HttpPost]
  14247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14248. public async Task<IActionResult> UploadCus(IFormFile file)
  14249. {
  14250. try
  14251. {
  14252. if (file != null)
  14253. {
  14254. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14255. //文件名称
  14256. string projectFileName = file.FileName;
  14257. //上传的文件的路径
  14258. string filePath = "";
  14259. if (!Directory.Exists(fileDir))
  14260. {
  14261. Directory.CreateDirectory(fileDir);
  14262. }
  14263. //上传的文件的路径
  14264. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  14265. using (FileStream fs = System.IO.File.Create(filePath))
  14266. {
  14267. file.CopyTo(fs);
  14268. fs.Flush();
  14269. }
  14270. return Ok(JsonView(true, "上传成功!", projectFileName));
  14271. }
  14272. else
  14273. {
  14274. return Ok(JsonView(false, "上传失败!"));
  14275. }
  14276. }
  14277. catch (Exception ex)
  14278. {
  14279. return Ok(JsonView(false, "程序错误!"));
  14280. throw;
  14281. }
  14282. }
  14283. /// <summary>
  14284. /// 保险删除指定文件
  14285. /// </summary>
  14286. /// <param name="dto"></param>
  14287. /// <returns></returns>
  14288. [HttpPost]
  14289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14290. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  14291. {
  14292. try
  14293. {
  14294. string filePath = "";
  14295. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14296. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  14297. //int id = 0;
  14298. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  14299. // 删除该文件
  14300. try
  14301. {
  14302. System.IO.File.Delete(filePath);
  14303. 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()
  14304. {
  14305. Attachment = "",
  14306. }).ExecuteCommandAsync();
  14307. if (result != 0)
  14308. {
  14309. return Ok(JsonView(true, "成功!"));
  14310. }
  14311. else
  14312. {
  14313. return Ok(JsonView(false, "失败!"));
  14314. }
  14315. }
  14316. catch (Exception)
  14317. {
  14318. 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()
  14319. {
  14320. Attachment = "",
  14321. }).ExecuteCommandAsync();
  14322. if (result != 0)
  14323. {
  14324. return Ok(JsonView(true, "成功!"));
  14325. }
  14326. else
  14327. {
  14328. return Ok(JsonView(false, "失败!"));
  14329. }
  14330. }
  14331. }
  14332. catch (Exception ex)
  14333. {
  14334. return Ok(JsonView(false, "程序错误!"));
  14335. throw;
  14336. }
  14337. }
  14338. /// <summary>
  14339. /// 保险费用操作(删除)
  14340. /// </summary>
  14341. /// <param name="dto"></param>
  14342. /// <returns></returns>
  14343. [HttpPost]
  14344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14345. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  14346. {
  14347. try
  14348. {
  14349. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  14350. if (!res)
  14351. {
  14352. return Ok(JsonView(false, "删除失败"));
  14353. }
  14354. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  14355. {
  14356. IsDel = 1,
  14357. DeleteUserId = dto.DeleteUserId,
  14358. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14359. }).ExecuteCommandAsync();
  14360. return Ok(JsonView(true, "删除成功!"));
  14361. }
  14362. catch (Exception ex)
  14363. {
  14364. return Ok(JsonView(false, "程序错误!"));
  14365. throw;
  14366. }
  14367. }
  14368. #endregion
  14369. #region 接团客户名单 PageId 104
  14370. /// <summary>
  14371. /// 接团客户名单
  14372. /// 迁移数据(慎用!)
  14373. /// </summary>
  14374. /// <param name="dto"></param>
  14375. /// <returns></returns>
  14376. [HttpPost]
  14377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14378. public async Task<IActionResult> PostTourClientListChange()
  14379. {
  14380. try
  14381. {
  14382. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  14383. //var groupClinetData1
  14384. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  14385. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  14386. int updateCount = 0;
  14387. if (oldOAClientList.Count > 0)
  14388. {
  14389. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  14390. _sqlSugar.BeginTran();
  14391. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  14392. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  14393. foreach (var item in oldOAClientList)
  14394. {
  14395. int comId = 0;
  14396. string format = "yyyy-MM-dd HH:mm:ss";
  14397. string data11 = "1990-01-01 00:00";
  14398. var data1 = IsValidDate(item.OPdate, format);
  14399. if (data1) data11 = item.OPdate;
  14400. //客户公司验证
  14401. if (!string.IsNullOrEmpty(item.Company))
  14402. {
  14403. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  14404. if (clientComInfo == null) // add
  14405. {
  14406. var addInfo = new Crm_CustomerCompany()
  14407. {
  14408. CompanyAbbreviation = "",
  14409. CompanyFullName = item.Company,
  14410. Address = "",
  14411. PostCodes = "",
  14412. LastedOpUserId = item.OPer,
  14413. LastedOpDt = Convert.ToDateTime(data11),
  14414. CreateUserId = item.OPer,
  14415. CreateTime = Convert.ToDateTime(data11),
  14416. IsDel = 0
  14417. };
  14418. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  14419. if (comId1 > 0) comId = comId1;
  14420. }
  14421. else comId = clientComInfo.Id;
  14422. }
  14423. //客户人员验证
  14424. int clientId = 0;
  14425. string name = item.LastName + item.Name;
  14426. if (!string.IsNullOrEmpty(name))
  14427. {
  14428. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  14429. if (clientInfo == null)
  14430. {
  14431. DateTime? dateTime = null;
  14432. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  14433. if (isDt) dateTime = birthDayDt;
  14434. var addInfo1 = new Crm_DeleClient()
  14435. {
  14436. CrmCompanyId = comId,
  14437. DiId = -1,
  14438. LastName = item.LastName,
  14439. FirstName = item.Name,
  14440. OldName = "",
  14441. Pinyin = item.Pinyin,
  14442. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  14443. Marriage = 0,
  14444. Phone = item.Phone,
  14445. Job = item.Job,
  14446. BirthDay = dateTime
  14447. };
  14448. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  14449. if (clientId1 > 0) clientId = clientId1;
  14450. }
  14451. else clientId = clientInfo.Id;
  14452. }
  14453. if (clientId < 1)
  14454. {
  14455. continue;
  14456. }
  14457. int airType = 0;
  14458. if (item.AirType == "超经舱") airType = 459;
  14459. else if (item.AirType == "公务舱") airType = 458;
  14460. else if (item.AirType == "经济舱") airType = 460;
  14461. else if (item.AirType == "其他") airType = 565;
  14462. else if (item.AirType == "头等舱") airType = 457;
  14463. var _TourClientListEntity = new Grp_TourClientList()
  14464. {
  14465. DiId = item.Diid,
  14466. ClientId = clientId,
  14467. CreateUserId = item.OPer,
  14468. CreateTime = Convert.ToDateTime(data11),
  14469. Remark = item.Remark,
  14470. IsDel = item.Isdel,
  14471. ShippingSpaceTypeId = airType,
  14472. ShippingSpaceSpecialNeeds = item.AirRemark,
  14473. HotelSpecialNeeds = item.RoomType
  14474. };
  14475. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  14476. if (_TourClientList > 0)
  14477. {
  14478. updateCount++;
  14479. }
  14480. }
  14481. _sqlSugar.CommitTran();
  14482. }
  14483. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  14484. }
  14485. catch (Exception ex)
  14486. {
  14487. _sqlSugar.RollbackTran();
  14488. return Ok(JsonView(false, ex.Message));
  14489. }
  14490. return Ok(JsonView(true));
  14491. }
  14492. private bool IsValidDate(string dateString, string format)
  14493. {
  14494. DateTime dateValue;
  14495. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  14496. return valid;
  14497. }
  14498. /// <summary>
  14499. /// 接团客户名单
  14500. /// 根据团组Id查询List
  14501. /// </summary>
  14502. /// <param name="dto"></param>
  14503. /// <returns></returns>
  14504. [HttpPost]
  14505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14506. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  14507. {
  14508. #region 参数验证
  14509. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  14510. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  14511. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  14512. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14513. #region 页面操作权限验证
  14514. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14515. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14516. #endregion
  14517. #endregion
  14518. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  14519. if (viewData.Code != 0)
  14520. {
  14521. return Ok(JsonView(false, viewData.Msg));
  14522. }
  14523. return Ok(JsonView(viewData.Data));
  14524. }
  14525. /// <summary>
  14526. /// 接团客户名单
  14527. /// 基础数据 Init
  14528. /// </summary>
  14529. /// <param name="_dto"></param>
  14530. /// <returns></returns>
  14531. [HttpPost]
  14532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14533. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  14534. {
  14535. #region 参数验证
  14536. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14537. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14538. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14539. #region 页面操作权限验证
  14540. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14541. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14542. #endregion
  14543. #endregion
  14544. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  14545. }
  14546. /// <summary>
  14547. /// 接团客户名单
  14548. /// 根据 Id查询 Details
  14549. /// </summary>
  14550. /// <param name="_dto"></param>
  14551. /// <returns></returns>
  14552. [HttpPost]
  14553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14554. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  14555. {
  14556. #region 参数验证
  14557. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14558. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14559. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14560. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14561. #region 页面操作权限验证
  14562. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14563. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14564. #endregion
  14565. #endregion
  14566. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  14567. if (viewData.Code != 0)
  14568. {
  14569. return Ok(JsonView(false, viewData.Msg));
  14570. }
  14571. return Ok(JsonView(viewData.Data));
  14572. }
  14573. /// <summary>
  14574. /// 接团客户名单
  14575. /// Add Or Edit
  14576. /// </summary>
  14577. /// <param name="_dto"></param>
  14578. /// <returns></returns>
  14579. [HttpPost]
  14580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14581. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  14582. {
  14583. #region 参数验证
  14584. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14585. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14586. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14587. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14588. #region 页面操作权限验证
  14589. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14590. if (_dto.Id == 0) //添加
  14591. {
  14592. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14593. }
  14594. else if (_dto.Id >= 0) //修改
  14595. {
  14596. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14597. }
  14598. #endregion
  14599. #endregion
  14600. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  14601. if (viewData.Code != 0)
  14602. {
  14603. return Ok(JsonView(false, viewData.Msg));
  14604. }
  14605. return Ok(JsonView(true));
  14606. }
  14607. /// <summary>
  14608. /// 接团客户名单
  14609. /// AddMultiple(添加多个)
  14610. /// </summary>
  14611. /// <param name="_dto"></param>
  14612. /// <returns></returns>
  14613. [HttpPost]
  14614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14615. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  14616. {
  14617. #region 参数验证
  14618. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14619. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14620. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14621. #region 页面操作权限验证
  14622. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14623. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14624. #endregion
  14625. #endregion
  14626. var viewData = await _tourClientListRep._AddMultiple(_dto);
  14627. if (viewData.Code != 0)
  14628. {
  14629. return Ok(JsonView(false, viewData.Msg));
  14630. }
  14631. return Ok(JsonView(true));
  14632. }
  14633. /// <summary>
  14634. /// 接团客户名单
  14635. /// Del
  14636. /// </summary>
  14637. /// <param name="_dto"></param>
  14638. /// <returns></returns>
  14639. [HttpPost]
  14640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14641. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  14642. {
  14643. #region 参数验证
  14644. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14645. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14646. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14647. #region 页面操作权限验证
  14648. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14649. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14650. #endregion
  14651. #endregion
  14652. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  14653. if (viewData.Code != 0)
  14654. {
  14655. return Ok(JsonView(false, viewData.Msg));
  14656. }
  14657. return Ok(JsonView(true));
  14658. }
  14659. /// <summary>
  14660. /// 接团客户名单
  14661. /// 文件下载 客户名单
  14662. /// </summary>
  14663. /// <param name="_dto"></param>
  14664. /// <returns></returns>
  14665. [HttpPost]
  14666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14667. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  14668. {
  14669. #region 参数验证
  14670. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14671. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14672. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  14673. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14674. #region 页面操作权限验证
  14675. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14676. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14677. #endregion
  14678. #endregion
  14679. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  14680. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  14681. From Grp_TourClientList tcl
  14682. Left Join
  14683. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  14684. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  14685. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  14686. From Crm_DeleClient dc
  14687. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  14688. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  14689. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  14690. Where dc.IsDel = 0) temp
  14691. On temp.DcId =tcl.ClientId
  14692. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  14693. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  14694. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  14695. //载入模板
  14696. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  14697. if (_dto.Language == 1)
  14698. {
  14699. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  14700. }
  14701. //载入模板
  14702. var doc = new Document(tempPath);
  14703. DocumentBuilder builder = new DocumentBuilder(doc);
  14704. //获取word里所有表格
  14705. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14706. //获取所填表格的序数
  14707. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14708. var rowStart = tableOne.Rows[0]; //获取第1行
  14709. if (_dto.Language == 0)
  14710. {
  14711. //循环赋值
  14712. for (int i = 0; i < DcList.Count; i++)
  14713. {
  14714. EncryptionProcessor.DecryptProperties(DcList[i]);
  14715. builder.MoveToCell(0, i + 1, 0, 0);
  14716. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  14717. builder.MoveToCell(0, i + 1, 1, 0);
  14718. int sex = DcList[i].Sex;
  14719. string sexStr = string.Empty;
  14720. if (sex == 0) sexStr = "男";
  14721. else if (sex == 1) sexStr = "女";
  14722. else sexStr = "未设置";
  14723. builder.Write(sexStr);
  14724. builder.MoveToCell(0, i + 1, 2, 0);
  14725. string birthDay = DcList[i].BirthDay;
  14726. string birthDayStr = string.Empty;
  14727. if (!string.IsNullOrEmpty(birthDay))
  14728. {
  14729. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  14730. }
  14731. builder.Write(birthDayStr);
  14732. builder.MoveToCell(0, i + 1, 3, 0);
  14733. string company = "";
  14734. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  14735. {
  14736. company = DcList[i].CompanyFullName.ToString();
  14737. }
  14738. builder.Write(company);
  14739. builder.MoveToCell(0, i + 1, 4, 0);
  14740. builder.Write(DcList[i].Job);
  14741. }
  14742. }
  14743. else if (_dto.Language == 1)
  14744. {
  14745. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  14746. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  14747. List<string> transArrayStr = new List<string>();
  14748. string transStrRes1 = "";
  14749. for (int i = 0; i < DcList.Count; i++)
  14750. {
  14751. var dc = DcList[i];
  14752. EncryptionProcessor.DecryptProperties(dc);
  14753. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  14754. if (dc.Job.Equals("暂无")) dc.Job = "-";
  14755. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  14756. if (DcList.Count - 1 == i) transStrRes1 += str1;
  14757. else transStrRes1 += $"{str1}|";
  14758. }
  14759. //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";
  14760. string transStrRes = "";
  14761. if (transStrRes1.Length > 0)
  14762. {
  14763. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  14764. }
  14765. //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
  14766. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  14767. //List<string> transArray = new List<string> { };
  14768. List<TranslateInfo> transArray = new List<TranslateInfo>();
  14769. if (transStrRes.Contains("|"))
  14770. {
  14771. string[] transArray1 = transStrRes.Split('|');
  14772. if (transArray1.Length > 0)
  14773. {
  14774. foreach (var item in transArray1)
  14775. {
  14776. if (item.Contains("&"))
  14777. {
  14778. string[] transArray2 = item.Split('&');
  14779. int index = 0;
  14780. string companyName = "", job = "";
  14781. if (transArray2.Length > 0)
  14782. {
  14783. bool success = int.TryParse(transArray2[0].Trim(), out index);
  14784. if (1 < transArray2.Length) companyName = transArray2[1];
  14785. if (2 < transArray2.Length) job = transArray2[2];
  14786. }
  14787. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  14788. }
  14789. }
  14790. }
  14791. }
  14792. //循环赋值
  14793. for (int i = 0; i < DcList.Count; i++)
  14794. {
  14795. string PYName = "";
  14796. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  14797. {
  14798. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  14799. string PY_First = DcList[i].Pinyin.Split('/')[1];
  14800. PYName = PY_First + " " + PY_Last;
  14801. }
  14802. else
  14803. {
  14804. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  14805. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  14806. PYName = PY_First + " " + PY_Last;
  14807. }
  14808. builder.MoveToCell(0, i + 1, 0, 0);
  14809. builder.Write(PYName);
  14810. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  14811. builder.MoveToCell(0, i + 1, 1, 0);
  14812. builder.Write(sex);
  14813. DateTime birthDt;
  14814. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  14815. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  14816. builder.MoveToCell(0, i + 1, 2, 0);
  14817. builder.Write(birthday);
  14818. string company = string.Empty, job = string.Empty;
  14819. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  14820. if (dcTransInfo != null)
  14821. {
  14822. company = dcTransInfo.CompanyName;
  14823. job = dcTransInfo.Job;
  14824. }
  14825. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  14826. {
  14827. //查询对照表
  14828. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  14829. if (tempCec != null)
  14830. {
  14831. company = tempCec.enName;
  14832. }
  14833. //翻译
  14834. else
  14835. {
  14836. }
  14837. }
  14838. builder.MoveToCell(0, i + 1, 3, 0);
  14839. builder.Write(company);
  14840. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  14841. {
  14842. //查询对照表
  14843. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  14844. if (tempPec != null)
  14845. {
  14846. job = tempPec.enName;
  14847. }
  14848. //翻译
  14849. else
  14850. {
  14851. }
  14852. }
  14853. builder.MoveToCell(0, i + 1, 4, 0);
  14854. builder.Write(job);
  14855. }
  14856. }
  14857. //删除多余行
  14858. while (tableOne.Rows.Count > DcList.Count + 1)
  14859. {
  14860. tableOne.Rows.RemoveAt(DcList.Count + 1);
  14861. }
  14862. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  14863. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  14864. doc.Save(fileDir);
  14865. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  14866. return Ok(JsonView(true, "操作成功!", Url));
  14867. }
  14868. private class TranslateInfo
  14869. {
  14870. public int Index { get; set; }
  14871. public string CompanyName { get; set; }
  14872. public string Job { get; set; }
  14873. }
  14874. #endregion
  14875. #region 团组倒推表
  14876. /// <summary>
  14877. /// 倒推表基础数据
  14878. /// Init
  14879. /// </summary>
  14880. /// <param name="dto"></param>
  14881. /// <returns></returns>
  14882. [HttpPost]
  14883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14884. public async Task<IActionResult> PostInvertedListInit()
  14885. {
  14886. var viewData = await _invertedListRep._Init();
  14887. if (viewData.Code != 0)
  14888. {
  14889. return Ok(JsonView(false, viewData.Msg));
  14890. }
  14891. return Ok(JsonView(viewData.Data));
  14892. }
  14893. /// <summary>
  14894. /// 倒推表
  14895. /// Info
  14896. /// </summary>
  14897. /// <param name="dto"></param>
  14898. /// <returns></returns>
  14899. [HttpPost]
  14900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14901. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  14902. {
  14903. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  14904. if (viewData.Code != 0)
  14905. {
  14906. return Ok(JsonView(false, viewData.Msg));
  14907. }
  14908. return Ok(JsonView(viewData.Data));
  14909. }
  14910. /// <summary>
  14911. /// 倒推表
  14912. /// Create
  14913. /// </summary>
  14914. /// <param name="dto"></param>
  14915. /// <returns></returns>
  14916. [HttpPost]
  14917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14918. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  14919. {
  14920. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  14921. if (viewData.Code != 0)
  14922. {
  14923. return Ok(JsonView(false, viewData.Msg));
  14924. }
  14925. return Ok(JsonView(viewData.Data));
  14926. }
  14927. /// <summary>
  14928. /// 倒推表
  14929. /// Update
  14930. /// </summary>
  14931. /// <param name="dto"></param>
  14932. /// <returns></returns>
  14933. [HttpPost]
  14934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14935. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  14936. {
  14937. var viewData = await _invertedListRep._Update(dto);
  14938. if (viewData.Code != 0)
  14939. {
  14940. return Ok(JsonView(false, viewData.Msg));
  14941. }
  14942. return Ok(JsonView(viewData.Data));
  14943. }
  14944. /// <summary>
  14945. /// 倒推表
  14946. /// File Download
  14947. /// </summary>
  14948. /// <param name="dto"></param>
  14949. /// <returns></returns>
  14950. [HttpPost]
  14951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14952. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  14953. {
  14954. var info2 = await _invertedListRep._Info(1, dto.DiId);
  14955. if (info2.Code != 0)
  14956. {
  14957. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  14958. }
  14959. var info1 = info2.Data as InvertedListInfoView;
  14960. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  14961. string teamName = "";
  14962. if (info != null) teamName = info.TeamName;
  14963. //载入模板
  14964. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  14965. DocumentBuilder builder = new DocumentBuilder(doc);
  14966. //利用键值对存放数据
  14967. Dictionary<string, string> dic = new Dictionary<string, string>();
  14968. dic.Add("TeamName", teamName);
  14969. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  14970. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  14971. dic.Add("BPRemark", info1.ApprovalDataRemark);
  14972. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  14973. dic.Add("SQRemark", info1.ApprovalRemark);
  14974. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  14975. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  14976. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  14977. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  14978. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  14979. dic.Add("QZRemark", info1.VisaInformationRemark);
  14980. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  14981. dic.Add("SQQZRemark", info1.SendVisaRemark);
  14982. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  14983. dic.Add("CQRemark", info1.IssueVisaRemark);
  14984. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  14985. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  14986. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  14987. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  14988. #region 填充word模板书签内容
  14989. foreach (var key in dic.Keys)
  14990. {
  14991. builder.MoveToBookmark(key);
  14992. builder.Write(dic[key]);
  14993. }
  14994. #endregion
  14995. var fileDir = AppSettingsHelper.Get("WordBasePath");
  14996. string fileName = $"{teamName}团出行准备流程表.doc";
  14997. string filePath = fileDir + $@"InvertedList/{fileName}";
  14998. doc.Save(filePath);
  14999. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  15000. return Ok(JsonView(true, "操作成功!", Url));
  15001. }
  15002. #endregion
  15003. #region 三公签证费用(签证费、代办费)
  15004. /// <summary>
  15005. /// 三公签证费用(签证费、代办费)
  15006. /// List
  15007. /// </summary>
  15008. /// <returns></returns>
  15009. [HttpPost]
  15010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15011. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  15012. {
  15013. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  15014. if (_view.Code != 0)
  15015. {
  15016. return Ok(JsonView(false, _view.Msg));
  15017. }
  15018. return Ok(JsonView(true, "操作成功!", _view.Data));
  15019. }
  15020. /// <summary>
  15021. /// 三公签证费用(签证费、代办费)
  15022. /// Add Or Update
  15023. /// </summary>
  15024. /// <returns></returns>
  15025. [HttpPost]
  15026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15027. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  15028. {
  15029. var _view = await _visaFeeInfoRep._Update(_dto);
  15030. if (_view.Code != 0)
  15031. {
  15032. return Ok(JsonView(false, _view.Msg));
  15033. }
  15034. return Ok(JsonView(true, _view.Msg));
  15035. }
  15036. #endregion
  15037. #region 酒店询价
  15038. /// <summary>
  15039. /// 酒店询价
  15040. /// Init
  15041. /// </summary>
  15042. /// <param name="dto"></param>
  15043. /// <returns></returns>
  15044. [HttpPost]
  15045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15046. public async Task<IActionResult> PostHotelInquiryInit()
  15047. {
  15048. var res = await _hotelInquiryRep._Init();
  15049. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15050. return Ok(JsonView(true, res.Msg, res.Data));
  15051. }
  15052. /// <summary>
  15053. /// 酒店询价
  15054. /// page Item
  15055. /// </summary>
  15056. /// <param name="_dto"></param>
  15057. /// <returns></returns>
  15058. [HttpPost]
  15059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15060. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  15061. {
  15062. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  15063. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15064. var view = res.Data as PageDataViewBase;
  15065. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  15066. }
  15067. /// <summary>
  15068. /// 酒店询价
  15069. /// info
  15070. /// </summary>
  15071. /// <param name="_dto"></param>
  15072. /// <returns></returns>
  15073. [HttpPost]
  15074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15075. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  15076. {
  15077. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  15078. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15079. return Ok(JsonView(true, res.Msg, res.Data));
  15080. }
  15081. /// <summary>
  15082. /// 酒店询价
  15083. /// Add Or Edit
  15084. /// </summary>
  15085. /// <param name="_dto"></param>
  15086. /// <returns></returns>
  15087. [HttpPost]
  15088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15089. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  15090. {
  15091. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  15092. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15093. return Ok(JsonView(true, res.Msg, res.Data));
  15094. }
  15095. /// <summary>
  15096. /// 酒店询价
  15097. /// Del
  15098. /// </summary>
  15099. /// <param name="_dto"></param>
  15100. /// <returns></returns>
  15101. [HttpPost]
  15102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15103. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  15104. {
  15105. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  15106. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15107. return Ok(JsonView(true, res.Msg, res.Data));
  15108. }
  15109. #endregion
  15110. #region 下载匹配op行程单
  15111. /// <summary>
  15112. /// 匹配op行程单
  15113. /// Init
  15114. /// </summary>
  15115. /// <param name="dto">团组列表请求dto</param>
  15116. /// <returns></returns>
  15117. [HttpPost]
  15118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15119. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  15120. {
  15121. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15122. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15123. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  15124. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  15125. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  15126. .Where(it => it.IsDel == 0)
  15127. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  15128. .OrderByDescending(it => it.CreateUserId)
  15129. .ToList();
  15130. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  15131. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15132. var diids = groupInfos.Select(it => it.Id).ToList();
  15133. List<string> countrys = new List<string>();
  15134. foreach (var item in country)
  15135. {
  15136. var data = _groupRepository.FormartTeamName(item);
  15137. var dataArray = _groupRepository.GroupSplitCountry(data);
  15138. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15139. }
  15140. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  15141. List<string> areaArray = new List<string>(); //GetGroupCityLine
  15142. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  15143. foreach (var item in areaItem)
  15144. {
  15145. string areaStr = item.Value;
  15146. if (!string.IsNullOrEmpty(areaStr))
  15147. {
  15148. string[] str1 = areaStr.Split("-");
  15149. if (str1.Length > 0)
  15150. {
  15151. areaArray.AddRange(str1);
  15152. }
  15153. }
  15154. }
  15155. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  15156. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  15157. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  15158. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  15159. .ToList();
  15160. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  15161. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  15162. .Where(it => countriesIds.Contains(it.Id))
  15163. .Select(it => new { it.Id, Name = it.Name_CN })
  15164. .ToList();
  15165. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  15166. .Select(it => it.TeamName).ToList();
  15167. stopwatch.Stop();
  15168. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  15169. }
  15170. ///// <summary>
  15171. ///// 匹配op行程单
  15172. ///// Init 查询区域数据
  15173. ///// </summary>
  15174. ///// <param name="dto">团组列表请求dto</param>
  15175. ///// <returns></returns>
  15176. //[HttpPost]
  15177. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15178. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  15179. //{
  15180. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15181. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  15182. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  15183. // if (string.IsNullOrEmpty(countriesDataStr))
  15184. // {
  15185. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  15186. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  15187. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  15188. // }
  15189. // else
  15190. // {
  15191. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  15192. // }
  15193. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  15194. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  15195. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  15196. // List<dynamic> childList = new List<dynamic>();
  15197. // int parentId = dto.CountriesId;
  15198. // if (provinceData.Count > 1)
  15199. // {
  15200. // foreach (var item1 in provinceData)
  15201. // {
  15202. // List<dynamic> childList1 = new List<dynamic>();
  15203. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  15204. // foreach (var item2 in citiesData1)
  15205. // {
  15206. // List<dynamic> childList2 = new List<dynamic>();
  15207. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15208. // foreach (var item3 in countiesData1)
  15209. // {
  15210. // childList2.Add(new
  15211. // {
  15212. // id = item3.Id,
  15213. // parentId = item2.Id,
  15214. // level = "district",
  15215. // name = item3.Name_CN,
  15216. // });
  15217. // }
  15218. // childList1.Add(new
  15219. // {
  15220. // id = item2.Id,
  15221. // parentId = item1.Id,
  15222. // level = "city",
  15223. // name = item2.Name_CN,
  15224. // childList = childList2
  15225. // });
  15226. // }
  15227. // childList.Add(new
  15228. // {
  15229. // id = item1.Id,
  15230. // parentId = parentId,
  15231. // level = "province",
  15232. // name = item1.Name_CN,
  15233. // childList = childList1
  15234. // });
  15235. // }
  15236. // //城市
  15237. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  15238. // foreach (var item2 in citiesData2)
  15239. // {
  15240. // List<dynamic> childList22 = new List<dynamic>();
  15241. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15242. // foreach (var item3 in countiesData1)
  15243. // {
  15244. // childList22.Add(new
  15245. // {
  15246. // id = item3.Id,
  15247. // parentId = item2.Id,
  15248. // level = "district",
  15249. // name = item3.Name_CN,
  15250. // });
  15251. // }
  15252. // childList.Add(new
  15253. // {
  15254. // id = item2.Id,
  15255. // parentId = parentId,
  15256. // level = "city",
  15257. // name = item2.Name_CN,
  15258. // childList = childList22
  15259. // });
  15260. // }
  15261. // }
  15262. // else
  15263. // {
  15264. // foreach (var item2 in citiesData)
  15265. // {
  15266. // string cname = item2.Name_CN;
  15267. // List<dynamic> childList1 = new List<dynamic>();
  15268. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15269. // foreach (var item3 in countiesData1)
  15270. // {
  15271. // childList1.Add(new
  15272. // {
  15273. // Id = item3.Id,
  15274. // parentId = item2.Id,
  15275. // level = "district",
  15276. // name = item3.Name_CN
  15277. // });
  15278. // }
  15279. // childList.Add(new
  15280. // {
  15281. // id = item2.Id,
  15282. // parentId = parentId,
  15283. // level = "city",
  15284. // name = item2.Name_CN,
  15285. // childList = childList1
  15286. // });
  15287. // }
  15288. // }
  15289. // stopwatch.Stop();
  15290. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  15291. //}
  15292. /// <summary>
  15293. /// 匹配op行程单
  15294. /// 接团信息列表 Page
  15295. /// </summary>
  15296. /// <param name="dto">团组列表请求dto</param>
  15297. /// <returns></returns>
  15298. [HttpPost]
  15299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15300. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  15301. {
  15302. var swatch = new Stopwatch();
  15303. swatch.Start();
  15304. #region 参数验证
  15305. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15306. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15307. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15308. #region 页面操作权限验证
  15309. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15310. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  15311. #endregion
  15312. #endregion
  15313. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15314. {
  15315. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  15316. string sqlWhere = "";
  15317. if (!string.IsNullOrEmpty(dto.Country))
  15318. {
  15319. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  15320. }
  15321. if (!string.IsNullOrEmpty(dto.Area))
  15322. {
  15323. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  15324. }
  15325. if (!string.IsNullOrEmpty(dto.TeamName))
  15326. {
  15327. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  15328. }
  15329. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  15330. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  15331. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  15332. swatch.Stop();
  15333. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  15334. }
  15335. else
  15336. {
  15337. return Ok(JsonView(false, "查询失败"));
  15338. }
  15339. }
  15340. /// <summary>
  15341. /// 匹配op行程单
  15342. /// 行程单下载
  15343. /// </summary>
  15344. /// <param name="dto">团组列表请求dto</param>
  15345. /// <returns></returns>
  15346. [HttpPost]
  15347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15348. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  15349. {
  15350. #region 参数验证
  15351. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15352. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15353. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15354. #region 页面操作权限验证
  15355. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15356. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  15357. #endregion
  15358. #endregion
  15359. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15360. {
  15361. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  15362. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  15363. }
  15364. else
  15365. {
  15366. return Ok(JsonView(false, "下载失败!"));
  15367. }
  15368. }
  15369. #endregion
  15370. #region 国家信息 数据 注释
  15371. //[HttpPost]
  15372. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  15373. //{
  15374. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  15375. // foreach (var item in dto)
  15376. // {
  15377. // infos.Add(new Grp_GroupsTaskAssignment()
  15378. // {
  15379. // DIId = item,
  15380. // CTId = 82,
  15381. // UId = 248,
  15382. // IsEnable = 1,
  15383. // CreateUserId = 233,
  15384. // CreateTime = DateTime.Now,
  15385. // IsDel = 0
  15386. // });
  15387. // infos.Add(new Grp_GroupsTaskAssignment()
  15388. // {
  15389. // DIId = item,
  15390. // CTId = 82,
  15391. // UId = 286,
  15392. // IsEnable = 1,
  15393. // CreateUserId = 233,
  15394. // CreateTime = DateTime.Now,
  15395. // IsDel = 0
  15396. // });
  15397. // }
  15398. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  15399. // return Ok("操作成功");
  15400. //}
  15401. //public class paramJsonDto
  15402. //{
  15403. // public List<CountriesInfo> str { get; set; }
  15404. //}
  15405. //[HttpPost]
  15406. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  15407. //{
  15408. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  15409. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  15410. // List<Sys_Cities> cities = new List<Sys_Cities>();
  15411. // List<Sys_Cities> districts = new List<Sys_Cities>();
  15412. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15413. // _sqlSugar.BeginTran();
  15414. // int countitiesIndex = 0;
  15415. // foreach (var item in dto.str)
  15416. // {
  15417. // dynamic data = item.c;
  15418. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  15419. // if (data != null)
  15420. // {
  15421. // countitiesIndex++;
  15422. // foreach (var item1 in data)
  15423. // {
  15424. // string cnname = item1.cn;
  15425. // string enname = item1.en;
  15426. // Sys_Cities provinceInfo = new Sys_Cities()
  15427. // {
  15428. // CountriesId = countriesId,
  15429. // Name_CN = cnname,
  15430. // Name_EN = enname,
  15431. // ParentId = 0,
  15432. // IsCapital = 1,
  15433. // CreateUserId = 208,
  15434. // CreateTime = DateTime.Now,
  15435. // IsDel = 0
  15436. // };
  15437. // if (item1.lv == "province") //省份
  15438. // {
  15439. // provinceInfo.Level = 1;
  15440. // int provinceId = 0;
  15441. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  15442. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  15443. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15444. // var data1 = item1.c;
  15445. // foreach (var item2 in data1)
  15446. // {
  15447. // if (item2.lv == "city")
  15448. // {
  15449. // string citycnname = item2.cn;
  15450. // string cityenname = item2.en;
  15451. // Sys_Cities cityInfo = new Sys_Cities()
  15452. // {
  15453. // CountriesId = countriesId,
  15454. // ParentId = provinceId,
  15455. // Level = 2,
  15456. // Name_CN = citycnname,
  15457. // Name_EN = cityenname,
  15458. // IsCapital = 1,
  15459. // CreateUserId = 208,
  15460. // CreateTime = DateTime.Now,
  15461. // IsDel = 0
  15462. // };
  15463. // if (item2.c != null)
  15464. // {
  15465. // int cityId = 0;
  15466. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  15467. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15468. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  15469. // foreach (var item3 in item2.c)
  15470. // {
  15471. // if (item3.lv == "district")
  15472. // {
  15473. // var districtInfo = new Sys_Cities()
  15474. // {
  15475. // CountriesId = countriesId,
  15476. // Name_CN = item3.cn,
  15477. // Name_EN = item3.en,
  15478. // Level = 3,
  15479. // ParentId = cityId,
  15480. // IsCapital = 1,
  15481. // CreateUserId = 208,
  15482. // CreateTime = DateTime.Now,
  15483. // IsDel = 0
  15484. // };
  15485. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15486. // //{
  15487. // districts.Add(districtInfo);
  15488. // //}
  15489. // }
  15490. // }
  15491. // }
  15492. // else
  15493. // {
  15494. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  15495. // //{
  15496. // cities.Add(cityInfo);
  15497. // //}
  15498. // }
  15499. // }
  15500. // }
  15501. // }
  15502. // else if (item1.lv == "city")//城市
  15503. // {
  15504. // provinceInfo.Level = 2;
  15505. // if (item1.c != null)
  15506. // {
  15507. // int cityId = 0;
  15508. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  15509. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15510. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15511. // foreach (var item3 in item1.c)
  15512. // {
  15513. // if (item3.lv == "district")
  15514. // {
  15515. // var districtInfo = new Sys_Cities()
  15516. // {
  15517. // CountriesId = countriesId,
  15518. // Name_CN = item3.cn,
  15519. // Name_EN = item3.en,
  15520. // Level = 3,
  15521. // ParentId = cityId,
  15522. // IsCapital = 1,
  15523. // CreateUserId = 208,
  15524. // CreateTime = DateTime.Now,
  15525. // IsDel = 0
  15526. // };
  15527. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15528. // //{
  15529. // districts.Add(districtInfo);
  15530. // //}
  15531. // }
  15532. // }
  15533. // }
  15534. // else
  15535. // {
  15536. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  15537. // //{
  15538. // cities.Add(provinceInfo);
  15539. // //}
  15540. // }
  15541. // }
  15542. // }
  15543. // }
  15544. // }
  15545. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  15546. // cities = cities.Distinct().ToList();
  15547. // districts = districts.Distinct().ToList();
  15548. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  15549. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  15550. // cities.AddRange(districts);
  15551. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  15552. // //_sqlSugar.RollbackTran();
  15553. // _sqlSugar.CommitTran();
  15554. // return Ok(JsonView(false, "操作成功!"));
  15555. //}
  15556. //[HttpPost]
  15557. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  15558. //{
  15559. // List<CountitiesInfo> infos = dto.MyProperty;
  15560. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  15561. // _sqlSugar.BeginTran();
  15562. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15563. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  15564. // foreach (var item in infos)
  15565. // {
  15566. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  15567. // if (countryInfo != null)
  15568. // {
  15569. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  15570. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  15571. // if (cityInfo1 != null)
  15572. // {
  15573. // cityInfo1.IsCapital = 0;
  15574. // cityInfos.Add(cityInfo1);
  15575. // }
  15576. // }
  15577. // }
  15578. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  15579. // .UpdateColumns(it => it.IsCapital)
  15580. // .WhereColumns(it => it.Id)
  15581. // .ExecuteCommand();
  15582. // //_sqlSugar.RollbackTran();
  15583. // _sqlSugar.CommitTran();
  15584. // return Ok(JsonView(false, "操作成功!"));
  15585. //}
  15586. //public class CounrtiesDto
  15587. //{
  15588. // public List<CountitiesInfo> MyProperty { get; set; }
  15589. //}
  15590. //public class CountitiesInfo
  15591. //{
  15592. // /// <summary>
  15593. // /// 圣约翰
  15594. // /// </summary>
  15595. // public string capital_name_chinese { get; set; }
  15596. // /// <summary>
  15597. // ///
  15598. // /// </summary>
  15599. // public string capital_name { get; set; }
  15600. // /// <summary>
  15601. // ///
  15602. // /// </summary>
  15603. // public string country_type { get; set; }
  15604. // /// <summary>
  15605. // /// 安提瓜和巴布达
  15606. // /// </summary>
  15607. // public string country_name_chinese { get; set; }
  15608. // /// <summary>
  15609. // /// 安提瓜和巴布达
  15610. // /// </summary>
  15611. // public string country_name_chinese_short { get; set; }
  15612. // /// <summary>
  15613. // /// 安提瓜和巴布达
  15614. // /// </summary>
  15615. // public string country_name_chinese_UN { get; set; }
  15616. // /// <summary>
  15617. // ///
  15618. // /// </summary>
  15619. // public string country_name_english_abbreviation { get; set; }
  15620. // /// <summary>
  15621. // ///
  15622. // /// </summary>
  15623. // public string country_name_english_formal { get; set; }
  15624. // /// <summary>
  15625. // ///
  15626. // /// </summary>
  15627. // public string country_name_english_UN { get; set; }
  15628. // /// <summary>
  15629. // ///
  15630. // /// </summary>
  15631. // public string continent_name { get; set; }
  15632. // /// <summary>
  15633. // ///
  15634. // /// </summary>
  15635. // public string subregion_name { get; set; }
  15636. // /// <summary>
  15637. // ///
  15638. // /// </summary>
  15639. // public string country_code2 { get; set; }
  15640. // /// <summary>
  15641. // ///
  15642. // /// </summary>
  15643. // public string country_code3 { get; set; }
  15644. // /// <summary>
  15645. // ///
  15646. // /// </summary>
  15647. // public string phone_code { get; set; }
  15648. //}
  15649. //public class CountriesInfo : BasicInfo
  15650. //{
  15651. // public List<CitiesInfo> c { get; set; }
  15652. //}
  15653. //public class CitiesInfo : BasicInfo
  15654. //{
  15655. // public List<AreaInfo> c { get; set; }
  15656. //}
  15657. //public class AreaInfo : BasicInfo
  15658. //{
  15659. // public List<AreaInfo> c { get; set; }
  15660. //}
  15661. //public class BasicInfo
  15662. //{
  15663. // public string code { get; set; }
  15664. // public string cn { get; set; }
  15665. // public string lv { get; set; }
  15666. // public string en { get; set; }
  15667. //}
  15668. #endregion
  15669. #region 查看邀请方
  15670. /// <summary>
  15671. /// 查看邀请方
  15672. /// 邀请方信息 Init
  15673. /// </summary>
  15674. /// <param name="dto"></param>
  15675. /// <returns></returns>
  15676. [HttpPost]
  15677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15678. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  15679. {
  15680. string sqlWhere = string.Empty;
  15681. if (!string.IsNullOrEmpty(dto.Search))
  15682. {
  15683. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  15684. }
  15685. string sql = string.Format($@"Select
  15686. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  15687. Id,
  15688. UnitName
  15689. From Res_InvitationOfficialActivityData
  15690. Where IsDel = 0
  15691. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  15692. RefAsync<int> total = 0;
  15693. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15694. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  15695. }
  15696. /// <summary>
  15697. /// 查看邀请方
  15698. /// 国家信息 Init
  15699. /// </summary>
  15700. /// <param name="dto"></param>
  15701. /// <returns></returns>
  15702. [HttpPost]
  15703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15704. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  15705. {
  15706. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  15707. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15708. var diids = groupInfos.Select(it => it.Id).ToList();
  15709. List<string> countrys = new List<string>();
  15710. foreach (var item in country)
  15711. {
  15712. var data = _groupRepository.FormartTeamName(item);
  15713. var dataArray = _groupRepository.GroupSplitCountry(data);
  15714. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15715. }
  15716. countrys = countrys.Distinct().ToList();
  15717. for (int i = 0; i < countrys.Count; i++)
  15718. {
  15719. string item = countrys[i];
  15720. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  15721. {
  15722. countrys.Remove(item);
  15723. i--;
  15724. }
  15725. }
  15726. RefAsync<int> total = 0;
  15727. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  15728. .Where(it => countrys.Contains(it.Name_CN))
  15729. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15730. .Select(it => new { id = it.Id, name = it.Name_CN })
  15731. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15732. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15733. }
  15734. /// <summary>
  15735. /// 查看邀请方
  15736. /// 城市信息 Init
  15737. /// </summary>
  15738. /// <param name="dto"></param>
  15739. /// <returns></returns>
  15740. [HttpPost]
  15741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15742. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  15743. {
  15744. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  15745. RefAsync<int> total = 0;
  15746. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  15747. .Where(it => it.CountriesId == dto.CountiesId)
  15748. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15749. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  15750. .Select(it => new { id = it.Id, name = it.Name_CN })
  15751. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15752. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15753. }
  15754. /// <summary>
  15755. /// 查看邀请方
  15756. /// 团组名称 Init
  15757. /// </summary>
  15758. /// <param name="dto"></param>
  15759. /// <returns></returns>
  15760. [HttpPost]
  15761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15762. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  15763. {
  15764. var watch = new Stopwatch();
  15765. watch.Start();
  15766. RefAsync<int> total = 0;
  15767. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  15768. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  15769. .Where((oa, di) => oa.IsDel == 0)
  15770. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  15771. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  15772. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  15773. .Distinct()
  15774. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15775. watch.Stop();
  15776. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  15777. }
  15778. /// <summary>
  15779. /// 查看邀请方
  15780. /// 团组 & 邀请方信息
  15781. /// </summary>
  15782. /// <param name="dto"></param>
  15783. /// <returns></returns>
  15784. [HttpPost]
  15785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15786. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  15787. {
  15788. var watch = new Stopwatch();
  15789. watch.Start();
  15790. RefAsync<int> total = 0;
  15791. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  15792. .AS("Grp_DelegationInfo")
  15793. .Includes(x => x.InvitingInfos)
  15794. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  15795. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  15796. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  15797. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  15798. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  15799. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  15800. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15801. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  15802. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  15803. infos.ForEach(x =>
  15804. {
  15805. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  15806. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  15807. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  15808. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  15809. });
  15810. watch.Stop();
  15811. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  15812. }
  15813. #endregion
  15814. #region 报批行程
  15815. /// <summary>
  15816. /// 报批行程初始化
  15817. /// </summary>
  15818. /// <param name="dto"></param>
  15819. /// <returns></returns>
  15820. [HttpPost]
  15821. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  15822. {
  15823. const int chiNumber = 5;
  15824. var jw = JsonView(false);
  15825. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  15826. var group = groupList.First();
  15827. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  15828. group = groupList.First(x => x.Id == diid);
  15829. if (group == null)
  15830. {
  15831. jw.Msg = "暂无团组!";
  15832. return Ok(jw);
  15833. }
  15834. var data = new
  15835. {
  15836. groupList = groupList.Select(x => new
  15837. {
  15838. x.TeamName,
  15839. x.Id
  15840. }),
  15841. content = new ArrayList(),
  15842. groupInfo = new
  15843. {
  15844. group.VisitDays,
  15845. group.TourCode,
  15846. group.VisitPNumber,
  15847. group.TeamName,
  15848. group.Id,
  15849. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  15850. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  15851. },
  15852. };
  15853. var resultArr = new ArrayList();
  15854. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  15855. if (content.Count == 0)
  15856. {
  15857. var stay = "-";
  15858. var cityPath = "-";
  15859. //添加城市路径以及住宿地
  15860. //黑屏代码数据
  15861. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  15862. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  15863. {
  15864. jw = JsonView(true, "黑屏代码有误!", data);
  15865. return Ok(jw);
  15866. }
  15867. foreach (DataRow row in dtBlack.Rows)
  15868. {
  15869. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  15870. {
  15871. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  15872. return Ok(jw);
  15873. }
  15874. }
  15875. //黑屏代码获取时间区间
  15876. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  15877. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  15878. _sqlSugar.BeginTran();
  15879. for (int i = 0; i < timeArr.Count; i++)
  15880. {
  15881. stay = "-";
  15882. cityPath = "-";
  15883. DateTime NewData = DateTime.Parse(timeArr[i]);
  15884. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  15885. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  15886. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  15887. if (tbSelect.Length > 0)
  15888. {
  15889. List<string> threeCodeStr = new List<string>();
  15890. foreach (var item in tbSelect)
  15891. {
  15892. var threeCode = item["Three"].ToString() ?? "";
  15893. if (threeCode.Length == 6)
  15894. {
  15895. var start = threeCode.Substring(0, 3);
  15896. var end = threeCode.Substring(3, 3);
  15897. if (threeCodeStr.Count == 0)
  15898. {
  15899. threeCodeStr.Add(start);
  15900. threeCodeStr.Add(end);
  15901. }
  15902. else
  15903. {
  15904. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  15905. {
  15906. threeCodeStr.Add(end);
  15907. }
  15908. else
  15909. {
  15910. threeCodeStr.Add(start);
  15911. threeCodeStr.Add(end);
  15912. }
  15913. }
  15914. }
  15915. }
  15916. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  15917. var last = threeCodeStr.Last();
  15918. foreach (var item in threeCodeStr)
  15919. {
  15920. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  15921. if (item.Equals(last))
  15922. {
  15923. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  15924. }
  15925. }
  15926. cityPath = cityPath.Trim('-');
  15927. }
  15928. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  15929. appro.Diid = diid ?? -1;
  15930. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  15931. appro.Id = thisId;
  15932. appro.CreateUserId = dto.UserId;
  15933. appro.CreateTime = DateTime.Now;
  15934. content.Add(appro);
  15935. }
  15936. _sqlSugar.CommitTran();
  15937. }
  15938. foreach (var x in content)
  15939. {
  15940. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  15941. if (chiList.Count < chiNumber)
  15942. {
  15943. for (int i = chiList.Count; i < chiNumber; i++)
  15944. {
  15945. chiList.Add(new Grp_ApprovalTravelDetails());
  15946. }
  15947. }
  15948. resultArr.Add(new
  15949. {
  15950. x.Id,
  15951. x.Date,
  15952. x.Diid,
  15953. chiList = chiList.Select(x1 => new
  15954. {
  15955. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  15956. x1.Details,
  15957. x1.ParentId,
  15958. x1.Id
  15959. })
  15960. });
  15961. }
  15962. data = data with
  15963. {
  15964. content = resultArr,
  15965. };
  15966. jw = JsonView(true, "获取成功!", data);
  15967. return Ok(jw);
  15968. }
  15969. /// <summary>
  15970. /// 报批行程删除
  15971. /// </summary>
  15972. /// <param name="dto"></param>
  15973. /// <returns></returns>
  15974. [HttpPost]
  15975. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  15976. {
  15977. var jw = JsonView(false);
  15978. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  15979. if (group == null)
  15980. {
  15981. jw.Msg = "团组参数有误!";
  15982. return Ok(jw);
  15983. }
  15984. try
  15985. {
  15986. _sqlSugar.BeginTran();
  15987. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  15988. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  15989. {
  15990. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  15991. DeleteUserId = dto.uesrId,
  15992. IsDel = 1
  15993. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  15994. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  15995. {
  15996. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  15997. DeleteUserId = dto.uesrId,
  15998. IsDel = 1
  15999. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  16000. _sqlSugar.CommitTran();
  16001. jw = JsonView(true, "删除成功");
  16002. }
  16003. catch (Exception ex)
  16004. {
  16005. jw = JsonView(false, ex.Message);
  16006. }
  16007. return Ok(jw);
  16008. }
  16009. /// <summary>
  16010. /// 报批行程保存
  16011. /// </summary>
  16012. /// <param name="dto"></param>
  16013. /// <returns></returns>
  16014. [HttpPost]
  16015. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  16016. {
  16017. var jw = JsonView(false);
  16018. var Find = dto.Arr.Find(x => x.id == 0);
  16019. if (Find != null)
  16020. {
  16021. jw.Msg = "生成的ID为0!";
  16022. return Ok(jw);
  16023. }
  16024. foreach (var item in dto.Arr)
  16025. {
  16026. foreach (var chi in item.chiList)
  16027. {
  16028. if (chi.parentId == 0)
  16029. {
  16030. chi.parentId = item.id;
  16031. }
  16032. }
  16033. }
  16034. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  16035. _sqlSugar.BeginTran();
  16036. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  16037. {
  16038. var parentIds = dto.Arr.Select(x => x.id).ToList();
  16039. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  16040. {
  16041. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16042. DeleteUserId = dto.UserId,
  16043. IsDel = 1
  16044. }).ExecuteCommand();
  16045. }
  16046. try
  16047. {
  16048. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  16049. {
  16050. CreateTime = DateTime.Now,
  16051. CreateUserId = dto.UserId,
  16052. Details = x.details,
  16053. ParentId = x.parentId,
  16054. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  16055. Remark = "",
  16056. IsDel = 0
  16057. }).ToList()).ExecuteCommand();
  16058. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  16059. {
  16060. Id = x.id,
  16061. Details = x.details,
  16062. ParentId = x.parentId,
  16063. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  16064. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  16065. {
  16066. Details = x.Details,
  16067. ParentId = x.ParentId,
  16068. Time = x.Time
  16069. }).ExecuteCommand();
  16070. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  16071. {
  16072. Id = x.id,
  16073. Date = x.date,
  16074. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  16075. {
  16076. Date = x.Date
  16077. }).ExecuteCommand();
  16078. _sqlSugar.CommitTran();
  16079. jw = JsonView(true, "保存成功!");
  16080. }
  16081. catch (Exception ex)
  16082. {
  16083. _sqlSugar.RollbackTran();
  16084. jw = JsonView(false, "保存失败!" + ex.Message);
  16085. }
  16086. return Ok(jw);
  16087. }
  16088. /// <summary>
  16089. /// 报批行程生成
  16090. /// </summary>
  16091. /// <param name="dto"></param>
  16092. /// <returns></returns>
  16093. [HttpPost]
  16094. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  16095. {
  16096. var jw = JsonView(false);
  16097. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16098. if (group == null)
  16099. {
  16100. jw.Msg = "暂无该团组!";
  16101. return Ok(jw);
  16102. }
  16103. //黑屏代码数据
  16104. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  16105. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  16106. {
  16107. jw.Msg = "黑屏代码有误!";
  16108. return Ok(jw);
  16109. }
  16110. foreach (DataRow row in dtBlack.Rows)
  16111. {
  16112. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  16113. {
  16114. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  16115. return Ok(jw);
  16116. }
  16117. }
  16118. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  16119. var resultArr = new ArrayList();
  16120. if (officialActivitiesArr.Count == 0)
  16121. {
  16122. jw.Msg = "暂无公务出访信息!";
  16123. return Ok(jw);
  16124. }
  16125. try
  16126. {
  16127. _sqlSugar.BeginTran();
  16128. DeleteApprovalJourney(new
  16129. Domain.Dtos.Groups.DeleteApprovalJourney
  16130. {
  16131. Diid = dto.Diid,
  16132. uesrId = dto.Userid
  16133. });
  16134. var stay = "-";
  16135. var cityPath = "-";
  16136. //添加城市路径以及住宿地
  16137. //黑屏代码获取时间区间
  16138. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  16139. var empty = "【未收入该三字码!请机票同事录入】";
  16140. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  16141. for (int i = 0; i < timeArr.Count; i++)
  16142. {
  16143. stay = "-";
  16144. cityPath = "-";
  16145. var chiarr = new List<Grp_ApprovalTravelDetails>();
  16146. DateTime NewData = DateTime.Parse(timeArr[i]);
  16147. 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();
  16148. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  16149. if (tbSelect.Length > 0)
  16150. {
  16151. List<string> threeCodeStr = new List<string>();
  16152. bool isTrade = false;
  16153. string trip = string.Empty;
  16154. var rowLast = tbSelect.Last();
  16155. var rowFirst = tbSelect.First();
  16156. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  16157. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  16158. var takeOffTime = DateTime.Parse(timeArr[i]);
  16159. var fallToTime = DateTime.Parse(timeArr[i]);
  16160. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  16161. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  16162. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  16163. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  16164. foreach (var item in tbSelect)
  16165. {
  16166. var start = string.Empty;
  16167. var end = string.Empty;
  16168. var threeCode = item["Three"].ToString() ?? "";
  16169. if (threeCode.Length == 6)
  16170. {
  16171. start = threeCode.Substring(0, 3);
  16172. end = threeCode.Substring(3, 3);
  16173. if (threeCodeStr.Count == 0)
  16174. {
  16175. threeCodeStr.Add(start);
  16176. threeCodeStr.Add(end);
  16177. }
  16178. else
  16179. {
  16180. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  16181. {
  16182. threeCodeStr.Add(end);
  16183. }
  16184. else
  16185. {
  16186. threeCodeStr.Add(start);
  16187. threeCodeStr.Add(end);
  16188. }
  16189. }
  16190. }
  16191. //处理机票信息
  16192. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  16193. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  16194. if (start_Object == null)
  16195. {
  16196. start_Object = new Res_ThreeCode()
  16197. {
  16198. AirPort = empty,
  16199. AirPort_En = empty,
  16200. City = empty,
  16201. Country = empty,
  16202. Four = empty,
  16203. Three = empty,
  16204. };
  16205. }
  16206. if (end_Object == null)
  16207. {
  16208. end_Object = new Res_ThreeCode()
  16209. {
  16210. AirPort = empty,
  16211. AirPort_En = empty,
  16212. City = empty,
  16213. Country = empty,
  16214. Four = empty,
  16215. Three = empty,
  16216. };
  16217. }
  16218. //机型判断
  16219. string airModel = item["AirModel"].ToString();
  16220. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  16221. string flightTime = item["FlightTime"].ToString();
  16222. if (flightTime!.Contains(":"))
  16223. {
  16224. flightTime = flightTime.Replace(":", "小时");
  16225. flightTime += "分钟";
  16226. }
  16227. if (flightTime.Contains("H"))
  16228. {
  16229. flightTime = flightTime.Replace("H", "小时");
  16230. }
  16231. if (flightTime.Contains("M"))
  16232. {
  16233. flightTime = flightTime.Replace("M", "分钟");
  16234. }
  16235. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  16236. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  16237. {
  16238. flightTime = flightDataTime.Hour > 0
  16239. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  16240. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  16241. ? flightDataTime.Minute.ToString() + "分钟" : "";
  16242. }
  16243. //航班号
  16244. string flightcode = item["Fliagtcode"].ToString();
  16245. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  16246. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  16247. if (aircompany == null)
  16248. {
  16249. aircompany = new Res_AirCompany
  16250. {
  16251. CnName = hsEmpty,
  16252. EnName = hsEmpty,
  16253. ShortCode = hsEmpty,
  16254. };
  16255. }
  16256. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  16257. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  16258. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  16259. if (isTrade)
  16260. {
  16261. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  16262. }
  16263. else
  16264. {
  16265. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  16266. }
  16267. }
  16268. chiarr.Add(new Grp_ApprovalTravelDetails
  16269. {
  16270. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  16271. CreateTime = DateTime.Now,
  16272. CreateUserId = dto.Userid,
  16273. ParentId = 0,
  16274. Details = trip
  16275. });
  16276. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  16277. var last = threeCodeStr.Last();
  16278. foreach (var item in threeCodeStr)
  16279. {
  16280. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  16281. if (item.Equals(last))
  16282. {
  16283. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  16284. }
  16285. }
  16286. cityPath = cityPath.Trim('-');
  16287. }
  16288. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  16289. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  16290. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  16291. appro.Diid = dto.Diid;
  16292. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  16293. appro.Id = thisId;
  16294. appro.CreateUserId = dto.Userid;
  16295. appro.CreateTime = DateTime.Now;
  16296. foreach (var item in gwinfo)
  16297. {
  16298. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  16299. chi.Details = "拜访" + item.Client;
  16300. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  16301. {
  16302. chi.Details += "," + item.ReqSample;
  16303. }
  16304. chi.ParentId = thisId;
  16305. chi.Time = item.Time;
  16306. chiarr.Add(chi);
  16307. }
  16308. if (chiarr.Count < 5)
  16309. {
  16310. for (int j = chiarr.Count; j < 5; j++)
  16311. {
  16312. chiarr.Add(new
  16313. Grp_ApprovalTravelDetails());
  16314. }
  16315. }
  16316. resultArr.Add(new
  16317. {
  16318. appro.Id,
  16319. appro.Date,
  16320. appro.Diid,
  16321. chiList = chiarr.Select(x1 => new
  16322. {
  16323. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  16324. x1.Details,
  16325. x1.ParentId,
  16326. x1.Id
  16327. })
  16328. });
  16329. }
  16330. _sqlSugar.CommitTran();
  16331. jw = JsonView(true, "生成成功!", resultArr);
  16332. }
  16333. catch (Exception ex)
  16334. {
  16335. jw.Code = 400;
  16336. jw.Msg = "生成失败!" + ex.Message;
  16337. }
  16338. return Ok(jw);
  16339. }
  16340. /// <summary>
  16341. /// 报批行程word导出
  16342. /// </summary>
  16343. /// <param name="dto"></param>
  16344. /// <returns></returns>
  16345. [HttpPost]
  16346. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  16347. {
  16348. var jw = JsonView(false);
  16349. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16350. if (group == null)
  16351. {
  16352. jw.Msg = "暂无该团组!";
  16353. return Ok(jw);
  16354. }
  16355. //模板路径
  16356. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  16357. //载入模板
  16358. Document doc = new Document(tempPath);
  16359. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16360. //获取所填表格的序数
  16361. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16362. Aspose.Words.Tables.Row titleRowClone = null;
  16363. Aspose.Words.Tables.Row CenterRowClone = null;
  16364. int index = 0;
  16365. int indexChi = 0;
  16366. int SetIndex = 0;
  16367. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  16368. //获取数据,放到datatable
  16369. foreach (var item in ApprovalTravelArr)
  16370. {
  16371. if (index > 0)
  16372. {
  16373. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  16374. tableOne.AppendChild(titleRowClone);
  16375. }
  16376. var textTime = item.Date;
  16377. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  16378. SetCells(tableOne, doc, SetIndex, 0, textTime);
  16379. SetIndex++;
  16380. if (ChiRep.Count > 0)
  16381. {
  16382. foreach (var itemChi in ChiRep)
  16383. {
  16384. var txtTime = itemChi.Time;
  16385. var txtDetail = itemChi.Details;
  16386. if (indexChi > 0)
  16387. {
  16388. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16389. tableOne.AppendChild(CenterRowClone);
  16390. }
  16391. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  16392. {
  16393. SetCells(tableOne, doc, SetIndex, 0, "");
  16394. SetCells(tableOne, doc, SetIndex, 1, "");
  16395. indexChi++;
  16396. SetIndex++;
  16397. break;
  16398. }
  16399. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  16400. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  16401. indexChi++;
  16402. SetIndex++;
  16403. }
  16404. }
  16405. else
  16406. {
  16407. if (indexChi > 0)
  16408. {
  16409. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16410. tableOne.AppendChild(CenterRowClone);
  16411. }
  16412. SetCells(tableOne, doc, SetIndex, 0, "");
  16413. SetCells(tableOne, doc, SetIndex, 1, "");
  16414. indexChi++;
  16415. SetIndex++;
  16416. }
  16417. index++;
  16418. }
  16419. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  16420. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16421. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16422. jw.Code = 200;
  16423. jw.Msg = "";
  16424. return Ok(jw);
  16425. }
  16426. private string intToString(int numberVal)
  16427. {
  16428. string numberval = numberVal.ToString();
  16429. Dictionary<char, string> Number = new Dictionary<char, string>();
  16430. Number.Add('1', "一");
  16431. Number.Add('2', "二");
  16432. Number.Add('3', "三");
  16433. Number.Add('4', "四");
  16434. Number.Add('5', "五");
  16435. Number.Add('6', "六");
  16436. Number.Add('7', "七");
  16437. Number.Add('8', "八");
  16438. Number.Add('9', "九");
  16439. string stringNumberVal = string.Empty;
  16440. for (int i = 0; i < numberval.Length; i++)
  16441. {
  16442. if (i == 0)
  16443. {
  16444. stringNumberVal += Number[numberval[i]];
  16445. }
  16446. else if (i >= 1)
  16447. {
  16448. if (numberval[i] == '0')
  16449. {
  16450. stringNumberVal = "十";
  16451. }
  16452. else
  16453. {
  16454. stringNumberVal += "十" + Number[numberval[i]];
  16455. }
  16456. }
  16457. }
  16458. return stringNumberVal;
  16459. }
  16460. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  16461. {
  16462. //获取table中的某个单元格,从0开始
  16463. Cell lshCell = table.Rows[rows].Cells[cells];
  16464. //将单元格中段落移除
  16465. foreach (Node item in lshCell.Paragraphs)
  16466. {
  16467. lshCell.Paragraphs.Remove(item);
  16468. }
  16469. if (val.Contains("\r\n"))
  16470. {
  16471. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  16472. foreach (var item in spArr)
  16473. {
  16474. //新建一个段落
  16475. Paragraph p = new Paragraph(doc);
  16476. var r = new Run(doc, item);
  16477. //把设置的值赋给之前新建的段落
  16478. p.AppendChild(r);
  16479. //将此段落加到单元格内
  16480. lshCell.AppendChild(p);
  16481. }
  16482. }
  16483. else
  16484. {
  16485. //新建一个段落
  16486. Paragraph p = new Paragraph(doc);
  16487. var r = new Run(doc, val);
  16488. //把设置的值赋给之前新建的段落
  16489. p.AppendChild(r);
  16490. //将此段落加到单元格内
  16491. lshCell.AppendChild(p);
  16492. }
  16493. }
  16494. [HttpPost]
  16495. public async Task<IActionResult> ServerHttp(string paramStr)
  16496. {
  16497. paramStr = paramStr.TrimEnd('\'');
  16498. paramStr = paramStr.TrimStart('\'');
  16499. JsonView jw = JsonView(false);
  16500. JObject param = JObject.Parse(paramStr);
  16501. if (!param.ContainsKey("url"))
  16502. {
  16503. jw.Msg = "url null";
  16504. return Ok(jw);
  16505. }
  16506. string url = param["url"]!.ToString();
  16507. var methon = "get";
  16508. Dictionary<string, string> headValues = null;
  16509. string bodyStr = string.Empty;
  16510. if (param.ContainsKey("methon"))
  16511. {
  16512. methon = param["methon"]!.ToString().ToLower();
  16513. }
  16514. if (param.ContainsKey("header"))
  16515. {
  16516. var header = param["header"]!.ToString();
  16517. JObject headerJobject = JObject.Parse(header);
  16518. headValues = new Dictionary<string, string>();
  16519. foreach (JProperty item in headerJobject.Properties())
  16520. {
  16521. var value = item.Value.ToString();
  16522. var head = item.Path;
  16523. headValues.Add(head, value);
  16524. }
  16525. }
  16526. HttpClient client = new HttpClient();
  16527. string responseString = string.Empty;
  16528. StringContent content = null;
  16529. if (headValues != null)
  16530. {
  16531. foreach (var item in headValues.Keys)
  16532. {
  16533. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  16534. {
  16535. if (param.ContainsKey("body"))
  16536. {
  16537. bodyStr = param["body"]!.ToString();
  16538. }
  16539. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  16540. }
  16541. else
  16542. {
  16543. client.DefaultRequestHeaders.Add(item, headValues[item]);
  16544. }
  16545. }
  16546. }
  16547. try
  16548. {
  16549. if (methon == "get")
  16550. {
  16551. responseString = await client.GetStringAsync(url);
  16552. }
  16553. else if (methon == "post")
  16554. {
  16555. var request = new HttpRequestMessage(HttpMethod.Post, url)
  16556. {
  16557. Content = content
  16558. };
  16559. var response = await client.SendAsync(request);
  16560. try
  16561. {
  16562. Stream responseStream = await response.Content.ReadAsStreamAsync();
  16563. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  16564. {
  16565. using (StreamReader reader = new StreamReader(gzipStream))
  16566. {
  16567. responseString = await reader.ReadToEndAsync();
  16568. }
  16569. }
  16570. }
  16571. catch (Exception)
  16572. {
  16573. responseString = await response.Content.ReadAsStringAsync();
  16574. }
  16575. }
  16576. else
  16577. {
  16578. responseString = "methon error";
  16579. }
  16580. jw = JsonView(true, "success", responseString);
  16581. }
  16582. catch (Exception ex)
  16583. {
  16584. jw.Msg = "error " + ex.Message;
  16585. jw.Data = ex.StackTrace;
  16586. }
  16587. finally
  16588. {
  16589. client.Dispose();
  16590. }
  16591. return Ok(jw);
  16592. }
  16593. #endregion
  16594. #region 团组接待意见调查
  16595. /// <summary>
  16596. /// 团组接待意见调查 - 信息管理
  16597. /// 基础数据(团组)
  16598. /// </summary>
  16599. /// <param name="dto"></param>
  16600. /// <returns></returns>
  16601. [HttpGet]
  16602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16603. public async Task<IActionResult> OpinionaireInit()
  16604. {
  16605. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  16606. .Select(x => new
  16607. {
  16608. x.Id,
  16609. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  16610. })
  16611. .OrderByDescending(x => x.Id)
  16612. .ToListAsync();
  16613. return Ok(JsonView(groupData, groupData.Count));
  16614. }
  16615. /// <summary>
  16616. /// 团组接待意见调查 - 信息管理
  16617. /// 列表
  16618. /// </summary>
  16619. /// <param name="groupId"></param>
  16620. /// <returns></returns>
  16621. [HttpGet("{groupId}")]
  16622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16623. public async Task<IActionResult> OpinionaireManageList(int groupId)
  16624. {
  16625. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16626. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  16627. .Select(x => new
  16628. {
  16629. x.Id,
  16630. x.TourGuideName,
  16631. x.CityName,
  16632. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  16633. x.CreateTime
  16634. })
  16635. .OrderBy(x => x.Id)
  16636. .ToListAsync();
  16637. return Ok(JsonView(data));
  16638. }
  16639. /// <summary>
  16640. /// 团组接待意见调查 - 信息管理
  16641. /// 保存
  16642. /// </summary>
  16643. /// <param name="dto"></param>
  16644. /// <returns></returns>
  16645. [HttpPost]
  16646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16647. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  16648. {
  16649. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16650. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16651. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16652. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  16653. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  16654. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  16655. _opinionaireRep.BeginTran();
  16656. if (addData != null && addData.Count > 0)
  16657. {
  16658. foreach (var item in addData)
  16659. {
  16660. item.CreateUserId = currUserInfo.UserId;
  16661. item.DiId = dto.DiId;
  16662. }
  16663. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  16664. }
  16665. if (updData != null && updData.Count > 0)
  16666. {
  16667. var upd = await _opinionaireRep._sqlSugar
  16668. .Updateable(updData)
  16669. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  16670. .WhereColumns(x => new { x.Id })
  16671. .ExecuteCommandAsync();
  16672. }
  16673. _opinionaireRep.CommitTran();
  16674. return Ok(JsonView("操作成功!"));
  16675. }
  16676. /// <summary>
  16677. /// 团组接待意见调查 - 信息管理
  16678. /// 删除
  16679. /// </summary>
  16680. /// <param name="id"></param>
  16681. /// <returns></returns>
  16682. [HttpDelete("{id}")]
  16683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16684. public async Task<IActionResult> OpinionaireManageDel(int id)
  16685. {
  16686. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16687. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16688. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  16689. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  16690. if (!del) return Ok(JsonView("操作失败!"));
  16691. return Ok(JsonView("操作成功!"));
  16692. }
  16693. /// <summary>
  16694. /// 团组接待意见调查 - 用户
  16695. /// 列表
  16696. /// </summary>
  16697. /// <param name="id"></param>
  16698. /// <returns></returns>
  16699. [HttpGet("{diId}")]
  16700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16701. public async Task<IActionResult> OpinionaireUserList(int diId)
  16702. {
  16703. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16704. var sql = string.Format(@"
  16705. SELECT
  16706. o.Id,
  16707. o.DiId,
  16708. di.TeamName AS 'GroupName',
  16709. di.VisitPNumber AS 'PeopleNumber',
  16710. di.ClientName AS 'LeadGroup',
  16711. di.VisitCountry AS 'Travel',
  16712. di.VisitDays AS 'Days',
  16713. o.CityName,
  16714. o.TourGuideName,
  16715. o.Catering,
  16716. o.CateringReason,
  16717. o.Stay,
  16718. o.StayReason,
  16719. o.[Route],
  16720. o.RouteReason,
  16721. o.OfficialActivity,
  16722. o.OfficialActivityReason,
  16723. o.TourGuide,
  16724. o.TourGuideReason,
  16725. o.[Translate],
  16726. o.TranslateReason,
  16727. o.Trip,
  16728. o.TripReason,
  16729. o.ESFileName,
  16730. o.SignatureDate,
  16731. o.Remark
  16732. FROM
  16733. Grp_Opinionaire o
  16734. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  16735. WHERE
  16736. o.IsDel = 0
  16737. AND o.DiId = {0}
  16738. ORDER BY
  16739. o.Id ASC", diId);
  16740. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  16741. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  16742. return Ok(JsonView(data));
  16743. }
  16744. /// <summary>
  16745. /// 团组接待意见调查 - 用户
  16746. /// 保存
  16747. /// </summary>
  16748. /// <param name="id"></param>
  16749. /// <returns></returns>
  16750. [HttpPost]
  16751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16752. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  16753. {
  16754. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  16755. foreach (var item in dto)
  16756. {
  16757. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  16758. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  16759. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  16760. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  16761. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  16762. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  16763. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  16764. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  16765. }
  16766. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  16767. if (!Directory.Exists(filePathBase))
  16768. {
  16769. Directory.CreateDirectory(filePathBase);
  16770. }
  16771. #region 上传文件
  16772. var filePaths = new List<string>();
  16773. foreach (var item in dto)
  16774. {
  16775. var file = item.File;
  16776. // 将文件保存到指定位置
  16777. var filePath = Path.Combine(filePathBase, file.FileName);
  16778. using (var stream = new FileStream(filePath, FileMode.Create))
  16779. {
  16780. await file.CopyToAsync(stream);
  16781. }
  16782. //验证文件是否上传成功
  16783. if (!System.IO.File.Exists(filePath))
  16784. {
  16785. foreach (var filePathStr in filePaths)
  16786. {
  16787. System.IO.File.Delete(filePathStr);
  16788. }
  16789. return Ok(JsonView(false, "文件上传失败!"));
  16790. }
  16791. item.ESFileName = file.FileName;
  16792. }
  16793. #endregion
  16794. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  16795. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  16796. .UpdateColumns(x => new
  16797. {
  16798. x.Catering,
  16799. x.CateringReason,
  16800. x.Stay,
  16801. x.StayReason,
  16802. x.Route,
  16803. x.RouteReason,
  16804. x.OfficialActivity,
  16805. x.OfficialActivityReason,
  16806. x.TourGuide,
  16807. x.TourGuideReason,
  16808. x.Translate,
  16809. x.TranslateReason,
  16810. x.Trip,
  16811. x.TripReason,
  16812. x.ESFileName,
  16813. x.SignatureDate,
  16814. x.Remark
  16815. })
  16816. .WhereColumns(x => new { x.Id })
  16817. .ExecuteCommandAsync();
  16818. if (upd < 1)
  16819. {
  16820. foreach (var filePathStr in filePaths)
  16821. {
  16822. System.IO.File.Delete(filePathStr);
  16823. }
  16824. return Ok(JsonView(false));
  16825. }
  16826. return Ok(JsonView(true));
  16827. }
  16828. #endregion
  16829. // /// <summary>
  16830. // ///
  16831. // /// </summary>
  16832. // /// <param name="_dto"></param>
  16833. // /// <returns></returns>
  16834. // [HttpPost]
  16835. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16836. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  16837. // {
  16838. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  16839. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  16840. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  16841. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  16842. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  16843. // dic_psg.Add("客人", 974);
  16844. // dic_psg.Add("司机", 975);
  16845. // dic_psg.Add("导游", 976);
  16846. // dic_psg.Add("公司内部人员", 977);
  16847. // dic_psg.Add("司机/导游/公司内部人员", 978);
  16848. // foreach (var item in list_visa)
  16849. // {
  16850. // Grp_VisaInfo temp = new Grp_VisaInfo();
  16851. // temp.Id = item.Id;
  16852. // temp.DIId = item.DIId;
  16853. // temp.VisaClient = item.VisaClient;
  16854. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  16855. // temp.VisaCurrency = item.VisaCurrency;
  16856. // temp.IsThird = item.IsThird;
  16857. // if (dic_psg.ContainsKey(item.PassengerType))
  16858. // {
  16859. // temp.PassengerType = dic_psg[item.PassengerType];
  16860. // }
  16861. // else {
  16862. // temp.PassengerType = -1;
  16863. // }
  16864. // temp.VisaNumber = item.VisaNumber;
  16865. // temp.VisaFreeNumber = item.VisaFreeNumber;
  16866. // temp.CreateUserId = item.Operators;
  16867. // DateTime dt_ct;
  16868. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  16869. // if (b_ct)
  16870. // {
  16871. // temp.CreateTime = dt_ct;
  16872. // }
  16873. // else
  16874. // {
  16875. // temp.CreateTime = DateTime.Now;
  16876. // }
  16877. // temp.DeleteTime = "";
  16878. // temp.DeleteUserId = 0;
  16879. // temp.Remark = item.Remark;
  16880. // if (string.IsNullOrEmpty(temp.Remark)) {
  16881. // temp.Remark = "";
  16882. // }
  16883. // temp.IsDel = item.IsDel;
  16884. // temp.VisaDescription = item.VisaAttachment;
  16885. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  16886. //([Id]
  16887. // ,[DIId]
  16888. // ,[VisaClient]
  16889. // ,[VisaPrice]
  16890. // ,[VisaCurrency]
  16891. // ,[IsThird]
  16892. // ,[PassengerType]
  16893. // ,[VisaNumber]
  16894. // ,[VisaFreeNumber]
  16895. // ,[CreateUserId]
  16896. // ,[CreateTime]
  16897. // ,[DeleteTime]
  16898. // ,[DeleteUserId]
  16899. // ,[Remark]
  16900. // ,[IsDel]
  16901. // ,[visaDescription])
  16902. // VALUES
  16903. // ({0},{1},'{2}',{3},{4}
  16904. //,{5},{6},{7},{8},{9}
  16905. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  16906. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  16907. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  16908. //);
  16909. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  16910. // }
  16911. // return Ok(JsonView(true, "操作成功!"));
  16912. // }
  16913. /// <summary>
  16914. /// 123132123
  16915. /// </summary>
  16916. /// <param name="_dto"></param>
  16917. /// <returns></returns>
  16918. [HttpPost]
  16919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16920. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  16921. {
  16922. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  16923. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  16924. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  16925. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  16926. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  16927. dicDetail.Add(789, 1034);
  16928. dicDetail.Add(790, 1035);
  16929. dicDetail.Add(791, 1036);
  16930. dicDetail.Add(792, 1037);
  16931. dicDetail.Add(793, 1038);
  16932. dicDetail.Add(794, 1039);
  16933. dicDetail.Add(795, 1040);
  16934. dicDetail.Add(796, 1041);
  16935. dicDetail.Add(797, 1042);
  16936. dicDetail.Add(798, 1043);
  16937. dicDetail.Add(801, 1044);
  16938. dicDetail.Add(802, 1045);
  16939. dicDetail.Add(803, 1046);
  16940. Dictionary<int, int> dic = new Dictionary<int, int>();
  16941. dic.Add(806, 1027);
  16942. dic.Add(807, 1028);
  16943. dic.Add(808, 1029);
  16944. dic.Add(809, 1030);
  16945. dic.Add(810, 1031);
  16946. dic.Add(811, 1032);
  16947. dic.Add(812, 1033);
  16948. foreach (var item in list_visa)
  16949. {
  16950. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  16951. temp.Coefficient = item.coefficient;
  16952. DateTime dtCrt;
  16953. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  16954. if (b1)
  16955. {
  16956. temp.CreateTime = dtCrt;
  16957. }
  16958. else
  16959. {
  16960. temp.CreateTime = DateTime.Now;
  16961. }
  16962. temp.CreateUserId = item.Operators;
  16963. temp.DeleteTime = "";
  16964. temp.DeleteUserId = 0;
  16965. temp.DiId = int.Parse(item.DIID);
  16966. temp.FilePath = item.FilePath;
  16967. temp.IsDel = item.IsDel;
  16968. temp.Price = item.Price;
  16969. temp.PriceCount = 1;
  16970. temp.PriceCurrency = item.Currency;
  16971. int detailId = 0;
  16972. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  16973. {
  16974. detailId = dicDetail[item.PriceTypeDetail];
  16975. }
  16976. temp.PriceDetailType = detailId;
  16977. temp.PriceDt = DateTime.Now;
  16978. temp.PriceName = item.PriceName;
  16979. temp.PriceSum = item.Price;
  16980. int tid = 0;
  16981. if (dic.ContainsKey(item.PriceType))
  16982. {
  16983. tid = dic[item.PriceType];
  16984. }
  16985. temp.PriceType = tid;
  16986. temp.Remark = item.Remark;
  16987. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  16988. }
  16989. return Ok(JsonView(true, "操作成功!"));
  16990. }
  16991. [HttpPost]
  16992. public IActionResult TimeTest()
  16993. {
  16994. var jw = JsonView(false, "error");
  16995. _sqlSugar.BeginTran();
  16996. try
  16997. {
  16998. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  16999. .Select(x => new Crm_NewClientData
  17000. {
  17001. Id = x.Id,
  17002. Client = x.Client,
  17003. Contact = x.Contact,
  17004. Location = x.Location,
  17005. })
  17006. .ToList();
  17007. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  17008. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  17009. Stopwatch stopwatch = new Stopwatch();
  17010. // 开始计时
  17011. stopwatch.Start();
  17012. foreach (var item in clientList)
  17013. {
  17014. EncryptionProcessor.DecryptProperties(item);
  17015. }
  17016. stopwatch.Stop();
  17017. jw.Code = 200;
  17018. jw.Data = stopwatch.ElapsedMilliseconds;
  17019. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  17020. }
  17021. catch (Exception ex)
  17022. {
  17023. jw.Code = 400;
  17024. jw.Msg = ex.Message;
  17025. }
  17026. return Ok(jw);
  17027. }
  17028. }
  17029. }