GroupsController.cs 1.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using DiffMatchPatch;
  7. using EyeSoft.Runtime.InteropServices;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.SignalR;
  10. using Microsoft.IdentityModel.Tokens;
  11. using Microsoft.VisualBasic;
  12. using MySqlX.XDevAPI.Relational;
  13. using NetTaste;
  14. using NPOI.HSSF.UserModel;
  15. using NPOI.SS.Formula.Functions;
  16. using NPOI.SS.UserModel;
  17. using NPOI.SS.Util;
  18. using NPOI.XSSF.UserModel;
  19. using OASystem.API.Middlewares;
  20. using OASystem.API.OAMethodLib;
  21. using OASystem.API.OAMethodLib.APNs;
  22. using OASystem.API.OAMethodLib.File;
  23. using OASystem.API.OAMethodLib.Hub.HubClients;
  24. using OASystem.API.OAMethodLib.Hub.Hubs;
  25. using OASystem.API.OAMethodLib.JuHeAPI;
  26. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  27. using OASystem.Domain.AesEncryption;
  28. using OASystem.Domain.Attributes;
  29. using OASystem.Domain.Dtos.CRM;
  30. using OASystem.Domain.Dtos.FileDto;
  31. using OASystem.Domain.Dtos.Financial;
  32. using OASystem.Domain.Dtos.Groups;
  33. using OASystem.Domain.Entities.Customer;
  34. using OASystem.Domain.Entities.Financial;
  35. using OASystem.Domain.Entities.Groups;
  36. using OASystem.Domain.ViewModels.Financial;
  37. using OASystem.Domain.ViewModels.Groups;
  38. using OASystem.Domain.ViewModels.QiYeWeChat;
  39. using OASystem.Domain.ViewModels.Statistics;
  40. using OASystem.Infrastructure.Repositories.CRM;
  41. using OASystem.Infrastructure.Repositories.Financial;
  42. using OASystem.Infrastructure.Repositories.Groups;
  43. using OASystem.Infrastructure.Tools;
  44. using Org.BouncyCastle.Crypto;
  45. using Org.BouncyCastle.Utilities;
  46. using Quartz.Util;
  47. using SqlSugar.Extensions;
  48. using System.Collections;
  49. using System.Data;
  50. using System.Diagnostics;
  51. using System.Drawing.Printing;
  52. using System.Globalization;
  53. using System.IO.Compression;
  54. using System.Text.Json;
  55. using System.Web;
  56. using System.Xml.Linq;
  57. using TencentCloud.Ocr.V20181119.Models;
  58. using static OASystem.API.OAMethodLib.JWTHelper;
  59. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  60. using Bookmark = Aspose.Words.Bookmark;
  61. using Cell = Aspose.Words.Tables.Cell;
  62. using Table = Aspose.Words.Tables.Table;
  63. namespace OASystem.API.Controllers
  64. {
  65. /// <summary>
  66. /// 团组相关
  67. /// </summary>
  68. //[Authorize]
  69. [Route("api/[controller]/[action]")]
  70. public class GroupsController : ControllerBase
  71. {
  72. private readonly ILogger<GroupsController> _logger;
  73. private readonly GrpScheduleRepository _grpScheduleRep;
  74. private readonly IMapper _mapper;
  75. private readonly DelegationInfoRepository _groupRepository;
  76. private readonly TaskAssignmentRepository _taskAssignmentRep;
  77. private readonly AirTicketResRepository _airTicketResRep;
  78. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  79. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  80. private readonly DelegationEnDataRepository _delegationEnDataRep;
  81. private readonly DelegationVisaRepository _delegationVisaRep;
  82. private readonly VisaPriceRepository _visaPriceRep;
  83. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  84. private readonly HotelPriceRepository _hotelPriceRep;
  85. private readonly CustomersRepository _customersRep;
  86. private readonly MessageRepository _message;
  87. private readonly SqlSugarClient _sqlSugar;
  88. private readonly TourClientListRepository _tourClientListRep;
  89. private readonly TeamRateRepository _teamRateRep;
  90. #region 成本相关
  91. private readonly CheckBoxsRepository _checkBoxs;
  92. private readonly GroupCostRepository _GroupCostRepository;
  93. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  94. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  95. #endregion
  96. private readonly SetDataRepository _setDataRep;
  97. private string url;
  98. private string path;
  99. private readonly EnterExitCostRepository _enterExitCostRep;
  100. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  101. private readonly UsersRepository _usersRep;
  102. private readonly IJuHeApiService _juHeApi;
  103. private readonly InvertedListRepository _invertedListRep;
  104. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  105. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  106. private readonly ThreeCodeRepository _threeCodeRepository;
  107. private readonly HotelInquiryRepository _hotelInquiryRep;
  108. private readonly FeeAuditRepository _feeAuditRep;
  109. private readonly VisaCommissionRepository _visaCommissionRep;
  110. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  111. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  112. private readonly List<CurrencyInfo> _currencyInit;
  113. private readonly List<int> _portTypeData;
  114. private readonly TableOperationRecordRepository _tableorRep;
  115. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  116. private readonly RestaurantRepository _restaurantRep;
  117. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  118. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  119. /// <summary>
  120. /// 构造函数
  121. /// </summary>
  122. /// <param name="logger"></param>
  123. /// <param name="mapper"></param>
  124. /// <param name="hubContext"></param>
  125. /// <param name="sqlSugar"></param>
  126. /// <param name="grpScheduleRep"></param>
  127. /// <param name="groupRepository"></param>
  128. /// <param name="taskAssignmentRep"></param>
  129. /// <param name="airTicketResRep"></param>
  130. /// <param name="decreasePaymentsRep"></param>
  131. /// <param name="InvitationOfficialActivitiesRep"></param>
  132. /// <param name="delegationEnDataRep"></param>
  133. /// <param name="enterExitCostRep"></param>
  134. /// <param name="delegationVisaRep"></param>
  135. /// <param name="message"></param>
  136. /// <param name="visaPriceRep"></param>
  137. /// <param name="carTouristGuideGroundRep"></param>
  138. /// <param name="checkBoxs"></param>
  139. /// <param name="GroupCostRepository"></param>
  140. /// <param name="CostTypeHotelNumberRepository"></param>
  141. /// <param name="GroupCostParameterRepository"></param>
  142. /// <param name="hotelPriceRep"></param>
  143. /// <param name="customersRep"></param>
  144. /// <param name="setDataRep"></param>
  145. /// <param name="tourClientListRep"></param>
  146. /// <param name="teamRateRep"></param>
  147. /// <param name="usersRep"></param>
  148. /// <param name="juHeApi"></param>
  149. /// <param name="invertedListRep"></param>
  150. /// <param name="visaFeeInfoRep"></param>
  151. /// <param name="ticketBlackCodeRep"></param>
  152. /// <param name="hotelInquiryRep"></param>
  153. /// <param name="threeCodeRepository"></param>
  154. /// <param name="feeAuditRep"></param>
  155. /// <param name="visaCommissionRep"></param>
  156. /// <param name="ffrRep"></param>
  157. /// <param name="opinionaireRep"></param>
  158. /// <param name="tableorRep"></param>
  159. /// <param name="enterExitCostDraftRep"></param>
  160. /// <param name="restaurantRep"></param>
  161. /// <param name="enterExitCostQuoteRep"></param>
  162. /// <param name="grpOrderPreInfoRep"></param>
  163. public GroupsController(
  164. ILogger<GroupsController> logger,
  165. IMapper mapper,
  166. IHubContext<ChatHub, IChatClient> hubContext,
  167. SqlSugarClient sqlSugar,
  168. GrpScheduleRepository grpScheduleRep,
  169. DelegationInfoRepository groupRepository,
  170. TaskAssignmentRepository taskAssignmentRep,
  171. AirTicketResRepository airTicketResRep,
  172. DecreasePaymentsRepository decreasePaymentsRep,
  173. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  174. DelegationEnDataRepository delegationEnDataRep,
  175. EnterExitCostRepository enterExitCostRep,
  176. DelegationVisaRepository delegationVisaRep,
  177. MessageRepository message,
  178. VisaPriceRepository visaPriceRep,
  179. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  180. CheckBoxsRepository checkBoxs,
  181. GroupCostRepository GroupCostRepository,
  182. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  183. GroupCostParameterRepository GroupCostParameterRepository,
  184. HotelPriceRepository hotelPriceRep,
  185. CustomersRepository customersRep,
  186. SetDataRepository setDataRep,
  187. TourClientListRepository tourClientListRep,
  188. TeamRateRepository teamRateRep,
  189. UsersRepository usersRep,
  190. IJuHeApiService juHeApi,
  191. InvertedListRepository invertedListRep,
  192. VisaFeeInfoRepository visaFeeInfoRep,
  193. TicketBlackCodeRepository ticketBlackCodeRep,
  194. HotelInquiryRepository hotelInquiryRep,
  195. ThreeCodeRepository threeCodeRepository,
  196. FeeAuditRepository feeAuditRep,
  197. VisaCommissionRepository visaCommissionRep,
  198. ForeignReceivablesRepository ffrRep,
  199. OpinionaireRepository opinionaireRep,
  200. TableOperationRecordRepository tableorRep,
  201. EnterExitCostDraftRepository enterExitCostDraftRep,
  202. RestaurantRepository restaurantRep,
  203. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  204. GroupOrderPreInfoRepository grpOrderPreInfoRep
  205. )
  206. {
  207. _logger = logger;
  208. _mapper = mapper;
  209. _grpScheduleRep = grpScheduleRep;
  210. _groupRepository = groupRepository;
  211. _taskAssignmentRep = taskAssignmentRep;
  212. _airTicketResRep = airTicketResRep;
  213. _sqlSugar = sqlSugar;
  214. url = AppSettingsHelper.Get("ExcelBaseUrl");
  215. path = AppSettingsHelper.Get("ExcelBasePath");
  216. if (!System.IO.Directory.Exists(path))
  217. {
  218. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  219. }
  220. _decreasePaymentsRep = decreasePaymentsRep;
  221. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  222. _delegationEnDataRep = delegationEnDataRep;
  223. _enterExitCostRep = enterExitCostRep;
  224. _delegationVisaRep = delegationVisaRep;
  225. _message = message;
  226. _visaPriceRep = visaPriceRep;
  227. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  228. _checkBoxs = checkBoxs;
  229. _GroupCostRepository = GroupCostRepository;
  230. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  231. _GroupCostParameterRepository = GroupCostParameterRepository;
  232. _hotelPriceRep = hotelPriceRep;
  233. _customersRep = customersRep;
  234. _setDataRep = setDataRep;
  235. _tourClientListRep = tourClientListRep;
  236. _teamRateRep = teamRateRep;
  237. _hubContext = hubContext;
  238. _usersRep = usersRep;
  239. _juHeApi = juHeApi;
  240. _invertedListRep = invertedListRep;
  241. _visaFeeInfoRep = visaFeeInfoRep;
  242. _ticketBlackCodeRep = ticketBlackCodeRep;
  243. _hotelInquiryRep = hotelInquiryRep;
  244. _threeCodeRepository = threeCodeRepository;
  245. _feeAuditRep = feeAuditRep;
  246. _visaCommissionRep = visaCommissionRep;
  247. _ffrRep = ffrRep;
  248. _opinionaireRep = opinionaireRep;
  249. _currencyInit = new List<CurrencyInfo>()
  250. {
  251. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  252. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  253. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  254. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  255. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  256. };
  257. _portTypeData = new List<int>() { 2, 3 };
  258. _tableorRep = tableorRep;
  259. _enterExitCostDraftRep = enterExitCostDraftRep;
  260. _restaurantRep = restaurantRep;
  261. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  262. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  263. }
  264. #region 流程管控
  265. /// <summary>
  266. /// 获取团组流程管控信息
  267. /// </summary>
  268. /// <param name="_jsonDto">查询参数</param>
  269. /// <returns></returns>
  270. [HttpPost]
  271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  272. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  273. {
  274. if (string.IsNullOrEmpty(_jsonDto.Paras))
  275. {
  276. return Ok(JsonView(false, "参数为空"));
  277. }
  278. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  279. if (_ScheduleDto != null)
  280. {
  281. if (_ScheduleDto.SearchType == 2)//获取列表
  282. {
  283. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  284. return Ok(JsonView(_grpScheduleViewList));
  285. }
  286. else//获取对象
  287. {
  288. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  289. if (_grpScheduleView != null)
  290. {
  291. return Ok(JsonView(_grpScheduleView));
  292. }
  293. }
  294. }
  295. else
  296. {
  297. return Ok(JsonView(false, "参数反序列化失败"));
  298. }
  299. return Ok(JsonView(false, "暂无数据!"));
  300. }
  301. /// <summary>
  302. /// 修改团组流程管控详细表数据
  303. /// </summary>
  304. /// <param name="dto"></param>
  305. /// <returns></returns>
  306. [HttpPost]
  307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  308. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  309. {
  310. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  311. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  312. .SetColumns(it => it.Duty == _detail.Duty)
  313. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  314. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  315. .SetColumns(it => it.JobContent == _detail.JobContent)
  316. .SetColumns(it => it.Remark == _detail.Remark)
  317. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  318. .Where(s => s.Id == dto.Id)
  319. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  320. .ExecuteCommandAsync();
  321. if (result > 0)
  322. {
  323. return Ok(JsonView(true, "保存成功!"));
  324. }
  325. return Ok(JsonView(false, "保存失败!"));
  326. }
  327. /// <summary>
  328. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  329. /// </summary>
  330. /// <param name="dto"></param>
  331. /// <returns></returns>
  332. [HttpPost]
  333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  334. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  335. {
  336. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  337. _detail.IsDel = 1;
  338. _detail.DeleteUserId = dto.Duty;
  339. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  340. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  341. .SetColumns(it => it.IsDel == _detail.IsDel)
  342. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  343. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  344. .Where(it => it.Id == dto.Id)
  345. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  346. //.WhereColumns(s => s.Id == dto.Id)
  347. .ExecuteCommandAsync();
  348. if (result > 0)
  349. {
  350. return Ok(JsonView(true, "删除成功!"));
  351. }
  352. return Ok(JsonView(false, "删除失败!"));
  353. }
  354. /// <summary>
  355. /// 增加团组流程管控详细表数据
  356. /// </summary>
  357. /// <param name="dto"></param>
  358. /// <returns></returns>
  359. [HttpPost]
  360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  361. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  362. {
  363. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  364. if (DateTime.Now < _detail.ExpectBeginDt)
  365. {
  366. _detail.StepStatus = 0;
  367. }
  368. else
  369. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  370. _detail.StepStatus = 1;
  371. }
  372. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  373. if (result > 0)
  374. {
  375. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  376. return Ok(JsonView(true, "添加成功!", _result));
  377. }
  378. return Ok(JsonView(false, "添加失败!"));
  379. }
  380. #endregion
  381. #region 团组前期信息
  382. /// <summary>
  383. /// 团组前期信息 List
  384. /// </summary>
  385. /// <returns></returns>
  386. [HttpPost]
  387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  388. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  389. {
  390. var search = dto.Search;
  391. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  392. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  393. .Where((opi, u) => opi.IsDel == 0)
  394. .OrderByDescending((opi, u) => opi.CreateTime)
  395. .Select((opi, u) => new GroupOrderPreInfoListView()
  396. {
  397. Id = opi.Id,
  398. Name = opi.Name,
  399. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && x.FormTempId == 1).Select(x => x.Value),
  400. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && x.FormTempId == 2).Select(x => x.Value),
  401. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && x.FormTempId == 4).Select(x => x.Value),
  402. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && x.FormTempId == 6).Select(x => x.Value),
  403. Operator = u.CnName,
  404. OperationTime = opi.CreateTime
  405. })
  406. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  407. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  408. .ToListAsync();
  409. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  410. int total = list.Count;
  411. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  412. var listPageData1 = listPageData
  413. .Skip((dto.PageIndex - 1) * dto.PageSize)
  414. .Take(dto.PageSize)
  415. .ToList();
  416. var infoIds = listPageData1.Select(x => x.Id).ToList();
  417. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  418. .Where(x => x.IsDel == 0 && x.STid == 109)
  419. .ToArrayAsync();
  420. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  421. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  422. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  423. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  424. .ToListAsync();
  425. foreach (var item in listPageData1)
  426. {
  427. var typeDatas1 = typeDatas.Select(x => new
  428. {
  429. Id = x.Id,
  430. Name = x.Name,
  431. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  432. }).ToArray();
  433. item.VersionDetails = typeDatas1;
  434. }
  435. return Ok(JsonView(listPageData1, listPageData1.Count));
  436. }
  437. /// <summary>
  438. /// 团组前期信息 Init
  439. /// </summary>
  440. /// <returns></returns>
  441. [HttpGet("{userId}")]
  442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  443. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  444. {
  445. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  446. }
  447. /// <summary>
  448. /// 国家数据源
  449. /// </summary>
  450. /// <returns></returns>
  451. [HttpGet]
  452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  453. public async Task<IActionResult> CountryInit()
  454. {
  455. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  456. return Ok(JsonView(countrys));
  457. }
  458. /// <summary>
  459. /// 城市数据源
  460. /// </summary>
  461. /// <returns></returns>
  462. [HttpGet("{countryLabel}")]
  463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  464. public async Task<IActionResult> CityByCountry(string countryLabel)
  465. {
  466. countryLabel = HttpUtility.UrlDecode(countryLabel);
  467. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  468. var citys = Array.Empty<string?>();
  469. if (countryList.Any())
  470. {
  471. var cityDatas = await _sqlSugar
  472. .Queryable<Grp_NationalTravelFee>()
  473. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  474. .ToArrayAsync();
  475. foreach (var item in cityDatas)
  476. {
  477. if (item.City.Contains("城市"))
  478. {
  479. item.City = item.Country + "-所有城市";
  480. }
  481. }
  482. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  483. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  484. }
  485. return Ok(JsonView(citys));
  486. }
  487. /// <summary>
  488. /// 团组前期信息 Info
  489. /// </summary>
  490. /// <param name="dto">Id</param>
  491. /// <returns></returns>
  492. [HttpGet("{Id}/{TempId}")]
  493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  494. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  495. {
  496. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  497. }
  498. /// <summary>
  499. /// 团组前期信息 Save
  500. /// </summary>
  501. /// <param name="dto">Id</param>
  502. /// <returns></returns>
  503. [HttpPost]
  504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  505. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  506. {
  507. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  508. }
  509. /// <summary>
  510. /// 团组前期信息 文件下载
  511. /// </summary>
  512. /// <param name="dto">Id</param>
  513. /// <returns></returns>
  514. [HttpGet("{Id}/{TempId}")]
  515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  516. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  517. {
  518. int id = dto.Id, tempId = dto.TempId;
  519. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  520. var data = view.Data as GrpOrderPreInfoView;
  521. #region Excel
  522. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  523. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  524. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  525. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  526. var fileNamePrefix = string.Empty;
  527. if (tempId == 1405)
  528. {
  529. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  530. fileNamePrefix = $"{data.Name}_无商邀版";
  531. }
  532. else if (tempId == 1406)
  533. {
  534. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  535. fileNamePrefix = $"{data.Name}_有商邀版";
  536. }
  537. else
  538. {
  539. //tempId == 1404 默认下载
  540. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  541. fileNamePrefix = $"{data.Name}_单接送机";
  542. }
  543. foreach (var item in data.Items)
  544. {
  545. var obj = item.NewValue;
  546. if (obj == null) item.OriginVal = "";
  547. else if (obj.Equals("有") || obj.Equals("无"))
  548. {
  549. item.OriginVal = obj.ToString();
  550. }
  551. else if (obj is object[] objArray)
  552. {
  553. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  554. item.OriginVal = string.Join("、", stringArray);
  555. }
  556. else if (obj is string[] stringArray)
  557. {
  558. item.OriginVal = string.Join("、", stringArray);
  559. }
  560. else if (obj.Equals("-"))
  561. {
  562. item.OriginVal = "";
  563. }
  564. }
  565. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  566. fileName = CommonFun.ValidFileName(fileName);
  567. //载入模板
  568. WorkbookDesigner designer = new WorkbookDesigner();
  569. designer.Workbook = new Workbook(tempPath);
  570. if (tempId == 1406)
  571. {
  572. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  573. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  574. for (int i = 1; i <= view2.Length; i++)
  575. {
  576. view2[i - 1].Index = i;
  577. }
  578. designer.SetDataSource("View1", view1);
  579. designer.SetDataSource("View2", view2);
  580. }
  581. else
  582. {
  583. designer.SetDataSource("View", data.Items);
  584. }
  585. designer.Process();
  586. if (!Directory.Exists(savePath))
  587. {
  588. Directory.CreateDirectory(savePath);
  589. }
  590. string serverPath = $"{savePath}{fileName}";
  591. designer.Workbook.Save(serverPath);
  592. string rst = $"{servicePath}{ftpPath}{fileName}";
  593. #endregion
  594. return Ok(JsonView(new { url = rst }));
  595. }
  596. #endregion
  597. #region 团组基本信息
  598. /// <summary>
  599. /// 接团信息列表
  600. /// </summary>
  601. /// <param name="dto">团组列表请求dto</param>
  602. /// <returns></returns>
  603. [HttpPost]
  604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  605. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  606. {
  607. var groupData = await _groupRepository.GetGroupList(dto);
  608. if (groupData.Code != 0)
  609. {
  610. return Ok(JsonView(false, groupData.Msg));
  611. }
  612. return Ok(JsonView(groupData.Data));
  613. }
  614. /// <summary>
  615. /// 分页查询团组列表
  616. /// </summary>
  617. /// <param name="dto"></param>
  618. /// <returns></returns>
  619. [HttpPost]
  620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  621. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  622. {
  623. var watch = new Stopwatch();
  624. watch.Start();
  625. RefAsync<int> total = 0;
  626. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  627. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  628. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  629. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  630. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  631. .Distinct()
  632. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  633. watch.Stop();
  634. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  635. }
  636. /// <summary>
  637. /// 接团信息列表 Page Init
  638. /// </summary>
  639. /// <returns></returns>
  640. [HttpPost]
  641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  642. public async Task<IActionResult> PostGroupPageListInit()
  643. {
  644. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  645. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  646. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  647. var _view = new
  648. {
  649. depData = depDatas,
  650. rankData = rankDatas
  651. };
  652. return Ok(JsonView(true, "查询成功!", _view));
  653. }
  654. /// <summary>
  655. /// 接团信息列表 Page
  656. /// </summary>
  657. /// <param name="dto">团组列表请求dto</param>
  658. /// <returns></returns>
  659. [HttpPost]
  660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  661. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  662. {
  663. #region 参数验证
  664. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  665. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  666. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  667. #region 页面操作权限验证
  668. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  669. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  670. #endregion
  671. #endregion
  672. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  673. {
  674. string sqlWhere = string.Empty;
  675. if (dto.IsSure == 0) //未完成
  676. {
  677. sqlWhere += string.Format(@" And IsSure = 0");
  678. }
  679. else if (dto.IsSure == 1) //已完成
  680. {
  681. sqlWhere += string.Format(@" And IsSure = 1");
  682. }
  683. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  684. {
  685. string tj = dto.SearchCriteria;
  686. 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}%')",
  687. tj, tj, tj, tj, tj);
  688. }
  689. if (int.TryParse(dto.Rank, out int rankId))
  690. {
  691. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  692. }
  693. string sqlWhere1 = string.Empty;
  694. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  695. {
  696. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  697. }
  698. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  699. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  700. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  701. JietuanOperator,IsSure,CreateTime,IsBid
  702. From (
  703. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  704. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  705. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  706. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  707. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  708. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  709. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  710. From Grp_DelegationInfo gdi
  711. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  712. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  713. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  714. Where gdi.IsDel = 0 {0}
  715. ) temp {1}", sqlWhere, sqlWhere1);
  716. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  717. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  718. var _view = new
  719. {
  720. PageFuncAuth = pageFunAuthView,
  721. Data = _DelegationList
  722. };
  723. return Ok(JsonView(true, "查询成功!", _view, total));
  724. }
  725. else
  726. {
  727. return Ok(JsonView(false, "查询失败"));
  728. }
  729. }
  730. /// <summary>
  731. /// 团组列表
  732. /// </summary>
  733. /// <returns></returns>
  734. [HttpPost]
  735. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  736. {
  737. #region 参数验证
  738. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  739. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  740. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  741. #region 页面操作权限验证
  742. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  743. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  744. #endregion
  745. #endregion
  746. if (dto.PortType != 1 && dto.PortType != 2)
  747. {
  748. return Ok(JsonView(false, "查询失败!"));
  749. }
  750. string orderbyStr = "order by gdi.CreateTime Desc";
  751. string sqlWhere = string.Empty;
  752. if (dto.IsSure == 0) //未完成
  753. {
  754. sqlWhere += string.Format(@" And IsSure = 0");
  755. }
  756. else if (dto.IsSure == 1) //已完成
  757. {
  758. sqlWhere += string.Format(@" And IsSure = 1");
  759. }
  760. //团组类型
  761. if (dto.TeamDid > 0)
  762. {
  763. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  764. }
  765. //团组名称
  766. if (!string.IsNullOrEmpty(dto.TeamName))
  767. {
  768. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  769. }
  770. //客户名称
  771. if (!string.IsNullOrEmpty(dto.ClientName))
  772. {
  773. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  774. }
  775. //客户单位
  776. if (!string.IsNullOrEmpty(dto.ClientUnit))
  777. {
  778. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  779. }
  780. //出访时间
  781. if (!string.IsNullOrEmpty(dto.visitDataTime))
  782. {
  783. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  784. orderbyStr = "order by gdi.VisitDate";
  785. }
  786. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  787. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  788. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  789. JietuanOperator,IsSure,CreateTime
  790. From (
  791. Select row_number() over({0}) as Row_Number,
  792. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  793. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  794. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  795. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  796. From Grp_DelegationInfo gdi
  797. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  798. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  799. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  800. Where gdi.IsDel = 0 {1}
  801. ) temp ", orderbyStr, sqlWhere);
  802. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  803. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  804. #region 处理所属部门
  805. /*
  806. * 1.sq 和 gyy 等显示 市场部
  807. * 2.王鸽和主管及张总还有管理员号统一国交部
  808. * 2-1. 4 管理员 ,21 张海麟
  809. */
  810. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  811. List<int> userIds1 = new List<int>() { 4, 21 };
  812. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  813. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  814. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  815. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  816. .ToList();
  817. foreach (var item in _DelegationList)
  818. {
  819. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  820. }
  821. #endregion
  822. var _view = new
  823. {
  824. PageFuncAuth = pageFunAuthView,
  825. Data = _DelegationList
  826. };
  827. return Ok(JsonView(true, "查询成功!", _view, total));
  828. }
  829. /// <summary>
  830. /// 接团信息详情
  831. /// </summary>
  832. /// <param name="dto">团组info请求dto</param>
  833. /// <returns></returns>
  834. [HttpPost]
  835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  836. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  837. {
  838. var groupData = await _groupRepository.GetGroupInfo(dto);
  839. if (groupData.Code != 0)
  840. {
  841. return Ok(JsonView(false, groupData.Msg));
  842. }
  843. return Ok(JsonView(groupData.Data));
  844. }
  845. /// <summary>
  846. /// 接团信息 编辑添加
  847. /// 基础信息数据源
  848. /// </summary>
  849. /// <param name="dto"></param>
  850. /// <returns></returns>
  851. [HttpPost]
  852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  853. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  854. {
  855. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  856. if (groupData.Code != 0)
  857. {
  858. return Ok(JsonView(false, groupData.Msg));
  859. }
  860. return Ok(JsonView(groupData.Data));
  861. }
  862. /// <summary>
  863. /// 接团信息 编辑添加
  864. /// 省份-城市 基础信息数据源
  865. /// </summary>
  866. /// <param name="dto"></param>
  867. /// <returns></returns>
  868. [HttpPost]
  869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  870. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  871. {
  872. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  873. string search = dto.Search;
  874. var data = await _groupRepository.CityBasicSource();
  875. int total = data.Length;
  876. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  877. .Skip((pageIndex - 1) * pageSize)
  878. .Take(pageSize)
  879. .ToArray();
  880. return Ok(JsonView(data, total));
  881. }
  882. /// <summary>
  883. /// 接团信息 操作(增改)
  884. /// </summary>
  885. /// <param name="dto"></param>
  886. /// <returns></returns>
  887. [HttpPost]
  888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  889. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  890. {
  891. // 创建 Stopwatch 实例
  892. Stopwatch stopwatch = Stopwatch.StartNew();
  893. decimal ffrPrice = 0.00M;
  894. DateTime? visitDt = null;
  895. if (dto.Status == 2)
  896. {
  897. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  898. if (groupInfo != null)
  899. {
  900. ffrPrice = groupInfo.PaymentMoney;
  901. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  902. }
  903. }
  904. var groupData = await _groupRepository.GroupOperation(dto);
  905. if (groupData.Code != 0)
  906. {
  907. return Ok(JsonView(false, groupData.Msg));
  908. }
  909. int diId = 0;
  910. try
  911. {
  912. //添加时 默认加入团组汇率
  913. if (dto.Status == 1) //添加
  914. {
  915. diId = groupData.Data;
  916. //添加默认币种
  917. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  918. //默认分配权限
  919. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  920. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  921. var _managerIds = new List<int>() { 22, 32, 21 };
  922. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  923. if (userIds.Count > 0)
  924. {
  925. userIds.Add(208);
  926. //创建团组管控
  927. GroupStepForDelegation.CreateWorkStep(diId);
  928. //发送消息
  929. string groupName = dto.TeamName;
  930. string createGroupUser = string.Empty;
  931. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  932. if (userInfo != null) createGroupUser = userInfo.CnName;
  933. string title = $"系统通知";
  934. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  935. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  936. }
  937. //默认创建倒推表
  938. await _invertedListRep._Create(dto.UserId, diId);
  939. }
  940. else if (dto.Status == 2)
  941. {
  942. diId = dto.Id;
  943. }
  944. #region 签证人员团组时间通知
  945. #region 计算出访起止时间
  946. var startTime = new DateTime();
  947. var endTime = new DateTime();
  948. if (DateTime.TryParse(dto.VisitDate, out startTime))
  949. {
  950. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  951. }
  952. #endregion
  953. #endregion
  954. #region 团组操作默认添加/修改收款账单
  955. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  956. {
  957. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  958. .Where(x => x.IsDel == 0 &&
  959. x.Diid == diId &&
  960. x.Remark.Equals("预付款")
  961. )
  962. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  963. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  964. .FirstAsync();
  965. ffrInfo = new Fin_ForeignReceivables()
  966. {
  967. Diid = diId,
  968. PriceName = dto.ClientUnit,
  969. Price = dto.PaymentMoney,
  970. Count = 1,
  971. Unit = $"元",
  972. ItemSumPrice = dto.PaymentMoney,
  973. Rate = 1.0000M,
  974. Currency = 836,
  975. AddingWay = 0,
  976. CreateUserId = dto.UserId,
  977. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  978. Remark = $"预付款"
  979. };
  980. if (ffrInfo == null) //Add
  981. {
  982. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  983. }
  984. else //修改
  985. {
  986. await _sqlSugar.Updateable(ffrInfo)
  987. .UpdateColumns(x => new
  988. {
  989. x.PriceName,
  990. x.Price,
  991. x.ItemSumPrice,
  992. x.CreateTime,
  993. x.CreateUserId
  994. })
  995. .WhereColumns(x => x.Id)
  996. .ExecuteCommandAsync();
  997. }
  998. }
  999. #endregion
  1000. if (diId > 0)
  1001. {
  1002. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1003. }
  1004. // 停止计时
  1005. stopwatch.Stop();
  1006. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1007. }
  1008. catch (Exception ex)
  1009. {
  1010. // 停止计时
  1011. stopwatch.Stop();
  1012. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1013. Logs(ex.Message);
  1014. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1015. }
  1016. // 停止计时
  1017. stopwatch.Stop();
  1018. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1019. }
  1020. /// <summary>
  1021. /// 接团流程操作(增改)
  1022. /// 安卓端使用 建团时添加客户名单
  1023. /// </summary>
  1024. /// <param name="dto"></param>
  1025. /// <returns></returns>
  1026. [HttpPost]
  1027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1028. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1029. {
  1030. #region 参数验证
  1031. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1032. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1033. #region 页面操作权限验证
  1034. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1035. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1036. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1037. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1038. #endregion
  1039. #endregion
  1040. try
  1041. {
  1042. //_sqlSugar.BeginTran();
  1043. decimal ffrPrice = 0.00M;
  1044. DateTime? visitDt = null;
  1045. if (dto.Status == 2)
  1046. {
  1047. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1048. if (groupInfo != null)
  1049. {
  1050. ffrPrice = groupInfo.PaymentMoney;
  1051. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1052. }
  1053. }
  1054. var _dto = new GroupOperationDto();
  1055. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1056. var groupData = await _groupRepository.GroupOperation(_dto);
  1057. if (groupData.Code != 0)
  1058. {
  1059. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1060. }
  1061. int diId = 0;
  1062. //添加时 默认加入团组汇率
  1063. if (dto.Status == 1) //添加
  1064. {
  1065. diId = groupData.Data;
  1066. //添加默认币种
  1067. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1068. //默认分配权限
  1069. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1070. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1071. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1072. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1073. if (userIds.Count > 0)
  1074. {
  1075. userIds.Add(208);
  1076. //创建团组管控
  1077. GroupStepForDelegation.CreateWorkStep(diId);
  1078. //发送消息
  1079. string groupName = dto.TeamName;
  1080. string createGroupUser = string.Empty;
  1081. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1082. if (userInfo != null) createGroupUser = userInfo.CnName;
  1083. string title = $"系统通知";
  1084. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1085. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1086. }
  1087. #region 应用推送
  1088. try
  1089. {
  1090. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1091. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1092. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1093. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1094. {
  1095. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1096. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1097. }
  1098. }
  1099. catch (Exception ex)
  1100. {
  1101. }
  1102. #endregion
  1103. //默认创建倒推表
  1104. await _invertedListRep._Create(dto.UserId, diId);
  1105. }
  1106. if (dto.Status == 2)
  1107. {
  1108. diId = dto.Id;
  1109. if (diId == 0)
  1110. {
  1111. //_sqlSugar.RollbackTran();
  1112. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1113. }
  1114. }
  1115. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1116. if (viewData.Code != 0)
  1117. {
  1118. //_sqlSugar.RollbackTran();
  1119. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1120. }
  1121. #region 团组操作默认添加/修改收款账单
  1122. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1123. {
  1124. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1125. .Where(x => x.IsDel == 0 &&
  1126. x.Diid == diId &&
  1127. x.Remark.Equals("预付款")
  1128. )
  1129. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1130. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1131. .FirstAsync();
  1132. ffrInfo = new Fin_ForeignReceivables()
  1133. {
  1134. Diid = diId,
  1135. PriceName = dto.ClientUnit,
  1136. Price = dto.PaymentMoney,
  1137. Count = 1,
  1138. Unit = $"元",
  1139. ItemSumPrice = dto.PaymentMoney,
  1140. Rate = 1.0000M,
  1141. Currency = 836,
  1142. AddingWay = 0,
  1143. CreateUserId = dto.UserId,
  1144. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1145. Remark = $"预付款"
  1146. };
  1147. if (ffrInfo == null) //Add
  1148. {
  1149. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1150. }
  1151. else //修改
  1152. {
  1153. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1154. .UpdateColumns(x => new
  1155. {
  1156. x.PriceName,
  1157. x.Price,
  1158. x.ItemSumPrice,
  1159. x.CreateTime,
  1160. x.CreateUserId
  1161. })
  1162. .WhereColumns(x => x.Id)
  1163. .ExecuteCommandAsync();
  1164. }
  1165. }
  1166. #endregion
  1167. #region 签证人员团组时间通知
  1168. #region 计算出访起止时间
  1169. var startTime = new DateTime();
  1170. var endTime = new DateTime();
  1171. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1172. {
  1173. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1174. }
  1175. #endregion
  1176. if (diId > 0)
  1177. {
  1178. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1179. }
  1180. #endregion
  1181. //_sqlSugar.CommitTran();
  1182. return Ok(JsonView(true, "添加成功"));
  1183. }
  1184. catch (Exception ex)
  1185. {
  1186. _sqlSugar.RollbackTran();
  1187. return Ok(JsonView(false, ex.Message));
  1188. }
  1189. }
  1190. /// <summary>
  1191. /// 接团流程操作(增改)
  1192. /// 安卓端使用 建团时添加客户名单
  1193. /// </summary>
  1194. /// <param name="dto"></param>
  1195. /// <returns></returns>
  1196. [HttpPost]
  1197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1198. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1199. {
  1200. #region 参数验证
  1201. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1202. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1203. #region 页面操作权限验证
  1204. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1205. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1206. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1207. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1208. #endregion
  1209. #endregion
  1210. _sqlSugar.BeginTran();
  1211. decimal ffrPrice = 0.00M;
  1212. DateTime? visitDt = null;
  1213. if (dto.Status == 2)
  1214. {
  1215. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1216. if (groupInfo != null)
  1217. {
  1218. ffrPrice = groupInfo.PaymentMoney;
  1219. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1220. }
  1221. }
  1222. var _dto = new GroupOperationDto();
  1223. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1224. var groupData = await _groupRepository.GroupOperation(_dto);
  1225. if (groupData.Code != 0)
  1226. {
  1227. _sqlSugar.RollbackTran();
  1228. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1229. }
  1230. try
  1231. {
  1232. int diId = 0;
  1233. //添加时 默认加入团组汇率
  1234. if (dto.Status == 1) //添加
  1235. {
  1236. diId = groupData.Data;
  1237. //添加默认币种
  1238. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1239. //默认分配权限
  1240. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1241. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1242. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1243. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1244. if (userIds.Count > 0)
  1245. {
  1246. userIds.Add(208);
  1247. //创建团组管控
  1248. GroupStepForDelegation.CreateWorkStep(diId);
  1249. //发送消息
  1250. string groupName = dto.TeamName;
  1251. string createGroupUser = string.Empty;
  1252. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1253. if (userInfo != null) createGroupUser = userInfo.CnName;
  1254. string title = $"系统通知";
  1255. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1256. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1257. }
  1258. #region 应用推送
  1259. try
  1260. {
  1261. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1262. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1263. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1264. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1265. {
  1266. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1267. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1268. }
  1269. }
  1270. catch (Exception ex)
  1271. {
  1272. _sqlSugar.CommitTran();
  1273. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1274. }
  1275. #endregion
  1276. //默认创建倒推表
  1277. await _invertedListRep._Create(dto.UserId, diId);
  1278. }
  1279. else if (dto.Status == 2)
  1280. {
  1281. diId = dto.Id;
  1282. if (diId == 0)
  1283. {
  1284. _sqlSugar.RollbackTran();
  1285. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1286. }
  1287. }
  1288. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1289. if (viewData.Code != 0)
  1290. {
  1291. _sqlSugar.RollbackTran();
  1292. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1293. }
  1294. #region 团组操作默认添加/修改收款账单
  1295. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1296. {
  1297. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1298. .Where(x => x.IsDel == 0 &&
  1299. x.Diid == diId &&
  1300. x.Remark.Equals("预付款")
  1301. )
  1302. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1303. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1304. .FirstAsync();
  1305. ffrInfo = new Fin_ForeignReceivables()
  1306. {
  1307. Diid = diId,
  1308. PriceName = dto.ClientUnit,
  1309. Price = dto.PaymentMoney,
  1310. Count = 1,
  1311. Unit = $"元",
  1312. ItemSumPrice = dto.PaymentMoney,
  1313. Rate = 1.0000M,
  1314. Currency = 836,
  1315. AddingWay = 0,
  1316. CreateUserId = dto.UserId,
  1317. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1318. Remark = $"预付款"
  1319. };
  1320. if (ffrInfo == null) //Add
  1321. {
  1322. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1323. }
  1324. else //修改
  1325. {
  1326. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1327. .UpdateColumns(x => new
  1328. {
  1329. x.PriceName,
  1330. x.Price,
  1331. x.ItemSumPrice,
  1332. x.CreateTime,
  1333. x.CreateUserId
  1334. })
  1335. .WhereColumns(x => x.Id)
  1336. .ExecuteCommandAsync();
  1337. }
  1338. }
  1339. #endregion
  1340. #region 签证人员团组时间通知
  1341. #region 计算出访起止时间
  1342. var startTime = new DateTime();
  1343. var endTime = new DateTime();
  1344. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1345. {
  1346. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1347. }
  1348. #endregion
  1349. if (diId > 0)
  1350. {
  1351. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1352. }
  1353. #endregion
  1354. _sqlSugar.CommitTran();
  1355. return Ok(JsonView(true));
  1356. }
  1357. catch (Exception ex)
  1358. {
  1359. _sqlSugar.RollbackTran();
  1360. return Ok(JsonView(false, ex.Message));
  1361. }
  1362. }
  1363. /// <summary>
  1364. /// 接团信息 操作(删除)
  1365. /// </summary>
  1366. /// <param name="dto"></param>
  1367. /// <returns></returns>
  1368. [HttpPost]
  1369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1370. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1371. {
  1372. var diId = dto.Id;
  1373. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1374. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1375. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1376. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1377. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1378. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1379. #endregion
  1380. var groupData = await _groupRepository.GroupDel(dto);
  1381. if (groupData.Code != 0)
  1382. {
  1383. return Ok(JsonView(false, groupData.Msg));
  1384. }
  1385. return Ok(JsonView(true));
  1386. }
  1387. /// <summary>
  1388. /// 获取团组销售报价号
  1389. /// 团组添加时 使用
  1390. /// </summary>
  1391. /// <returns></returns>
  1392. [HttpPost]
  1393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1394. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1395. {
  1396. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1397. if (groupData.Code != 0)
  1398. {
  1399. return Ok(JsonView(false, groupData.Msg));
  1400. }
  1401. object salesQuoteNo = new
  1402. {
  1403. SalesQuoteNo = groupData.Data
  1404. };
  1405. return Ok(JsonView(salesQuoteNo));
  1406. }
  1407. /// <summary>
  1408. /// 设置确认出团
  1409. /// </summary>
  1410. /// <param name="dto"></param>
  1411. /// <returns></returns>
  1412. [HttpPost]
  1413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1414. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1415. {
  1416. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1417. if (groupData.Code != 0)
  1418. {
  1419. return Ok(JsonView(false, groupData.Msg));
  1420. }
  1421. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1422. #region OA消息推送
  1423. try
  1424. {
  1425. string groupName = groupInfo.TeamName;
  1426. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1427. string title = $"系统通知";
  1428. string content = $"团组[{groupName}]已确认出团!";
  1429. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1430. }
  1431. catch (Exception ex)
  1432. {
  1433. }
  1434. #endregion
  1435. #region 应用推送
  1436. try
  1437. {
  1438. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1439. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1440. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1441. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1442. {
  1443. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1444. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1445. }
  1446. }
  1447. catch (Exception ex)
  1448. {
  1449. }
  1450. #endregion
  1451. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1452. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1453. }
  1454. /// <summary>
  1455. /// 获取团组名称data And 签证国别Data
  1456. /// </summary>
  1457. /// <param name="dto"></param>
  1458. /// <returns></returns>
  1459. [HttpPost]
  1460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1461. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1462. {
  1463. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1464. if (groupData.Code != 0)
  1465. {
  1466. return Ok(JsonView(false, groupData.Msg));
  1467. }
  1468. return Ok(JsonView(groupData.Data));
  1469. }
  1470. /// <summary>
  1471. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1472. /// </summary>
  1473. /// <returns></returns>
  1474. [HttpPost]
  1475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1476. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1477. {
  1478. try
  1479. {
  1480. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1481. if (groupData.Code != 0)
  1482. {
  1483. return Ok(JsonView(false, groupData.Msg));
  1484. }
  1485. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1486. }
  1487. catch (Exception ex)
  1488. {
  1489. return Ok(JsonView(false, "程序错误!"));
  1490. throw;
  1491. }
  1492. }
  1493. /// <summary>
  1494. /// 团组清单 Excel
  1495. /// </summary>
  1496. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1497. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1498. /// <returns></returns>
  1499. [HttpGet]
  1500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1501. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1502. {
  1503. DateTime _beginDt, _endDt;
  1504. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1505. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1506. if (!beginBool && !endBool)
  1507. {
  1508. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1509. }
  1510. string sql = string.Format(@"
  1511. SELECT
  1512. ROW_NUMBER,
  1513. Id,
  1514. SalesQuoteNo,
  1515. TourCode,
  1516. TeamTypeId,
  1517. TeamType,
  1518. TeamLevId,
  1519. TeamLev,
  1520. TeamName,
  1521. ClientName,
  1522. ClientUnit,
  1523. VisitDate,
  1524. VisitDays,
  1525. VisitPNumber,
  1526. JietuanOperatorId,
  1527. JietuanOperator,
  1528. IsSure,
  1529. CreateUserName,
  1530. IsBid
  1531. FROM
  1532. (
  1533. SELECT
  1534. ROW_NUMBER() OVER(
  1535. ORDER BY
  1536. gdi.CreateTime Desc
  1537. ) AS ROW_NUMBER,
  1538. gdi.Id,
  1539. SalesQuoteNo,
  1540. TourCode,
  1541. ssd.Id TeamTypeId,
  1542. ssd.Name TeamType,
  1543. ssd1.Id TeamLevId,
  1544. ssd1.Name TeamLev,
  1545. TeamName,
  1546. ClientName,
  1547. ClientUnit,
  1548. VisitDate,
  1549. VisitDays,
  1550. VisitPNumber,
  1551. JietuanOperator JietuanOperatorId,
  1552. su.CnName JietuanOperator,
  1553. IsSure,
  1554. gdi.CreateTime,
  1555. su1.CnName As CreateUserName,
  1556. gdi.IsBid
  1557. FROM
  1558. Grp_DelegationInfo gdi
  1559. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1560. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1561. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1562. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1563. WHERE
  1564. gdi.IsDel = 0
  1565. AND gdi.IsBid = 0
  1566. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1567. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1568. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1569. #region 处理所属部门
  1570. /*
  1571. * 1.sq 和 gyy 等显示 市场部
  1572. * 2.王鸽和主管及张总还有管理员号统一国交部
  1573. * 2-1. 4 管理员 ,21 张海麟
  1574. */
  1575. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1576. List<int> userIds1 = new List<int>() { 4, 21 };
  1577. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1578. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1579. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1580. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1581. .ToListAsync();
  1582. var droupIds = groupList.Select(it => it.Id).ToList();
  1583. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1584. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1585. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1586. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1587. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1588. {
  1589. DiId = tcl.DiId,
  1590. LastName = dc.LastName,
  1591. FirstName = dc.FirstName,
  1592. Sex = dc.Sex,
  1593. Birthday = dc.BirthDay,
  1594. Company = cc.CompanyFullName,
  1595. Job = dc.Job,
  1596. CreateTime = tcl.CreateTime,
  1597. })
  1598. .ToList();
  1599. foreach (var item in groupList)
  1600. {
  1601. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1602. string groupFirstName = "";
  1603. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1604. if (currDatas.Any())
  1605. {
  1606. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1607. }
  1608. item.GroupFirst = groupFirstName;
  1609. }
  1610. #endregion
  1611. #region Excel
  1612. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1613. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1614. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1615. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1616. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1617. //载入模板
  1618. WorkbookDesigner designer = new WorkbookDesigner();
  1619. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1620. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1621. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1622. dt.TableName = "GroupList";
  1623. designer.SetDataSource(dt);
  1624. designer.Process();
  1625. if (!Directory.Exists(savePath))
  1626. {
  1627. Directory.CreateDirectory(savePath);
  1628. }
  1629. string serverPath = $"{savePath}{fileName}";
  1630. designer.Workbook.Save(serverPath);
  1631. string rst = $"{servicePath}{ftpPath}{fileName}";
  1632. #endregion
  1633. return Ok(JsonView(true, "操作成功!", rst));
  1634. }
  1635. #endregion
  1636. #region 团组&签证
  1637. /// <summary>
  1638. /// 根据团组Id获取签证客户信息List
  1639. /// </summary>
  1640. /// <param name="dto">请求dto</param>
  1641. /// <returns></returns>
  1642. [HttpPost]
  1643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1644. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1645. {
  1646. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1647. if (groupData.Code != 0)
  1648. {
  1649. return Ok(JsonView(false, groupData.Msg));
  1650. }
  1651. return Ok(JsonView(groupData.Data));
  1652. }
  1653. /// <summary>
  1654. /// IOS获取团组签证拍照上传进度01(团组列表)
  1655. /// </summary>
  1656. /// <param name="dto">请求dto</param>
  1657. /// <returns></returns>
  1658. [HttpPost]
  1659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1660. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1661. {
  1662. if (dto == null)
  1663. {
  1664. return Ok(JsonView(false, "参数为空"));
  1665. }
  1666. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1667. return Ok(JsonView(visaList));
  1668. }
  1669. /// <summary>
  1670. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1671. /// </summary>
  1672. /// <returns></returns>
  1673. [HttpPost]
  1674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1675. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1676. {
  1677. if (dto == null)
  1678. {
  1679. return Ok(JsonView(false, "请求错误:"));
  1680. }
  1681. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1682. return Ok(JsonView(list));
  1683. }
  1684. /// <summary>
  1685. /// IOS获取团组签证拍照上传进度03(相册)
  1686. /// </summary>
  1687. /// <returns></returns>
  1688. [HttpPost]
  1689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1690. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1691. {
  1692. if (dto == null)
  1693. {
  1694. return Ok(JsonView(false, "请求错误:"));
  1695. }
  1696. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1697. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1698. list.ForEach(s => s.url = url);
  1699. return Ok(JsonView(list));
  1700. }
  1701. /// <summary>
  1702. /// IOS获取团组签证拍照上传进度04(图片上传)
  1703. /// </summary>
  1704. /// <param name="dto"></param>
  1705. /// <returns></returns>
  1706. [HttpPost]
  1707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1708. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1709. {
  1710. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1711. //if (!string.IsNullOrEmpty(result))
  1712. //{
  1713. //}
  1714. //else {
  1715. // return Ok(JsonView(false, "上传失败"));
  1716. //}
  1717. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1718. int sucNum = 0;
  1719. try
  1720. {
  1721. foreach (var item in dto.base64DataList)
  1722. {
  1723. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1724. string result = DecodeBase64ToImage(item, imageName);
  1725. if (!string.IsNullOrEmpty(result))
  1726. {
  1727. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1728. pic.CreateUserId = dto.CreateUserId;
  1729. pic.PicName = imageName;
  1730. pic.PicPath = result;
  1731. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1732. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1733. if (insertResult > 0)
  1734. {
  1735. sucNum++;
  1736. }
  1737. }
  1738. }
  1739. }
  1740. catch (Exception ex)
  1741. {
  1742. return Ok(JsonView(false, ex.Message));
  1743. }
  1744. string msg = string.Format(@"成功上传{0}张", sucNum);
  1745. return Ok(JsonView(true, msg));
  1746. }
  1747. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1748. {
  1749. string filename = "";//声明一个string类型的相对路径
  1750. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1751. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1752. try//会有异常抛出,try,catch一下
  1753. {
  1754. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1755. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1756. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1757. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1758. //文件名称
  1759. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1760. //上传的文件的路径
  1761. string filePath = "";
  1762. if (!Directory.Exists(fileDir))
  1763. {
  1764. Directory.CreateDirectory(fileDir);
  1765. }
  1766. //上传的文件的路径
  1767. filePath = fileDir + filename;
  1768. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1769. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1770. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1771. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1772. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1773. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1774. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1775. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1776. bitmap.Dispose();
  1777. }
  1778. catch (Exception e)
  1779. {
  1780. string massage = e.Message;
  1781. Logs("IOS图片上传Error:" + massage);
  1782. //filename = e.Message;
  1783. }
  1784. return filename;//返回相对路径
  1785. }
  1786. /// <summary>
  1787. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1788. /// </summary>
  1789. /// <param name="dto"></param>
  1790. /// <returns></returns>
  1791. [HttpPost]
  1792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1793. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1794. {
  1795. if (dto == null)
  1796. {
  1797. return Ok(JsonView(false, "请求错误:"));
  1798. }
  1799. string msg = "参数错误";
  1800. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1801. {
  1802. try
  1803. {
  1804. //_delegationVisaRep.BeginTran();
  1805. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1806. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1807. .Where(s => s.Id == dto.visaProgressCustomerId)
  1808. .ExecuteCommandAsync();
  1809. if (updCount > 0 && dto.publishCode == 1)
  1810. {
  1811. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1812. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1813. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1814. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1815. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1816. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1817. if (groupData == null)
  1818. {
  1819. _delegationVisaRep.RollbackTran();
  1820. }
  1821. string title = string.Format(@"[签证进度更新]");
  1822. string content = string.Format(@"测试文本");
  1823. bool rst = await _message.AddMsg(new MessageDto()
  1824. {
  1825. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1826. IssuerId = dto.publisher,
  1827. Title = title,
  1828. Content = content,
  1829. ReleaseTime = DateTime.Now,
  1830. UIdList = new List<int> {
  1831. 234
  1832. }
  1833. });
  1834. if (rst)
  1835. {
  1836. return Ok(JsonView(true, "发送通知成功"));
  1837. }
  1838. }
  1839. //_delegationVisaRep.CommitTran();
  1840. }
  1841. catch (Exception)
  1842. {
  1843. //_delegationVisaRep.RollbackTran();
  1844. }
  1845. }
  1846. return Ok(JsonView(true, msg));
  1847. }
  1848. #endregion
  1849. #region 团组任务分配
  1850. /// <summary>
  1851. /// 团组任务分配初始化
  1852. /// </summary>
  1853. /// <returns></returns>
  1854. [HttpPost]
  1855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1856. public async Task<IActionResult> GetTaskAssignmen()
  1857. {
  1858. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1859. if (groupData.Code != 0)
  1860. {
  1861. return Ok(JsonView(false, groupData.Msg));
  1862. }
  1863. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1864. }
  1865. /// <summary>
  1866. /// 团组任务分配查询
  1867. /// </summary>
  1868. /// <param name="dto"></param>
  1869. /// <returns></returns>
  1870. [HttpPost]
  1871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1872. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1873. {
  1874. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1875. if (groupData.Code != 0)
  1876. {
  1877. return Ok(JsonView(false, groupData.Msg));
  1878. }
  1879. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1880. }
  1881. /// <summary>
  1882. /// 团组任务分配操作
  1883. /// </summary>
  1884. /// <param name="dto"></param>
  1885. /// <returns></returns>
  1886. [HttpPost]
  1887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1888. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1889. {
  1890. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1891. if (groupData.Code != 0)
  1892. {
  1893. return Ok(JsonView(false, groupData.Msg));
  1894. }
  1895. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1896. }
  1897. /// <summary>
  1898. /// 团组任务分配
  1899. /// 批量分配
  1900. /// 查询团组
  1901. /// </summary>
  1902. /// <param name="dto"></param>
  1903. /// <returns></returns>
  1904. [HttpPost]
  1905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1906. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1907. {
  1908. //参数验证
  1909. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1910. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1911. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1912. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1913. }
  1914. /// <summary>
  1915. /// 团组任务分配
  1916. /// 批量分配
  1917. /// </summary>
  1918. /// <param name="dto"></param>
  1919. /// <returns></returns>
  1920. [HttpPost]
  1921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1922. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1923. {
  1924. //参数验证
  1925. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1926. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1927. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1928. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1929. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1930. }
  1931. #endregion
  1932. #region 团组费用审核
  1933. /// <summary>
  1934. /// 费用审核
  1935. /// 团组列表 Page
  1936. /// </summary>
  1937. /// <param name="_dto">团组列表请求dto</param>
  1938. /// <returns></returns>
  1939. [HttpPost]
  1940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1941. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1942. {
  1943. #region 参数验证
  1944. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1945. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1946. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1947. #region 页面操作权限验证
  1948. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1949. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1950. #endregion
  1951. #endregion
  1952. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1953. {
  1954. string sqlWhere = string.Empty;
  1955. if (_dto.IsSure == 0) //未完成
  1956. {
  1957. sqlWhere += string.Format(@" And IsSure = 0");
  1958. }
  1959. else if (_dto.IsSure == 1) //已完成
  1960. {
  1961. sqlWhere += string.Format(@" And IsSure = 1");
  1962. }
  1963. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1964. {
  1965. string tj = _dto.SearchCriteria;
  1966. 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}%')",
  1967. tj, tj, tj, tj, tj);
  1968. }
  1969. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1970. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1971. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1972. From (
  1973. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1974. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1975. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1976. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1977. From Grp_DelegationInfo gdi
  1978. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1979. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1980. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1981. Where gdi.IsDel = 0 {0}
  1982. ) temp ", sqlWhere);
  1983. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1984. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1985. var _view = new
  1986. {
  1987. PageFuncAuth = pageFunAuthView,
  1988. Data = _DelegationList
  1989. };
  1990. return Ok(JsonView(true, "查询成功!", _view, total));
  1991. }
  1992. else
  1993. {
  1994. return Ok(JsonView(false, "查询失败"));
  1995. }
  1996. }
  1997. /// <summary>
  1998. /// 获取团组费用审核
  1999. /// </summary>
  2000. /// <param name="_dto"></param>
  2001. /// <returns></returns>
  2002. [HttpPost]
  2003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2004. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2005. {
  2006. try
  2007. {
  2008. #region 参数验证
  2009. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2010. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2011. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2012. #region 页面操作权限验证
  2013. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2014. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2015. #endregion
  2016. #endregion
  2017. var _view = new Grp_CreditCardPaymentView();
  2018. var clientNameList = getSimplClientList(_dto.DiId);
  2019. #region 费用清单
  2020. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2021. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2022. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2023. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2024. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2025. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2026. /*
  2027. * 76://酒店预订
  2028. */
  2029. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2030. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2031. /*
  2032. * 79://车/导游地接
  2033. */
  2034. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2035. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2036. /*
  2037. * 80: //签证
  2038. */
  2039. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2040. /*
  2041. *81: //邀请/公务活动
  2042. */
  2043. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2044. /*
  2045. * 82: //团组客户保险
  2046. */
  2047. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2048. /*
  2049. * Lable = 85 机票预订
  2050. */
  2051. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2052. /*
  2053. * 85 机票预定
  2054. */
  2055. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2056. /*
  2057. * 98 其他款项
  2058. */
  2059. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2060. /*
  2061. * 285:收款退还
  2062. */
  2063. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2064. /*
  2065. * 1015: //超支费用
  2066. */
  2067. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2068. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2069. /*
  2070. * 币种信息
  2071. */
  2072. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2073. /*
  2074. * 车/导游地接 费用类型
  2075. */
  2076. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2077. /*
  2078. * 车/导游地接 费用类型
  2079. */
  2080. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2081. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2082. /*
  2083. * 用户信息
  2084. */
  2085. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2086. /*
  2087. * 费用模块
  2088. */
  2089. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2090. string priceModule = string.Empty;
  2091. if (sdPriceName != null)
  2092. {
  2093. priceModule = sdPriceName.Name;
  2094. }
  2095. /*
  2096. * 成本信息
  2097. */
  2098. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2099. decimal _groupRate = 0.0000M;
  2100. string _groupCurrencyCode = "-";
  2101. if (groupCost != null)
  2102. {
  2103. _groupRate = groupCost.Rate;
  2104. if (int.TryParse(groupCost.Currency, out int _currency))
  2105. {
  2106. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2107. }
  2108. else _groupCurrencyCode = groupCost.Currency;
  2109. }
  2110. string costContentSql = $"Select * From Grp_GroupCost";
  2111. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2112. //处理日期为空的天数
  2113. for (int i = 0; i < groupCostDetails.Count; i++)
  2114. if (i != 0)
  2115. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2116. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2117. /*
  2118. * 处理详情数据
  2119. */
  2120. foreach (var entity in entityList)
  2121. {
  2122. var _detail = new Grp_CreditCardPaymentDetailView();
  2123. _detail.Id = entity.Id;
  2124. _detail.PriceName = priceModule;
  2125. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2126. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2127. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2128. //处理金额
  2129. if (entity.CTable == 1015)
  2130. {
  2131. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2132. if (czInfo != null)
  2133. {
  2134. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2135. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2136. }
  2137. }
  2138. /*
  2139. * 应付款金额
  2140. */
  2141. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2142. string PaymentCurrency_WaitPay = "Unknown";
  2143. string hotelCurrncyCode = "Unknown";
  2144. string hotelCurrncyName = "Unknown";
  2145. if (sdPaymentCurrency_WaitPay != null)
  2146. {
  2147. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2148. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2149. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2150. if (hotelCurrncyCode.Equals("CNY"))
  2151. {
  2152. entity.DayRate = 1.0000M;
  2153. }
  2154. }
  2155. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2156. /*
  2157. * 此次付款金额
  2158. */
  2159. decimal CurrPayStr = 0.00M,
  2160. OriginalCurrPay = 0.00M;
  2161. if (entity.PayPercentage == 0)
  2162. {
  2163. if (entity.PayThenMoney != 0)
  2164. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2165. }
  2166. else
  2167. {
  2168. if (entity.PayMoney != 0)
  2169. {
  2170. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2171. }
  2172. }
  2173. //if (_dto.Label == 79)
  2174. //{
  2175. // string original = string.Empty;
  2176. // if (hotelCurrncyCode.Equals("CNY"))
  2177. // {
  2178. // OriginalCurrPay = CurrPayStr;
  2179. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2180. // }
  2181. // else
  2182. // {
  2183. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2184. // //760 EUR(7600.00 CNY)
  2185. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2186. // }
  2187. //}
  2188. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2189. string original = string.Empty;
  2190. if (hotelCurrncyCode.Equals("CNY"))
  2191. {
  2192. OriginalCurrPay = CurrPayStr;
  2193. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2194. }
  2195. else
  2196. {
  2197. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2198. //760 EUR(7600.00 CNY)
  2199. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2200. }
  2201. /*
  2202. * 剩余尾款
  2203. */
  2204. decimal BalanceStr = 0;
  2205. if (CurrPayStr != 0)
  2206. {
  2207. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2208. BalanceStr = 0;
  2209. else
  2210. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2211. }
  2212. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2213. /*
  2214. * Bus名称
  2215. */
  2216. _detail.BusName = "待增加";
  2217. /*
  2218. *费用所属
  2219. */
  2220. switch (entity.CTable)
  2221. {
  2222. case 76://酒店预订
  2223. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2224. if (hotelReservations != null)
  2225. {
  2226. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2227. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2228. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2229. string roomFeeStr = "", roomFeestr1 = "";
  2230. //是否比较房型价格
  2231. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2232. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2233. roomFeeStr += $"<br/>";
  2234. var roomTotal = 0.00M;
  2235. if (hotelReservations.SingleRoomPrice > 0)
  2236. {
  2237. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2238. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2239. //__isSingle = true;
  2240. roomTotal += fee;
  2241. }
  2242. if (hotelReservations.DoubleRoomPrice > 0)
  2243. {
  2244. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2245. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2246. // __isDouble = true;
  2247. roomTotal += fee;
  2248. }
  2249. if (hotelReservations.SuiteRoomPrice > 0)
  2250. {
  2251. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2252. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2253. //__isSuite = true;
  2254. roomTotal += fee;
  2255. }
  2256. if (hotelReservations.OtherRoomPrice > 0)
  2257. {
  2258. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2259. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2260. //__isOther = true;
  2261. roomTotal += fee;
  2262. }
  2263. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2264. else roomFeeStr += " 0.00 * 0";
  2265. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2266. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2267. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2268. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2269. /*
  2270. * 费用类型
  2271. * 1:房费
  2272. * 2:早餐
  2273. * 3:地税
  2274. * 4:城市税
  2275. * </summary>
  2276. */
  2277. //地税
  2278. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2279. if (governmentRentData != null)
  2280. {
  2281. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2282. governmentRentFee = governmentRentData.Price;
  2283. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2284. if (governmentRentCurrData != null)
  2285. {
  2286. governmentRentCode = governmentRentCurrData.Name;
  2287. governmentRentName = $"({governmentRentCurrData.Remark})";
  2288. }
  2289. }
  2290. //城市税
  2291. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2292. if (cityTaxData != null)
  2293. {
  2294. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2295. cityTaxFee = cityTaxData.Price;
  2296. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2297. if (cityTaxCurrData != null)
  2298. {
  2299. cityTaxCode = cityTaxCurrData.Name;
  2300. cityTaxName = $"({cityTaxCurrData.Remark})";
  2301. }
  2302. }
  2303. //酒店早餐
  2304. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2305. if (breakfastData != null)
  2306. {
  2307. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2308. breakfastFee = breakfastData.Price;
  2309. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2310. if (breakfastCurrData != null)
  2311. {
  2312. breakfastCode = breakfastCurrData.Name;
  2313. breakfastName = $"({breakfastCurrData.Remark})";
  2314. }
  2315. }
  2316. //房间费用
  2317. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2318. if (roomData != null)
  2319. {
  2320. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2321. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2322. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2323. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2324. roomFee = roomData.Price;
  2325. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2326. if (roomCurrData != null)
  2327. {
  2328. roomCode = roomCurrData.Name;
  2329. roomName = $"({roomCurrData.Remark})";
  2330. }
  2331. }
  2332. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2333. string hotelCostStr = "";
  2334. decimal hotelCsotTotal = 0.00M;
  2335. if (groupCost != null)
  2336. {
  2337. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2338. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2339. }
  2340. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2341. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2342. string hotelCost_day = "";
  2343. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2344. foreach (var item in hotelCostDetails1)
  2345. {
  2346. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2347. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2348. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2349. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2350. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2351. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2352. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2353. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2354. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2355. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2356. hotelCost_day += @$"<br/>";
  2357. }
  2358. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2359. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2360. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2361. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2362. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2363. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2364. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2365. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2366. $"房间说明: {hotelReservations.Remark} <br/>" +
  2367. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2368. $"{hotelBreakfastStr}" +
  2369. $"{hotelGovernmentRentStr}" +
  2370. $"{hotelCityTaxStr}";
  2371. _detail.PriceNameContent = hotelReservations.HotelName;
  2372. }
  2373. break;
  2374. case 79://车/导游地接
  2375. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2376. if (touristGuideGroundReservations != null)
  2377. {
  2378. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2379. {
  2380. _detail.BusName = touristGuideGroundReservations.BusName;
  2381. }
  2382. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2383. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2384. //if (isInt)
  2385. //{
  2386. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2387. // if (cityInfo != null)
  2388. // {
  2389. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2390. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2391. // if (carFeeItem != null)
  2392. // {
  2393. // nameContent += $@"({carFeeItem.Name})";
  2394. // }
  2395. // _detail.PriceNameContent = nameContent;
  2396. // }
  2397. //}
  2398. //else
  2399. //{
  2400. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2401. //}
  2402. var touristGuideGroundReservationsContents =
  2403. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2404. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2405. foreach (var item in touristGuideGroundReservationsContents)
  2406. {
  2407. string typeName = "Unknown";
  2408. string carCurrencyCode = "Unknown";
  2409. string carCurrencyName = "Unknown";
  2410. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2411. if (carTypeData != null) typeName = carTypeData.Name;
  2412. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2413. if (currencyData != null)
  2414. {
  2415. carCurrencyCode = currencyData.Name;
  2416. carCurrencyName = currencyData.Remark;
  2417. }
  2418. //op、成本 币种是否一致
  2419. bool IsCurrencyAgreement = false;
  2420. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2421. string opCostStr = string.Empty;
  2422. decimal opCostTypePrice = 0.00M;
  2423. #region 处理成本各项费用
  2424. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2425. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2426. if (opCost.Count > 0)
  2427. {
  2428. switch (item.SId)
  2429. {
  2430. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2431. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2432. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2433. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2434. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2435. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2436. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2437. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2438. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2439. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2440. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2441. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2442. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2443. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2444. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2445. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2446. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2447. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2448. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2449. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2450. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2451. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2452. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2453. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2454. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2455. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2456. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2457. }
  2458. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2459. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2460. }
  2461. #endregion
  2462. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2463. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2464. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2465. $"{opTypeStr} {opCostStr}<br/>" +
  2466. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2467. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2468. }
  2469. _detail.PriceMsgContent = priceMsg;
  2470. }
  2471. break;
  2472. case 80: //签证
  2473. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2474. if (visaInfo != null)
  2475. {
  2476. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2477. _detail.PriceNameContent = visaInfo.VisaDescription;
  2478. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2479. }
  2480. break;
  2481. case 81: //邀请/公务活动
  2482. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2483. if (_ioa != null)
  2484. {
  2485. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2486. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2487. sendCurrName = "Unknown", //快递费用币种 Name
  2488. sendCurrCode = "Unknown", //快递费用币种 Code
  2489. eventsCurrName = "Unknown", //公务活动费币种 Name
  2490. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2491. translateCurrName = "Unknown", //公务翻译费 Name
  2492. translateCurrCode = "Unknown"; //公务翻译费 Code
  2493. #region 处理费用币种
  2494. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2495. if (inviteCurrData != null)
  2496. {
  2497. inviteCurrName = inviteCurrData.Remark;
  2498. inviteCurrCode = inviteCurrData.Name;
  2499. }
  2500. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2501. if (sendCurrData != null)
  2502. {
  2503. sendCurrName = sendCurrData.Remark;
  2504. sendCurrCode = sendCurrData.Name;
  2505. }
  2506. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2507. if (eventsCurrData != null)
  2508. {
  2509. eventsCurrName = eventsCurrData.Remark;
  2510. eventsCurrCode = eventsCurrData.Name;
  2511. }
  2512. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2513. if (translateCurrData != null)
  2514. {
  2515. translateCurrName = translateCurrData.Remark;
  2516. translateCurrCode = translateCurrData.Name;
  2517. }
  2518. #endregion
  2519. _detail.PriceNameContent = _ioa.InviterArea;
  2520. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2521. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2522. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2523. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2524. $@"备注:" + _ioa.Remark + "<br/>";
  2525. }
  2526. break;
  2527. case 82: //团组客户保险
  2528. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2529. if (customers != null)
  2530. {
  2531. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2532. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2533. }
  2534. break;
  2535. case 85: //机票预订
  2536. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2537. if (jpRes != null)
  2538. {
  2539. string FlightsDescription = jpRes.FlightsDescription;
  2540. string PriceDescription = jpRes.PriceDescription;
  2541. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2542. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2543. }
  2544. break;
  2545. case 98://其他款项
  2546. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2547. if (gdpRes != null)
  2548. {
  2549. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2550. _detail.PriceNameContent = gdpRes.PriceName;
  2551. }
  2552. break;
  2553. case 285://收款退还
  2554. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2555. if (refundAndOtherMoney != null)
  2556. {
  2557. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2558. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2559. }
  2560. break;
  2561. case 751://酒店早餐
  2562. break;
  2563. case 1015://超支费用
  2564. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2565. if (groupExtraCost != null)
  2566. {
  2567. _detail.PriceNameContent = groupExtraCost.PriceName;
  2568. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2569. }
  2570. break;
  2571. default:
  2572. break;
  2573. }
  2574. /*
  2575. * 申请人
  2576. */
  2577. string operatorName = " - ";
  2578. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2579. if (_opUser != null)
  2580. {
  2581. operatorName = _opUser.CnName;
  2582. }
  2583. _detail.OperatorName = operatorName;
  2584. /*
  2585. * 审核人
  2586. */
  2587. string auditOperatorName = "Unknown";
  2588. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2589. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2590. else
  2591. {
  2592. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2593. if (_adUser != null)
  2594. {
  2595. auditOperatorName = _adUser.CnName;
  2596. }
  2597. }
  2598. _detail.AuditOperatorName = auditOperatorName;
  2599. /*
  2600. * 超预算比例
  2601. */
  2602. string overBudgetStr = "";
  2603. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2604. else if (entity.ExceedBudget == 0)
  2605. {
  2606. if (entity.CTable == 76 || entity.CTable == 79)
  2607. {
  2608. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2609. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2610. }
  2611. else
  2612. {
  2613. overBudgetStr = "未超预算";
  2614. }
  2615. }
  2616. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2617. _detail.OverBudget = overBudgetStr;
  2618. decimal auditFee = 0.00M; //已审核金额 人名币
  2619. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2620. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2621. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2622. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2623. {
  2624. auditedFeeOriginal = entity.PayMoney;
  2625. auditFee = CurrPayStr;
  2626. }
  2627. else if (entity.IsAuditGM == 0)
  2628. {
  2629. unAuditFeeCNY = CurrPayStr;
  2630. unAuditFeeOriginal = OriginalCurrPay;
  2631. OriginalCurrPay = 0.00M;
  2632. }
  2633. /*
  2634. * 费用总计
  2635. */
  2636. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2637. {
  2638. CurrencyId = entity.PaymentCurrency,
  2639. CurrencyName = PaymentCurrency_WaitPay,
  2640. AmountPayable = entity.PayMoney,
  2641. ThisPayment = OriginalCurrPay,
  2642. BalancePayment = BalanceStr,
  2643. AuditedFunds = auditFee,
  2644. AuditedFundsOriginal = auditedFeeOriginal,
  2645. UnAuditFundsCNY = unAuditFeeCNY,
  2646. UnAuditFundsOriginal = unAuditFeeOriginal
  2647. });
  2648. _detail.IsAuditGM = entity.IsAuditGM;
  2649. detailList.Add(_detail);
  2650. }
  2651. #endregion
  2652. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2653. /*
  2654. * 下方描述处理
  2655. */
  2656. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2657. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2658. if (ccpCurrencyPrice != null)
  2659. {
  2660. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2661. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2662. }
  2663. else
  2664. {
  2665. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2666. }
  2667. string amountPayableStr = string.Format(@"应付款总金额: ");
  2668. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2669. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2670. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2671. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2672. foreach (var item in nonDuplicat)
  2673. {
  2674. var currencyName = item.CurrencyName;
  2675. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2676. if (strs.Count > 0)
  2677. {
  2678. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2679. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2680. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2681. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2682. //单独处理此次付款金额
  2683. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2684. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2685. //单独处理已审核费用
  2686. //if (item.CurrencyId == 836) //人民币
  2687. //{
  2688. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2689. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2690. //}
  2691. //else
  2692. //{
  2693. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2694. //}
  2695. if (currencyName.Equals("CNY"))
  2696. {
  2697. //已审核费用
  2698. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2699. //未审核费用
  2700. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2701. }
  2702. else
  2703. {
  2704. //已审核费用
  2705. 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"));
  2706. //未审核费用
  2707. 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"));
  2708. }
  2709. }
  2710. }
  2711. _view.TotalStr1 = amountPayableStr[..^1];
  2712. _view.TotalStr2 = thisPaymentStr[..^1];
  2713. _view.TotalStr3 = balancePaymentStr[..^1];
  2714. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2715. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2716. var _view1 = new
  2717. {
  2718. PageFuncAuth = pageFunAuthView,
  2719. Data = _view
  2720. };
  2721. return Ok(JsonView(_view1));
  2722. }
  2723. catch (Exception ex)
  2724. {
  2725. return Ok(JsonView(false, ex.Message));
  2726. }
  2727. }
  2728. /// <summary>
  2729. /// 费用审核
  2730. /// 修改团组费用审核状态
  2731. /// </summary>
  2732. /// <param name="_dto">参数Json字符串</param>
  2733. /// <returns></returns>
  2734. [HttpPost]
  2735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2736. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2737. {
  2738. #region 参数验证
  2739. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2740. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2741. #endregion
  2742. #region 页面操作权限验证
  2743. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2744. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2745. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2746. #endregion
  2747. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2748. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2749. DateTime dtNow = DateTime.Now;
  2750. _groupRepository.BeginTran();
  2751. int rst = 0;
  2752. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2753. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2754. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2755. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2756. List<dynamic> msgDatas = new List<dynamic>();
  2757. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2758. foreach (var item in idList)
  2759. {
  2760. int CreditId = int.Parse(item);
  2761. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2762. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2763. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2764. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2765. .Where(s => s.Id == CreditId)
  2766. .ExecuteCommandAsync();
  2767. if (result < 1)
  2768. {
  2769. rst = -1;
  2770. _groupRepository.RollbackTran();
  2771. return Ok(JsonView(false, "操作失败并回滚!"));
  2772. }
  2773. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2774. if (creditData != null)
  2775. {
  2776. #region 应用通知配置
  2777. try
  2778. {
  2779. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2780. }
  2781. catch (Exception ex)
  2782. {
  2783. }
  2784. #endregion
  2785. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2786. string groupNameStr = string.Empty;
  2787. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2788. if (groupData != null) groupNameStr = groupData.TeamName;
  2789. string creditTypeStr = string.Empty;
  2790. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2791. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2792. string creditCurrency = string.Empty;
  2793. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2794. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2795. if (creditCurrency.Equals("CNY"))
  2796. {
  2797. creditData.DayRate = 1.0000M;
  2798. }
  2799. if (creditData.PayPercentage == 0.00M)
  2800. {
  2801. creditData.PayPercentage = 100M;
  2802. }
  2803. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2804. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2805. string msgContent = "";
  2806. if (creditCurrency.Equals("CNY"))
  2807. {
  2808. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2809. }
  2810. else
  2811. {
  2812. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2813. }
  2814. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2815. }
  2816. }
  2817. if (rst == 0)
  2818. {
  2819. _groupRepository.CommitTran();
  2820. foreach (var item in msgDatas)
  2821. {
  2822. //发送消息
  2823. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2824. }
  2825. #region 应用推送
  2826. try
  2827. {
  2828. foreach (var ccpId in dic_ccp_user.Keys)
  2829. {
  2830. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2831. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2832. }
  2833. }
  2834. catch (Exception)
  2835. {
  2836. }
  2837. #endregion
  2838. return Ok(JsonView(true, "操作成功!"));
  2839. }
  2840. return Ok(JsonView(false, "操作失败!"));
  2841. }
  2842. #endregion
  2843. #region 机票费用录入
  2844. /// <summary>
  2845. /// 机票录入当前登录人可操作团组
  2846. /// </summary>
  2847. /// <param name="dto"></param>
  2848. /// <returns></returns>
  2849. [HttpPost]
  2850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2851. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2852. {
  2853. try
  2854. {
  2855. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2856. if (groupData.Code != 0)
  2857. {
  2858. return Ok(JsonView(false, groupData.Msg));
  2859. }
  2860. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2861. }
  2862. catch (Exception ex)
  2863. {
  2864. return Ok(JsonView(false, "程序错误!"));
  2865. throw;
  2866. }
  2867. }
  2868. /// <summary>
  2869. /// 机票费用录入列表
  2870. /// </summary>
  2871. /// <param name="dto"></param>
  2872. /// <returns></returns>
  2873. [HttpPost]
  2874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2875. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2876. {
  2877. try
  2878. {
  2879. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2880. if (groupData.Code != 0)
  2881. {
  2882. return Ok(JsonView(false, groupData.Msg));
  2883. }
  2884. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2885. }
  2886. catch (Exception ex)
  2887. {
  2888. return Ok(JsonView(false, ex.Message));
  2889. throw;
  2890. }
  2891. }
  2892. /// <summary>
  2893. /// 根据id查询费用录入信息
  2894. /// </summary>
  2895. /// <param name="dto"></param>
  2896. /// <returns></returns>
  2897. [HttpPost]
  2898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2899. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2900. {
  2901. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2902. if (groupData.Code != 0)
  2903. {
  2904. return Ok(JsonView(false, groupData.Msg));
  2905. }
  2906. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2907. }
  2908. /// <summary>
  2909. /// 机票费用录入操作(Status:1.新增,2.修改)
  2910. /// </summary>
  2911. /// <param name="dto"></param>
  2912. /// <returns></returns>
  2913. [HttpPost]
  2914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2915. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2916. {
  2917. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2918. if (groupData.Code != 0)
  2919. {
  2920. return Ok(JsonView(false, groupData.Msg));
  2921. }
  2922. #region 应用推送
  2923. try
  2924. {
  2925. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2926. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2927. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2928. //2024-10-21 新增LZ UID
  2929. var userIds = new List<int>() { 21 };
  2930. string title = $"系统通知";
  2931. string content = "";
  2932. var diId = dto.AirTicketResOpData.DiId;
  2933. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2934. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2935. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2936. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2937. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2938. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2939. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2940. }
  2941. catch (Exception ex)
  2942. {
  2943. }
  2944. #endregion
  2945. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2946. }
  2947. /// <summary>
  2948. /// 根据舱位类型查询接团客户名单信息
  2949. /// </summary>
  2950. /// <param name="dto"></param>
  2951. /// <returns></returns>
  2952. [HttpPost]
  2953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2954. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2955. {
  2956. try
  2957. {
  2958. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2959. if (crm_Groups.Count != 0)
  2960. {
  2961. List<dynamic> Customer = new List<dynamic>();
  2962. foreach (var item in crm_Groups)
  2963. {
  2964. var data = new
  2965. {
  2966. Id = item.Id,
  2967. Pinyin = item.Pinyin,
  2968. Name = item.LastName + item.FirstName
  2969. };
  2970. Customer.Add(data);
  2971. }
  2972. return Ok(JsonView(true, "查询成功!", Customer));
  2973. }
  2974. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2975. }
  2976. catch (Exception ex)
  2977. {
  2978. return Ok(JsonView(false, "程序错误!"));
  2979. throw;
  2980. }
  2981. }
  2982. /// <summary>
  2983. /// 根据团号获取客户信息
  2984. /// </summary>
  2985. /// <param name="dto"></param>
  2986. /// <returns></returns>
  2987. [HttpPost]
  2988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2989. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2990. {
  2991. var jw = JsonView(false);
  2992. if (dto.DIID < 1)
  2993. {
  2994. jw.Msg += "请输入正确的diid";
  2995. return Ok(jw);
  2996. }
  2997. var arr = getSimplClientList(dto.DIID);
  2998. jw = JsonView(true, "获取成功!", arr);
  2999. return Ok(jw);
  3000. }
  3001. private List<SimplClientInfo> getSimplClientList(int diId)
  3002. {
  3003. 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);
  3004. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3005. foreach (var item in arr)
  3006. {
  3007. EncryptionProcessor.DecryptProperties(item);
  3008. }
  3009. return arr;
  3010. }
  3011. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3012. {
  3013. string result = origin;
  3014. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3015. {
  3016. string[] temparr = origin.Split(',');
  3017. string fistrStr = temparr[0];
  3018. int count = temparr.Count();
  3019. int tempId;
  3020. bool success = int.TryParse(fistrStr, out tempId);
  3021. if (success)
  3022. {
  3023. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3024. if (tempInfo != null)
  3025. {
  3026. if (count > 1)
  3027. {
  3028. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3029. }
  3030. else
  3031. {
  3032. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3033. }
  3034. }
  3035. }
  3036. }
  3037. return result;
  3038. }
  3039. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3040. {
  3041. string result = origin;
  3042. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3043. {
  3044. string[] temparr = origin.Split(',');
  3045. result = "";
  3046. foreach (var item in temparr)
  3047. {
  3048. int tempId;
  3049. bool success = int.TryParse(item, out tempId);
  3050. if (success)
  3051. {
  3052. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3053. if (tempInfo != null)
  3054. {
  3055. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3056. }
  3057. }
  3058. }
  3059. }
  3060. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3061. return result;
  3062. }
  3063. /// <summary>
  3064. /// 机票费用录入,删除
  3065. /// </summary>
  3066. /// <param name="dto"></param>
  3067. /// <returns></returns>
  3068. [HttpPost]
  3069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3070. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3071. {
  3072. try
  3073. {
  3074. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3075. if (res)
  3076. {
  3077. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3078. {
  3079. IsDel = 1,
  3080. DeleteUserId = dto.DeleteUserId,
  3081. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3082. }).ExecuteCommandAsync();
  3083. return Ok(JsonView(true, "删除成功!"));
  3084. }
  3085. return Ok(JsonView(false, "删除失败!"));
  3086. }
  3087. catch (Exception ex)
  3088. {
  3089. return Ok(JsonView(false, "程序错误!"));
  3090. throw;
  3091. }
  3092. }
  3093. /// <summary>
  3094. /// 导出机票录入报表
  3095. /// </summary>
  3096. /// <param name="dto"></param>
  3097. /// <returns></returns>
  3098. [HttpPost]
  3099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3100. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3101. {
  3102. try
  3103. {
  3104. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3105. if (groupData.Code != 0)
  3106. {
  3107. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3108. }
  3109. else
  3110. {
  3111. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3112. if (AirTicketReservations.Count != 0)
  3113. {
  3114. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3115. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3116. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3117. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3118. WorkbookDesigner designer = new WorkbookDesigner();
  3119. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3120. decimal countCost = 0;
  3121. foreach (var item in AirTicketReservations)
  3122. {
  3123. #region 处理客人姓名
  3124. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3125. item.ClientName = clientNames;
  3126. #endregion
  3127. if (item.BankType == "其他")
  3128. {
  3129. item.BankNo = "--";
  3130. }
  3131. else
  3132. {
  3133. if (!string.IsNullOrEmpty(item.BankType))
  3134. {
  3135. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3136. }
  3137. }
  3138. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3139. item.Price = System.Decimal.Round(item.Price, 2);
  3140. countCost += Convert.ToDecimal(item.Price);
  3141. }
  3142. designer.SetDataSource("Export", AirTicketReservations);
  3143. designer.SetDataSource("ExportDiCode", diCode);
  3144. designer.SetDataSource("ExportDiName", diName);
  3145. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3146. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3147. designer.Process();
  3148. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3149. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3150. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3151. return Ok(JsonView(true, "成功", url = rst));
  3152. }
  3153. else
  3154. {
  3155. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3156. }
  3157. }
  3158. }
  3159. catch (Exception ex)
  3160. {
  3161. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3162. throw;
  3163. }
  3164. }
  3165. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3166. /// <summary>
  3167. /// 行程单导出
  3168. /// </summary>
  3169. /// <param name="dto"></param>
  3170. /// <returns></returns>
  3171. [HttpPost]
  3172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3173. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3174. {
  3175. try
  3176. {
  3177. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3178. if (groupData.Code != 0)
  3179. {
  3180. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3181. }
  3182. else
  3183. {
  3184. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3185. if (dto.Language == "CN")
  3186. {
  3187. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3188. DocumentBuilder builder = new DocumentBuilder(doc);
  3189. int tableIndex = 0;//表格索引
  3190. //得到文档中的第一个表格
  3191. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3192. foreach (var item in _AirTicketReservations)
  3193. {
  3194. #region 处理固定数据
  3195. string[] FlightsCode = item.FlightsCode.Split('/');
  3196. if (FlightsCode.Length != 0)
  3197. {
  3198. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3199. if (_AirCompany != null)
  3200. {
  3201. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3202. }
  3203. else
  3204. {
  3205. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3206. }
  3207. }
  3208. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3209. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3210. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3211. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3212. string name = "";
  3213. foreach (string clientName in nameArray)
  3214. {
  3215. if (!name.Contains(clientName))
  3216. {
  3217. name += clientName + ",";
  3218. }
  3219. }
  3220. if (!string.IsNullOrWhiteSpace(name))
  3221. {
  3222. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3223. }
  3224. else
  3225. {
  3226. table.Range.Bookmarks["ClientName"].Text = "--";
  3227. }
  3228. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3229. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3230. table.Range.Bookmarks["JointTicket"].Text = "--";
  3231. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3232. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3233. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3234. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3235. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3236. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3237. #endregion
  3238. #region 循环数据处理
  3239. List<AirInfo> airs = new List<AirInfo>();
  3240. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3241. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3242. for (int i = 0; i < FlightsCode.Length; i++)
  3243. {
  3244. AirInfo air = new AirInfo();
  3245. string[] tempstr = DayArray[i]
  3246. .Replace("\r\n", string.Empty)
  3247. .Replace("\\r\\n", string.Empty)
  3248. .TrimStart().TrimEnd()
  3249. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3250. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3251. string starCity = "";
  3252. if (star_Three != null)
  3253. {
  3254. starCity = star_Three.AirPort;
  3255. }
  3256. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3257. string EndCity = "";
  3258. if (End_Three != null)
  3259. {
  3260. EndCity = End_Three.AirPort;
  3261. }
  3262. air.Destination = starCity + "/" + EndCity;
  3263. air.Flight = FlightsCode[i];
  3264. air.SeatingClass = item.CTypeName;
  3265. string dateTime = tempstr[2];
  3266. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3267. air.FlightDate = DateTemp;
  3268. air.DepartureTime = tempstr[5];
  3269. air.LandingTime = tempstr[6];
  3270. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3271. air.TicketStatus = "--";
  3272. air.Luggage = "--";
  3273. air.DepartureTerminal = "--";
  3274. air.LandingTerminal = "--";
  3275. airs.Add(air);
  3276. }
  3277. int row = 13;
  3278. for (int i = 0; i < airs.Count; i++)
  3279. {
  3280. if (airs.Count > 2)
  3281. {
  3282. for (int j = 0; j < airs.Count - 2; j++)
  3283. {
  3284. var CopyRow = table.Rows[12].Clone(true);
  3285. table.Rows.Add(CopyRow);
  3286. }
  3287. }
  3288. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3289. int index = 0;
  3290. foreach (PropertyInfo property in properties)
  3291. {
  3292. string value = property.GetValue(airs[i]).ToString();
  3293. Cell ishcel0 = table.Rows[row].Cells[index];
  3294. Paragraph p = new Paragraph(doc);
  3295. string s = value;
  3296. p.AppendChild(new Run(doc, s));
  3297. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3298. ishcel0.AppendChild(p);
  3299. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3300. index++;
  3301. }
  3302. row++;
  3303. }
  3304. #endregion
  3305. Paragraph lastParagraph = new Paragraph(doc);
  3306. //第一个表格末尾加段落
  3307. table.ParentNode.InsertAfter(lastParagraph, table);
  3308. //复制第一个表格
  3309. Table cloneTable = (Table)table.Clone(true);
  3310. //在文档末尾段落后面加入复制的表格
  3311. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3312. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3313. {
  3314. int rownewsIndex = 13;
  3315. for (int i = 0; i < 2; i++)
  3316. {
  3317. var CopyRow = table.Rows[12].Clone(true);
  3318. table.Rows.RemoveAt(13);
  3319. table.Rows.Add(CopyRow);
  3320. rownewsIndex++;
  3321. }
  3322. }
  3323. else
  3324. {
  3325. table.Rows.RemoveAt(12);
  3326. }
  3327. cloneTable.Rows.RemoveAt(12);
  3328. }
  3329. if (_AirTicketReservations.Count != 0)
  3330. {
  3331. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3332. if (FlightsCode.Length != 0)
  3333. {
  3334. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3335. if (_AirCompany != null)
  3336. {
  3337. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3338. }
  3339. else
  3340. {
  3341. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3342. }
  3343. }
  3344. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3345. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3346. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3347. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3348. string name = "";
  3349. foreach (string clientName in nameArray)
  3350. {
  3351. if (!name.Contains(clientName))
  3352. {
  3353. name += clientName + ",";
  3354. }
  3355. }
  3356. if (!string.IsNullOrWhiteSpace(name))
  3357. {
  3358. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3359. }
  3360. else
  3361. {
  3362. table.Range.Bookmarks["ClientName"].Text = "--";
  3363. }
  3364. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3365. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3366. table.Range.Bookmarks["JointTicket"].Text = "--";
  3367. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3368. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3369. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3370. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3371. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3372. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3373. }
  3374. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3375. //保存合并后的文档
  3376. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3377. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3378. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3379. return Ok(JsonView(true, "成功!", rst));
  3380. }
  3381. else
  3382. {
  3383. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3384. DocumentBuilder builder = new DocumentBuilder(doc);
  3385. int tableIndex = 0;//表格索引
  3386. //得到文档中的第一个表格
  3387. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3388. List<string> texts = new List<string>();
  3389. foreach (var item in _AirTicketReservations)
  3390. {
  3391. string[] FlightsCode = item.FlightsCode.Split('/');
  3392. if (FlightsCode.Length != 0)
  3393. {
  3394. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3395. if (_AirCompany != null)
  3396. {
  3397. if (!transDic.ContainsKey(_AirCompany.CnName))
  3398. {
  3399. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3400. }
  3401. }
  3402. else
  3403. {
  3404. if (!transDic.ContainsKey("--"))
  3405. {
  3406. transDic.Add("--", "--");
  3407. }
  3408. }
  3409. }
  3410. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3411. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3412. string name = "";
  3413. foreach (string clientName in nameArray)
  3414. {
  3415. name += clientName + ",";
  3416. }
  3417. if (!texts.Contains(name))
  3418. {
  3419. texts.Add(name);
  3420. }
  3421. List<AirInfo> airs = new List<AirInfo>();
  3422. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3423. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3424. for (int i = 0; i < FlightsCode.Length; i++)
  3425. {
  3426. AirInfo air = new AirInfo();
  3427. string[] tempstr = DayArray[i]
  3428. .Replace("\r\n", string.Empty)
  3429. .Replace("\\r\\n", string.Empty)
  3430. .TrimStart().TrimEnd()
  3431. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3432. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3433. if (star_Three != null)
  3434. {
  3435. if (!transDic.ContainsKey(star_Three.AirPort))
  3436. {
  3437. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3438. }
  3439. }
  3440. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3441. if (End_Three != null)
  3442. {
  3443. if (!transDic.ContainsKey(End_Three.AirPort))
  3444. {
  3445. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3446. }
  3447. }
  3448. if (!texts.Contains(item.CTypeName))
  3449. {
  3450. texts.Add(item.CTypeName);
  3451. }
  3452. }
  3453. }
  3454. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3455. if (transData.Count > 0)
  3456. {
  3457. foreach (TranslateResult item in transData)
  3458. {
  3459. if (!transDic.ContainsKey(item.Query))
  3460. {
  3461. transDic.Add(item.Query, item.Translation);
  3462. }
  3463. }
  3464. }
  3465. foreach (var item in _AirTicketReservations)
  3466. {
  3467. #region 处理固定数据
  3468. string[] FlightsCode = item.FlightsCode.Split('/');
  3469. if (FlightsCode.Length != 0)
  3470. {
  3471. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3472. if (_AirCompany != null)
  3473. {
  3474. string str = "--";
  3475. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3476. if (!string.IsNullOrEmpty(translateResult))
  3477. {
  3478. str = translateResult;
  3479. str = _airTicketResRep.Processing(str);
  3480. }
  3481. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3482. }
  3483. else
  3484. {
  3485. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3486. }
  3487. }
  3488. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3489. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3490. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3491. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3492. string names = "";
  3493. foreach (string clientName in nameArray)
  3494. {
  3495. names += clientName + ",";
  3496. }
  3497. if (!string.IsNullOrWhiteSpace(names))
  3498. {
  3499. string str = "--";
  3500. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3501. if (!string.IsNullOrEmpty(translateResult))
  3502. {
  3503. str = translateResult;
  3504. str = _airTicketResRep.Processing(str);
  3505. }
  3506. table.Range.Bookmarks["ClientName"].Text = str;
  3507. }
  3508. else
  3509. {
  3510. table.Range.Bookmarks["ClientName"].Text = "--";
  3511. }
  3512. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3513. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3514. table.Range.Bookmarks["JointTicket"].Text = "--";
  3515. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3516. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3517. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3518. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3519. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3520. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3521. #endregion
  3522. #region 循环数据处理
  3523. List<AirInfo> airs = new List<AirInfo>();
  3524. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3525. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3526. for (int i = 0; i < FlightsCode.Length; i++)
  3527. {
  3528. AirInfo air = new AirInfo();
  3529. string[] tempstr = DayArray[i]
  3530. .Replace("\r\n", string.Empty)
  3531. .Replace("\\r\\n", string.Empty)
  3532. .TrimStart().TrimEnd()
  3533. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3534. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3535. string starCity = "";
  3536. if (star_Three != null)
  3537. {
  3538. string str2 = "--";
  3539. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3540. if (!string.IsNullOrEmpty(translateResult2))
  3541. {
  3542. str2 = translateResult2;
  3543. str2 = _airTicketResRep.Processing(str2);
  3544. }
  3545. starCity = str2;
  3546. }
  3547. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3548. string EndCity = "";
  3549. if (End_Three != null)
  3550. {
  3551. string str1 = "--";
  3552. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3553. if (!string.IsNullOrEmpty(translateResult1))
  3554. {
  3555. str1 = translateResult1;
  3556. str1 = _airTicketResRep.Processing(str1);
  3557. }
  3558. EndCity = str1;
  3559. }
  3560. air.Destination = starCity + "/" + EndCity;
  3561. air.Flight = FlightsCode[i];
  3562. string str = "--";
  3563. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3564. if (!string.IsNullOrEmpty(translateResult))
  3565. {
  3566. str = translateResult;
  3567. str = _airTicketResRep.Processing(str);
  3568. }
  3569. air.SeatingClass = str;
  3570. string dateTime = tempstr[2];
  3571. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3572. air.FlightDate = DateTemp;
  3573. air.DepartureTime = tempstr[5];
  3574. air.LandingTime = tempstr[6];
  3575. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3576. air.TicketStatus = "--";
  3577. air.Luggage = "--";
  3578. air.DepartureTerminal = "--";
  3579. air.LandingTerminal = "--";
  3580. airs.Add(air);
  3581. }
  3582. int row = 13;
  3583. for (int i = 0; i < airs.Count; i++)
  3584. {
  3585. if (airs.Count > 2)
  3586. {
  3587. for (int j = 0; j < airs.Count - 2; j++)
  3588. {
  3589. var CopyRow = table.Rows[12].Clone(true);
  3590. table.Rows.Add(CopyRow);
  3591. }
  3592. }
  3593. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3594. int index = 0;
  3595. foreach (PropertyInfo property in properties)
  3596. {
  3597. string value = property.GetValue(airs[i]).ToString();
  3598. Cell ishcel0 = table.Rows[row].Cells[index];
  3599. Paragraph p = new Paragraph(doc);
  3600. string s = value;
  3601. p.AppendChild(new Run(doc, s));
  3602. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3603. ishcel0.AppendChild(p);
  3604. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3605. //ishcel0.CellFormat.VerticalAlignment=
  3606. index++;
  3607. }
  3608. row++;
  3609. }
  3610. #endregion
  3611. Paragraph lastParagraph = new Paragraph(doc);
  3612. //第一个表格末尾加段落
  3613. table.ParentNode.InsertAfter(lastParagraph, table);
  3614. //复制第一个表格
  3615. Table cloneTable = (Table)table.Clone(true);
  3616. //在文档末尾段落后面加入复制的表格
  3617. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3618. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3619. {
  3620. int rownewsIndex = 13;
  3621. for (int i = 0; i < 2; i++)
  3622. {
  3623. var CopyRow = table.Rows[12].Clone(true);
  3624. table.Rows.RemoveAt(13);
  3625. table.Rows.Add(CopyRow);
  3626. rownewsIndex++;
  3627. }
  3628. }
  3629. else
  3630. {
  3631. table.Rows.RemoveAt(12);
  3632. }
  3633. cloneTable.Rows.RemoveAt(12);
  3634. }
  3635. if (_AirTicketReservations.Count != 0)
  3636. {
  3637. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3638. if (FlightsCode.Length != 0)
  3639. {
  3640. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3641. if (_AirCompany != null)
  3642. {
  3643. string str = "--";
  3644. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3645. if (!string.IsNullOrEmpty(translateResult))
  3646. {
  3647. str = translateResult;
  3648. str = _airTicketResRep.Processing(str);
  3649. }
  3650. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3651. }
  3652. else
  3653. {
  3654. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3655. }
  3656. }
  3657. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3658. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3659. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3660. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3661. string names = "";
  3662. foreach (string clientName in nameArray)
  3663. {
  3664. names += clientName + ",";
  3665. }
  3666. if (!string.IsNullOrWhiteSpace(names))
  3667. {
  3668. string str = "--";
  3669. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3670. if (!string.IsNullOrEmpty(translateResult))
  3671. {
  3672. str = translateResult;
  3673. str = _airTicketResRep.Processing(str);
  3674. }
  3675. table.Range.Bookmarks["ClientName"].Text = str;
  3676. }
  3677. else
  3678. {
  3679. table.Range.Bookmarks["ClientName"].Text = "--";
  3680. }
  3681. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3682. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3683. table.Range.Bookmarks["JointTicket"].Text = "--";
  3684. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3685. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3686. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3687. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3688. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3689. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3690. }
  3691. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3692. //保存合并后的文档
  3693. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3694. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3695. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3696. return Ok(JsonView(true, "成功!", rst));
  3697. }
  3698. }
  3699. }
  3700. catch (Exception ex)
  3701. {
  3702. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3703. throw;
  3704. }
  3705. }
  3706. #endregion
  3707. #region 团组增减款项 --> 其他款项
  3708. /// <summary>
  3709. /// 团组增减款项下拉框绑定
  3710. /// </summary>
  3711. /// <param name="dto"></param>
  3712. /// <returns></returns>
  3713. [HttpPost]
  3714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3715. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3716. {
  3717. #region 参数验证
  3718. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3719. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3720. #endregion
  3721. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3722. }
  3723. /// <summary>
  3724. /// 根据团组Id查询团组增减款项
  3725. /// </summary>
  3726. /// <param name="dto"></param>
  3727. /// <returns></returns>
  3728. [HttpPost]
  3729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3730. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3731. {
  3732. #region 参数验证
  3733. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3734. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3735. #endregion
  3736. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3737. }
  3738. /// <summary>
  3739. /// 团组增减款项操作(Status:1.新增,2.修改)
  3740. /// </summary>
  3741. /// <param name="dto"></param>
  3742. /// <returns></returns>
  3743. [HttpPost]
  3744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3745. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3746. {
  3747. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3748. if (groupData.Code != 200)
  3749. {
  3750. return Ok(JsonView(false, groupData.Msg));
  3751. }
  3752. #region 应用推送
  3753. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3754. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3755. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3756. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3757. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3758. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3759. //自动审核
  3760. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3761. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3762. //2024-10-21 新增LZ UID
  3763. var userIds = new List<int>() { 21 };
  3764. string title = $"系统通知";
  3765. string content = "";
  3766. var diId = dto.DiId;
  3767. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3768. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3769. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3770. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3771. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3772. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3773. #endregion
  3774. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3775. }
  3776. /// <summary>
  3777. /// 团组增减款项操作 删除
  3778. /// </summary>
  3779. /// <param name="dto"></param>
  3780. /// <returns></returns>
  3781. [HttpPost]
  3782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3783. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3784. {
  3785. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3786. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3787. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3788. if (res.Code == 0)
  3789. {
  3790. return Ok(JsonView(true, "删除成功!"));
  3791. }
  3792. return Ok(JsonView(false, "删除失败!"));
  3793. }
  3794. /// <summary>
  3795. /// 根据团组增减款项Id查询
  3796. /// </summary>
  3797. /// <param name="dto"></param>
  3798. /// <returns></returns>
  3799. [HttpPost]
  3800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3801. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3802. {
  3803. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3804. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3805. }
  3806. /// <summary>
  3807. /// 查询供应商名称
  3808. /// </summary>
  3809. /// <param name="dto"></param>
  3810. /// <returns></returns>
  3811. [HttpPost]
  3812. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3813. {
  3814. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3815. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3816. ?? new List<Grp_DecreasePayments>();
  3817. dbResult = dbResult.Distinct(new
  3818. ProductComparer()).ToList();
  3819. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3820. {
  3821. x.Id,
  3822. x.SupplierAddress,
  3823. x.SupplierArea,
  3824. x.SupplierContact,
  3825. x.SupplierContactNumber,
  3826. x.SupplierEmail,
  3827. x.SupplierName,
  3828. x.SupplierSocialAccount,
  3829. x.SupplierTypeId,
  3830. }).ToList());
  3831. return Ok(jw);
  3832. }
  3833. /// <summary>
  3834. /// 团组增减款项 OTA匹配
  3835. /// </summary>
  3836. /// <param name="file"></param>
  3837. /// <returns></returns>
  3838. [HttpPost]
  3839. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3840. {
  3841. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3842. string fileName = file.FileName;
  3843. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3844. {
  3845. return Ok(JsonView(false, "请上传Excel文件!"));
  3846. }
  3847. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3848. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3849. if (!Directory.Exists(path))
  3850. {
  3851. Directory.CreateDirectory(path);
  3852. }
  3853. var filePath = @$"{path}/{fileName}";
  3854. //保存文件
  3855. using (FileStream fs = System.IO.File.Create(filePath))
  3856. {
  3857. file.CopyTo(fs);
  3858. fs.Flush();
  3859. }
  3860. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3861. //读取ExcelFile
  3862. DataTable dt = ConvertExcelToDataTable(filePath);
  3863. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3864. dt.TableName = "TB";
  3865. //修改table列名
  3866. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3867. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3868. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3869. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3870. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3871. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3872. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3873. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3874. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3875. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3876. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3877. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3878. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3879. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3880. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3881. var otaOrderNos = new List<string>();
  3882. foreach (DataRow item in dt.Rows)
  3883. {
  3884. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3885. }
  3886. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3887. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3888. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3889. .Select((dp, di) => new
  3890. {
  3891. dp.PriceName,
  3892. dp.OTAOrderNo,
  3893. dp.FeeTotal,
  3894. di.TeamName,
  3895. })
  3896. .ToListAsync();
  3897. foreach (DataRow item in dt.Rows)
  3898. {
  3899. var otaOrderNo = item["OTAOrderNo"].ToString();
  3900. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3901. if (oaData == null) continue;
  3902. item["GroupName"] = oaData.TeamName;
  3903. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3904. }
  3905. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3906. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3907. List<DataTable> datas = new List<DataTable>();
  3908. datas.Add(dt);
  3909. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3910. return Ok(JsonView(true, "操作成功", new { url = url }));
  3911. }
  3912. #region
  3913. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3914. {
  3915. // 创建Workbook对象
  3916. Workbook workbook = new Workbook(excelFilePath);
  3917. // 获取第一个工作表
  3918. Worksheet worksheet = workbook.Worksheets[0];
  3919. // 将工作表转换为DataTable
  3920. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3921. return dataTable;
  3922. }
  3923. #endregion
  3924. #endregion
  3925. #region 文件上传、删除
  3926. /// <summary>
  3927. /// region 文件上传 可以带参数
  3928. /// </summary>
  3929. /// <param name="file"></param>
  3930. /// <returns></returns>
  3931. [HttpPost]
  3932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3933. public async Task<IActionResult> UploadProject(IFormFile file)
  3934. {
  3935. //var TypeName = Request.Headers["TypeName"].ToString();
  3936. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3937. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3938. ////文件名称
  3939. //string projectFileName = file.FileName;
  3940. ////上传的文件的路径
  3941. //string filePath = $"{fileDir}/{projectFileName}";
  3942. //if (TypeName == "A")//A代表团组增减款项
  3943. //{
  3944. // filePath = fileDir + $@"\团组增减款项相关文件";
  3945. // if (!Directory.Exists(filePath))
  3946. // {
  3947. // Directory.CreateDirectory(filePath);
  3948. // }
  3949. // //上传的文件的路径
  3950. // filePath += $@"\{projectFileName}";
  3951. //}
  3952. //else if (TypeName == "B")//B代表商邀相关文件
  3953. //{
  3954. // //上传的文件的路径
  3955. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3956. // if (!Directory.Exists(filePath))
  3957. // {
  3958. // Directory.CreateDirectory(filePath);
  3959. // }
  3960. // //上传的文件的路径
  3961. // filePath = $@"\{projectFileName}";
  3962. //}
  3963. //try
  3964. //{
  3965. // using (FileStream fs = System.IO.File.Create(filePath))
  3966. // {
  3967. // file.CopyTo(fs);
  3968. // fs.Flush();
  3969. // }
  3970. //}
  3971. //catch (Exception ex)
  3972. //{
  3973. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3974. //}
  3975. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3976. try
  3977. {
  3978. var TypeName = Request.Headers["TypeName"].ToString();
  3979. if (file != null)
  3980. {
  3981. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3982. //文件名称
  3983. string projectFileName = file.FileName;
  3984. //上传的文件的路径
  3985. string filePath = $"{fileDir}/{projectFileName}";
  3986. if (TypeName == "A")//A代表团组增减款项
  3987. {
  3988. if (!Directory.Exists(fileDir))
  3989. {
  3990. Directory.CreateDirectory(fileDir);
  3991. }
  3992. //上传的文件的路径
  3993. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3994. }
  3995. else if (TypeName == "B")//B代表商邀相关文件
  3996. {
  3997. if (!Directory.Exists(fileDir))
  3998. {
  3999. Directory.CreateDirectory(fileDir);
  4000. }
  4001. //上传的文件的路径
  4002. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4003. }
  4004. using (FileStream fs = System.IO.File.Create(filePath))
  4005. {
  4006. file.CopyTo(fs);
  4007. fs.Flush();
  4008. }
  4009. return Ok(JsonView(true, "上传成功!", projectFileName));
  4010. }
  4011. else
  4012. {
  4013. return Ok(JsonView(false, "上传失败!"));
  4014. }
  4015. }
  4016. catch (Exception ex)
  4017. {
  4018. return Ok(JsonView(false, "程序错误!"));
  4019. }
  4020. }
  4021. /// <summary>
  4022. /// 删除指定文件
  4023. /// </summary>
  4024. /// <param name="dto"></param>
  4025. /// <returns></returns>
  4026. [HttpPost]
  4027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4028. public async Task<IActionResult> DelFile(DelFileDto dto)
  4029. {
  4030. try
  4031. {
  4032. var TypeName = Request.Headers["TypeName"].ToString();
  4033. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4034. string filePath = "";
  4035. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4036. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4037. int id = 0;
  4038. if (TypeName == "A")
  4039. {
  4040. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4041. // 删除该文件
  4042. System.IO.File.Delete(filePath);
  4043. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4044. .Where(a => a.Id == dto.Id)
  4045. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4046. .ExecuteCommandAsync();
  4047. }
  4048. else if (TypeName == "B")
  4049. {
  4050. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4051. // 删除该文件
  4052. System.IO.File.Delete(filePath);
  4053. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4054. if (info != null)
  4055. {
  4056. string[] files = new string[] { };
  4057. if (!string.IsNullOrEmpty(info.Attachment))
  4058. {
  4059. try
  4060. {
  4061. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4062. }
  4063. catch (Exception)
  4064. {
  4065. files = new List<string>() { info.Attachment }.ToArray();
  4066. }
  4067. }
  4068. if (files.Length > 0)
  4069. {
  4070. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4071. string filePath2 = string.Empty;
  4072. if (files1.Length > 0)
  4073. {
  4074. filePath2 = JsonConvert.SerializeObject(files1);
  4075. }
  4076. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4077. .Where(a => a.Id == dto.Id)
  4078. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4079. .ExecuteCommandAsync();
  4080. }
  4081. }
  4082. }
  4083. if (id != 0)
  4084. {
  4085. return Ok(JsonView(true, "成功!"));
  4086. }
  4087. else
  4088. {
  4089. return Ok(JsonView(false, "失败!"));
  4090. }
  4091. }
  4092. catch (Exception ex)
  4093. {
  4094. return Ok(JsonView(false, "程序错误!"));
  4095. throw;
  4096. }
  4097. }
  4098. /// <summary>
  4099. /// 文件上传多个文件 可以带参数
  4100. /// </summary>
  4101. /// <param name="files"></param>
  4102. /// <returns></returns>
  4103. [HttpPost]
  4104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4105. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4106. {
  4107. try
  4108. {
  4109. var TypeName = Request.Headers["TypeName"].ToString();
  4110. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4111. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4112. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4113. var filePahts = new List<string>();
  4114. foreach (var file in files)
  4115. {
  4116. //文件名称
  4117. string projectFileName = file.FileName;
  4118. //上传的文件的路径
  4119. string filePath = $"{fileDir}/{projectFileName}";
  4120. if (TypeName == "A")//A代表团组增减款项
  4121. {
  4122. if (!Directory.Exists(fileDir))
  4123. {
  4124. Directory.CreateDirectory(fileDir);
  4125. }
  4126. //上传的文件的路径
  4127. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4128. }
  4129. else if (TypeName == "B")//B代表商邀相关文件
  4130. {
  4131. if (!Directory.Exists(fileDir))
  4132. {
  4133. Directory.CreateDirectory(fileDir);
  4134. }
  4135. //上传的文件的路径
  4136. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4137. }
  4138. using (FileStream fs = System.IO.File.Create(filePath))
  4139. {
  4140. file.CopyTo(fs);
  4141. fs.Flush();
  4142. }
  4143. filePahts.Add(projectFileName);
  4144. }
  4145. return Ok(JsonView(true, "上传成功!", filePahts));
  4146. }
  4147. catch (Exception ex)
  4148. {
  4149. return Ok(JsonView(false, "程序错误!"));
  4150. }
  4151. }
  4152. #endregion
  4153. #region 商邀费用录入
  4154. /// <summary>
  4155. /// 根据团组Id查询商邀费用列表
  4156. /// </summary>
  4157. /// <param name="dto"></param>
  4158. /// <returns></returns>
  4159. [HttpPost]
  4160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4161. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4162. {
  4163. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4164. if (groupData.Code != 0)
  4165. {
  4166. return Ok(JsonView(false, groupData.Msg));
  4167. }
  4168. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4169. }
  4170. /// <summary>
  4171. /// 商邀费用列表
  4172. /// 下载文件
  4173. /// </summary>
  4174. /// <param name="id"></param>
  4175. /// <returns></returns>
  4176. [HttpGet("{id}")]
  4177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4178. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4179. {
  4180. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4181. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4182. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4183. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4184. var filePaths = new List<string>();
  4185. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4186. try
  4187. {
  4188. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4189. }
  4190. catch (Exception ex)
  4191. {
  4192. filePaths.Add(info.Attachment);
  4193. }
  4194. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4195. for (int i = 0; i < filePaths.Count; i++)
  4196. {
  4197. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4198. }
  4199. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4200. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4201. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4202. {
  4203. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4204. {
  4205. foreach (string filePath in filePaths)
  4206. {
  4207. if (System.IO.File.Exists(filePath))
  4208. {
  4209. // 获取文件名
  4210. string fileName = Path.GetFileName(filePath);
  4211. // 将文件添加到ZIP归档中
  4212. zipArchive.CreateEntryFromFile(filePath, fileName);
  4213. }
  4214. }
  4215. }
  4216. }
  4217. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4218. }
  4219. /// <summary>
  4220. /// 商邀费用 Info Page 基础数据源
  4221. /// </summary>
  4222. /// <returns></returns>
  4223. [HttpPost]
  4224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4225. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4226. {
  4227. try
  4228. {
  4229. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4230. if (groupData.Code != 0)
  4231. {
  4232. return Ok(JsonView(false, groupData.Msg));
  4233. }
  4234. return Ok(JsonView(true, "操作成功", groupData.Data));
  4235. }
  4236. catch (Exception ex)
  4237. {
  4238. return Ok(JsonView(false, ex.Message));
  4239. throw;
  4240. }
  4241. }
  4242. /// <summary>
  4243. /// 根据商邀费用ID查询C表和商邀费用数据
  4244. /// </summary>
  4245. /// <param name="dto"></param>
  4246. /// <returns></returns>
  4247. [HttpPost]
  4248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4249. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4250. {
  4251. try
  4252. {
  4253. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4254. if (groupData.Code != 0)
  4255. {
  4256. return Ok(JsonView(false, groupData.Msg));
  4257. }
  4258. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4259. }
  4260. catch (Exception ex)
  4261. {
  4262. return Ok(JsonView(false, ex.Message));
  4263. throw;
  4264. }
  4265. }
  4266. /// <summary>
  4267. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4268. /// </summary>
  4269. /// <param name="dto"></param>
  4270. /// <returns></returns>
  4271. [HttpPost]
  4272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4273. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4274. {
  4275. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4276. if (groupData.Code != 0)
  4277. {
  4278. return Ok(JsonView(false, groupData.Msg));
  4279. }
  4280. #region 应用推送
  4281. try
  4282. {
  4283. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4284. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4285. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4286. //2024-10-21 新增LZ UID
  4287. var userIds = new List<int>() { 21 };
  4288. string title = $"系统通知";
  4289. string content = "";
  4290. var diId = dto.DiId;
  4291. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4292. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4293. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4294. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4295. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4296. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4297. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4298. }
  4299. catch (Exception ex)
  4300. {
  4301. }
  4302. #endregion
  4303. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4304. }
  4305. /// <summary>
  4306. /// 商邀删除
  4307. /// </summary>
  4308. /// <param name="dto"></param>
  4309. /// <returns></returns>
  4310. [HttpPost]
  4311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4312. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4313. {
  4314. try
  4315. {
  4316. _sqlSugar.BeginTran();
  4317. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4318. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4319. {
  4320. IsDel = 1,
  4321. DeleteUserId = dto.DeleteUserId,
  4322. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4323. })
  4324. .Where(it => it.Id == dto.Id)
  4325. .ExecuteCommand();
  4326. if (res1 > 0)
  4327. {
  4328. int _diId = 0;
  4329. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4330. if (_ioaInfo != null)
  4331. {
  4332. _diId = _ioaInfo.DiId;
  4333. }
  4334. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4335. .SetColumns(a => new Grp_CreditCardPayment()
  4336. {
  4337. IsDel = 1,
  4338. DeleteUserId = dto.DeleteUserId,
  4339. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4340. })
  4341. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4342. .ExecuteCommand();
  4343. if (res2 > 0)
  4344. {
  4345. _sqlSugar.CommitTran();
  4346. return Ok(JsonView(true, "删除成功!"));
  4347. }
  4348. }
  4349. _sqlSugar.RollbackTran();
  4350. return Ok(JsonView(false, "删除失败"));
  4351. }
  4352. catch (Exception ex)
  4353. {
  4354. _sqlSugar.RollbackTran();
  4355. return Ok(JsonView(false, ex.Message));
  4356. }
  4357. }
  4358. /// <summary>
  4359. /// 团组模块文件上传
  4360. /// </summary>
  4361. /// <param name="dto"></param>
  4362. /// <returns></returns>
  4363. [HttpPost]
  4364. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4365. {
  4366. var jw = JsonView(false);
  4367. long M = 1024 * 1024;
  4368. if (dto.Files == null || dto.Files.Count == 0)
  4369. {
  4370. jw.Msg = "无文件信息!";
  4371. return Ok(jw);
  4372. }
  4373. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4374. {
  4375. jw.Msg = "文件大小超过20M!";
  4376. return Ok(jw);
  4377. }
  4378. //var nameSp = dto.File.FileName.Split(".");
  4379. //if (nameSp.Length < 2)
  4380. //{
  4381. // jw.Msg = "拓展名称有误!";
  4382. // return Ok(jw);
  4383. //}
  4384. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4385. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4386. //{
  4387. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4388. // return Ok(jw);
  4389. //}
  4390. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4391. if (Ctable == null)
  4392. {
  4393. jw.Msg = "Ctable指向有误!";
  4394. return Ok(jw);
  4395. }
  4396. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4397. if (groupInfo == null)
  4398. {
  4399. jw.Msg = "团组信息不存在!";
  4400. return Ok(jw);
  4401. }
  4402. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4403. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4404. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4405. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4406. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4407. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4408. try
  4409. {
  4410. if (!Directory.Exists(fileBase))
  4411. {
  4412. Directory.CreateDirectory(fileBase);
  4413. }
  4414. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4415. foreach (var fileStream in dto.Files)
  4416. {
  4417. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4418. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4419. {
  4420. Cid = dto.Cid,
  4421. CreateTime = DateTime.Now,
  4422. CreateUserId = dto.Userid,
  4423. Ctable = dto.Ctable,
  4424. Diid = dto.Diid,
  4425. IsDel = 0,
  4426. FilePath = saveFilePath,
  4427. FileName = fileStream.FileName
  4428. };
  4429. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4430. {
  4431. fileStream.CopyTo(fs);
  4432. fs.Flush();
  4433. }
  4434. saveArr.Add(file);
  4435. }
  4436. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4437. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4438. jw = JsonView(true, "保存成功!", new
  4439. {
  4440. count = addResult,
  4441. filesName = saveArr.Select(x => x.FileName)
  4442. });
  4443. }
  4444. catch (Exception ex)
  4445. {
  4446. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4447. {
  4448. count = 0,
  4449. filesName = new string[0],
  4450. });
  4451. }
  4452. return Ok(jw);
  4453. }
  4454. /// <summary>
  4455. /// 查询各模块已保存文件
  4456. /// </summary>
  4457. /// <param name="dto"></param>
  4458. /// <returns></returns>
  4459. [HttpPost]
  4460. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4461. {
  4462. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4463. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4464. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4465. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4466. {
  4467. expression = Expressionable.Create<Grp_GroupModelFile>()
  4468. .And(x => visaIds.Contains(x.CreateUserId));
  4469. }
  4470. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4471. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4472. .Where(expression.ToExpression())
  4473. .ToList();
  4474. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4475. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4476. {
  4477. x.FileName,
  4478. x.Id,
  4479. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4480. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4481. })));
  4482. }
  4483. /// <summary>
  4484. /// 下载该团组下的所有文件
  4485. /// </summary>
  4486. /// <param name="dto"></param>
  4487. /// <returns></returns>
  4488. [HttpPost]
  4489. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4490. {
  4491. var jw = JsonView(false);
  4492. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4493. if (groupInfo == null)
  4494. {
  4495. jw.Msg = "团组信息不存在!";
  4496. return Ok(jw);
  4497. }
  4498. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4499. var isModule = Convert.ToBoolean(dto.isModule);
  4500. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4501. IOOperatorHelper io = new IOOperatorHelper();
  4502. if (isModule)
  4503. {
  4504. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4505. foreach (var moduleArr in moduleGroup)
  4506. {
  4507. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4508. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4509. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4510. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4511. foreach (var item in moduleArr)
  4512. {
  4513. if (System.IO.File.Exists(item.FilePath))
  4514. {
  4515. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4516. {
  4517. byte[] bytes = new byte[fileStream.Length];
  4518. fileStream.Read(bytes, 0, bytes.Length);
  4519. fileStream.Close();
  4520. Stream stream = new MemoryStream(bytes);
  4521. chiZips.Add(item.FileName, stream);
  4522. }
  4523. }
  4524. }
  4525. if (chiZips.Count > 0)
  4526. {
  4527. var byts = io.ConvertZipStream(chiZips);
  4528. Stream stream = new MemoryStream(byts);
  4529. Zips.Add(key.Name + "_.zip", stream);
  4530. }
  4531. }
  4532. }
  4533. else
  4534. {
  4535. foreach (var item in dbQuery)
  4536. {
  4537. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4538. {
  4539. byte[] bytes = new byte[fileStream.Length];
  4540. fileStream.Read(bytes, 0, bytes.Length);
  4541. fileStream.Close();
  4542. Stream stream = new MemoryStream(bytes);
  4543. while (Zips.Keys.Contains(item.FileName))
  4544. {
  4545. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4546. }
  4547. Zips.Add(item.FileName, stream);
  4548. }
  4549. }
  4550. }
  4551. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4552. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4553. if (Zips.Count > 0)
  4554. {
  4555. var byts = io.ConvertZipStream(Zips);
  4556. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4557. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4558. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4559. }
  4560. else
  4561. {
  4562. jw.Msg = "暂无生成文件!";
  4563. }
  4564. return Ok(jw);
  4565. }
  4566. /// <summary>
  4567. /// 下载该团组下此模块的所有文件
  4568. /// </summary>
  4569. /// <param name="dto"></param>
  4570. /// <returns></returns>
  4571. [HttpPost]
  4572. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4573. {
  4574. var jw = JsonView(false);
  4575. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4576. if (groupInfo == null)
  4577. {
  4578. jw.Msg = "团组信息不存在!";
  4579. return Ok(jw);
  4580. }
  4581. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4582. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4583. && x.IsDel == 0);
  4584. if (key == null)
  4585. {
  4586. jw.Msg = "Ctable指向错误!";
  4587. return Ok(jw);
  4588. }
  4589. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4590. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4591. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4592. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4593. IOOperatorHelper io = new IOOperatorHelper();
  4594. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4595. foreach (var item in dbQuery)
  4596. {
  4597. if (System.IO.File.Exists(item.FilePath))
  4598. {
  4599. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4600. {
  4601. byte[] bytes = new byte[fileStream.Length];
  4602. fileStream.Read(bytes, 0, bytes.Length);
  4603. fileStream.Close();
  4604. Stream stream = new MemoryStream(bytes);
  4605. while (Zips.Keys.Contains(item.FileName))
  4606. {
  4607. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4608. }
  4609. Zips.Add(item.FileName, stream);
  4610. }
  4611. }
  4612. }
  4613. if (Zips.Count > 0)
  4614. {
  4615. var byts = io.ConvertZipStream(Zips);
  4616. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4617. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4618. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4619. }
  4620. else
  4621. {
  4622. jw.Msg = "暂无生成文件!";
  4623. }
  4624. return Ok(jw);
  4625. }
  4626. /// <summary>
  4627. /// 删除该团组下的指定文件
  4628. /// </summary>
  4629. /// <param name="dto"></param>
  4630. /// <returns></returns>
  4631. [HttpPost]
  4632. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4633. {
  4634. var jw = JsonView(false);
  4635. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4636. if (sing == null)
  4637. {
  4638. jw.Msg = "暂无";
  4639. return Ok(jw);
  4640. }
  4641. if (System.IO.File.Exists(sing.FilePath))
  4642. {
  4643. try
  4644. {
  4645. System.IO.File.Delete(sing.FilePath);
  4646. }
  4647. catch (Exception ex)
  4648. {
  4649. jw.Msg = "删除失败!" + ex.Message;
  4650. return Ok(jw);
  4651. }
  4652. }
  4653. sing.IsDel = 1;
  4654. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4655. sing.DeleteUserId = dto.UserId;
  4656. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4657. jw = JsonView(true, "删除成功!");
  4658. return Ok(jw);
  4659. }
  4660. #endregion
  4661. #region 团组英文资料
  4662. /// <summary>
  4663. /// 查询团组英文所有资料
  4664. /// </summary>
  4665. /// <param name="dto"></param>
  4666. /// <returns></returns>
  4667. [HttpPost]
  4668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4669. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4670. {
  4671. try
  4672. {
  4673. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4674. if (groupData.Code != 0)
  4675. {
  4676. return Ok(JsonView(false, groupData.Msg));
  4677. }
  4678. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4679. }
  4680. catch (Exception ex)
  4681. {
  4682. return Ok(JsonView(false, "程序错误!"));
  4683. throw;
  4684. }
  4685. }
  4686. /// <summary>
  4687. /// 团组英文资料操作(Status:1.新增,2.修改)
  4688. /// </summary>
  4689. /// <param name="dto"></param>
  4690. /// <returns></returns>
  4691. [HttpPost]
  4692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4693. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4694. {
  4695. try
  4696. {
  4697. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4698. if (groupData.Code != 0)
  4699. {
  4700. return Ok(JsonView(false, groupData.Msg));
  4701. }
  4702. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4703. }
  4704. catch (Exception ex)
  4705. {
  4706. return Ok(JsonView(false, "程序错误!"));
  4707. throw;
  4708. }
  4709. }
  4710. /// <summary>
  4711. /// 团组英文资料Id查询数据
  4712. /// </summary>
  4713. /// <param name="dto"></param>
  4714. /// <returns></returns>
  4715. [HttpPost]
  4716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4717. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4718. {
  4719. try
  4720. {
  4721. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4722. if (_DelegationEnData != null)
  4723. {
  4724. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4725. }
  4726. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4727. }
  4728. catch (Exception ex)
  4729. {
  4730. return Ok(JsonView(false, "程序错误!"));
  4731. throw;
  4732. }
  4733. }
  4734. /// <summary>
  4735. /// 团组英文资料删除
  4736. /// </summary>
  4737. /// <param name="dto"></param>
  4738. /// <returns></returns>
  4739. [HttpPost]
  4740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4741. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4742. {
  4743. try
  4744. {
  4745. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4746. if (!res)
  4747. {
  4748. return Ok(JsonView(false, "删除失败"));
  4749. }
  4750. return Ok(JsonView(true, "删除成功!"));
  4751. }
  4752. catch (Exception ex)
  4753. {
  4754. return Ok(JsonView(false, "程序错误!"));
  4755. throw;
  4756. }
  4757. }
  4758. #endregion
  4759. #region 导出邀请函
  4760. /// <summary>
  4761. /// 导出邀请函页面初始化
  4762. /// </summary>
  4763. /// <param name="dto"></param>
  4764. /// <returns></returns>
  4765. [HttpPost]
  4766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4767. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4768. {
  4769. try
  4770. {
  4771. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4772. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4773. if (dto.DiId == 0)
  4774. {
  4775. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4776. }
  4777. else
  4778. {
  4779. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4780. }
  4781. return Ok(JsonView(true, "查询成功!", new
  4782. {
  4783. deleClient = crm_Deles,
  4784. delegations = grp_Delegations
  4785. }));
  4786. }
  4787. catch (Exception ex)
  4788. {
  4789. return Ok(JsonView(false, "程序错误!"));
  4790. throw;
  4791. }
  4792. }
  4793. /// <summary>
  4794. /// 导出邀请函
  4795. /// </summary>
  4796. /// <param name="dto"></param>
  4797. /// <returns></returns>
  4798. [HttpPost]
  4799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4800. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4801. {
  4802. #region 参数验证
  4803. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4804. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4805. #endregion
  4806. try
  4807. {
  4808. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4809. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4810. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4811. From Grp_TourClientList tcl
  4812. Left Join
  4813. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4814. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4815. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4816. From Crm_DeleClient dc
  4817. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4818. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4819. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4820. Where dc.IsDel = 0) temp
  4821. On temp.DcId =tcl.ClientId
  4822. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4823. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4824. List<string> texts = new List<string>();
  4825. if (datas.Count != 0)
  4826. {
  4827. foreach (TourClientListDetailsView item in datas)
  4828. {
  4829. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4830. {
  4831. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4832. }
  4833. else
  4834. {
  4835. string name = item.LastName + item.FirstName;
  4836. texts.Add(name);
  4837. }
  4838. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4839. {
  4840. if (!transDic.ContainsKey(item.Job))
  4841. {
  4842. texts.Add(item.Job);
  4843. }
  4844. }
  4845. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4846. {
  4847. texts.Add(item.CompanyFullName);
  4848. }
  4849. }
  4850. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4851. if (transData.Count > 0)
  4852. {
  4853. foreach (TranslateResult item in transData)
  4854. {
  4855. if (!transDic.ContainsKey(item.Query))
  4856. {
  4857. transDic.Add(item.Query, item.Translation);
  4858. }
  4859. }
  4860. }
  4861. List<GuestList> list = new List<GuestList>();
  4862. foreach (TourClientListDetailsView dele in datas)
  4863. {
  4864. GuestList guestList = new GuestList();
  4865. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4866. {
  4867. guestList.Name = dele.Pinyin;
  4868. }
  4869. else
  4870. {
  4871. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4872. guestList.Name = Name;
  4873. }
  4874. if (dele.Sex == 0)
  4875. {
  4876. guestList.Sex = "Male";
  4877. }
  4878. else if (dele.Sex == 1)
  4879. {
  4880. guestList.Sex = "Female";
  4881. }
  4882. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4883. if (!string.IsNullOrEmpty(dele.Job))
  4884. {
  4885. guestList.Job = dele.Job;
  4886. }
  4887. list.Add(guestList);
  4888. }
  4889. //载入模板
  4890. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4891. DocumentBuilder builder = new DocumentBuilder(doc);
  4892. //获取word里所有表格
  4893. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4894. //获取所填表格的序数
  4895. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4896. var rowStart = tableOne.Rows[0]; //获取第1行
  4897. //循环赋值
  4898. for (int i = 0; i < list.Count; i++)
  4899. {
  4900. builder.MoveToCell(0, i + 1, 0, 0);
  4901. builder.Write(list[i].Name.ToString());
  4902. builder.MoveToCell(0, i + 1, 1, 0);
  4903. builder.Write(list[i].Sex.ToString());
  4904. builder.MoveToCell(0, i + 1, 2, 0);
  4905. builder.Write(list[i].DOB.ToString());
  4906. builder.MoveToCell(0, i + 1, 3, 0);
  4907. builder.Write(list[i].Job.ToString());
  4908. }
  4909. //删除多余行
  4910. while (tableOne.Rows.Count > list.Count + 1)
  4911. {
  4912. tableOne.Rows.RemoveAt(list.Count + 1);
  4913. }
  4914. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4915. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4916. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4917. doc.Save(filePath);
  4918. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4919. return Ok(JsonView(true, "操作成功!", Url));
  4920. }
  4921. else
  4922. {
  4923. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4924. }
  4925. }
  4926. catch (Exception ex)
  4927. {
  4928. return Ok(JsonView(false, ex.Message));
  4929. throw;
  4930. }
  4931. }
  4932. #endregion
  4933. #region 团组经理模块 出入境费用
  4934. /// <summary>
  4935. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4936. /// </summary>
  4937. /// <returns></returns>
  4938. [HttpPost]
  4939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4940. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  4941. {
  4942. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4943. var groupNamFirst = groupNameData.FirstOrDefault();
  4944. //SetDataInfoView
  4945. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  4946. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4947. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4948. //验证城市归属并给默认值
  4949. int provinceId = 122;
  4950. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  4951. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  4952. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4953. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4954. return Ok(JsonView(true, "查询成功!", new
  4955. {
  4956. GroupNameData = groupNameData,
  4957. CurrencyData = _CurrencyData,
  4958. WordTypeData = wordTypeData,
  4959. ExcelTypeData = excelTypeData,
  4960. CurrencyInit = _currencyInfos,
  4961. ViewPermissionData = viewPermissionData
  4962. }));
  4963. }
  4964. /// <summary>
  4965. /// 团组模块 - 出入境费用
  4966. /// 实时汇率 tips
  4967. /// 签证费用 tips
  4968. /// 机票费用 tips
  4969. /// </summary>
  4970. /// <returns></returns>
  4971. [HttpPost]
  4972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4973. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4974. {
  4975. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4976. //默认币种显示
  4977. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4978. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4979. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4980. return Ok(JsonView(true, "查询成功!", new
  4981. {
  4982. //GroupNameData = groupNameData.Data,
  4983. visaData = visaData.Data,
  4984. airData = airData.Data,
  4985. reteInfos = reteInfos
  4986. }));
  4987. }
  4988. /// <summary>
  4989. /// 团组模块 - 出入境费用 - Info
  4990. /// </summary>
  4991. /// <returns></returns>
  4992. [HttpPost]
  4993. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4995. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4996. {
  4997. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4998. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4999. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5000. }
  5001. /// <summary>
  5002. /// 团组模块 - 出入境费用 - 设置view权限
  5003. /// </summary>
  5004. /// <returns></returns>
  5005. [HttpPost]
  5006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5007. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5008. {
  5009. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5010. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5011. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5012. var permissions = new List<Grp_EnterExitCostPermission>();
  5013. foreach (var userId in dto.UserIds)
  5014. {
  5015. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5016. }
  5017. if (permissions.Any())
  5018. {
  5019. _sqlSugar.BeginTran();
  5020. try
  5021. {
  5022. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5023. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5024. if (result < 1)
  5025. {
  5026. _sqlSugar.RollbackTran();
  5027. return Ok(JsonView(false));
  5028. }
  5029. }
  5030. catch (Exception ex)
  5031. {
  5032. _sqlSugar.RollbackTran();
  5033. return Ok(JsonView(false, ex.Message));
  5034. }
  5035. _sqlSugar.CommitTran();
  5036. return Ok(JsonView(true));
  5037. }
  5038. return Ok(JsonView(false));
  5039. }
  5040. /// <summary>
  5041. /// 团组模块 - 出入境费用 - Add And Update
  5042. /// </summary>
  5043. /// <returns></returns>
  5044. [HttpPost]
  5045. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5047. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5048. {
  5049. try
  5050. {
  5051. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5052. if (dto.DayOtherPriceData.Any())
  5053. {
  5054. var inserList = dto.DayOtherPriceData
  5055. .Where(x => x.Id == 0)
  5056. .Select(x => new Grp_DayOtherPrice
  5057. {
  5058. Cost = x.Cost,
  5059. Id = x.Id,
  5060. CreateTime = DateTime.Now,
  5061. CreateUserId = dto.UserId,
  5062. Currency = x.Currency,
  5063. Diid = x.DiId,
  5064. Index = x.Index,
  5065. IsDel = 0,
  5066. SetDataId = x.SetDataId,
  5067. SubTotal = x.SubTotal,
  5068. Remark = x.Remark
  5069. })
  5070. .ToList();
  5071. var updateList = dto.DayOtherPriceData
  5072. .Where(x => x.Id != 0)
  5073. .Select(x => new Grp_DayOtherPrice
  5074. {
  5075. Cost = x.Cost,
  5076. Id = x.Id,
  5077. CreateTime = DateTime.Now,
  5078. CreateUserId = dto.UserId,
  5079. Currency = x.Currency,
  5080. Diid = x.DiId,
  5081. Index = x.Index,
  5082. IsDel = 0,
  5083. SetDataId = x.SetDataId,
  5084. SubTotal = x.SubTotal,
  5085. Remark = x.Remark
  5086. })
  5087. .ToList();
  5088. //添加
  5089. _sqlSugar.BeginTran();
  5090. if (inserList.Any())
  5091. {
  5092. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5093. }
  5094. if (updateList.Any())
  5095. {
  5096. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5097. }
  5098. _sqlSugar.CommitTran();
  5099. }
  5100. if (data.Code != 0)
  5101. {
  5102. return Ok(JsonView(false, data.Msg));
  5103. }
  5104. //生成默认文件pdf并且通知人员
  5105. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5106. {
  5107. DiId = dto.DiId,
  5108. ExportType = 1,
  5109. SubTypeId = 1005
  5110. }, "pdf");
  5111. //发送通知
  5112. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5113. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5114. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5115. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5116. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5117. //汇率信息记录
  5118. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5119. return Ok(JsonView(true, data.Msg, data.Data));
  5120. }
  5121. catch (Exception ex)
  5122. {
  5123. return Ok(JsonView(false, ex.Message));
  5124. }
  5125. }
  5126. /// <summary>
  5127. /// 团组模块 - 出入境费用 - Confirm 费用
  5128. /// </summary>
  5129. /// <returns></returns>
  5130. [HttpPost]
  5131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5132. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5133. {
  5134. //TODO:测试完毕需把对应的用户ID更改
  5135. //1、数据表添加字段
  5136. //2、更改字段接口()
  5137. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5138. //3、确认成功 给财务发送消息
  5139. if (_view.Code == 200)
  5140. {
  5141. if (dto.Type == 1)
  5142. {
  5143. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5144. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5145. }
  5146. }
  5147. return Ok(_view);
  5148. }
  5149. /// <summary>
  5150. /// 团组模块 - 出入境费用 - File download
  5151. /// </summary>
  5152. /// <param name="dto"></param>
  5153. /// <returns></returns>
  5154. [HttpPost]
  5155. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5157. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5158. {
  5159. try
  5160. {
  5161. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5162. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5163. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5164. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5165. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5166. 3 团组成员名单 1 团组成员名单", ""));
  5167. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5168. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5169. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5170. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5171. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5172. //数据源
  5173. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5174. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5175. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5176. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5177. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5178. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5179. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5180. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5181. .Select((x, a, b) => new
  5182. {
  5183. x.Index,
  5184. itemName = a.Name,
  5185. CurrencyStr = b.Name,
  5186. x.Cost,
  5187. x.SubTotal,
  5188. x.Remark
  5189. })
  5190. .OrderBy((x) => x.Index)
  5191. .ToList(); //其他款项费用
  5192. var peiceItemCurrencys = new List<string>();
  5193. if (_DayAndCosts.Any())
  5194. {
  5195. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5196. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5197. }
  5198. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5199. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5200. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5201. {
  5202. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5203. }
  5204. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5205. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5206. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5207. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5208. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5209. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5210. .Select((tcl, dc, cc) => new ClientInfo
  5211. {
  5212. LastName = dc.LastName,
  5213. FirstName = dc.FirstName,
  5214. Sex = dc.Sex,
  5215. Birthday = dc.BirthDay,
  5216. Company = cc.CompanyFullName,
  5217. Job = dc.Job
  5218. })
  5219. .ToList();
  5220. foreach (var item in DeleClientList)
  5221. {
  5222. EncryptionProcessor.DecryptProperties(item);
  5223. }
  5224. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5225. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5226. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5227. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5228. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5229. if (dto.ExportType == 1) //明细表
  5230. {
  5231. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5232. {
  5233. //获取模板
  5234. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5235. //载入模板
  5236. Document doc = new Document(tempPath);
  5237. DocumentBuilder builder = new DocumentBuilder(doc);
  5238. //利用键值对存放数据
  5239. Dictionary<string, string> dic = new Dictionary<string, string>();
  5240. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5241. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5242. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5243. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5244. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5245. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5246. //境内费用(其他费用)
  5247. if (_EnterExitCosts.ChoiceOne == 1)
  5248. {
  5249. string row1_1 = "";
  5250. if (_EnterExitCosts.Visa > 0)
  5251. {
  5252. //insidePayTotal += _EnterExitCosts.Visa;
  5253. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5254. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5255. {
  5256. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5257. }
  5258. }
  5259. string row1_2 = "";
  5260. if (_EnterExitCosts.YiMiao > 0)
  5261. {
  5262. //insidePayTotal += _EnterExitCosts.YiMiao;
  5263. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5264. }
  5265. if (_EnterExitCosts.HeSuan > 0)
  5266. {
  5267. //insidePayTotal += _EnterExitCosts.HeSuan;
  5268. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5269. }
  5270. if (_EnterExitCosts.Service > 0)
  5271. {
  5272. //insidePayTotal += _EnterExitCosts.Service;
  5273. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5274. }
  5275. string row1_3 = "";
  5276. if (_EnterExitCosts.Safe > 0)
  5277. {
  5278. //insidePayTotal += _EnterExitCosts.Safe;
  5279. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5280. }
  5281. if (_EnterExitCosts.Ticket > 0)
  5282. {
  5283. //insidePayTotal += _EnterExitCosts.Ticket;
  5284. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5285. }
  5286. string row1 = "";
  5287. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5288. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5289. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5290. row1 += $"备注:{_EnterExitCosts.Remark}";
  5291. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5292. dic.Add("Row1Str", row1);
  5293. }
  5294. string airTotalStr = string.Empty,
  5295. airPriceStr = string.Empty;
  5296. //经济舱
  5297. if (_EnterExitCosts.SumJJC == 1)
  5298. {
  5299. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5300. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5301. }
  5302. //公务舱
  5303. if (_EnterExitCosts.SumGWC == 1)
  5304. {
  5305. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5306. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5307. }
  5308. //头等舱
  5309. if (_EnterExitCosts.SumTDC == 1)
  5310. {
  5311. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5312. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5313. }
  5314. //汇率描述
  5315. string rateStr = "";
  5316. if (peiceItemCurrencyInfos.Any())
  5317. {
  5318. rateStr = "\r\n汇率描述:";
  5319. foreach (var item in peiceItemCurrencyInfos)
  5320. {
  5321. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5322. }
  5323. }
  5324. string twoItemRemark = "备注:";
  5325. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5326. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5327. dic.Add("AirTotalStr", airTotalStr);
  5328. dic.Add("AirPriceStr", airPriceStr);
  5329. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5330. dic.Add("TwoItemRemark", twoItemRemark);
  5331. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5332. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5333. int table1Row = 0,
  5334. table2Row = 0,
  5335. table3Row = 0,
  5336. table4Row = 0,
  5337. table5Row = 0;
  5338. //住宿费
  5339. if (_EnterExitCosts.ChoiceThree == 1)
  5340. {
  5341. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5342. table1Row = dac1.Count;
  5343. #region 填充word表格内容
  5344. for (int i = 0; i < dac1.Count; i++)
  5345. {
  5346. Grp_DayAndCost dac = dac1[i];
  5347. if (dac == null) continue;
  5348. builder.MoveToCell(0, i, 0, 0);
  5349. builder.Write("第" + dac.Days.ToString() + "晚:");
  5350. builder.MoveToCell(0, i, 1, 0);
  5351. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5352. //builder.Write(dac.Place == null ? "" : dac.Place);
  5353. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5354. builder.MoveToCell(0, i, 2, 0);
  5355. builder.Write("费用标准:");
  5356. string curr = "";
  5357. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5358. if (currData != null)
  5359. {
  5360. curr = currData.Name;
  5361. }
  5362. builder.MoveToCell(0, i, 3, 0);
  5363. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5364. builder.MoveToCell(0, i, 4, 0);
  5365. builder.Write("费用小计:");
  5366. builder.MoveToCell(0, i, 5, 0);
  5367. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5368. }
  5369. #endregion
  5370. }
  5371. else dic.Add("SubZS", "0.00");
  5372. //删除多余行
  5373. while (table1.Rows.Count > table1Row)
  5374. {
  5375. table1.Rows.RemoveAt(table1Row);
  5376. }
  5377. //伙食费
  5378. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5379. if (_EnterExitCosts.ChoiceFour == 1)
  5380. {
  5381. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5382. table2Row = dac2.Count;
  5383. #region 填充word表格内容
  5384. for (int i = 0; i < dac2.Count; i++)
  5385. {
  5386. Grp_DayAndCost dac = dac2[i];
  5387. if (dac == null) continue;
  5388. builder.MoveToCell(1, i, 0, 0);
  5389. builder.Write("第" + dac.Days.ToString() + "天:");
  5390. builder.MoveToCell(1, i, 1, 0);
  5391. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5392. builder.MoveToCell(1, i, 2, 0);
  5393. builder.Write("费用标准:");
  5394. string curr = "";
  5395. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5396. if (currData != null)
  5397. {
  5398. curr = currData.Name;
  5399. }
  5400. builder.MoveToCell(1, i, 3, 0);
  5401. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5402. builder.MoveToCell(1, i, 4, 0);
  5403. builder.Write("费用小计:");
  5404. builder.MoveToCell(1, i, 5, 0);
  5405. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5406. }
  5407. #endregion
  5408. }
  5409. else dic.Add("SubHS", "0.00");
  5410. //删除多余行
  5411. while (table2.Rows.Count > table2Row)
  5412. {
  5413. table2.Rows.RemoveAt(table2Row);
  5414. }
  5415. //公杂费
  5416. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5417. if (_EnterExitCosts.ChoiceFive == 1)
  5418. {
  5419. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5420. table3Row = dac3.Count;
  5421. #region 填充word表格内容
  5422. for (int i = 0; i < dac3.Count; i++)
  5423. {
  5424. Grp_DayAndCost dac = dac3[i];
  5425. if (dac == null) continue;
  5426. builder.MoveToCell(2, i, 0, 0);
  5427. builder.Write("第" + dac.Days.ToString() + "天:");
  5428. builder.MoveToCell(2, i, 1, 0);
  5429. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5430. builder.MoveToCell(2, i, 2, 0);
  5431. builder.Write("费用标准:");
  5432. string curr = "";
  5433. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5434. if (currData != null)
  5435. {
  5436. curr = currData.Name;
  5437. }
  5438. builder.MoveToCell(2, i, 3, 0);
  5439. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5440. builder.MoveToCell(2, i, 4, 0);
  5441. builder.Write("费用小计:");
  5442. builder.MoveToCell(2, i, 5, 0);
  5443. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5444. }
  5445. //删除多余行
  5446. while (table3.Rows.Count > table3Row)
  5447. {
  5448. table3.Rows.RemoveAt(table3Row);
  5449. }
  5450. #endregion
  5451. }
  5452. else dic.Add("SubGZF", "0.00");
  5453. //删除多余行
  5454. while (table3.Rows.Count > table3Row)
  5455. {
  5456. table3.Rows.RemoveAt(table3Row);
  5457. }
  5458. //培训费
  5459. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5460. if (_EnterExitCosts.ChoiceSix == 1)
  5461. {
  5462. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5463. dic.Add("SubPX", pxStr);
  5464. table4Row = dac4.Count;
  5465. #region 填充word表格内容
  5466. for (int i = 0; i < dac4.Count; i++)
  5467. {
  5468. Grp_DayAndCost dac = dac4[i];
  5469. if (dac == null) continue;
  5470. builder.MoveToCell(3, i, 0, 0);
  5471. builder.Write("第" + dac.Days.ToString() + "天:");
  5472. builder.MoveToCell(3, i, 1, 0);
  5473. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5474. builder.MoveToCell(3, i, 2, 0);
  5475. builder.Write("费用标准:");
  5476. string curr = "";
  5477. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5478. if (currData != null)
  5479. {
  5480. curr = currData.Name;
  5481. }
  5482. builder.MoveToCell(3, i, 3, 0);
  5483. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5484. builder.MoveToCell(3, i, 4, 0);
  5485. builder.Write("费用小计:");
  5486. builder.MoveToCell(3, i, 5, 0);
  5487. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5488. }
  5489. #endregion
  5490. }
  5491. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5492. //删除多余行
  5493. while (table4.Rows.Count > table4Row)
  5494. {
  5495. table4.Rows.RemoveAt(table4Row);
  5496. }
  5497. //其他费用
  5498. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5499. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5500. {
  5501. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5502. dic.Add("titleQi", qtStr);
  5503. table5Row = dac5.Count;
  5504. #region 填充word表格内容
  5505. for (int i = 0; i < dac5.Count; i++)
  5506. {
  5507. var dac = dac5[i];
  5508. if (dac == null) continue;
  5509. builder.MoveToCell(4, i, 0, 0);
  5510. builder.Write("第" + dac.Index.ToString() + "项:");
  5511. builder.MoveToCell(4, i, 1, 0);
  5512. builder.Write(dac.itemName);
  5513. builder.MoveToCell(4, i, 2, 0);
  5514. builder.Write("费用标准:");
  5515. builder.MoveToCell(4, i, 3, 0);
  5516. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5517. builder.MoveToCell(4, i, 4, 0);
  5518. builder.Write("费用小计:");
  5519. builder.MoveToCell(4, i, 5, 0);
  5520. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5521. builder.MoveToCell(4, i, 6, 0);
  5522. builder.Write("备注:");
  5523. builder.MoveToCell(4, i, 7, 0);
  5524. builder.Write(dac.Remark);
  5525. }
  5526. #endregion
  5527. }
  5528. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5529. //删除多余行
  5530. while (table5.Rows.Count > table5Row)
  5531. {
  5532. table5.Rows.RemoveAt(table5Row);
  5533. }
  5534. //加上其他费用
  5535. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5536. decimal subJJC = 0.00M,
  5537. subGWC = 0.00M,
  5538. subTDC = 0.00M;
  5539. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5540. string totalLabel = string.Format("全部费用总计:");
  5541. //经济舱
  5542. if (_EnterExitCosts.SumJJC == 1)
  5543. {
  5544. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5545. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5546. }
  5547. //公务舱
  5548. if (_EnterExitCosts.SumGWC == 1)
  5549. {
  5550. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5551. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5552. }
  5553. //头等舱
  5554. if (_EnterExitCosts.SumTDC == 1)
  5555. {
  5556. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5557. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5558. }
  5559. //TotalLabel
  5560. dic.Add("TotalLabel", totalLabel);
  5561. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5562. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5563. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5564. #region 填充word模板书签内容
  5565. foreach (var key in dic.Keys)
  5566. {
  5567. Bookmark bookmark = doc.Range.Bookmarks[key];
  5568. if (bookmark != null)
  5569. {
  5570. builder.MoveToBookmark(key);
  5571. builder.Write(dic[key]);
  5572. }
  5573. }
  5574. #endregion
  5575. #region 设置页眉
  5576. string userLabel = string.Empty;
  5577. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5578. if (currUserInfo != null)
  5579. {
  5580. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5581. if (userInfo != null)
  5582. {
  5583. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5584. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5585. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5586. }
  5587. }
  5588. //设置页脚
  5589. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5590. #endregion
  5591. //文件名
  5592. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5593. AsposeHelper.removewatermark_v2180();
  5594. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5595. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5596. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5597. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5598. }
  5599. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5600. {
  5601. //获取模板
  5602. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5603. //载入模板
  5604. Document doc = new Document(tempPath);
  5605. DocumentBuilder builder = new DocumentBuilder(doc);
  5606. Dictionary<string, string> dic = new Dictionary<string, string>();
  5607. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5608. {
  5609. List<string> list = new List<string>();
  5610. try
  5611. {
  5612. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5613. foreach (var item in spilitArr)
  5614. {
  5615. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5616. var depCode = spDotandEmpty[2].Substring(0, 3);
  5617. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5618. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5619. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5620. list.Add(depName);
  5621. list.Add(arrName);
  5622. }
  5623. list = list.Distinct().ToList();
  5624. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5625. }
  5626. catch (Exception)
  5627. {
  5628. dic.Add("ReturnCode", "行程录入不正确!");
  5629. }
  5630. }
  5631. else
  5632. {
  5633. dic.Add("ReturnCode", "未录入行程!");
  5634. }
  5635. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5636. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5637. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5638. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5639. {
  5640. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5641. dic.Add("Day", sp.Days.ToString());
  5642. }
  5643. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5644. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5645. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5646. //dic.Add("Names", Names);
  5647. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5648. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5649. decimal dac1totalPrice = 0.00M;
  5650. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5651. foreach (var dac in dac1)
  5652. {
  5653. if (dac.SubTotal == 0.00M)
  5654. {
  5655. continue;
  5656. }
  5657. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5658. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5659. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5660. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5661. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5662. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5663. builder.Write(currency);//币种
  5664. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5665. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5666. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5667. builder.Write("");//人数
  5668. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5669. builder.Write("");//天数
  5670. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5671. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5672. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5673. decimal rate = 0.00M;
  5674. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5675. builder.Write(rate.ToString("#0.0000"));//汇率
  5676. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5677. decimal rbmPrice = dac.SubTotal;
  5678. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5679. accommodationStartIndex++;
  5680. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5681. }
  5682. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5683. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5684. {
  5685. table1.Rows.RemoveAt(i - 1);
  5686. foodandotherStartIndex--;
  5687. }
  5688. if (dac2.Count == dac3.Count)//国家 币种 金额
  5689. {
  5690. for (int i = 0; i < dac2.Count; i++)
  5691. {
  5692. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5693. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5694. }
  5695. }
  5696. decimal dac2totalPrice = 0.00M;
  5697. foreach (var dac in dac2)
  5698. {
  5699. if (dac.SubTotal == 0)
  5700. {
  5701. continue;
  5702. }
  5703. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5704. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5705. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5706. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5707. builder.Write(currency);//币种
  5708. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5709. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5710. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5711. builder.Write("");//人数
  5712. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5713. builder.Write("");//天数
  5714. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5715. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5716. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5717. decimal rate = 0.00M;
  5718. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5719. builder.Write(rate.ToString("#0.0000"));//汇率
  5720. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5721. decimal rbmPrice = dac.SubTotal;
  5722. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5723. foodandotherStartIndex++;
  5724. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5725. }
  5726. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5727. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5728. {
  5729. table1.Rows.RemoveAt(i - 1);
  5730. }
  5731. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5732. string otherFeeStr = "";
  5733. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5734. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5735. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5736. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5737. foreach (var otherInfo in dac5)
  5738. {
  5739. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5740. }
  5741. #endregion
  5742. if (otherFeeStr.Length > 0)
  5743. {
  5744. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5745. otherFeeStr = $"({otherFeeStr})";
  5746. dic.Add("OtherFeeStr", otherFeeStr);
  5747. }
  5748. //总计
  5749. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5750. //国际旅费
  5751. string outsideAir = string.Empty;
  5752. string allPriceAir = string.Empty;
  5753. if (_EnterExitCosts.SumJJC == 1)
  5754. {
  5755. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5756. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5757. }
  5758. if (_EnterExitCosts.SumGWC == 1)
  5759. {
  5760. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5761. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5762. }
  5763. if (_EnterExitCosts.SumTDC == 1)
  5764. {
  5765. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5766. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5767. }
  5768. dic.Add("InTravelPrice", $"({outsideAir})");
  5769. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5770. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5771. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5772. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5773. foreach (var key in dic.Keys)
  5774. {
  5775. builder.MoveToBookmark(key);
  5776. builder.Write(dic[key]);
  5777. }
  5778. //模板文件名
  5779. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5780. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5781. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5782. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5783. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5784. }
  5785. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5786. {
  5787. //获取模板
  5788. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5789. //载入模板
  5790. WorkbookDesigner designer = new WorkbookDesigner();
  5791. designer.Workbook = new Workbook(tempPath);
  5792. Dictionary<string, string> dic = new Dictionary<string, string>();
  5793. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5794. {
  5795. List<string> list = new List<string>();
  5796. try
  5797. {
  5798. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5799. foreach (var item in spilitArr)
  5800. {
  5801. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5802. var depCode = spDotandEmpty[2].Substring(0, 3);
  5803. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5804. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5805. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5806. list.Add(depName);
  5807. list.Add(arrName);
  5808. }
  5809. list = list.Distinct().ToList();
  5810. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5811. }
  5812. catch (Exception)
  5813. {
  5814. dic.Add("ReturnCode", "行程录入不正确!");
  5815. }
  5816. }
  5817. else
  5818. {
  5819. dic.Add("ReturnCode", "未录入行程!");
  5820. }
  5821. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5822. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5823. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5824. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5825. {
  5826. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5827. dic.Add("Day", sp.Days.ToString());
  5828. }
  5829. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5830. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5831. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5832. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5833. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5834. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5835. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5836. designer.SetDataSource("Name", Names);
  5837. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5838. designer.SetDataSource("Day", dic["Day"] + "天");
  5839. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5840. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5841. int startIndex = 10;
  5842. const int startIndexcopy = 10;
  5843. if (dac2.Count == dac3.Count)//国家 币种 金额
  5844. {
  5845. for (int i = 0; i < dac2.Count; i++)
  5846. {
  5847. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5848. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5849. }
  5850. }
  5851. DataTable dtdac1 = new DataTable();
  5852. List<string> place = new List<string>();
  5853. dtdac1.Columns.AddRange(new DataColumn[] {
  5854. new DataColumn(){ ColumnName = "city"},
  5855. new DataColumn(){ ColumnName = "curr"},
  5856. new DataColumn(){ ColumnName = "criterion"},
  5857. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5858. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5859. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5860. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5861. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5862. });
  5863. DataTable dtdac2 = new DataTable();
  5864. dtdac2.Columns.AddRange(new DataColumn[] {
  5865. new DataColumn(){ ColumnName = "city"},
  5866. new DataColumn(){ ColumnName = "curr"},
  5867. new DataColumn(){ ColumnName = "criterion"},
  5868. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5869. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5870. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5871. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5872. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5873. });
  5874. dtdac1.TableName = "tb1";
  5875. dtdac2.TableName = "tb2";
  5876. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5877. foreach (var item in dac1)
  5878. {
  5879. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5880. if (place.Contains(item.Place))
  5881. {
  5882. continue;
  5883. }
  5884. DataRow row = dtdac1.NewRow();
  5885. row["city"] = item.Place;
  5886. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5887. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5888. row["curr"] = currency;
  5889. row["rate"] = rate.ToString("#0.0000");
  5890. row["criterion"] = item.Cost.ToString("#0.00");
  5891. row["number"] = 1;
  5892. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5893. //row["costRMB"] = rbmPrice;
  5894. dtdac1.Rows.Add(row);
  5895. place.Add(item.Place);
  5896. }
  5897. place = new List<string>();
  5898. foreach (var item in dac2)
  5899. {
  5900. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5901. if (place.Contains(item.Place))
  5902. {
  5903. continue;
  5904. }
  5905. DataRow row = dtdac2.NewRow();
  5906. row["city"] = item.Place;
  5907. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5908. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5909. row["curr"] = currency;
  5910. row["rate"] = rate.ToString("#0.0000");
  5911. row["criterion"] = item.Cost.ToString("#0.00");
  5912. row["number"] = 1;
  5913. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5914. //row["cost"] = item.SubTotal;
  5915. //row["costRMB"] = rbmPrice;
  5916. dtdac2.Rows.Add(row);
  5917. place.Add(item.Place);
  5918. //dac2totalPrice += rbmPrice;
  5919. }
  5920. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5921. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5922. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5923. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5924. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5925. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5926. string cell4Str1 = string.Empty;
  5927. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5928. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5929. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5930. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5931. string cellStr = $" 5.其他费用(";
  5932. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5933. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5934. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5935. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5936. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5937. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5938. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5939. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5940. foreach (var otherInfo in dac5)
  5941. {
  5942. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5943. }
  5944. #endregion
  5945. if (cellStr.Length > 8)
  5946. {
  5947. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5948. }
  5949. cellStr += ")";
  5950. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5951. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5952. decimal pxFee = dac4.Sum(it => it.Cost);
  5953. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5954. string celllastStr1 = "";
  5955. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5956. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5957. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5958. celllastStr1 += $",国际旅费 元";
  5959. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5960. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5961. designer.SetDataSource("cell4Str", cell4Str);
  5962. designer.SetDataSource("cellStr", cellStr);
  5963. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5964. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5965. designer.SetDataSource("celllastStr", celllastStr);
  5966. Workbook wb = designer.Workbook;
  5967. var sheet = wb.Worksheets[0];
  5968. //绑定datatable数据集
  5969. designer.SetDataSource(dtdac1);
  5970. designer.SetDataSource(dtdac2);
  5971. designer.Process();
  5972. var rowStart = dtdac1.Rows.Count;
  5973. while (rowStart > 0)
  5974. {
  5975. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5976. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5977. startIndex++;
  5978. rowStart--;
  5979. }
  5980. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5981. startIndex += 1; //总计行
  5982. rowStart = dtdac2.Rows.Count;
  5983. while (rowStart > 0)
  5984. {
  5985. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5986. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5987. startIndex++;
  5988. rowStart--;
  5989. }
  5990. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5991. wb.CalculateFormula(true);
  5992. //模板文件名
  5993. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5994. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5995. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5996. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5997. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5998. }
  5999. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6000. {
  6001. //获取模板
  6002. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6003. //载入模板
  6004. Document doc = new Document(tempPath);
  6005. DocumentBuilder builder = new DocumentBuilder(doc);
  6006. Dictionary<string, string> dic = new Dictionary<string, string>();
  6007. dic.Add("GroupName", _DelegationInfo.TeamName);
  6008. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6009. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6010. string missionLeaderJob = "";//负责人job
  6011. //int groupNumber = 0; //团人数
  6012. if (DeleClientList.Count > 0)
  6013. {
  6014. missionLeader = DeleClientList[0]?.Name ?? "";
  6015. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6016. }
  6017. dic.Add("MissionLeader", missionLeader); //团负责人
  6018. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6019. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6020. #region MyRegion
  6021. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6022. //{
  6023. // List<string> list = new List<string>();
  6024. // try
  6025. // {
  6026. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6027. // foreach (var item in spilitArr)
  6028. // {
  6029. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6030. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6031. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6032. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6033. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6034. // list.Add(depName);
  6035. // list.Add(arrName);
  6036. // }
  6037. // list = list.Distinct().ToList();
  6038. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6039. // }
  6040. // catch (Exception)
  6041. // {
  6042. // dic.Add("ReturnCode", "行程录入不正确!");
  6043. // }
  6044. //}
  6045. //else
  6046. //{
  6047. // dic.Add("ReturnCode", "未录入行程!");
  6048. //}
  6049. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6050. dic.Add("ReturnCode", string.Join("、", countrys));
  6051. #endregion
  6052. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6053. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6054. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6055. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6056. //{
  6057. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6058. // dic.Add("Day", sp.Days.ToString());
  6059. //}
  6060. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6061. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6062. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6063. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6064. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6065. //培训人员名单
  6066. int cultivateRowIndex = 7;
  6067. foreach (var item in DeleClientList)
  6068. {
  6069. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6070. builder.Write(item.Name);
  6071. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6072. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6073. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6074. string birthDay = "";
  6075. if (item.Birthday != null)
  6076. {
  6077. DateTime dt = Convert.ToDateTime(item.Birthday);
  6078. birthDay = $"{dt.Year}.{dt.Month}";
  6079. }
  6080. builder.Write(birthDay);
  6081. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6082. builder.Write(item.Company);
  6083. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6084. builder.Write(item.Job);
  6085. cultivateRowIndex++;
  6086. }
  6087. //删除多余行
  6088. //cultivateRowIndex -= 2;
  6089. int delRows = 10 + 7 - cultivateRowIndex;
  6090. if (delRows > 0)
  6091. {
  6092. for (int i = 0; i < delRows; i++)
  6093. {
  6094. table1.Rows.RemoveAt(cultivateRowIndex);
  6095. //cultivateRowIndex++;
  6096. }
  6097. }
  6098. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6099. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6100. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6101. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6102. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6103. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6104. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6105. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6106. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6107. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6108. //其他费用
  6109. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6110. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6111. //其他费用合计
  6112. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6113. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6114. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6115. //公务舱合计
  6116. //国际旅费
  6117. //string outsideJJ = "";
  6118. //string allPriceJJ = "";
  6119. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6120. {
  6121. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6122. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6123. }
  6124. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6125. {
  6126. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6127. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6128. }
  6129. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6130. {
  6131. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6132. dic.Add("AirFeeTotal", airFeeTotalStr);
  6133. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6134. dic.Add("FeeTotal", feeTotalStr);
  6135. }
  6136. foreach (var key in dic.Keys)
  6137. {
  6138. builder.MoveToBookmark(key);
  6139. builder.Write(dic[key]);
  6140. }
  6141. //模板文件名
  6142. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6143. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6144. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6145. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6146. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6147. }
  6148. }
  6149. else if (dto.ExportType == 2) //表格
  6150. {
  6151. //利用键值对存放数据
  6152. Dictionary<string, string> dic = new Dictionary<string, string>();
  6153. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6154. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6155. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6156. dic.Add("Day", sp.Days.ToString());
  6157. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6158. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6159. {
  6160. //获取模板
  6161. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6162. //载入模板
  6163. Document doc = new Document(tempPath);
  6164. DocumentBuilder builder = new DocumentBuilder(doc);
  6165. dic.Add("TeamName", _DelegationInfo.TeamName);
  6166. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6167. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6168. string missionLeaderName = "",
  6169. missionLeaderJob = "";
  6170. if (DeleClientList.Count > 0)
  6171. {
  6172. missionLeaderName = DeleClientList[0].Name;
  6173. missionLeaderJob = DeleClientList[0].Job;
  6174. }
  6175. dic.Add("MissionLeaderName", missionLeaderName);
  6176. dic.Add("MissionLeaderJob", missionLeaderJob);
  6177. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6178. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6179. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6180. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6181. int rowCount = 10;//总人数行
  6182. int startRowIndex = 7; //起始行
  6183. for (int i = 0; i < DeleClientList.Count; i++)
  6184. {
  6185. builder.MoveToCell(0, startRowIndex, 0, 0);
  6186. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6187. builder.MoveToCell(0, startRowIndex, 1, 0);
  6188. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6189. builder.Write(sex);//性别
  6190. builder.MoveToCell(0, startRowIndex, 2, 0);
  6191. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6192. builder.MoveToCell(0, startRowIndex, 3, 0);
  6193. builder.Write(DeleClientList[i].Company);//工作单位
  6194. builder.MoveToCell(0, startRowIndex, 4, 0);
  6195. builder.Write(DeleClientList[i].Job);//职务及级别
  6196. builder.MoveToCell(0, startRowIndex, 5, 0);
  6197. builder.Write("");//人员属性
  6198. builder.MoveToCell(0, startRowIndex, 6, 0);
  6199. builder.Write("");//上次出国时间
  6200. startRowIndex++;
  6201. }
  6202. int nullRow = rowCount - DeleClientList.Count;//空行
  6203. for (int i = 0; i < nullRow; i++)
  6204. {
  6205. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6206. }
  6207. foreach (var key in dic.Keys)
  6208. {
  6209. builder.MoveToBookmark(key);
  6210. builder.Write(dic[key]);
  6211. }
  6212. //模板文件名
  6213. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6214. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6215. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6216. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6217. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6218. }
  6219. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6220. {
  6221. //获取模板
  6222. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6223. //载入模板
  6224. Document doc = new Document(tempPath);
  6225. DocumentBuilder builder = new DocumentBuilder(doc);
  6226. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6227. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6228. dic.Add("Names", Names);
  6229. int accommodationRows = 12;
  6230. //int foodandotherRows = 12;
  6231. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6232. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6233. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6234. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6235. int accommodationStartIndex = 6;
  6236. decimal dac1totalPrice = 0.00M;
  6237. foreach (var dac in dac1)
  6238. {
  6239. if (dac.SubTotal == 0)
  6240. {
  6241. continue;
  6242. }
  6243. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6244. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6245. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6246. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6247. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6248. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6249. builder.Write(currency);//币种
  6250. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6251. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6252. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6253. builder.Write("");//人数
  6254. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6255. builder.Write("");//天数
  6256. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6257. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6258. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6259. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6260. builder.Write(rate.ToString("#0.0000"));//汇率
  6261. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6262. decimal rbmPrice = rate * dac.SubTotal;
  6263. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6264. accommodationStartIndex++;
  6265. dac1totalPrice += rbmPrice;
  6266. }
  6267. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6268. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6269. builder.Write("小计");
  6270. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6271. builder.Write(dac1totalPrice.ToString("#0.00"));
  6272. accommodationStartIndex++;
  6273. int nullRow = accommodationRows - dac1.Count;
  6274. //删除空行
  6275. //if (nullRow > 0)
  6276. //{
  6277. // int rowIndex = accommodationStartIndex;
  6278. // for (int i = 0; i < nullRow; i++)
  6279. // {
  6280. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6281. // row.Remove();
  6282. // rowIndex++;
  6283. // }
  6284. //}
  6285. if (dac2.Count == dac3.Count)//国家 币种 金额
  6286. {
  6287. for (int i = 0; i < dac2.Count; i++)
  6288. {
  6289. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6290. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6291. }
  6292. }
  6293. int foodandotherStartIndex = 19;//
  6294. decimal dac2totalPrice = 0.00M;
  6295. foreach (var dac in dac2)
  6296. {
  6297. if (dac.SubTotal == 0)
  6298. {
  6299. continue;
  6300. }
  6301. //foodandotherStartIndex = 12;
  6302. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6303. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6304. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6305. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6306. builder.Write(currency);//币种
  6307. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6308. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6309. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6310. builder.Write("");//人数
  6311. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6312. builder.Write("");//天数
  6313. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6314. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6315. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6316. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6317. builder.Write(rate.ToString("#0.0000"));//汇率
  6318. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6319. decimal rbmPrice = rate * dac.SubTotal;
  6320. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6321. foodandotherStartIndex++;
  6322. dac2totalPrice += rbmPrice;
  6323. }
  6324. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6325. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6326. //删除空行
  6327. //if (dac2.Count < foodandotherRows)
  6328. //{
  6329. // while (table2.Rows.Count > dac2.Count)
  6330. // {
  6331. // table2.Rows.RemoveAt(dac2.Count);
  6332. // }
  6333. //}
  6334. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6335. string otherFeeStr = "";
  6336. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6337. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6338. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6339. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6340. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6341. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6342. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6343. foreach (var otherInfo in dac5)
  6344. {
  6345. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6346. }
  6347. #endregion
  6348. if (otherFeeStr.Length > 0)
  6349. {
  6350. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6351. otherFeeStr = $"({otherFeeStr})";
  6352. dic.Add("OtherFeeStr", otherFeeStr);
  6353. }
  6354. foreach (var key in dic.Keys)
  6355. {
  6356. builder.MoveToBookmark(key);
  6357. builder.Write(dic[key]);
  6358. }
  6359. //模板文件名
  6360. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6361. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6362. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6363. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6364. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6365. }
  6366. }
  6367. else if (dto.ExportType == 3)
  6368. {
  6369. if (dto.SubTypeId == 1) //团组成员名单
  6370. {
  6371. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6372. //获取模板
  6373. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6374. //载入模板
  6375. Document doc = new Document(tempPath);
  6376. DocumentBuilder builder = new DocumentBuilder(doc);
  6377. //获取word里所有表格
  6378. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6379. //获取所填表格的序数
  6380. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6381. var rowStart = tableOne.Rows[0]; //获取第1行
  6382. //循环赋值
  6383. for (int i = 0; i < DeleClientList.Count; i++)
  6384. {
  6385. builder.MoveToCell(0, i + 1, 0, 0);
  6386. builder.Write(DeleClientList[i].Name);
  6387. builder.MoveToCell(0, i + 1, 1, 0);
  6388. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6389. builder.Write(sex);
  6390. builder.MoveToCell(0, i + 1, 2, 0);
  6391. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6392. builder.MoveToCell(0, i + 1, 3, 0);
  6393. builder.Write(DeleClientList[i].Company);
  6394. builder.MoveToCell(0, i + 1, 4, 0);
  6395. builder.Write(DeleClientList[i].Job);
  6396. }
  6397. //删除多余行
  6398. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6399. {
  6400. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6401. }
  6402. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6403. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6404. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6405. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6406. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6407. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6408. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6409. }
  6410. }
  6411. return Ok(JsonView(400, "操作失败!", ""));
  6412. }
  6413. catch (Exception ex)
  6414. {
  6415. return Ok(JsonView(400, ex.Message, ""));
  6416. }
  6417. }
  6418. /// <summary>
  6419. /// 获取三公费用标准city
  6420. /// </summary>
  6421. /// <param name="placeData"></param>
  6422. /// <param name="nationalTravelFeeId"></param>
  6423. /// <returns></returns>
  6424. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6425. {
  6426. string _city = string.Empty;
  6427. if (placeData.Count < 1) return _city;
  6428. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6429. if (data == null) return _city;
  6430. string country = data.Country;
  6431. string city = data.City;
  6432. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6433. else _city = city;
  6434. return _city;
  6435. }
  6436. ///// <summary>
  6437. ///// 团组模块 - 出入境费用 - 明细表导出
  6438. ///// </summary>
  6439. ///// <returns></returns>
  6440. //[HttpPost]
  6441. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6442. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6443. //{
  6444. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6445. // if (data.Code != 0)
  6446. // {
  6447. // return Ok(JsonView(false, data.Msg));
  6448. // }
  6449. // return Ok(JsonView(true, data.Msg, data.Data));
  6450. //}
  6451. /// <summary>
  6452. /// 团组模块 - 出入境费用 - 一键清空
  6453. /// </summary>
  6454. /// <returns></returns>
  6455. [HttpPost]
  6456. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6458. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6459. {
  6460. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6461. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6462. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6463. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6464. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6465. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6466. .SetColumns(x => new Grp_DayOtherPrice
  6467. {
  6468. IsDel = 1,
  6469. DeleteUserId = dto.UserId,
  6470. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6471. })
  6472. .ExecuteCommandAsync();
  6473. if (_view.Code == 0)
  6474. {
  6475. return Ok(JsonView(true, "操作成功"));
  6476. }
  6477. return Ok(JsonView(false, "操作失败"));
  6478. }
  6479. /// <summary>
  6480. /// 团组模块 - 出入境费用 - 子项删除
  6481. /// </summary>
  6482. /// <returns></returns>
  6483. [HttpPost]
  6484. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6486. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6487. {
  6488. try
  6489. {
  6490. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6491. if (data.Code != 0)
  6492. {
  6493. return Ok(JsonView(false, data.Msg));
  6494. }
  6495. return Ok(JsonView(true, "操作成功!", data.Data));
  6496. }
  6497. catch (Exception ex)
  6498. {
  6499. return Ok(JsonView(false, ex.Message));
  6500. }
  6501. }
  6502. /// <summary>
  6503. /// 删除三公其他费用
  6504. /// </summary>
  6505. /// <param name="dto"></param>
  6506. /// <returns></returns>
  6507. [HttpPost]
  6508. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6509. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6510. {
  6511. var jw = JsonView(false, "删除失败!");
  6512. var data = new Grp_DayOtherPrice()
  6513. {
  6514. Id = dto.Id,
  6515. IsDel = 1,
  6516. DeleteUserId = dto.DeleteUserId,
  6517. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6518. };
  6519. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6520. if (del > 0)
  6521. {
  6522. jw.Code = 200;
  6523. jw.Msg = "删除成功!";
  6524. }
  6525. return Ok(jw);
  6526. }
  6527. /// <summary>
  6528. /// 团组模块 - 出入境国家费用标准 List
  6529. /// </summary>
  6530. /// <returns></returns>
  6531. [HttpPost]
  6532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6533. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  6534. {
  6535. int provinceId = dto.ProvinceId;
  6536. if (provinceId < 1) provinceId = 122; //默认四川省数据
  6537. var nftData = await _sqlSugar
  6538. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  6539. JoinType.Left, ntf.Currency == sd1.Id,
  6540. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  6541. JoinType.Left, ntf.ProvinceId == c.Id
  6542. ))
  6543. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  6544. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  6545. {
  6546. Id = ntf.Id,
  6547. ProvinceId = ntf.ProvinceId,
  6548. ProvinceName = c.Name_CN,
  6549. Continent = ntf.Continent,
  6550. Country = ntf.Country,
  6551. City = ntf.City,
  6552. Currency = ntf.Currency,
  6553. CurrencyCode = sd1.Name,
  6554. CurrencyName = sd1.Remark,
  6555. RoomCost = ntf.RoomCost,
  6556. FoodCost = ntf.FoodCost,
  6557. PublicCost = ntf.PublicCost,
  6558. LastUpdateUserId = ntf.LastUpdateUserId,
  6559. LastUpdateUserName = u.CnName,
  6560. LastUpdateTime = ntf.LastUpdateTime
  6561. })
  6562. .ToListAsync();
  6563. return Ok(JsonView(true, "查询成功!", nftData));
  6564. }
  6565. /// <summary>
  6566. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6567. /// </summary>
  6568. /// <returns></returns>
  6569. [HttpPost]
  6570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6571. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6572. {
  6573. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6574. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6575. List<string> countryData = new List<string>();
  6576. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6577. countryData = countryData.Distinct().ToList();
  6578. List<dynamic> dataSource = new List<dynamic>();
  6579. foreach (var item in countryData)
  6580. {
  6581. var cityData1 = new List<string>();
  6582. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6583. var countryData2 = new
  6584. {
  6585. CountryName = item,
  6586. CityData = cityData1
  6587. };
  6588. if (!dataSource.Contains(countryData2))
  6589. {
  6590. dataSource.Add(countryData2);
  6591. }
  6592. }
  6593. return Ok(JsonView(true, "查询成功!", dataSource));
  6594. }
  6595. /// <summary>
  6596. /// 团组模块 - 出入境国家费用标准 Page List
  6597. /// </summary>
  6598. /// <returns></returns>
  6599. [HttpPost]
  6600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6601. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6602. {
  6603. int portId = dto.PortType,
  6604. pageIndex = dto.PageIndex,
  6605. pageSize = dto.PageSize;
  6606. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6607. if (pageIndex == 0) pageIndex = 1;
  6608. if (pageSize == 0) pageSize = 10;
  6609. RefAsync<int> total = 0;
  6610. var nationalTravelFeeData = await _sqlSugar
  6611. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  6612. JoinType.Left, ntf.Currency == sd1.Id,
  6613. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  6614. JoinType.Left, ntf.ProvinceId == sd2.Id
  6615. ))
  6616. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  6617. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  6618. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  6619. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  6620. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  6621. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  6622. {
  6623. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  6624. Id = ntf.Id,
  6625. ProvinceId = ntf.ProvinceId,
  6626. ProvinceName = sd2.Name_CN,
  6627. Continent = ntf.Continent,
  6628. Country = ntf.Country,
  6629. City = ntf.City,
  6630. Currency = ntf.Currency,
  6631. CurrencyCode = sd1.Name,
  6632. CurrencyName = sd1.Remark,
  6633. RoomCost = ntf.RoomCost,
  6634. FoodCost = ntf.FoodCost,
  6635. PublicCost = ntf.PublicCost,
  6636. LastUpdateUserId = ntf.LastUpdateUserId,
  6637. LastUpdateUserName = u.CnName,
  6638. LastUpdateTime = ntf.LastUpdateTime
  6639. })
  6640. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6641. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6642. }
  6643. /// <summary>
  6644. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6645. /// </summary>
  6646. /// <returns></returns>
  6647. [HttpPost]
  6648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6649. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6650. {
  6651. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6652. int portId = dto.PortType;
  6653. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6654. string whereSql = string.Empty;
  6655. if (!string.IsNullOrEmpty(dto.Country))
  6656. {
  6657. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6658. }
  6659. if (!string.IsNullOrEmpty(dto.City))
  6660. {
  6661. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6662. }
  6663. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6664. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  6665. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6666. From Grp_NationalTravelFee gntf
  6667. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6668. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6669. Where gntf.Isdel = 0 {0} ", whereSql);
  6670. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6671. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6672. }
  6673. /// <summary>
  6674. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6675. /// </summary>
  6676. /// <returns></returns>
  6677. [HttpPost]
  6678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6679. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6680. {
  6681. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  6682. }
  6683. /// <summary>
  6684. /// 团组模块 - 出入境国家费用标准 - Del
  6685. /// </summary>
  6686. /// <returns></returns>
  6687. [HttpPost]
  6688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6689. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6690. {
  6691. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6692. {
  6693. Id = dto.Id,
  6694. DeleteUserId = dto.DeleteUserId,
  6695. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6696. IsDel = 1
  6697. };
  6698. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6699. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6700. .WhereColumns(it => new { it.Id })
  6701. .ExecuteCommandAsync();
  6702. if (delStatus <= 0)
  6703. {
  6704. return Ok(JsonView(false, "删除失败!"));
  6705. }
  6706. return Ok(JsonView(true, "操作成功!"));
  6707. }
  6708. /// <summary>
  6709. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6710. /// 注:Get 请求Headers 加 Token
  6711. /// </summary>
  6712. /// <param name="groupId"></param>
  6713. /// <returns></returns>
  6714. [HttpGet("{groupId}")]
  6715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6716. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6717. {
  6718. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6719. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6720. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6721. data.ForEach(x =>
  6722. {
  6723. x.CreateUserId = _currUserInfo.UserId;
  6724. });
  6725. if (data.Any())
  6726. {
  6727. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6728. if (add > 0)
  6729. {
  6730. return Ok(JsonView(true, "操作成功!"));
  6731. }
  6732. }
  6733. return Ok(JsonView(false, "未操作!"));
  6734. }
  6735. #endregion
  6736. #region 团组经理模块 出入境费用-草稿
  6737. /// <summary>
  6738. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  6739. /// </summary>
  6740. /// <returns></returns>
  6741. [HttpGet]
  6742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6743. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  6744. {
  6745. var provData = await _groupRepository.ProvinceBasicSource();
  6746. return Ok(JsonView(true, "查询成功!", provData));
  6747. }
  6748. /// <summary>
  6749. /// 团组模块 - 出入境费用-草稿 - 文件类型list 更据省份Id获取
  6750. /// </summary>
  6751. /// <returns></returns>
  6752. [HttpGet("{provinceId}")]
  6753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6754. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  6755. {
  6756. //验证城市归属并给默认值
  6757. if (provinceId < 1) provinceId = 122;
  6758. /*
  6759. * 122 四川
  6760. * 108 贵州
  6761. * 103 重庆
  6762. * 132 云南
  6763. */
  6764. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6765. return Ok(JsonView(true, "查询成功!", new
  6766. {
  6767. WordTypeData = wordTypeData,
  6768. ExcelTypeData = excelTypeData,
  6769. }));
  6770. }
  6771. /// <summary>
  6772. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6773. /// </summary>
  6774. /// <returns></returns>
  6775. [HttpPost]
  6776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6777. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  6778. {
  6779. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6780. .Where(x => x.IsDel == 0)
  6781. .OrderByDescending(x => x.CreateTime)
  6782. .Select(x => new { x.Id, x.DraftName })
  6783. .ToListAsync();
  6784. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6785. //SetDataInfoView
  6786. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6787. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6788. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6789. int provinceId = dto.ProvinceId;
  6790. if (provinceId < 1) provinceId = 122;
  6791. /*
  6792. * 122 四川
  6793. * 108 贵州
  6794. * 103 重庆
  6795. * 132 云南
  6796. */
  6797. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6798. //默认币种显示
  6799. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6800. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6801. return Ok(JsonView(true, "查询成功!", new
  6802. {
  6803. DraftNameDatas = draftNameDatas,
  6804. CurrencyData = _CurrencyData,
  6805. WordTypeData = wordTypeData,
  6806. ExcelTypeData = excelTypeData,
  6807. CurrencyInit = _currencyInfos,
  6808. ViewPermissionData = viewPermissionData
  6809. }));
  6810. }
  6811. /// <summary>
  6812. /// 团组模块 - 出入境费用-草稿
  6813. /// 实时汇率 tips
  6814. /// 机票费用 tips
  6815. /// </summary>
  6816. /// <returns></returns>
  6817. [HttpPost]
  6818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6819. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6820. {
  6821. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6822. return Ok(JsonView(true, "查询成功!", new
  6823. {
  6824. //GroupNameData = groupNameData.Data,
  6825. //visaData = visaData.Data,
  6826. //airData = airData.Data,
  6827. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6828. }));
  6829. }
  6830. /// <summary>
  6831. /// 团组模块 - 出入境费用-草稿
  6832. /// 签证费用 tips
  6833. /// </summary>
  6834. /// <returns></returns>
  6835. [HttpPost]
  6836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6837. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6838. {
  6839. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6840. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6841. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6842. .Select(x => x.NationalTravelFeeId)
  6843. .Distinct()
  6844. .ToListAsync();
  6845. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6846. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6847. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6848. .Select(x => x.Country)
  6849. .Distinct()
  6850. .ToArrayAsync();
  6851. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6852. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6853. return Ok(JsonView(true, "查询成功!", new
  6854. {
  6855. totalAmt = totalAmt,
  6856. remark = remark
  6857. }));
  6858. }
  6859. /// <summary>
  6860. /// 团组模块 - 出入境费用-草稿 - Info
  6861. /// </summary>
  6862. /// <returns></returns>
  6863. [HttpPost]
  6864. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6866. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6867. {
  6868. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6869. }
  6870. /// <summary>
  6871. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6872. /// </summary>
  6873. /// <returns></returns>
  6874. [HttpPost]
  6875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6876. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6877. {
  6878. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6879. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6880. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6881. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6882. foreach (var userId in dto.UserIds)
  6883. {
  6884. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6885. }
  6886. if (permissions.Any())
  6887. {
  6888. _sqlSugar.BeginTran();
  6889. try
  6890. {
  6891. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6892. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6893. if (result < 1)
  6894. {
  6895. _sqlSugar.RollbackTran();
  6896. return Ok(JsonView(false));
  6897. }
  6898. }
  6899. catch (Exception ex)
  6900. {
  6901. _sqlSugar.RollbackTran();
  6902. return Ok(JsonView(false, ex.Message));
  6903. }
  6904. _sqlSugar.CommitTran();
  6905. return Ok(JsonView(true));
  6906. }
  6907. return Ok(JsonView(false));
  6908. }
  6909. /// <summary>
  6910. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6911. /// </summary>
  6912. /// <returns></returns>
  6913. [HttpPost]
  6914. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6916. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6917. {
  6918. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6919. if (data.Code != 0)
  6920. {
  6921. return Ok(JsonView(false, data.Msg));
  6922. }
  6923. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6924. //汇率信息记录
  6925. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6926. return Ok(JsonView(true, data.Msg, data.Data));
  6927. }
  6928. /// <summary>
  6929. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6930. /// </summary>
  6931. /// <param name="dto"></param>
  6932. /// <returns></returns>
  6933. [HttpPost]
  6934. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6936. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6937. {
  6938. try
  6939. {
  6940. var id = dto.Id;
  6941. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6942. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6943. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6944. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6945. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6946. 3 团组成员名单 1 团组成员名单", ""));
  6947. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6948. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6949. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6950. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6951. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6952. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6953. //数据源
  6954. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6955. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6956. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6957. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6958. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6959. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6960. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6961. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6962. .Select((x, a, b) => new
  6963. {
  6964. x.Index,
  6965. itemName = a.Name,
  6966. CurrencyStr = b.Name,
  6967. x.Cost,
  6968. x.SubTotal,
  6969. x.Remark
  6970. })
  6971. .OrderBy((x) => x.Index)
  6972. .ToList(); //其他款项费用
  6973. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6974. var peiceItemCurrencys = new List<string>();
  6975. if (_DayAndCosts.Any())
  6976. {
  6977. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6978. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6979. }
  6980. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6981. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6982. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6983. {
  6984. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6985. }
  6986. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6987. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6988. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6989. if (dto.ExportType == 1) //明细表
  6990. {
  6991. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6992. {
  6993. //获取模板
  6994. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6995. //载入模板
  6996. Document doc = new Document(tempPath);
  6997. DocumentBuilder builder = new DocumentBuilder(doc);
  6998. //利用键值对存放数据
  6999. Dictionary<string, string> dic = new Dictionary<string, string>();
  7000. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7001. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7002. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7003. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7004. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7005. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7006. //境内费用(其他费用)
  7007. if (_EnterExitCosts.ChoiceOne == 1)
  7008. {
  7009. string row1_1 = "";
  7010. if (_EnterExitCosts.Visa > 0)
  7011. {
  7012. //insidePayTotal += _EnterExitCosts.Visa;
  7013. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7014. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7015. {
  7016. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  7017. }
  7018. }
  7019. string row1_2 = "";
  7020. if (_EnterExitCosts.YiMiao > 0)
  7021. {
  7022. //insidePayTotal += _EnterExitCosts.YiMiao;
  7023. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7024. }
  7025. if (_EnterExitCosts.HeSuan > 0)
  7026. {
  7027. //insidePayTotal += _EnterExitCosts.HeSuan;
  7028. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7029. }
  7030. if (_EnterExitCosts.Service > 0)
  7031. {
  7032. //insidePayTotal += _EnterExitCosts.Service;
  7033. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7034. }
  7035. string row1_3 = "";
  7036. if (_EnterExitCosts.Safe > 0)
  7037. {
  7038. //insidePayTotal += _EnterExitCosts.Safe;
  7039. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7040. }
  7041. if (_EnterExitCosts.Ticket > 0)
  7042. {
  7043. //insidePayTotal += _EnterExitCosts.Ticket;
  7044. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7045. }
  7046. string row1 = "";
  7047. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7048. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7049. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7050. row1 += $"备注:{_EnterExitCosts.Remark}";
  7051. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7052. dic.Add("Row1Str", row1);
  7053. }
  7054. string airTotalStr = string.Empty,
  7055. airPriceStr = string.Empty;
  7056. //经济舱
  7057. if (_EnterExitCosts.SumJJC == 1)
  7058. {
  7059. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  7060. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  7061. }
  7062. //公务舱
  7063. if (_EnterExitCosts.SumGWC == 1)
  7064. {
  7065. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  7066. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  7067. }
  7068. //头等舱
  7069. if (_EnterExitCosts.SumTDC == 1)
  7070. {
  7071. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7072. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7073. }
  7074. //汇率描述
  7075. string rateStr = "";
  7076. if (peiceItemCurrencyInfos.Any())
  7077. {
  7078. rateStr = "\r\n汇率描述:";
  7079. foreach (var item in peiceItemCurrencyInfos)
  7080. {
  7081. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7082. }
  7083. }
  7084. string twoItemRemark = "备注:";
  7085. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7086. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7087. dic.Add("AirTotalStr", airTotalStr);
  7088. dic.Add("AirPriceStr", airPriceStr);
  7089. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7090. dic.Add("TwoItemRemark", twoItemRemark);
  7091. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7092. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7093. int table1Row = 0,
  7094. table2Row = 0,
  7095. table3Row = 0,
  7096. table4Row = 0,
  7097. table5Row = 0;
  7098. //住宿费
  7099. if (_EnterExitCosts.ChoiceThree == 1)
  7100. {
  7101. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7102. table1Row = dac1.Count;
  7103. #region 填充word表格内容
  7104. for (int i = 0; i < dac1.Count; i++)
  7105. {
  7106. var dac = dac1[i];
  7107. if (dac == null) continue;
  7108. builder.MoveToCell(0, i, 0, 0);
  7109. builder.Write("第" + dac.Days.ToString() + "晚:");
  7110. builder.MoveToCell(0, i, 1, 0);
  7111. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7112. //builder.Write(dac.Place == null ? "" : dac.Place);
  7113. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7114. builder.MoveToCell(0, i, 2, 0);
  7115. builder.Write("费用标准:");
  7116. string curr = "";
  7117. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7118. if (currData != null)
  7119. {
  7120. curr = currData.Name;
  7121. }
  7122. builder.MoveToCell(0, i, 3, 0);
  7123. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7124. builder.MoveToCell(0, i, 4, 0);
  7125. builder.Write("费用小计:");
  7126. builder.MoveToCell(0, i, 5, 0);
  7127. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7128. }
  7129. #endregion
  7130. }
  7131. else dic.Add("SubZS", "0.00");
  7132. //删除多余行
  7133. while (table1.Rows.Count > table1Row)
  7134. {
  7135. table1.Rows.RemoveAt(table1Row);
  7136. }
  7137. //伙食费
  7138. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7139. if (_EnterExitCosts.ChoiceFour == 1)
  7140. {
  7141. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7142. table2Row = dac2.Count;
  7143. #region 填充word表格内容
  7144. for (int i = 0; i < dac2.Count; i++)
  7145. {
  7146. var dac = dac2[i];
  7147. if (dac == null) continue;
  7148. builder.MoveToCell(1, i, 0, 0);
  7149. builder.Write("第" + dac.Days.ToString() + "天:");
  7150. builder.MoveToCell(1, i, 1, 0);
  7151. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7152. builder.MoveToCell(1, i, 2, 0);
  7153. builder.Write("费用标准:");
  7154. string curr = "";
  7155. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7156. if (currData != null)
  7157. {
  7158. curr = currData.Name;
  7159. }
  7160. builder.MoveToCell(1, i, 3, 0);
  7161. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7162. builder.MoveToCell(1, i, 4, 0);
  7163. builder.Write("费用小计:");
  7164. builder.MoveToCell(1, i, 5, 0);
  7165. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7166. }
  7167. #endregion
  7168. }
  7169. else dic.Add("SubHS", "0.00");
  7170. //删除多余行
  7171. while (table2.Rows.Count > table2Row)
  7172. {
  7173. table2.Rows.RemoveAt(table2Row);
  7174. }
  7175. //公杂费
  7176. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7177. if (_EnterExitCosts.ChoiceFive == 1)
  7178. {
  7179. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7180. table3Row = dac3.Count;
  7181. #region 填充word表格内容
  7182. for (int i = 0; i < dac3.Count; i++)
  7183. {
  7184. var dac = dac3[i];
  7185. if (dac == null) continue;
  7186. builder.MoveToCell(2, i, 0, 0);
  7187. builder.Write("第" + dac.Days.ToString() + "天:");
  7188. builder.MoveToCell(2, i, 1, 0);
  7189. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7190. builder.MoveToCell(2, i, 2, 0);
  7191. builder.Write("费用标准:");
  7192. string curr = "";
  7193. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7194. if (currData != null)
  7195. {
  7196. curr = currData.Name;
  7197. }
  7198. builder.MoveToCell(2, i, 3, 0);
  7199. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7200. builder.MoveToCell(2, i, 4, 0);
  7201. builder.Write("费用小计:");
  7202. builder.MoveToCell(2, i, 5, 0);
  7203. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7204. }
  7205. //删除多余行
  7206. while (table3.Rows.Count > table3Row)
  7207. {
  7208. table3.Rows.RemoveAt(table3Row);
  7209. }
  7210. #endregion
  7211. }
  7212. else dic.Add("SubGZF", "0.00");
  7213. //删除多余行
  7214. while (table3.Rows.Count > table3Row)
  7215. {
  7216. table3.Rows.RemoveAt(table3Row);
  7217. }
  7218. //培训费
  7219. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7220. if (_EnterExitCosts.ChoiceSix == 1)
  7221. {
  7222. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7223. dic.Add("SubPX", pxStr);
  7224. table4Row = dac4.Count;
  7225. #region 填充word表格内容
  7226. for (int i = 0; i < dac4.Count; i++)
  7227. {
  7228. var dac = dac4[i];
  7229. if (dac == null) continue;
  7230. builder.MoveToCell(3, i, 0, 0);
  7231. builder.Write("第" + dac.Days.ToString() + "天:");
  7232. builder.MoveToCell(3, i, 1, 0);
  7233. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7234. builder.MoveToCell(3, i, 2, 0);
  7235. builder.Write("费用标准:");
  7236. string curr = "";
  7237. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7238. if (currData != null)
  7239. {
  7240. curr = currData.Name;
  7241. }
  7242. builder.MoveToCell(3, i, 3, 0);
  7243. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7244. builder.MoveToCell(3, i, 4, 0);
  7245. builder.Write("费用小计:");
  7246. builder.MoveToCell(3, i, 5, 0);
  7247. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7248. }
  7249. #endregion
  7250. }
  7251. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7252. //删除多余行
  7253. while (table4.Rows.Count > table4Row)
  7254. {
  7255. table4.Rows.RemoveAt(table4Row);
  7256. }
  7257. //其他费用
  7258. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7259. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7260. {
  7261. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7262. dic.Add("titleQi", qtStr);
  7263. table5Row = dac5.Count;
  7264. #region 填充word表格内容
  7265. for (int i = 0; i < dac5.Count; i++)
  7266. {
  7267. var dac = dac5[i];
  7268. if (dac == null) continue;
  7269. builder.MoveToCell(4, i, 0, 0);
  7270. builder.Write("第" + dac.Index.ToString() + "项:");
  7271. builder.MoveToCell(4, i, 1, 0);
  7272. builder.Write(dac.itemName);
  7273. builder.MoveToCell(4, i, 2, 0);
  7274. builder.Write("费用标准:");
  7275. builder.MoveToCell(4, i, 3, 0);
  7276. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7277. builder.MoveToCell(4, i, 4, 0);
  7278. builder.Write("费用小计:");
  7279. builder.MoveToCell(4, i, 5, 0);
  7280. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7281. builder.MoveToCell(4, i, 6, 0);
  7282. builder.Write("备注:");
  7283. builder.MoveToCell(4, i, 7, 0);
  7284. builder.Write(dac.Remark);
  7285. }
  7286. #endregion
  7287. }
  7288. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7289. //删除多余行
  7290. while (table5.Rows.Count > table5Row)
  7291. {
  7292. table5.Rows.RemoveAt(table5Row);
  7293. }
  7294. //加上其他费用
  7295. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7296. decimal subJJC = 0.00M,
  7297. subGWC = 0.00M,
  7298. subTDC = 0.00M;
  7299. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7300. string totalLabel = string.Format("全部费用总计:");
  7301. //经济舱
  7302. if (_EnterExitCosts.SumJJC == 1)
  7303. {
  7304. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7305. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7306. }
  7307. //公务舱
  7308. if (_EnterExitCosts.SumGWC == 1)
  7309. {
  7310. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7311. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7312. }
  7313. //头等舱
  7314. if (_EnterExitCosts.SumTDC == 1)
  7315. {
  7316. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7317. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7318. }
  7319. //TotalLabel
  7320. dic.Add("TotalLabel", totalLabel);
  7321. #region 填充word模板书签内容
  7322. foreach (var key in dic.Keys)
  7323. {
  7324. Bookmark bookmark = doc.Range.Bookmarks[key];
  7325. if (bookmark != null)
  7326. {
  7327. builder.MoveToBookmark(key);
  7328. builder.Write(dic[key]);
  7329. }
  7330. }
  7331. #endregion
  7332. //文件名
  7333. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7334. strFileName = CommonFun.ValidFileName(strFileName);
  7335. AsposeHelper.removewatermark_v2180();
  7336. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7337. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7338. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7339. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7340. }
  7341. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7342. {
  7343. //获取模板
  7344. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7345. //载入模板
  7346. Document doc = new Document(tempPath);
  7347. DocumentBuilder builder = new DocumentBuilder(doc);
  7348. Dictionary<string, string> dic = new Dictionary<string, string>();
  7349. string returnCodeLabel = string.Empty;
  7350. if (nationalTravelFeeData.Any())
  7351. {
  7352. List<string> list = new List<string>();
  7353. foreach (var item in nationalTravelFeeData)
  7354. {
  7355. list.Add($"{item.Country}({item.City})");
  7356. }
  7357. list = list.Distinct().ToList();
  7358. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7359. }
  7360. var countryLabel = string.Empty;
  7361. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7362. if (countryData.Any())
  7363. {
  7364. countryLabel = string.Join("、", countryData);
  7365. }
  7366. dic.Add("ReturnCodeAir", returnCodeLabel);
  7367. dic.Add("VisitStartDate", "-");
  7368. dic.Add("VisitEndDate", "-");
  7369. dic.Add("Day", "-");
  7370. dic.Add("VisitCountry", countryLabel);
  7371. dic.Add("ClientUnit", "-");
  7372. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7373. //dic.Add("Names", Names);
  7374. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7375. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7376. decimal dac1totalPrice = 0.00M;
  7377. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7378. foreach (var dac in dac1)
  7379. {
  7380. if (dac.SubTotal == 0.00M)
  7381. {
  7382. continue;
  7383. }
  7384. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7385. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7386. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7387. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7388. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7389. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7390. builder.Write(currency);//币种
  7391. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7392. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7393. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7394. builder.Write("");//人数
  7395. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7396. builder.Write("");//天数
  7397. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7398. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7399. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7400. decimal rate = 0.00M;
  7401. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7402. builder.Write(rate.ToString("#0.0000"));//汇率
  7403. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7404. decimal rbmPrice = dac.SubTotal;
  7405. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7406. accommodationStartIndex++;
  7407. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7408. }
  7409. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7410. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7411. {
  7412. table1.Rows.RemoveAt(i - 1);
  7413. foodandotherStartIndex--;
  7414. }
  7415. if (dac2.Count == dac3.Count)//国家 币种 金额
  7416. {
  7417. for (int i = 0; i < dac2.Count; i++)
  7418. {
  7419. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7420. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7421. }
  7422. }
  7423. decimal dac2totalPrice = 0.00M;
  7424. foreach (var dac in dac2)
  7425. {
  7426. if (dac.SubTotal == 0)
  7427. {
  7428. continue;
  7429. }
  7430. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7431. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7432. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7433. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7434. builder.Write(currency);//币种
  7435. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7436. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7437. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7438. builder.Write("");//人数
  7439. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7440. builder.Write("");//天数
  7441. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7442. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7443. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7444. decimal rate = 0.00M;
  7445. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7446. builder.Write(rate.ToString("#0.0000"));//汇率
  7447. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7448. decimal rbmPrice = dac.SubTotal;
  7449. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7450. foodandotherStartIndex++;
  7451. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7452. }
  7453. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7454. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7455. {
  7456. table1.Rows.RemoveAt(i - 1);
  7457. }
  7458. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7459. string otherFeeStr = "";
  7460. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7461. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7462. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7463. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7464. foreach (var otherInfo in dac5)
  7465. {
  7466. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7467. }
  7468. #endregion
  7469. if (otherFeeStr.Length > 0)
  7470. {
  7471. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7472. otherFeeStr = $"({otherFeeStr})";
  7473. dic.Add("OtherFeeStr", otherFeeStr);
  7474. }
  7475. //总计
  7476. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7477. //国际旅费
  7478. string outsideAir = string.Empty;
  7479. string allPriceAir = string.Empty;
  7480. if (_EnterExitCosts.SumJJC == 1)
  7481. {
  7482. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7483. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7484. }
  7485. if (_EnterExitCosts.SumGWC == 1)
  7486. {
  7487. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7488. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7489. }
  7490. if (_EnterExitCosts.SumTDC == 1)
  7491. {
  7492. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7493. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7494. }
  7495. dic.Add("InTravelPrice", $"({outsideAir})");
  7496. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7497. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7498. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7499. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7500. foreach (var key in dic.Keys)
  7501. {
  7502. builder.MoveToBookmark(key);
  7503. builder.Write(dic[key]);
  7504. }
  7505. //模板文件名
  7506. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7507. strFileName = CommonFun.ValidFileName(strFileName);
  7508. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7509. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7510. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7511. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7512. }
  7513. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7514. {
  7515. //获取模板
  7516. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7517. //载入模板
  7518. WorkbookDesigner designer = new WorkbookDesigner();
  7519. designer.Workbook = new Workbook(tempPath);
  7520. Dictionary<string, string> dic = new Dictionary<string, string>();
  7521. string returnCodeLabel = string.Empty;
  7522. if (nationalTravelFeeData.Any())
  7523. {
  7524. List<string> list = new List<string>();
  7525. foreach (var item in nationalTravelFeeData)
  7526. {
  7527. list.Add($"{item.Country}({item.City})");
  7528. }
  7529. list = list.Distinct().ToList();
  7530. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7531. }
  7532. var countryLabel = string.Empty;
  7533. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7534. if (countryData.Any())
  7535. {
  7536. countryLabel = string.Join("、", countryData);
  7537. }
  7538. dic.Add("ReturnCodeAir", returnCodeLabel);
  7539. dic.Add("VisitStartDate", "-");
  7540. dic.Add("VisitEndDate", "-");
  7541. dic.Add("Day", "0");
  7542. dic.Add("VisitCountry", countryLabel);
  7543. dic.Add("ClientUnit", "-");
  7544. designer.SetDataSource("ClientUnit", "-");
  7545. designer.SetDataSource("VisitCountry", countryLabel);
  7546. designer.SetDataSource("Group", "-");
  7547. designer.SetDataSource("ClientUnitTitle", "-");
  7548. designer.SetDataSource("Name", "-");
  7549. designer.SetDataSource("VisitStartDate", "-");
  7550. designer.SetDataSource("Day", "0");
  7551. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7552. designer.SetDataSource("ReturnCodeAir", "-");
  7553. int startIndex = 10;
  7554. const int startIndexcopy = 10;
  7555. if (dac2.Count == dac3.Count)//国家 币种 金额
  7556. {
  7557. for (int i = 0; i < dac2.Count; i++)
  7558. {
  7559. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7560. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7561. }
  7562. }
  7563. DataTable dtdac1 = new DataTable();
  7564. List<string> place = new List<string>();
  7565. dtdac1.Columns.AddRange(new DataColumn[] {
  7566. new DataColumn(){ ColumnName = "city"},
  7567. new DataColumn(){ ColumnName = "curr"},
  7568. new DataColumn(){ ColumnName = "criterion"},
  7569. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7570. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7571. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7572. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7573. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7574. });
  7575. DataTable dtdac2 = new DataTable();
  7576. dtdac2.Columns.AddRange(new DataColumn[] {
  7577. new DataColumn(){ ColumnName = "city"},
  7578. new DataColumn(){ ColumnName = "curr"},
  7579. new DataColumn(){ ColumnName = "criterion"},
  7580. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7581. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7582. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7583. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7584. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7585. });
  7586. dtdac1.TableName = "tb1";
  7587. dtdac2.TableName = "tb2";
  7588. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7589. foreach (var item in dac1)
  7590. {
  7591. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7592. if (place.Contains(item.Place))
  7593. {
  7594. continue;
  7595. }
  7596. DataRow row = dtdac1.NewRow();
  7597. row["city"] = item.Place;
  7598. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7599. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7600. row["curr"] = currency;
  7601. row["rate"] = rate.ToString("#0.0000");
  7602. row["criterion"] = item.Cost.ToString("#0.00");
  7603. row["number"] = 1;
  7604. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7605. //row["costRMB"] = rbmPrice;
  7606. dtdac1.Rows.Add(row);
  7607. place.Add(item.Place);
  7608. }
  7609. place = new List<string>();
  7610. foreach (var item in dac2)
  7611. {
  7612. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7613. if (place.Contains(item.Place))
  7614. {
  7615. continue;
  7616. }
  7617. DataRow row = dtdac2.NewRow();
  7618. row["city"] = item.Place;
  7619. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7620. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7621. row["curr"] = currency;
  7622. row["rate"] = rate.ToString("#0.0000");
  7623. row["criterion"] = item.Cost.ToString("#0.00");
  7624. row["number"] = 1;
  7625. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7626. //row["cost"] = item.SubTotal;
  7627. //row["costRMB"] = rbmPrice;
  7628. dtdac2.Rows.Add(row);
  7629. place.Add(item.Place);
  7630. //dac2totalPrice += rbmPrice;
  7631. }
  7632. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7633. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7634. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7635. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7636. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7637. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7638. string cell4Str1 = string.Empty;
  7639. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7640. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7641. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7642. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7643. string cellStr = $" 5.其他费用(";
  7644. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7645. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7646. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7647. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7648. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7649. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7650. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7651. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7652. foreach (var otherInfo in dac5)
  7653. {
  7654. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7655. }
  7656. #endregion
  7657. if (cellStr.Length > 8)
  7658. {
  7659. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7660. }
  7661. cellStr += ")";
  7662. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7663. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7664. decimal pxFee = dac4.Sum(it => it.Cost);
  7665. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7666. string celllastStr1 = "";
  7667. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7668. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7669. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7670. celllastStr1 += $",国际旅费 元";
  7671. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7672. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7673. designer.SetDataSource("cell4Str", cell4Str);
  7674. designer.SetDataSource("cellStr", cellStr);
  7675. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7676. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7677. designer.SetDataSource("celllastStr", celllastStr);
  7678. Workbook wb = designer.Workbook;
  7679. var sheet = wb.Worksheets[0];
  7680. //绑定datatable数据集
  7681. designer.SetDataSource(dtdac1);
  7682. designer.SetDataSource(dtdac2);
  7683. designer.Process();
  7684. var rowStart = dtdac1.Rows.Count;
  7685. while (rowStart > 0)
  7686. {
  7687. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7688. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7689. startIndex++;
  7690. rowStart--;
  7691. }
  7692. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7693. startIndex += 1; //总计行
  7694. rowStart = dtdac2.Rows.Count;
  7695. while (rowStart > 0)
  7696. {
  7697. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7698. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7699. startIndex++;
  7700. rowStart--;
  7701. }
  7702. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7703. wb.CalculateFormula(true);
  7704. //模板文件名
  7705. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7706. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7707. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7708. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7709. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7710. }
  7711. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7712. {
  7713. //获取模板
  7714. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7715. //载入模板
  7716. Document doc = new Document(tempPath);
  7717. DocumentBuilder builder = new DocumentBuilder(doc);
  7718. Dictionary<string, string> dic = new Dictionary<string, string>();
  7719. dic.Add("GroupName", "-");
  7720. dic.Add("ClientUnit", "-");
  7721. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7722. //string missionLeaderJob = "";//负责人job
  7723. //int groupNumber = 0; //团人数
  7724. dic.Add("MissionLeader", "-"); //团负责人
  7725. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7726. dic.Add("GroupNumber", "0"); //团人数
  7727. dic.Add("Day", "0");
  7728. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7729. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7730. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7731. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7732. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7733. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7734. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7735. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7736. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7737. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7738. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7739. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7740. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7741. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7742. //其他费用
  7743. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7744. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7745. //其他费用合计
  7746. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7747. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7748. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7749. //公务舱合计
  7750. //国际旅费
  7751. //string outsideJJ = "";
  7752. //string allPriceJJ = "";
  7753. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7754. {
  7755. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7756. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7757. }
  7758. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7759. {
  7760. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7761. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7762. }
  7763. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7764. {
  7765. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7766. dic.Add("AirFeeTotal", airFeeTotalStr);
  7767. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7768. dic.Add("FeeTotal", feeTotalStr);
  7769. }
  7770. foreach (var key in dic.Keys)
  7771. {
  7772. builder.MoveToBookmark(key);
  7773. builder.Write(dic[key]);
  7774. }
  7775. //模板文件名
  7776. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7777. strFileName = CommonFun.ValidFileName(strFileName);
  7778. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7779. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7780. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7781. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7782. }
  7783. }
  7784. else if (dto.ExportType == 2) //表格
  7785. {
  7786. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7787. }
  7788. else if (dto.ExportType == 3)
  7789. {
  7790. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7791. }
  7792. return Ok(JsonView(400, "只可导出明细表!", ""));
  7793. }
  7794. catch (Exception ex)
  7795. {
  7796. return Ok(JsonView(400, ex.Message, ""));
  7797. }
  7798. }
  7799. /// <summary>
  7800. /// 获取三公费用标准city
  7801. /// </summary>
  7802. /// <param name="placeData"></param>
  7803. /// <param name="nationalTravelFeeId"></param>
  7804. /// <returns></returns>
  7805. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7806. {
  7807. string _city = string.Empty;
  7808. if (!placeData.Any()) return _city;
  7809. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7810. if (data == null) return _city;
  7811. string country = data.Country;
  7812. string city = data.City;
  7813. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7814. else _city = city;
  7815. return _city;
  7816. }
  7817. /// <summary>
  7818. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7819. /// </summary>
  7820. /// <returns></returns>
  7821. [HttpPost]
  7822. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7824. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7825. {
  7826. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7827. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7828. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7829. if (_view.Code == 0)
  7830. {
  7831. return Ok(JsonView(true, "操作成功"));
  7832. }
  7833. return Ok(JsonView(false, "操作失败"));
  7834. }
  7835. /// <summary>
  7836. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7837. /// </summary>
  7838. /// <returns></returns>
  7839. [HttpPost]
  7840. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7842. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7843. {
  7844. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7845. if (data.Code != 0)
  7846. {
  7847. return Ok(JsonView(false, data.Msg));
  7848. }
  7849. return Ok(JsonView(true, "操作成功!", data.Data));
  7850. }
  7851. /// <summary>
  7852. /// 三公其他费用草稿 删除
  7853. /// </summary>
  7854. /// <param name="dto"></param>
  7855. /// <returns></returns>
  7856. [HttpPost]
  7857. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7858. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7859. {
  7860. var jw = JsonView(false, "删除失败!");
  7861. var data = new Grp_DayOtherPriceDraft()
  7862. {
  7863. Id = dto.Id,
  7864. IsDel = 1,
  7865. DeleteUserId = dto.DeleteUserId,
  7866. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7867. };
  7868. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7869. if (del > 0)
  7870. {
  7871. jw.Code = 200;
  7872. jw.Msg = "删除成功!";
  7873. }
  7874. return Ok(jw);
  7875. }
  7876. /// <summary>
  7877. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7878. /// </summary>
  7879. /// <returns></returns>
  7880. [HttpPost]
  7881. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7882. {
  7883. var jw = JsonView(false);
  7884. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7885. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7886. jw.Code = StatusCodes.Status200OK;
  7887. jw.Msg = "操作成功!";
  7888. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  7889. return Ok(jw);
  7890. }
  7891. /// <summary>
  7892. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7893. /// </summary>
  7894. /// <param name="dto"></param>
  7895. /// <returns></returns>
  7896. [HttpPost]
  7897. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7898. {
  7899. int userId = dto.UserId,
  7900. portId = dto.PortType,
  7901. groupId = dto.GroupId,
  7902. draftId = dto.DraftId;
  7903. _portTypeData.Add(1);
  7904. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7905. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7906. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7907. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7908. _sqlSugar.BeginTran();
  7909. try
  7910. {
  7911. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7912. if (draftDatas == null)
  7913. {
  7914. _sqlSugar.RollbackTran();
  7915. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7916. }
  7917. //验证可覆盖已有数据 两边创建人需为同一人;
  7918. int draftCreateUserId = draftDatas.CreateUserId,
  7919. formalCreateUserId = 0;
  7920. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7921. if (formalData != null)
  7922. {
  7923. formalCreateUserId = formalData.CreateUserId;
  7924. if (draftCreateUserId != formalCreateUserId)
  7925. {
  7926. _sqlSugar.RollbackTran();
  7927. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7928. }
  7929. }
  7930. //默认添加查看、编辑权限(创建人、自己)
  7931. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  7932. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7933. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7934. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7935. newExterData.DiId = groupId;
  7936. newExterData.CreateUserId = userId;
  7937. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7938. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7939. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7940. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7941. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7942. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7943. //数据如果存在执行删除
  7944. if (enterExitCostInfo != null)
  7945. {
  7946. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7947. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7948. .Where(x => x.Id == enterExitCostInfo.Id)
  7949. .ExecuteCommand();
  7950. _sqlSugar.Updateable<Grp_DayAndCost>()
  7951. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7952. .Where(x => x.DiId == groupId)
  7953. .ExecuteCommand();
  7954. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7955. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7956. .Where(x => x.Diid == groupId)
  7957. .ExecuteCommand();
  7958. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7959. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7960. .Where(x => x.GroupId == groupId)
  7961. .ExecuteCommand();
  7962. }
  7963. //执行insert
  7964. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7965. if (insertId < 1)
  7966. {
  7967. _sqlSugar.RollbackTran();
  7968. return Ok(JsonView(false, "草稿数据导入失败!"));
  7969. }
  7970. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7971. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7972. #region 默认添加权限
  7973. #endregion
  7974. _sqlSugar.CommitTran();
  7975. //执行操作之后
  7976. //生成默认文件pdf并且通知人员
  7977. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7978. {
  7979. DiId = groupId,
  7980. ExportType = 1,
  7981. SubTypeId = 1005
  7982. }, "pdf");
  7983. //发送通知
  7984. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7985. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7986. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7987. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7988. //汇率信息记录
  7989. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7990. return Ok(JsonView(true));
  7991. }
  7992. catch (Exception ex)
  7993. {
  7994. _sqlSugar.RollbackTran();
  7995. return Ok(JsonView(false, ex.Message));
  7996. }
  7997. }
  7998. #endregion
  7999. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8000. /// <summary>
  8001. /// 获取币种基础数据(含逻辑处理)
  8002. /// </summary>
  8003. /// <returns></returns>
  8004. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8005. {
  8006. return await GeneralMethod.EnterExitCostInitRate();
  8007. }
  8008. /// <summary>
  8009. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8010. /// </summary>
  8011. /// <returns></returns>
  8012. [HttpPost]
  8013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8014. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8015. {
  8016. //验证城市归属并给默认值
  8017. int provinceId = dto.ProvinceId;
  8018. if (provinceId < 1) provinceId = 122;
  8019. var dataSource = await _sqlSugar
  8020. .Queryable<Sys_SetData>()
  8021. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8022. .ToListAsync();
  8023. var fileTypes = new List<EecSetDataInfoView>();
  8024. //三公费用-Word明细类型
  8025. var wordTypeData = dataSource
  8026. .Where(it => it.STid == 72)
  8027. .Select(x => new EecSetDataInfoView
  8028. {
  8029. ParentId = 1,
  8030. Id = x.Id,
  8031. Name = x.Name
  8032. })
  8033. .ToArray();
  8034. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8035. var excelTypeData = dataSource
  8036. .Where(it => it.STid == 73)
  8037. .Select(x => new EecSetDataInfoView
  8038. {
  8039. ParentId = 2,
  8040. Id = x.Id,
  8041. Name = x.Name
  8042. })
  8043. .ToArray();
  8044. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8045. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8046. fileTypes.Add(groupNameList);
  8047. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  8048. //默认币种显示
  8049. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8050. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8051. return Ok(JsonView(true, "查询成功!", new
  8052. {
  8053. FileTypeData = fileTypes,
  8054. CurrencyInit = _currencyInfos,
  8055. viewPermissionData = viewPermissionData
  8056. }));
  8057. }
  8058. /// <summary>
  8059. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  8060. /// </summary>
  8061. /// <returns></returns>
  8062. [HttpPost]
  8063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8064. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  8065. {
  8066. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8067. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8068. RefAsync<int> total = 0;
  8069. int diId = 0;
  8070. var status = int.TryParse(dto.GroupName, out diId);
  8071. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  8072. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8073. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8074. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8075. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8076. .OrderByDescending(x => x.VisitStartDate)
  8077. .Select(x => new EnterExitCostMobileGroupView()
  8078. {
  8079. Id = x.Id,
  8080. GroupName = x.TeamName,
  8081. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8082. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8083. ProvinceId = x.CityId
  8084. })
  8085. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8086. //处理省份Id
  8087. if (data.Any())
  8088. {
  8089. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8090. if (provCityDatas.Any())
  8091. {
  8092. foreach (var item in data)
  8093. {
  8094. var provinceId = item.ProvinceId;
  8095. var isDefualtVal = true;
  8096. if (provinceId > 0)
  8097. {
  8098. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  8099. if (parentId != null)
  8100. {
  8101. isDefualtVal = false;
  8102. item.ProvinceId = (int)parentId;
  8103. }
  8104. }
  8105. if (isDefualtVal)
  8106. {
  8107. item.ProvinceId = 122; //默认四川
  8108. }
  8109. }
  8110. }
  8111. }
  8112. //处理是否显示
  8113. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  8114. {
  8115. foreach (var item in data)
  8116. {
  8117. item.IsView = true;
  8118. }
  8119. }
  8120. return Ok(JsonView(true, "查询成功!", data, total));
  8121. }
  8122. /// <summary>
  8123. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  8124. /// </summary>
  8125. /// <returns></returns>
  8126. [HttpPost]
  8127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8128. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  8129. {
  8130. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8131. RefAsync<int> total = 0;
  8132. var data = await _sqlSugar.Queryable<Sys_SetData>()
  8133. .Where(x => x.IsDel == 0 && x.STid == 66)
  8134. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  8135. .Select(x => new
  8136. {
  8137. id = x.Id,
  8138. name = x.Name,
  8139. remark = x.Remark,
  8140. })
  8141. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8142. return Ok(JsonView(true, "查询成功!", data, total));
  8143. }
  8144. /// <summary>
  8145. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  8146. /// </summary>
  8147. /// <returns></returns>
  8148. [HttpPost]
  8149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8150. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  8151. {
  8152. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8153. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8154. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  8155. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  8156. var groupOtherRateData = groupRateData.TeamRates;
  8157. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8158. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8159. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8160. groupOtherRateData = groupOtherRateData
  8161. .Select(x => new TeamRateDescAddCurrencyIdView
  8162. {
  8163. CurrencyId = x.CurrencyId,
  8164. CurrencyName = x.CurrencyName,
  8165. CurrencyCode = x.CurrencyCode,
  8166. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8167. }).ToList();
  8168. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8169. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8170. }
  8171. /// <summary>
  8172. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8173. /// </summary>
  8174. /// <returns></returns>
  8175. [HttpPost]
  8176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8177. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8178. {
  8179. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8180. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8181. var tipsData = new List<int>() { 1, 2, 3 };
  8182. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8183. if (dto.TipsType == 1)
  8184. {
  8185. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8186. }
  8187. else if (dto.TipsType == 2)
  8188. {
  8189. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8190. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8191. }
  8192. else if (dto.TipsType == 3)
  8193. {
  8194. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8195. return Ok(JsonView(true, "查询成功!", airData.Data));
  8196. }
  8197. return Ok(JsonView(false));
  8198. }
  8199. /// <summary>
  8200. /// 团组模块 - 出入境国家费用标准-移动端 List
  8201. /// </summary>
  8202. /// <returns></returns>
  8203. [HttpPost]
  8204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8205. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8206. {
  8207. Stopwatch sw = new Stopwatch();
  8208. sw.Start();
  8209. int provinceId = dto.ProvinceId;
  8210. if (provinceId < 1) provinceId = 122; // 默认四川
  8211. RefAsync<int> total = 0;
  8212. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8213. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8214. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8215. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  8216. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8217. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8218. .Select((ntf, sd, u, sd1) => new
  8219. {
  8220. Id = ntf.Id,
  8221. Area = $"{ntf.Country}-{ntf.City}",
  8222. Currency = ntf.Currency,
  8223. CurrencyCode = sd.Name,
  8224. CurrencyName = sd.Remark,
  8225. RoomCost = ntf.RoomCost,
  8226. FoodCost = ntf.FoodCost,
  8227. PublicCost = ntf.PublicCost,
  8228. TrainCost = ntf.TrainCost,
  8229. LastUpdateUserId = ntf.LastUpdateUserId,
  8230. LastUpdateUserName = u.CnName,
  8231. LastUpdateTime = ntf.LastUpdateTime
  8232. })
  8233. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8234. sw.Stop();
  8235. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8236. }
  8237. /// <summary>
  8238. /// 团组模块 - 出入境费用-移动端 - Info
  8239. /// </summary>
  8240. /// <returns></returns>
  8241. [HttpPost]
  8242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8243. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8244. {
  8245. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8246. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8247. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8248. return Ok(data);
  8249. }
  8250. /// <summary>
  8251. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8252. /// </summary>
  8253. /// <returns></returns>
  8254. [HttpPost]
  8255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8256. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8257. {
  8258. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8259. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8260. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8261. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8262. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8263. mobileInfo.DiId = dto.DiId;
  8264. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8265. if (eecInfo == null) return Ok(mobileInfo);
  8266. //验证查看权限
  8267. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8268. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8269. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8270. mobileInfo.IsAssignPerm = isSet;
  8271. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8272. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8273. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8274. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8275. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8276. {
  8277. SubId = dac.Id,
  8278. DiId = dac.DiId,
  8279. Type = dac.Type,
  8280. Days = dac.Days,
  8281. NationalTravelFeeId = dac.NationalTravelFeeId,
  8282. Arae = $"{ntf.Country}-{ntf.City}",
  8283. Cost = dac.Cost,
  8284. Currency = dac.Currency,
  8285. CurrencyName = sd.Name,
  8286. SubTotal = dac.SubTotal,
  8287. })
  8288. .ToList();
  8289. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8290. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8291. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8292. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8293. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8294. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8295. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8296. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8297. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8298. //其他款项
  8299. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8300. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8301. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8302. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8303. .OrderBy((dop, sd1, sd2) => dop.Index)
  8304. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8305. {
  8306. SubId = dop.Id,
  8307. DiId = dop.Diid,
  8308. Index = dop.Index,
  8309. SetDataId = dop.SetDataId,
  8310. SetDataName = sd1.Name,
  8311. Cost = dop.Cost,
  8312. Currency = dop.Currency,
  8313. CurrencyName = sd2.Remark,
  8314. SubTotal = dop.SubTotal,
  8315. Remark = dop.Remark,
  8316. })
  8317. .ToArray();
  8318. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8319. return Ok(mobileInfo);
  8320. }
  8321. /// <summary>
  8322. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8323. /// </summary>
  8324. /// <returns></returns>
  8325. [HttpPost]
  8326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8327. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8328. {
  8329. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8330. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8331. //验证查看权限
  8332. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8333. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8334. var userIds = await _sqlSugar
  8335. .Queryable<Grp_EnterExitCostPermission>()
  8336. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8337. .Select(x => x.UserId)
  8338. .ToArrayAsync();
  8339. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8340. var perUsersView = new List<dynamic>();
  8341. foreach (var item in perUsers)
  8342. {
  8343. bool isView1 = false;
  8344. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8345. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8346. }
  8347. return Ok(JsonView(perUsersView));
  8348. }
  8349. /// <summary>
  8350. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8351. /// </summary>
  8352. /// <returns></returns>
  8353. [HttpPost]
  8354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8355. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8356. {
  8357. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8358. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8359. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8360. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8361. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8362. //验证查看权限
  8363. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8364. //if (!isView) return Ok(JsonView(false, msg));
  8365. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8366. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8367. var subType = dto.SubType;
  8368. if (subType == 1) //1:境内费用
  8369. {
  8370. var oneData = new ChoiceOneMobileSubInfoView()
  8371. {
  8372. Id = eecInfo.Id,
  8373. ChoiceOne = eecInfo.ChoiceOne,
  8374. ChoiceOneTotalCost = eecInfo.InsidePay,
  8375. Visa = eecInfo.Visa,
  8376. VisaRemark = eecInfo.VisaRemark,
  8377. YiMiao = eecInfo.YiMiao,
  8378. HeSuan = eecInfo.HeSuan,
  8379. Service = eecInfo.Service,
  8380. Ticket = eecInfo.Ticket,
  8381. Safe = eecInfo.Safe,
  8382. FirstItemRemark = eecInfo.FirstItemRemark
  8383. };
  8384. return Ok(JsonView(oneData));
  8385. }
  8386. else if (subType == 2) //2:国际旅费
  8387. {
  8388. var twoData = new ChoiceTwoMobileSubInfoView()
  8389. {
  8390. Id = eecInfo.Id,
  8391. ChoiceTwoJJ = eecInfo.SumJJC,
  8392. OutsideJJPay = eecInfo.OutsideJJPay,
  8393. ChoiceTwoGW = eecInfo.SumGWC,
  8394. OutsideGWPay = eecInfo.OutsideGWPay,
  8395. ChoiceTwoTD = eecInfo.SumTDC,
  8396. OutsideTDPay = eecInfo.OutsideTDPay,
  8397. AirJJ = eecInfo.AirJJ,
  8398. AirGW = eecInfo.AirGW,
  8399. AirTD = eecInfo.AirTD,
  8400. CityTranffic = eecInfo.CityTranffic,
  8401. TwoItemRemark = eecInfo.TwoItemRemark
  8402. };
  8403. return Ok(JsonView(twoData));
  8404. }
  8405. else if (subType == 3) //3:住宿费
  8406. {
  8407. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8408. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8409. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8410. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8411. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8412. {
  8413. SubId = dac.Id,
  8414. DiId = dac.DiId,
  8415. Type = dac.Type,
  8416. Days = dac.Days,
  8417. NationalTravelFeeId = dac.NationalTravelFeeId,
  8418. Arae = $"{ntf.Country}-{ntf.City}",
  8419. Cost = dac.Cost,
  8420. Currency = dac.Currency,
  8421. CurrencyName = sd.Name,
  8422. SubTotal = dac.SubTotal,
  8423. })
  8424. .ToArray();
  8425. var data = new ChoiceMobileSubInfo3To6View()
  8426. {
  8427. ParentId = eecInfo.Id,
  8428. Choice = eecInfo.ChoiceThree,
  8429. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8430. Details = dayAndCostDatas
  8431. };
  8432. return Ok(JsonView(data));
  8433. }
  8434. else if (subType == 4) //4:伙食费
  8435. {
  8436. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8437. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8438. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8439. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8440. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8441. {
  8442. SubId = dac.Id,
  8443. DiId = dac.DiId,
  8444. Type = dac.Type,
  8445. Days = dac.Days,
  8446. NationalTravelFeeId = dac.NationalTravelFeeId,
  8447. Arae = $"{ntf.Country}-{ntf.City}",
  8448. Cost = dac.Cost,
  8449. Currency = dac.Currency,
  8450. CurrencyName = sd.Name,
  8451. SubTotal = dac.SubTotal,
  8452. })
  8453. .ToArray();
  8454. var data = new ChoiceMobileSubInfo3To6View()
  8455. {
  8456. ParentId = eecInfo.Id,
  8457. Choice = eecInfo.ChoiceFour,
  8458. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8459. Details = dayAndCostDatas
  8460. };
  8461. return Ok(JsonView(data));
  8462. }
  8463. else if (subType == 5) //5:公杂费
  8464. {
  8465. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8466. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8467. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8468. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8469. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8470. {
  8471. SubId = dac.Id,
  8472. DiId = dac.DiId,
  8473. Type = dac.Type,
  8474. Days = dac.Days,
  8475. NationalTravelFeeId = dac.NationalTravelFeeId,
  8476. Arae = $"{ntf.Country}-{ntf.City}",
  8477. Cost = dac.Cost,
  8478. Currency = dac.Currency,
  8479. CurrencyName = sd.Name,
  8480. SubTotal = dac.SubTotal,
  8481. })
  8482. .ToArray();
  8483. var data = new ChoiceMobileSubInfo3To6View()
  8484. {
  8485. ParentId = eecInfo.Id,
  8486. Choice = eecInfo.ChoiceFive,
  8487. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8488. Details = dayAndCostDatas
  8489. };
  8490. return Ok(JsonView(data));
  8491. }
  8492. else if (subType == 6) //6:培训费
  8493. {
  8494. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8495. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8496. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8497. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8498. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8499. {
  8500. SubId = dac.Id,
  8501. DiId = dac.DiId,
  8502. Type = dac.Type,
  8503. Days = dac.Days,
  8504. NationalTravelFeeId = dac.NationalTravelFeeId,
  8505. Arae = $"{ntf.Country}-{ntf.City}",
  8506. Cost = dac.Cost,
  8507. Currency = dac.Currency,
  8508. CurrencyName = sd.Name,
  8509. SubTotal = dac.SubTotal,
  8510. })
  8511. .ToArray();
  8512. var data = new ChoiceMobileSubInfo3To6View()
  8513. {
  8514. ParentId = eecInfo.Id,
  8515. Choice = eecInfo.ChoiceSix,
  8516. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8517. Details = dayAndCostDatas
  8518. };
  8519. return Ok(JsonView(data));
  8520. }
  8521. else if (subType == 7) //7:其他
  8522. {
  8523. //其他款项
  8524. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8525. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8526. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8527. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8528. .OrderBy((dop, sd1, sd2) => dop.Index)
  8529. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8530. {
  8531. SubId = dop.Id,
  8532. DiId = dop.Diid,
  8533. Index = dop.Index,
  8534. SetDataId = dop.SetDataId,
  8535. SetDataName = sd1.Name,
  8536. Cost = dop.Cost,
  8537. Currency = dop.Currency,
  8538. CurrencyName = sd2.Name,
  8539. SubTotal = dop.SubTotal,
  8540. Remark = dop.Remark,
  8541. })
  8542. .ToArray();
  8543. var data = new ChoiceSevenMobileSubInfoView()
  8544. {
  8545. ParentId = eecInfo.Id,
  8546. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8547. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8548. Details = otherData
  8549. };
  8550. return Ok(JsonView(data));
  8551. }
  8552. return Ok(JsonView(false));
  8553. }
  8554. #region op
  8555. /// <summary>
  8556. /// 移动端更新费用消息通知
  8557. /// </summary>
  8558. /// <param name="diid"></param>
  8559. /// <param name="id"></param>
  8560. /// <param name="currUserId"></param>
  8561. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8562. {
  8563. try
  8564. {
  8565. ////生成默认文件pdf并且通知人员
  8566. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8567. //{
  8568. // DiId = diid,
  8569. // ExportType = 1,
  8570. // SubTypeId = 1005
  8571. //}, "pdf");
  8572. ////发送通知
  8573. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8574. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8575. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8576. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8577. ////汇率信息记录
  8578. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8579. }
  8580. catch (Exception ex)
  8581. {
  8582. //记录日志
  8583. throw;
  8584. }
  8585. }
  8586. /// <summary>
  8587. /// 验证出入境费用数据是否存在
  8588. /// 不存在添加
  8589. /// </summary>
  8590. /// <param name="diId"></param>
  8591. /// <param name="currUserId"></param>
  8592. /// <returns></returns>
  8593. /// <exception cref="CustomException"></exception>
  8594. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8595. {
  8596. var parentId = 0;
  8597. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8598. if (info != null)
  8599. {
  8600. parentId = info.Id;
  8601. }
  8602. else
  8603. {
  8604. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8605. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8606. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8607. parentId = addId;
  8608. }
  8609. return parentId;
  8610. }
  8611. /// <summary>
  8612. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8613. /// </summary>
  8614. /// <returns></returns>
  8615. [HttpPost]
  8616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8617. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8618. {
  8619. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8620. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8621. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8622. //验证编辑权限
  8623. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8624. //if (!isEdit) return Ok(JsonView(false, msg));
  8625. var permissions = new List<Grp_EnterExitCostPermission>();
  8626. foreach (var userId in dto.UserIds)
  8627. {
  8628. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8629. }
  8630. if (permissions.Any())
  8631. {
  8632. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8633. {
  8634. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8635. }
  8636. _sqlSugar.BeginTran();
  8637. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8638. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8639. if (result < 1)
  8640. {
  8641. _sqlSugar.RollbackTran();
  8642. return Ok(JsonView(false));
  8643. }
  8644. _sqlSugar.CommitTran();
  8645. return Ok(JsonView(true));
  8646. }
  8647. return Ok(JsonView(false));
  8648. }
  8649. /// <summary>
  8650. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8651. /// </summary>
  8652. /// <returns></returns>
  8653. [HttpPost]
  8654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8655. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8656. {
  8657. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8658. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8659. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8660. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8661. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8662. int id = dto.Id;
  8663. if (id <= 0) //add
  8664. {
  8665. //int provinceId = dto.ProvinceId;
  8666. int groupId = dto.DiId;
  8667. //if (provinceId < 1) provinceId = 122;
  8668. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  8669. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  8670. if (add < 1) return Ok(JsonView(false));
  8671. id = add;
  8672. }
  8673. else //update
  8674. {
  8675. ////验证编辑权限
  8676. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8677. //if (!isEdit) return Ok(JsonView(false, msg));
  8678. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8679. if (upd < 1) return Ok(JsonView(false));
  8680. }
  8681. #region 汇率变更时更改币种相关费用
  8682. var opDayCosts = new List<Grp_DayAndCost>();
  8683. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8684. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8685. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8686. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8687. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8688. .Select((dac, sd) => new
  8689. {
  8690. dac.Id,
  8691. dac.DiId,
  8692. CurrencyCode = sd.Name,
  8693. dac.Cost
  8694. })
  8695. .ToList();
  8696. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8697. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8698. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8699. .Select((dop, sd) => new
  8700. {
  8701. dop.Id,
  8702. dop.Diid,
  8703. CurrencyCode = sd.Name,
  8704. dop.Cost
  8705. })
  8706. .ToList();
  8707. if (dayCosts.Count > 0)
  8708. {
  8709. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8710. foreach (var dc in new_dayCosts)
  8711. {
  8712. var thisCurrency = dc.Key.ToUpper();
  8713. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8714. if (thisRate == 0.00M) continue;
  8715. foreach (var dcSub in dc)
  8716. {
  8717. opDayCosts.Add(new Grp_DayAndCost()
  8718. {
  8719. Id = dcSub.Id,
  8720. DiId = dcSub.DiId,
  8721. Cost = dcSub.Cost,
  8722. SubTotal = dcSub.Cost * thisRate,
  8723. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8724. });
  8725. }
  8726. }
  8727. if (opDayCosts.Count > 0)
  8728. {
  8729. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8730. }
  8731. }
  8732. if (dayOtherCosts.Count > 0)
  8733. {
  8734. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8735. foreach (var dc in new_dayOtherCosts)
  8736. {
  8737. var thisCurrency = dc.Key.ToUpper();
  8738. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8739. if (thisRate == 0.00M) continue;
  8740. foreach (var dcSub in dc)
  8741. {
  8742. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8743. {
  8744. Id = dcSub.Id,
  8745. Diid = dcSub.Diid,
  8746. Cost = dcSub.Cost,
  8747. SubTotal = dcSub.Cost * thisRate,
  8748. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8749. });
  8750. }
  8751. }
  8752. if (opDayOtherCosts.Count > 0)
  8753. {
  8754. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8755. }
  8756. }
  8757. #endregion
  8758. //消息通知
  8759. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8760. //汇率信息记录
  8761. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8762. return Ok(JsonView(new { parentId = id }));
  8763. }
  8764. /// <summary>
  8765. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8766. /// </summary>
  8767. /// <returns></returns>
  8768. [HttpPost]
  8769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8770. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8771. {
  8772. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8773. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8774. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8775. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  8776. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8777. int id = dto.Id;
  8778. if (id <= 0) //add
  8779. {
  8780. checkboxInfo.CreateUserId = dto.CurrUserId;
  8781. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8782. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8783. if (add < 1) return Ok(JsonView(false));
  8784. }
  8785. else //update
  8786. {
  8787. ////验证编辑权限
  8788. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8789. //if (!isEdit) return Ok(JsonView(false, msg));
  8790. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8791. .UpdateColumns(x => new
  8792. {
  8793. x.ChoiceOne,
  8794. x.ChoiceTwo,
  8795. x.SumJJC,
  8796. x.SumGWC,
  8797. x.SumTDC,
  8798. x.ChoiceThree,
  8799. x.ChoiceFour,
  8800. x.ChoiceFive,
  8801. x.ChoiceSix,
  8802. x.OtherExpenses_Checked
  8803. })
  8804. .Where(x => x.Id == id)
  8805. .ExecuteCommandAsync();
  8806. if (upd < 1) return Ok(JsonView(false));
  8807. }
  8808. return Ok(JsonView(new { parentId = id }));
  8809. }
  8810. /// <summary>
  8811. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8812. /// </summary>
  8813. /// <returns></returns>
  8814. [HttpPost]
  8815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8816. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8817. {
  8818. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8819. // if (provinceId < 1) provinceId = 122;
  8820. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8821. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8822. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8823. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8824. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8825. var checkboxInfo = new Grp_EnterExitCost()
  8826. {
  8827. Id = id,
  8828. //ProvinceId = provinceId,
  8829. DiId = diId,
  8830. CreateUserId = currUserId
  8831. };
  8832. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8833. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8834. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8835. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8836. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8837. if (id <= 0) //add
  8838. {
  8839. checkboxInfo.CreateUserId = dto.CurrUserId;
  8840. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8841. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8842. if (add < 1) return Ok(JsonView(false));
  8843. }
  8844. else //update
  8845. {
  8846. ////验证编辑权限
  8847. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8848. //if (!isEdit) return Ok(JsonView(false, msg));
  8849. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8850. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8851. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8852. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8853. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8854. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8855. .Where(x => x.Id == id)
  8856. .ExecuteCommandAsync();
  8857. if (upd < 1) return Ok(JsonView(false));
  8858. }
  8859. return Ok(JsonView(new { parentId = id }));
  8860. }
  8861. /// <summary>
  8862. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8863. /// </summary>
  8864. /// <returns></returns>
  8865. [HttpPost]
  8866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8867. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8868. {
  8869. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8870. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8871. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8872. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  8873. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8874. info.FirstItemRemark = dto.FirstItemRemark;
  8875. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8876. int id = dto.Id;
  8877. if (id <= 0) //add
  8878. {
  8879. info.CreateUserId = dto.CurrUserId;
  8880. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8881. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8882. if (add < 1) return Ok(JsonView(false));
  8883. id = add;
  8884. }
  8885. else //update
  8886. {
  8887. ////验证编辑权限
  8888. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8889. //if (!isEdit) return Ok(JsonView(false, msg));
  8890. var upd = await _sqlSugar.Updateable(info)
  8891. .UpdateColumns(x => new
  8892. {
  8893. x.ChoiceOne,
  8894. x.InsidePay,
  8895. x.VisaRemark,
  8896. x.Visa,
  8897. x.Service,
  8898. x.Safe,
  8899. x.Ticket,
  8900. x.HeSuan,
  8901. x.YiMiao,
  8902. x.FirstItemRemark
  8903. })
  8904. .Where(x => x.Id == id)
  8905. .ExecuteCommandAsync();
  8906. if (upd < 1) return Ok(JsonView(false));
  8907. }
  8908. //消息通知
  8909. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8910. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8911. }
  8912. /// <summary>
  8913. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8914. /// </summary>
  8915. /// <returns></returns>
  8916. [HttpPost]
  8917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8918. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8919. {
  8920. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8921. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8922. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8923. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  8924. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8925. info.DiId = dto.DiId;
  8926. //info.ProvinceId = dto.ProvinceId;
  8927. info.OutsideJJPay = dto.OutsideJJPay;
  8928. info.OutsideGWPay = dto.OutsideGWPay;
  8929. info.OutsideTDPay = dto.OutsideTDPay;
  8930. info.AirJJ = dto.AirJJ;
  8931. info.AirGW = dto.AirGW;
  8932. info.AirTD = dto.AirTD;
  8933. info.CityTranffic = dto.CityTranffic;
  8934. info.TwoItemRemark = dto.TwoItemRemark;
  8935. info.SumJJC = dto.ChoiceTwoJJ;
  8936. info.SumGWC = dto.ChoiceTwoGW;
  8937. info.SumTDC = dto.ChoiceTwoTD;
  8938. int id = dto.Id;
  8939. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8940. if (id <= 0) //add
  8941. {
  8942. info.CreateUserId = dto.CurrUserId;
  8943. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8944. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8945. if (addId <= 0) return Ok(JsonView(false));
  8946. id = addId;
  8947. }
  8948. else //update
  8949. {
  8950. ////验证编辑权限
  8951. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8952. //if (!isEdit) return Ok(JsonView(false, msg));
  8953. var upd = await _sqlSugar.Updateable(info)
  8954. .UpdateColumns(x => new
  8955. {
  8956. x.SumJJC,
  8957. x.OutsideJJPay,
  8958. x.SumGWC,
  8959. x.OutsideGWPay,
  8960. x.SumTDC,
  8961. x.OutsideTDPay,
  8962. x.AirJJ,
  8963. x.AirGW,
  8964. x.AirTD,
  8965. x.CityTranffic,
  8966. x.TwoItemRemark
  8967. })
  8968. .Where(x => x.Id == id)
  8969. .ExecuteCommandAsync();
  8970. if (upd < 1) return Ok(JsonView(false));
  8971. }
  8972. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8973. gwcItemTotal = info.AirGW + info.CityTranffic;
  8974. tdcItemTotal = info.AirTD + info.CityTranffic;
  8975. //消息通知
  8976. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8977. return Ok(JsonView(new
  8978. {
  8979. parentId = id,
  8980. choiceTwoJJ = dto.ChoiceTwoJJ,
  8981. jjcItemTotal = jjcItemTotal,
  8982. choiceTwoGW = dto.ChoiceTwoGW,
  8983. gwcItemTotal = gwcItemTotal,
  8984. choiceTwoTD = dto.ChoiceTwoTD,
  8985. tdcItemTotal = tdcItemTotal
  8986. }));
  8987. }
  8988. /// <summary>
  8989. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8990. /// </summary>
  8991. /// <returns></returns>
  8992. [HttpPost]
  8993. [ApiExplorerSettings(IgnoreApi = true)]
  8994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8995. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8996. {
  8997. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8998. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8999. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9000. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9001. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9002. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9003. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9004. var infos = infos1.Select(x => new Grp_DayAndCost
  9005. {
  9006. Id = x.Id,
  9007. DiId = dto.DiId,
  9008. Type = dto.FeeType,
  9009. Days = x.Days,
  9010. NationalTravelFeeId = x.NationalTravelFeeId,
  9011. Cost = x.Cost,
  9012. Currency = x.Currency,
  9013. SubTotal = x.SubTotal,
  9014. CreateUserId = dto.CurrUserId
  9015. })
  9016. .ToList();
  9017. var adds = infos.Where(x => x.Id <= 0).ToList();
  9018. var upds = infos.Where(x => x.Id > 0).ToList();
  9019. if (adds.Count > 0)
  9020. {
  9021. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9022. if (add < 1) return Ok(JsonView(false));
  9023. }
  9024. if (upds.Count > 0)
  9025. {
  9026. var upd = await _sqlSugar.Updateable(adds)
  9027. .UpdateColumns(x => new
  9028. {
  9029. x.Days,
  9030. x.NationalTravelFeeId,
  9031. x.Cost,
  9032. x.Currency,
  9033. x.SubTotal
  9034. })
  9035. .WhereColumns(x => new { x.Id })
  9036. .ExecuteCommandAsync();
  9037. if (upd < 1) return Ok(JsonView(false));
  9038. }
  9039. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9040. //消息通知
  9041. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9042. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9043. return Ok(JsonView(new { itemTotal = itemTotal }));
  9044. }
  9045. /// <summary>
  9046. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9047. /// </summary>
  9048. /// <returns></returns>
  9049. [HttpPost]
  9050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9051. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9052. {
  9053. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9054. int subId = dto.SubId, feeType = dto.FeeType;
  9055. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9056. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9057. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9058. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9059. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9060. subInfo.Id = subId;
  9061. subInfo.DiId = dto.DiId;
  9062. if (feeType == 3) subInfo.Type = 1;
  9063. else if (feeType == 4) subInfo.Type = 2;
  9064. else if (feeType == 5) subInfo.Type = 3;
  9065. else if (feeType == 6) subInfo.Type = 4;
  9066. subInfo.CreateUserId = dto.CurrUserId;
  9067. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9068. if (parentId < 1) return Ok(JsonView(false));
  9069. //子表op
  9070. if (subId < 1)
  9071. {
  9072. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9073. if (subAdd < 1) return Ok(JsonView(false));
  9074. }
  9075. else
  9076. {
  9077. ////验证编辑权限
  9078. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9079. //if (!isEdit) return Ok(JsonView(false, msg));
  9080. var subUpd = await _sqlSugar.Updateable(subInfo)
  9081. .UpdateColumns(x => new
  9082. {
  9083. x.Days,
  9084. x.NationalTravelFeeId,
  9085. x.Cost,
  9086. x.Currency,
  9087. x.SubTotal
  9088. })
  9089. .WhereColumns(x => new { x.Id })
  9090. .ExecuteCommandAsync();
  9091. if (subUpd < 1) return Ok(JsonView(false));
  9092. }
  9093. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  9094. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  9095. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9096. }
  9097. /// <summary>
  9098. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  9099. /// </summary>
  9100. /// <returns></returns>
  9101. [HttpPost]
  9102. [ApiExplorerSettings(IgnoreApi = true)]
  9103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9104. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  9105. {
  9106. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9107. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9108. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9109. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  9110. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  9111. {
  9112. Id = x.Id,
  9113. Diid = dto.DiId,
  9114. SetDataId = x.SetDataId,
  9115. Index = x.Index,
  9116. Cost = x.Cost,
  9117. Currency = x.Currency,
  9118. SubTotal = x.SubTotal,
  9119. CreateUserId = dto.CurrUserId,
  9120. Remark = x.Remark
  9121. }).ToList();
  9122. var adds = infos.Where(x => x.Id <= 0).ToList();
  9123. var upds = infos.Where(x => x.Id > 0).ToList();
  9124. if (adds.Count > 0)
  9125. {
  9126. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9127. if (add < 1) return Ok(JsonView(false));
  9128. }
  9129. if (upds.Count > 0)
  9130. {
  9131. var upd = await _sqlSugar.Updateable(adds)
  9132. .UpdateColumns(x => new
  9133. {
  9134. x.Index,
  9135. x.SetDataId,
  9136. x.Cost,
  9137. x.Currency,
  9138. x.SubTotal,
  9139. x.Remark
  9140. })
  9141. .WhereColumns(x => new { x.Id })
  9142. .ExecuteCommandAsync();
  9143. if (upd < 1) return Ok(JsonView(false));
  9144. }
  9145. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  9146. //消息通知
  9147. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9148. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9149. return Ok(JsonView(new { itemTotal = itemTotal }));
  9150. }
  9151. /// <summary>
  9152. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  9153. /// </summary>
  9154. /// <returns></returns>
  9155. [HttpPost]
  9156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9157. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  9158. {
  9159. int subId = dto.SubId;
  9160. int diId = dto.Diid;
  9161. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9162. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9163. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9164. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  9165. subInfo.Id = subId;
  9166. subInfo.Diid = dto.Diid;
  9167. subInfo.CreateUserId = dto.CurrUserId;
  9168. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  9169. if (parentId < 1) return Ok(JsonView(false));
  9170. #region 子表op
  9171. if (subId < 1)//add
  9172. {
  9173. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9174. if (subAdd < 1) return Ok(JsonView(false));
  9175. }
  9176. else //upd
  9177. {
  9178. ////验证编辑权限
  9179. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9180. //if (!isEdit) return Ok(JsonView(false, msg));
  9181. var subUpd = await _sqlSugar.Updateable(subInfo)
  9182. .UpdateColumns(x => new
  9183. {
  9184. x.Index,
  9185. x.SetDataId,
  9186. x.Cost,
  9187. x.Currency,
  9188. x.SubTotal,
  9189. x.Remark
  9190. })
  9191. .WhereColumns(x => new { x.Id })
  9192. .ExecuteCommandAsync();
  9193. if (subUpd < 1) return Ok(JsonView(false));
  9194. }
  9195. #endregion
  9196. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9197. //消息通知
  9198. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9199. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9200. }
  9201. /// <summary>
  9202. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9203. /// </summary>
  9204. /// <returns></returns>
  9205. [HttpPost]
  9206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9207. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9208. {
  9209. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9210. if (data.Code != 0)
  9211. {
  9212. return Ok(JsonView(false, data.Msg));
  9213. }
  9214. return Ok(JsonView(true, "操作成功!", data.Data));
  9215. }
  9216. /// <summary>
  9217. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9218. /// </summary>
  9219. /// <param name="dto"></param>
  9220. /// <returns></returns>
  9221. [HttpPost]
  9222. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9223. {
  9224. var data = new Grp_DayOtherPrice()
  9225. {
  9226. Id = dto.Id,
  9227. IsDel = 1,
  9228. DeleteUserId = dto.DeleteUserId,
  9229. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9230. };
  9231. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9232. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9233. return Ok(JsonView(false, "删除失败!"));
  9234. }
  9235. #endregion
  9236. #endregion
  9237. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9238. /// <summary>
  9239. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9240. /// </summary>
  9241. /// <returns></returns>
  9242. [HttpGet]
  9243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9244. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  9245. {
  9246. var provData = await _groupRepository.ProvinceBasicSource();
  9247. return Ok(JsonView(true, "查询成功!", provData));
  9248. }
  9249. /// <summary>
  9250. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9251. /// </summary>
  9252. /// <returns></returns>
  9253. [HttpPost]
  9254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9255. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9256. {
  9257. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9258. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9259. RefAsync<int> total = 0;
  9260. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9261. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9262. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9263. .Select(x => new
  9264. {
  9265. Id = x.Id,
  9266. DraftName = x.DraftName,
  9267. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9268. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9269. .Any()
  9270. })
  9271. .OrderByDescending(x => x.Id)
  9272. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9273. return Ok(JsonView(true, "查询成功!", data, total));
  9274. }
  9275. /// <summary>
  9276. /// 出入境费用-草稿 移动端
  9277. /// 获取币种基础数据(含逻辑处理)
  9278. /// </summary>
  9279. /// <returns></returns>
  9280. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9281. {
  9282. return await GeneralMethod.EnterExitCostInitRate();
  9283. }
  9284. /// <summary>
  9285. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9286. /// </summary>
  9287. /// <returns></returns>
  9288. [HttpPost]
  9289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9290. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  9291. {
  9292. //验证城市归属并给默认值
  9293. int provinceId = dto.ProvinceId;
  9294. if (provinceId < 1) provinceId = 122;
  9295. var dataSource = await _sqlSugar
  9296. .Queryable<Sys_SetData>()
  9297. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9298. .ToListAsync();
  9299. //三公费用-Word明细类型
  9300. var wordTypeData = dataSource.Where(it => it.STid == 72)
  9301. .Select(x => new SetDataInfoView
  9302. {
  9303. Id = x.Id,
  9304. Name = x.Name,
  9305. Remark = x.Remark
  9306. })
  9307. .ToList();
  9308. //三公费用-Excel明细类型
  9309. var excelTypeData = dataSource.Where(it => it.STid == 73)
  9310. .Select(x => new SetDataInfoView
  9311. {
  9312. Id = x.Id,
  9313. Name = x.Name,
  9314. Remark = x.Remark
  9315. })
  9316. .ToList();
  9317. //默认币种显示
  9318. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9319. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9320. return Ok(JsonView(true, "查询成功!", new
  9321. {
  9322. WordTypeData = wordTypeData,
  9323. ExcelTypeData = excelTypeData,
  9324. CurrencyInit = _currencyInfos,
  9325. viewPermissionData = viewPermissionData
  9326. }));
  9327. }
  9328. /// <summary>
  9329. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9330. /// </summary>
  9331. /// <returns></returns>
  9332. [HttpPost]
  9333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9334. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9335. {
  9336. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9337. RefAsync<int> total = 0;
  9338. int diId = 0;
  9339. var status = int.TryParse(dto.GroupName, out diId);
  9340. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9341. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9342. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9343. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9344. .OrderByDescending(x => x.VisitStartDate)
  9345. .Select(x => new
  9346. {
  9347. Id = x.Id,
  9348. GroupName = x.TeamName
  9349. })
  9350. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9351. return Ok(JsonView(true, "查询成功!", data, total));
  9352. }
  9353. /// <summary>
  9354. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9355. /// </summary>
  9356. /// <returns></returns>
  9357. [HttpPost]
  9358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9359. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9360. {
  9361. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9362. RefAsync<int> total = 0;
  9363. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9364. .Where(x => x.IsDel == 0 && x.STid == 66)
  9365. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9366. .Select(x => new
  9367. {
  9368. id = x.Id,
  9369. name = x.Name,
  9370. remark = x.Remark,
  9371. })
  9372. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9373. return Ok(JsonView(true, "查询成功!", data, total));
  9374. }
  9375. /// <summary>
  9376. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9377. /// </summary>
  9378. /// <returns></returns>
  9379. [HttpPost]
  9380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9381. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9382. {
  9383. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9384. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9385. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  9386. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9387. var groupOtherRateData = groupRateData.TeamRates;
  9388. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9389. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9390. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9391. groupOtherRateData = groupOtherRateData
  9392. .Select(x => new TeamRateDescAddCurrencyIdView
  9393. {
  9394. CurrencyId = x.CurrencyId,
  9395. CurrencyName = x.CurrencyName,
  9396. CurrencyCode = x.CurrencyCode,
  9397. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9398. }).ToList();
  9399. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9400. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9401. }
  9402. /// <summary>
  9403. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9404. /// </summary>
  9405. /// <returns></returns>
  9406. [HttpPost]
  9407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9408. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9409. {
  9410. int portType = dto.PortType;
  9411. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9412. var tipsData = new List<int>() { 1, 2, 3 };
  9413. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9414. if (dto.TipsType == 1)
  9415. {
  9416. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9417. }
  9418. else if (dto.TipsType == 2)
  9419. {
  9420. if (portType == 2)
  9421. {
  9422. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9423. }
  9424. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9425. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9426. .Select(x => x.NationalTravelFeeId)
  9427. .Distinct()
  9428. .ToListAsync();
  9429. if (portType == 2)
  9430. {
  9431. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9432. }
  9433. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9434. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9435. .Select(x => x.Country)
  9436. .Distinct()
  9437. .ToArrayAsync();
  9438. if (portType == 2)
  9439. {
  9440. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9441. }
  9442. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9443. return Ok(JsonView(true, "查询成功!", new
  9444. {
  9445. totalAmt = totalAmt,
  9446. remark = remark
  9447. }));
  9448. }
  9449. else if (dto.TipsType == 3)
  9450. {
  9451. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9452. }
  9453. return Ok(JsonView(false));
  9454. }
  9455. /// <summary>
  9456. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9457. /// </summary>
  9458. /// <returns></returns>
  9459. [HttpPost]
  9460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9461. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9462. {
  9463. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9464. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9465. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9466. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9467. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9468. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9469. var info = new Grp_EnterExitCostDraft()
  9470. {
  9471. ProvinceId = dto.ProvinceId,
  9472. DraftName = dto.DraftName,
  9473. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9474. CreateUserId = dto.CurrUserId
  9475. };
  9476. _sqlSugar.BeginTran();
  9477. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9478. if (draftId < 1)
  9479. {
  9480. _sqlSugar.RollbackTran();
  9481. return Ok(JsonView(false, "草稿创建失败!"));
  9482. }
  9483. //添加默认权限
  9484. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  9485. _sqlSugar.CommitTran();
  9486. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9487. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9488. mobileInfo.Id = draftId;
  9489. mobileInfo.DraftName = dto.DraftName;
  9490. mobileInfo.Currencys = rateInfos;
  9491. mobileInfo.IsAssignPerm = assignPerm;
  9492. return Ok(JsonView(mobileInfo));
  9493. }
  9494. /// <summary>
  9495. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9496. /// </summary>
  9497. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9498. /// <summary>
  9499. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9500. /// </summary>
  9501. /// <returns></returns>
  9502. [HttpPost]
  9503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9504. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9505. {
  9506. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9507. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9508. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9509. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9510. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9511. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9512. //验证查看编辑权限
  9513. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9514. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9515. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9516. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  9517. mobileInfo.IsAssignPerm = assignPerm;
  9518. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9519. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9520. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9521. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9522. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9523. {
  9524. ParentId = dac.ParentId,
  9525. SubId = dac.Id,
  9526. Type = dac.Type,
  9527. Days = dac.Days,
  9528. NationalTravelFeeId = dac.NationalTravelFeeId,
  9529. Arae = $"{ntf.Country}-{ntf.City}",
  9530. Cost = dac.Cost,
  9531. Currency = dac.Currency,
  9532. CurrencyName = sd.Name,
  9533. SubTotal = dac.SubTotal,
  9534. })
  9535. .ToList();
  9536. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9537. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9538. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9539. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9540. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9541. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9542. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9543. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9544. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9545. //其他款项
  9546. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9547. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9548. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9549. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9550. .OrderBy((dop, sd1, sd2) => dop.Index)
  9551. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9552. {
  9553. ParentId = dop.ParentId,
  9554. SubId = dop.Id,
  9555. Index = dop.Index,
  9556. SetDataId = dop.SetDataId,
  9557. SetDataName = sd1.Name,
  9558. Cost = dop.Cost,
  9559. Currency = dop.Currency,
  9560. CurrencyName = sd2.Remark,
  9561. SubTotal = dop.SubTotal,
  9562. Remark = dop.Remark,
  9563. })
  9564. .ToArray();
  9565. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9566. return Ok(mobileInfo);
  9567. }
  9568. /// <summary>
  9569. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9570. /// </summary>
  9571. /// <returns></returns>
  9572. [HttpPost]
  9573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9574. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9575. {
  9576. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9577. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9578. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9579. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9580. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9581. //验证查看编辑权限
  9582. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9583. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9584. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9585. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9586. var subType = dto.SubType;
  9587. if (subType == 1) //1:境内费用
  9588. {
  9589. var oneData = new ChoiceOneMobileSubInfoView()
  9590. {
  9591. Id = eecInfo.Id,
  9592. ChoiceOne = eecInfo.ChoiceOne,
  9593. ChoiceOneTotalCost = eecInfo.InsidePay,
  9594. Visa = eecInfo.Visa,
  9595. VisaRemark = eecInfo.VisaRemark,
  9596. YiMiao = eecInfo.YiMiao,
  9597. HeSuan = eecInfo.HeSuan,
  9598. Service = eecInfo.Service,
  9599. Ticket = eecInfo.Ticket,
  9600. Safe = eecInfo.Safe,
  9601. FirstItemRemark = eecInfo.FirstItemRemark
  9602. };
  9603. return Ok(JsonView(oneData));
  9604. }
  9605. else if (subType == 2) //2:国际旅费
  9606. {
  9607. var twoData = new ChoiceTwoMobileSubInfoView()
  9608. {
  9609. Id = eecInfo.Id,
  9610. ChoiceTwoJJ = eecInfo.SumJJC,
  9611. OutsideJJPay = eecInfo.OutsideJJPay,
  9612. ChoiceTwoGW = eecInfo.SumGWC,
  9613. OutsideGWPay = eecInfo.OutsideGWPay,
  9614. ChoiceTwoTD = eecInfo.SumTDC,
  9615. OutsideTDPay = eecInfo.OutsideTDPay,
  9616. AirJJ = eecInfo.AirJJ,
  9617. AirGW = eecInfo.AirGW,
  9618. AirTD = eecInfo.AirTD,
  9619. CityTranffic = eecInfo.CityTranffic,
  9620. TwoItemRemark = eecInfo.TwoItemRemark
  9621. };
  9622. return Ok(JsonView(twoData));
  9623. }
  9624. else if (subType == 3) //3:住宿费
  9625. {
  9626. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9627. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9628. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9629. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9630. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9631. {
  9632. ParentId = dac.ParentId,
  9633. SubId = dac.Id,
  9634. Type = dac.Type,
  9635. Days = dac.Days,
  9636. NationalTravelFeeId = dac.NationalTravelFeeId,
  9637. Arae = $"{ntf.Country}-{ntf.City}",
  9638. Cost = dac.Cost,
  9639. Currency = dac.Currency,
  9640. CurrencyName = sd.Name,
  9641. SubTotal = dac.SubTotal,
  9642. })
  9643. .ToArray();
  9644. var data = new ChoiceDraftMobileSubInfo3To6View()
  9645. {
  9646. ParentId = eecInfo.Id,
  9647. Choice = eecInfo.ChoiceThree,
  9648. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9649. Details = dayAndCostDatas
  9650. };
  9651. return Ok(JsonView(data));
  9652. }
  9653. else if (subType == 4) //4:伙食费
  9654. {
  9655. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9656. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9657. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9658. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9659. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9660. {
  9661. ParentId = dac.ParentId,
  9662. SubId = dac.Id,
  9663. Type = dac.Type,
  9664. Days = dac.Days,
  9665. NationalTravelFeeId = dac.NationalTravelFeeId,
  9666. Arae = $"{ntf.Country}-{ntf.City}",
  9667. Cost = dac.Cost,
  9668. Currency = dac.Currency,
  9669. CurrencyName = sd.Name,
  9670. SubTotal = dac.SubTotal,
  9671. })
  9672. .ToArray();
  9673. var data = new ChoiceDraftMobileSubInfo3To6View()
  9674. {
  9675. ParentId = eecInfo.Id,
  9676. Choice = eecInfo.ChoiceFour,
  9677. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9678. Details = dayAndCostDatas
  9679. };
  9680. return Ok(JsonView(data));
  9681. }
  9682. else if (subType == 5) //5:公杂费
  9683. {
  9684. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9685. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9686. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9687. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9688. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9689. {
  9690. ParentId = dac.ParentId,
  9691. SubId = dac.Id,
  9692. Type = dac.Type,
  9693. Days = dac.Days,
  9694. NationalTravelFeeId = dac.NationalTravelFeeId,
  9695. Arae = $"{ntf.Country}-{ntf.City}",
  9696. Cost = dac.Cost,
  9697. Currency = dac.Currency,
  9698. CurrencyName = sd.Name,
  9699. SubTotal = dac.SubTotal,
  9700. })
  9701. .ToArray();
  9702. var data = new ChoiceDraftMobileSubInfo3To6View()
  9703. {
  9704. ParentId = eecInfo.Id,
  9705. Choice = eecInfo.ChoiceFive,
  9706. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9707. Details = dayAndCostDatas
  9708. };
  9709. return Ok(JsonView(data));
  9710. }
  9711. else if (subType == 6) //6:培训费
  9712. {
  9713. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9714. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9715. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9716. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9717. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9718. {
  9719. ParentId = dac.ParentId,
  9720. SubId = dac.Id,
  9721. Type = dac.Type,
  9722. Days = dac.Days,
  9723. NationalTravelFeeId = dac.NationalTravelFeeId,
  9724. Arae = $"{ntf.Country}-{ntf.City}",
  9725. Cost = dac.Cost,
  9726. Currency = dac.Currency,
  9727. CurrencyName = sd.Name,
  9728. SubTotal = dac.SubTotal,
  9729. })
  9730. .ToArray();
  9731. var data = new ChoiceDraftMobileSubInfo3To6View()
  9732. {
  9733. ParentId = eecInfo.Id,
  9734. Choice = eecInfo.ChoiceSix,
  9735. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9736. Details = dayAndCostDatas
  9737. };
  9738. return Ok(JsonView(data));
  9739. }
  9740. else if (subType == 7) //7:其他
  9741. {
  9742. //其他款项
  9743. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9744. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9745. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9746. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9747. .OrderBy((dop, sd1, sd2) => dop.Index)
  9748. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9749. {
  9750. ParentId = dop.ParentId,
  9751. SubId = dop.Id,
  9752. Index = dop.Index,
  9753. SetDataId = dop.SetDataId,
  9754. SetDataName = sd1.Name,
  9755. Cost = dop.Cost,
  9756. Currency = dop.Currency,
  9757. CurrencyName = sd2.Name,
  9758. SubTotal = dop.SubTotal,
  9759. Remark = dop.Remark,
  9760. })
  9761. .ToArray();
  9762. var data = new ChoiceSevenDraftMobileSubInfoView()
  9763. {
  9764. ParentId = eecInfo.Id,
  9765. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9766. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9767. Details = otherData
  9768. };
  9769. return Ok(JsonView(data));
  9770. }
  9771. return Ok(JsonView(false));
  9772. }
  9773. #region op
  9774. /// <summary>
  9775. /// 移动端更新费用消息通知
  9776. /// </summary>
  9777. /// <param name="draftId"></param>
  9778. /// <param name="id"></param>
  9779. /// <param name="currUserId"></param>
  9780. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9781. {
  9782. try
  9783. {
  9784. ////生成默认文件pdf并且通知人员
  9785. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9786. //{
  9787. // DiId = draftId,
  9788. // ExportType = 1,
  9789. // SubTypeId = 1005
  9790. //}, "pdf");
  9791. ////发送通知
  9792. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9793. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9794. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9795. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9796. ////汇率信息记录
  9797. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9798. }
  9799. catch (Exception ex)
  9800. {
  9801. //记录日志
  9802. throw;
  9803. }
  9804. }
  9805. /// <summary>
  9806. /// 验证出入境费用数据是否存在
  9807. /// 不存在添加
  9808. /// </summary>
  9809. /// <param name="draftId"></param>
  9810. /// <param name="currUserId"></param>
  9811. /// <returns></returns>
  9812. /// <exception cref="CustomException"></exception>
  9813. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9814. {
  9815. var parentId = 0;
  9816. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9817. if (info != null) parentId = info.Id;
  9818. else
  9819. {
  9820. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9821. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9822. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9823. parentId = addId;
  9824. }
  9825. return parentId;
  9826. }
  9827. /// <summary>
  9828. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  9829. /// </summary>
  9830. /// <returns></returns>
  9831. [HttpPost]
  9832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9833. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  9834. {
  9835. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9836. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9837. //验证查看权限
  9838. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9839. if (!isView) return Ok(JsonView(false, _viewPermStr));
  9840. var userIds = await _sqlSugar
  9841. .Queryable<Grp_EnterExitCostDraftPermission>()
  9842. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  9843. .Select(x => x.UserId)
  9844. .ToArrayAsync();
  9845. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9846. var perUsersView = new List<dynamic>();
  9847. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  9848. var viewPermissionData = new List<PermissionViewUserview>();
  9849. if (feeBasePerm.Any())
  9850. {
  9851. foreach (var item in feeBasePerm)
  9852. {
  9853. if (item.Users.Any())
  9854. {
  9855. viewPermissionData.AddRange(item.Users);
  9856. }
  9857. }
  9858. }
  9859. foreach (var item in perUsers)
  9860. {
  9861. bool isView1 = false;
  9862. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9863. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  9864. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9865. }
  9866. return Ok(JsonView(perUsersView));
  9867. }
  9868. /// <summary>
  9869. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9870. /// </summary>
  9871. /// <returns></returns>
  9872. [HttpPost]
  9873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9874. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9875. {
  9876. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9877. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9878. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9879. //验证查看编辑权限
  9880. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9881. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9882. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  9883. foreach (var userId in dto.UserIds)
  9884. {
  9885. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9886. }
  9887. if (permissions.Any())
  9888. {
  9889. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9890. {
  9891. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9892. }
  9893. _sqlSugar.BeginTran();
  9894. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9895. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9896. if (result < 1)
  9897. {
  9898. _sqlSugar.RollbackTran();
  9899. return Ok(JsonView(false));
  9900. }
  9901. _sqlSugar.CommitTran();
  9902. return Ok(JsonView(true));
  9903. }
  9904. return Ok(JsonView(false));
  9905. }
  9906. /// <summary>
  9907. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  9908. /// </summary>
  9909. /// <returns></returns>
  9910. [HttpPost]
  9911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9912. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  9913. {
  9914. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9915. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9916. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9917. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  9918. int id = dto.DraftId;
  9919. if (id <= 0) //add
  9920. {
  9921. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9922. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9923. if (add < 1) return Ok(JsonView(false));
  9924. id = add;
  9925. }
  9926. else //update
  9927. {
  9928. //验证查看编辑权限
  9929. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9930. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9931. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9932. if (upd < 1) return Ok(JsonView(false));
  9933. }
  9934. return Ok(JsonView(new { parentId = id }));
  9935. }
  9936. /// <summary>
  9937. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9938. /// </summary>
  9939. /// <returns></returns>
  9940. [HttpPost]
  9941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9942. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9943. {
  9944. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9945. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9946. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9947. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9948. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9949. int id = dto.DraftId;
  9950. if (id <= 0) //add
  9951. {
  9952. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9953. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9954. if (add < 1) return Ok(JsonView(false));
  9955. id = add;
  9956. }
  9957. else //update
  9958. {
  9959. //验证查看编辑权限
  9960. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9961. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9962. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9963. if (upd < 1) return Ok(JsonView(false));
  9964. }
  9965. #region 汇率变更时更改币种相关费用
  9966. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9967. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9968. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9969. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9970. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9971. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9972. .Select((dac, sd) => new
  9973. {
  9974. dac.Id,
  9975. dac.ParentId,
  9976. CurrencyCode = sd.Name,
  9977. dac.Cost
  9978. })
  9979. .ToList();
  9980. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9981. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9982. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9983. .Select((dop, sd) => new
  9984. {
  9985. dop.Id,
  9986. dop.ParentId,
  9987. CurrencyCode = sd.Name,
  9988. dop.Cost
  9989. })
  9990. .ToList();
  9991. if (dayCosts.Count > 0)
  9992. {
  9993. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9994. foreach (var dc in new_dayCosts)
  9995. {
  9996. var thisCurrency = dc.Key.ToUpper();
  9997. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9998. if (thisRate == 0.00M) continue;
  9999. foreach (var dcSub in dc)
  10000. {
  10001. opDayCosts.Add(new Grp_DayAndCostDraft()
  10002. {
  10003. Id = dcSub.Id,
  10004. ParentId = dcSub.ParentId,
  10005. Cost = dcSub.Cost,
  10006. SubTotal = dcSub.Cost * thisRate,
  10007. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10008. });
  10009. }
  10010. }
  10011. if (opDayCosts.Count > 0)
  10012. {
  10013. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10014. }
  10015. }
  10016. if (dayOtherCosts.Count > 0)
  10017. {
  10018. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10019. foreach (var dc in new_dayOtherCosts)
  10020. {
  10021. var thisCurrency = dc.Key.ToUpper();
  10022. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10023. if (thisRate == 0.00M) continue;
  10024. foreach (var dcSub in dc)
  10025. {
  10026. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10027. {
  10028. Id = dcSub.Id,
  10029. ParentId = dcSub.ParentId,
  10030. Cost = dcSub.Cost,
  10031. SubTotal = dcSub.Cost * thisRate,
  10032. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10033. });
  10034. }
  10035. }
  10036. if (opDayOtherCosts.Count > 0)
  10037. {
  10038. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10039. }
  10040. }
  10041. #endregion
  10042. ////消息通知
  10043. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10044. ////汇率信息记录
  10045. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10046. return Ok(JsonView(new { parentId = id }));
  10047. }
  10048. /// <summary>
  10049. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  10050. /// </summary>
  10051. /// <returns></returns>
  10052. [HttpPost]
  10053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10054. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  10055. {
  10056. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10057. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10058. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10059. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10060. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10061. int id = dto.DraftId;
  10062. if (id <= 0) //add
  10063. {
  10064. checkboxInfo.ProvinceId = dto.ProvinceId;
  10065. checkboxInfo.CreateUserId = dto.CurrUserId;
  10066. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  10067. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10068. if (add < 1) return Ok(JsonView(false));
  10069. }
  10070. else //update
  10071. {
  10072. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10073. .UpdateColumns(x => new
  10074. {
  10075. x.ChoiceOne,
  10076. x.ChoiceTwo,
  10077. x.SumJJC,
  10078. x.SumGWC,
  10079. x.SumTDC,
  10080. x.ChoiceThree,
  10081. x.ChoiceFour,
  10082. x.ChoiceFive,
  10083. x.ChoiceSix,
  10084. x.OtherExpenses_Checked
  10085. })
  10086. .Where(x => x.Id == id)
  10087. .ExecuteCommandAsync();
  10088. if (upd < 1) return Ok(JsonView(false));
  10089. }
  10090. return Ok(JsonView(new { parentId = id }));
  10091. }
  10092. /// <summary>
  10093. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  10094. /// </summary>
  10095. /// <returns></returns>
  10096. [HttpPost]
  10097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10098. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  10099. {
  10100. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  10101. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10102. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10103. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10104. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10105. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10106. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10107. var checkboxInfo = new Grp_EnterExitCostDraft()
  10108. {
  10109. Id = draftId,
  10110. ProvinceId = dto.ProvinceId,
  10111. CreateUserId = currUserId
  10112. };
  10113. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10114. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10115. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10116. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10117. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10118. if (draftId <= 0) //add
  10119. {
  10120. checkboxInfo.CreateUserId = dto.CurrUserId;
  10121. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10122. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10123. if (add < 1) return Ok(JsonView(false));
  10124. }
  10125. else //update
  10126. {
  10127. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  10128. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10129. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10130. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10131. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10132. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10133. .Where(x => x.Id == draftId)
  10134. .ExecuteCommandAsync();
  10135. if (upd < 1) return Ok(JsonView(false));
  10136. }
  10137. return Ok(JsonView(new { parentId = draftId }));
  10138. }
  10139. /// <summary>
  10140. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  10141. /// </summary>
  10142. /// <returns></returns>
  10143. [HttpPost]
  10144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10145. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  10146. {
  10147. int id = dto.DraftId, currUserId = dto.CurrUserId;
  10148. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10149. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  10150. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10151. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10152. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10153. info.ProvinceId = dto.ProvinceId;
  10154. info.FirstItemRemark = dto.FirstItemRemark;
  10155. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10156. if (id <= 0) //add
  10157. {
  10158. info.CreateUserId = dto.CurrUserId;
  10159. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10160. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10161. if (add < 1) return Ok(JsonView(false));
  10162. id = add;
  10163. }
  10164. else //update
  10165. {
  10166. var upd = await _sqlSugar.Updateable(info)
  10167. .UpdateColumns(x => new
  10168. {
  10169. x.ChoiceOne,
  10170. x.InsidePay,
  10171. x.VisaRemark,
  10172. x.Visa,
  10173. x.Service,
  10174. x.Safe,
  10175. x.Ticket,
  10176. x.HeSuan,
  10177. x.YiMiao,
  10178. x.FirstItemRemark
  10179. })
  10180. .Where(x => x.Id == id)
  10181. .ExecuteCommandAsync();
  10182. if (upd < 1) return Ok(JsonView(false));
  10183. }
  10184. ////消息通知
  10185. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10186. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10187. }
  10188. /// <summary>
  10189. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  10190. /// </summary>
  10191. /// <returns></returns>
  10192. [HttpPost]
  10193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10194. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  10195. {
  10196. int id = dto.DraftId;
  10197. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10198. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  10199. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10200. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10201. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10202. info.ProvinceId = dto.ProvinceId;
  10203. info.OutsideJJPay = dto.OutsideJJPay;
  10204. info.OutsideGWPay = dto.OutsideGWPay;
  10205. info.OutsideTDPay = dto.OutsideTDPay;
  10206. info.AirJJ = dto.AirJJ;
  10207. info.AirGW = dto.AirGW;
  10208. info.AirTD = dto.AirTD;
  10209. info.CityTranffic = dto.CityTranffic;
  10210. info.TwoItemRemark = dto.TwoItemRemark;
  10211. info.SumJJC = dto.ChoiceTwoJJ;
  10212. info.SumGWC = dto.ChoiceTwoGW;
  10213. info.SumTDC = dto.ChoiceTwoTD;
  10214. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10215. if (id <= 0) //add
  10216. {
  10217. info.CreateUserId = dto.CurrUserId;
  10218. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10219. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10220. if (addId <= 0) return Ok(JsonView(false));
  10221. id = addId;
  10222. }
  10223. else //update
  10224. {
  10225. var upd = await _sqlSugar.Updateable(info)
  10226. .UpdateColumns(x => new
  10227. {
  10228. x.SumJJC,
  10229. x.OutsideJJPay,
  10230. x.SumGWC,
  10231. x.OutsideGWPay,
  10232. x.SumTDC,
  10233. x.OutsideTDPay,
  10234. x.AirJJ,
  10235. x.AirGW,
  10236. x.AirTD,
  10237. x.CityTranffic,
  10238. x.TwoItemRemark
  10239. })
  10240. .Where(x => x.Id == id)
  10241. .ExecuteCommandAsync();
  10242. if (upd < 1) return Ok(JsonView(false));
  10243. }
  10244. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10245. gwcItemTotal = info.AirGW + info.CityTranffic;
  10246. tdcItemTotal = info.AirTD + info.CityTranffic;
  10247. ////消息通知
  10248. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10249. return Ok(JsonView(new
  10250. {
  10251. parentId = id,
  10252. choiceTwoJJ = dto.ChoiceTwoJJ,
  10253. jjcItemTotal = jjcItemTotal,
  10254. choiceTwoGW = dto.ChoiceTwoGW,
  10255. gwcItemTotal = gwcItemTotal,
  10256. choiceTwoTD = dto.ChoiceTwoTD,
  10257. tdcItemTotal = tdcItemTotal
  10258. }));
  10259. }
  10260. /// <summary>
  10261. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10262. /// </summary>
  10263. /// <returns></returns>
  10264. [HttpPost]
  10265. [ApiExplorerSettings(IgnoreApi = true)]
  10266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10267. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10268. {
  10269. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10270. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10271. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10272. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10273. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10274. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10275. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10276. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10277. {
  10278. Id = x.Id,
  10279. ParentId = dto.DraftId,
  10280. Type = dto.FeeType,
  10281. Days = x.Days,
  10282. NationalTravelFeeId = x.NationalTravelFeeId,
  10283. Cost = x.Cost,
  10284. Currency = x.Currency,
  10285. SubTotal = x.SubTotal,
  10286. CreateUserId = dto.CurrUserId
  10287. })
  10288. .ToList();
  10289. var adds = infos.Where(x => x.Id <= 0).ToList();
  10290. var upds = infos.Where(x => x.Id > 0).ToList();
  10291. if (adds.Count > 0)
  10292. {
  10293. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10294. if (add < 1) return Ok(JsonView(false));
  10295. }
  10296. if (upds.Count > 0)
  10297. {
  10298. var upd = await _sqlSugar.Updateable(adds)
  10299. .UpdateColumns(x => new
  10300. {
  10301. x.Days,
  10302. x.NationalTravelFeeId,
  10303. x.Cost,
  10304. x.Currency,
  10305. x.SubTotal
  10306. })
  10307. .WhereColumns(x => new { x.Id })
  10308. .ExecuteCommandAsync();
  10309. if (upd < 1) return Ok(JsonView(false));
  10310. }
  10311. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10312. ////消息通知
  10313. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10314. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10315. return Ok(JsonView(new { itemTotal = itemTotal }));
  10316. }
  10317. /// <summary>
  10318. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10319. /// </summary>
  10320. /// <returns></returns>
  10321. [HttpPost]
  10322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10323. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10324. {
  10325. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10326. int subId = dto.SubId, feeType = dto.FeeType;
  10327. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10328. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10329. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10330. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10331. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10332. subInfo.Id = subId;
  10333. subInfo.ParentId = dto.DraftId;
  10334. if (feeType == 3) subInfo.Type = 1;
  10335. else if (feeType == 4) subInfo.Type = 2;
  10336. else if (feeType == 5) subInfo.Type = 3;
  10337. else if (feeType == 6) subInfo.Type = 4;
  10338. subInfo.CreateUserId = dto.CurrUserId;
  10339. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10340. if (parentId < 1) return Ok(JsonView(false));
  10341. //子表op
  10342. if (subId < 1)
  10343. {
  10344. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10345. if (subAdd < 1) return Ok(JsonView(false));
  10346. }
  10347. else
  10348. {
  10349. var subUpd = await _sqlSugar.Updateable(subInfo)
  10350. .UpdateColumns(x => new
  10351. {
  10352. x.Days,
  10353. x.NationalTravelFeeId,
  10354. x.Cost,
  10355. x.Currency,
  10356. x.SubTotal
  10357. })
  10358. .WhereColumns(x => new { x.Id })
  10359. .ExecuteCommandAsync();
  10360. if (subUpd < 1) return Ok(JsonView(false));
  10361. }
  10362. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10363. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10364. }
  10365. /// <summary>
  10366. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10367. /// </summary>
  10368. /// <returns></returns>
  10369. [HttpPost]
  10370. [ApiExplorerSettings(IgnoreApi = true)]
  10371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10372. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10373. {
  10374. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10375. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10376. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10377. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10378. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10379. {
  10380. Id = x.Id,
  10381. ParentId = dto.DraftId,
  10382. SetDataId = x.SetDataId,
  10383. Index = x.Index,
  10384. Cost = x.Cost,
  10385. Currency = x.Currency,
  10386. SubTotal = x.SubTotal,
  10387. CreateUserId = dto.CurrUserId,
  10388. Remark = x.Remark
  10389. }).ToList();
  10390. var adds = infos.Where(x => x.Id <= 0).ToList();
  10391. var upds = infos.Where(x => x.Id > 0).ToList();
  10392. if (adds.Count > 0)
  10393. {
  10394. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10395. if (add < 1) return Ok(JsonView(false));
  10396. }
  10397. if (upds.Count > 0)
  10398. {
  10399. var upd = await _sqlSugar.Updateable(adds)
  10400. .UpdateColumns(x => new
  10401. {
  10402. x.Index,
  10403. x.SetDataId,
  10404. x.Cost,
  10405. x.Currency,
  10406. x.SubTotal,
  10407. x.Remark
  10408. })
  10409. .WhereColumns(x => new { x.Id })
  10410. .ExecuteCommandAsync();
  10411. if (upd < 1) return Ok(JsonView(false));
  10412. }
  10413. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10414. //消息通知
  10415. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10416. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10417. return Ok(JsonView(new { itemTotal = itemTotal }));
  10418. }
  10419. /// <summary>
  10420. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10421. /// </summary>
  10422. /// <returns></returns>
  10423. [HttpPost]
  10424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10425. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10426. {
  10427. int subId = dto.SubId, id = dto.DraftId;
  10428. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10429. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10430. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10431. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10432. subInfo.Id = subId;
  10433. subInfo.ParentId = id;
  10434. subInfo.CreateUserId = dto.CurrUserId;
  10435. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10436. if (parentId < 1) return Ok(JsonView(false));
  10437. #region 子表op
  10438. if (subId < 1)//add
  10439. {
  10440. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10441. if (subAdd < 1) return Ok(JsonView(false));
  10442. }
  10443. else //upd
  10444. {
  10445. var subUpd = await _sqlSugar.Updateable(subInfo)
  10446. .UpdateColumns(x => new
  10447. {
  10448. x.Index,
  10449. x.SetDataId,
  10450. x.Cost,
  10451. x.Currency,
  10452. x.SubTotal,
  10453. x.Remark
  10454. })
  10455. .WhereColumns(x => new { x.Id })
  10456. .ExecuteCommandAsync();
  10457. if (subUpd < 1) return Ok(JsonView(false));
  10458. }
  10459. #endregion
  10460. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10461. ////消息通知
  10462. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10463. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10464. }
  10465. /// <summary>
  10466. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10467. /// </summary>
  10468. /// <returns></returns>
  10469. [HttpPost]
  10470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10471. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10472. {
  10473. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10474. if (data.Code != 0)
  10475. {
  10476. return Ok(JsonView(false, data.Msg));
  10477. }
  10478. return Ok(JsonView(true, "操作成功!", data.Data));
  10479. }
  10480. /// <summary>
  10481. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10482. /// </summary>
  10483. /// <param name="dto"></param>
  10484. /// <returns></returns>
  10485. [HttpPost]
  10486. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10487. {
  10488. var data = new Grp_DayOtherPriceDraft()
  10489. {
  10490. Id = dto.Id,
  10491. IsDel = 1,
  10492. DeleteUserId = dto.DeleteUserId,
  10493. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10494. };
  10495. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10496. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10497. return Ok(JsonView(false, "删除失败!"));
  10498. }
  10499. #endregion
  10500. #endregion
  10501. #region 团组经理模块 出入境费用报价表
  10502. /// <summary>
  10503. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10504. /// </summary>
  10505. /// <returns></returns>
  10506. [HttpPost]
  10507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10508. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10509. {
  10510. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10511. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10512. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10513. initRates.Insert(0, cnyInfo);
  10514. liveRates.Insert(0, cnyInfo);
  10515. return Ok(JsonView(true, "查询成功!", new
  10516. {
  10517. InitRates = initRates,
  10518. LiveRates = liveRates
  10519. }));
  10520. }
  10521. /// <summary>
  10522. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10523. /// </summary>
  10524. /// <returns></returns>
  10525. [HttpPost]
  10526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10527. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10528. {
  10529. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10530. }
  10531. /// <summary>
  10532. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10533. /// </summary>
  10534. /// <returns></returns>
  10535. [HttpPost]
  10536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10537. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10538. {
  10539. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10540. }
  10541. /// <summary>
  10542. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10543. /// </summary>
  10544. /// <returns></returns>
  10545. [HttpPost]
  10546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10547. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10548. {
  10549. int groupId = dto.DiId,
  10550. currUserId = dto.CurrUserId;
  10551. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  10552. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10553. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10554. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10555. var infoView = info.Data as EnterExitCostInfoView;
  10556. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10557. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10558. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10559. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10560. var eecRates = infoView.Currencys;
  10561. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10562. int pplNum = 1;
  10563. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10564. var views = new List<QuoteSubItemInfo>();
  10565. #region 数据填充
  10566. var intTravelCosts = new List<QuoteSubItemInfo>();
  10567. #region 机票费用 1354
  10568. int intTravelIndex = 1;
  10569. if (infoView.SumJJC == 1)
  10570. {
  10571. intTravelCosts.Add(new QuoteSubItemInfo
  10572. {
  10573. ItemId = 1354,
  10574. Index = intTravelIndex,
  10575. FeeName = "经济舱",
  10576. UnitPrice = infoView.AirJJ,
  10577. Currency = "CNY",
  10578. Quantity = 1,
  10579. PplNum = 1,
  10580. TotalAmt = infoView.AirJJ,
  10581. Remark = "",
  10582. });
  10583. intTravelIndex++;
  10584. }
  10585. if (infoView.SumGWC == 1)
  10586. {
  10587. intTravelCosts.Add(new QuoteSubItemInfo
  10588. {
  10589. ItemId = 1354,
  10590. Index = intTravelIndex,
  10591. FeeName = "公务舱",
  10592. UnitPrice = infoView.AirGW,
  10593. Currency = "CNY",
  10594. Quantity = 1,
  10595. PplNum = 1,
  10596. TotalAmt = infoView.AirGW,
  10597. Remark = "",
  10598. });
  10599. intTravelIndex++;
  10600. }
  10601. if (infoView.SumTDC == 1)
  10602. {
  10603. intTravelCosts.Add(new QuoteSubItemInfo
  10604. {
  10605. ItemId = 1354,
  10606. Index = intTravelIndex,
  10607. FeeName = "头等舱",
  10608. UnitPrice = infoView.AirTD,
  10609. Currency = "CNY",
  10610. Quantity = 1,
  10611. PplNum = 1,
  10612. TotalAmt = infoView.AirTD,
  10613. Remark = "",
  10614. });
  10615. intTravelIndex++;
  10616. }
  10617. intTravelCosts.Add(new QuoteSubItemInfo
  10618. {
  10619. ItemId = 1354,
  10620. Index = intTravelIndex,
  10621. FeeName = "城市间交通费用",
  10622. UnitPrice = infoView.CityTranffic,
  10623. Currency = "CNY",
  10624. Quantity = 1,
  10625. PplNum = pplNum,
  10626. TotalAmt = infoView.CityTranffic * pplNum,
  10627. Remark = "",
  10628. });
  10629. views.AddRange(intTravelCosts);
  10630. #endregion
  10631. var accomCosts = new List<QuoteSubItemInfo>();
  10632. #region 住宿费 1355
  10633. if (infoView.QuarterageData.Any())
  10634. {
  10635. int accomIndex = 1;
  10636. int accomItemTypeId = 1355;
  10637. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10638. foreach (var item in groupData)
  10639. {
  10640. string feeName = string.Empty;
  10641. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10642. if (countryInfo != null)
  10643. {
  10644. feeName = countryInfo.Country;
  10645. var city = countryInfo.City;
  10646. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10647. {
  10648. feeName += $"-{city}";
  10649. }
  10650. }
  10651. var hotelInfo = item.FirstOrDefault();
  10652. if (hotelInfo == null) continue;
  10653. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10654. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10655. int quantity = item.ToList().Count;
  10656. accomCosts.Add(new QuoteSubItemInfo
  10657. {
  10658. ItemId = accomItemTypeId,
  10659. Index = accomIndex,
  10660. FeeName = feeName,
  10661. UnitPrice = hotelInfo.Cost,
  10662. Currency = thisCurrency,
  10663. Quantity = quantity,
  10664. PplNum = pplNum,
  10665. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10666. Remark = "",
  10667. });
  10668. accomIndex++;
  10669. }
  10670. views.AddRange(accomCosts);
  10671. }
  10672. #endregion
  10673. var mealCosts = new List<QuoteSubItemInfo>();
  10674. #region 餐饮费 1356
  10675. if (infoView.BoardWagesData.Any())
  10676. {
  10677. var mealIndex = 1;
  10678. int mealItemTypeId = 1356;
  10679. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10680. foreach (var item in groupData)
  10681. {
  10682. string feeName = string.Empty;
  10683. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10684. if (countryInfo != null)
  10685. {
  10686. feeName = countryInfo.Country;
  10687. var city = countryInfo.City;
  10688. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10689. {
  10690. feeName += $"-{city}";
  10691. }
  10692. }
  10693. var mealInfo = item.FirstOrDefault();
  10694. if (mealInfo == null) continue;
  10695. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10696. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10697. int quantity = item.ToList().Count;
  10698. mealCosts.Add(new QuoteSubItemInfo
  10699. {
  10700. ItemId = mealItemTypeId,
  10701. Index = mealIndex,
  10702. FeeName = feeName,
  10703. UnitPrice = mealInfo.Cost,
  10704. Currency = thisCurrency,
  10705. Quantity = quantity,
  10706. PplNum = pplNum,
  10707. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10708. Remark = "",
  10709. });
  10710. mealIndex++;
  10711. }
  10712. views.AddRange(mealCosts);
  10713. }
  10714. #endregion
  10715. var miscCosts = new List<QuoteSubItemInfo>();
  10716. #region 公杂费 1364
  10717. if (infoView.MiscellaneousFeeData.Any())
  10718. {
  10719. var miscIndex = 1;
  10720. int miscItemTypeId = 1364;
  10721. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10722. foreach (var item in groupData)
  10723. {
  10724. string feeName = string.Empty;
  10725. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10726. if (countryInfo != null)
  10727. {
  10728. feeName = countryInfo.Country;
  10729. var city = countryInfo.City;
  10730. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10731. {
  10732. feeName += $"-{city}";
  10733. }
  10734. }
  10735. var miscInfo = item.FirstOrDefault();
  10736. if (miscInfo == null) continue;
  10737. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10738. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10739. int quantity = item.ToList().Count;
  10740. mealCosts.Add(new QuoteSubItemInfo
  10741. {
  10742. ItemId = miscItemTypeId,
  10743. Index = miscIndex,
  10744. FeeName = feeName,
  10745. UnitPrice = miscInfo.Cost,
  10746. Currency = thisCurrency,
  10747. Quantity = quantity,
  10748. PplNum = pplNum,
  10749. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10750. Remark = "",
  10751. });
  10752. miscIndex++;
  10753. }
  10754. views.AddRange(mealCosts);
  10755. }
  10756. #endregion
  10757. #region 签证+保险 1362
  10758. int visaInsIndex = 1;
  10759. int visaInsItemTypeId = 1362;
  10760. if (infoView.Visa > 0)
  10761. {
  10762. views.Add(new QuoteSubItemInfo()
  10763. {
  10764. ItemId = visaInsItemTypeId,
  10765. Index = visaInsIndex,
  10766. FeeName = $"签证",
  10767. UnitPrice = infoView.Visa,
  10768. Currency = $"CNY",
  10769. Quantity = 1,
  10770. PplNum = pplNum,
  10771. TotalAmt = infoView.Visa * pplNum,
  10772. Remark = "",
  10773. });
  10774. visaInsIndex++;
  10775. }
  10776. if (infoView.Safe > 0)
  10777. {
  10778. views.Add(new QuoteSubItemInfo()
  10779. {
  10780. ItemId = visaInsItemTypeId,
  10781. Index = visaInsIndex,
  10782. FeeName = $"保险",
  10783. UnitPrice = infoView.Safe,
  10784. Currency = $"CNY",
  10785. Quantity = 1,
  10786. PplNum = pplNum,
  10787. TotalAmt = infoView.Safe * pplNum,
  10788. Remark = "",
  10789. });
  10790. }
  10791. #endregion
  10792. #region 服务费 1363
  10793. int serviceFeeIndex = 1;
  10794. int serviceFeeItemTypeId = 1363;
  10795. if (infoView.Service > 0)
  10796. {
  10797. views.Add(new QuoteSubItemInfo()
  10798. {
  10799. ItemId = serviceFeeItemTypeId,
  10800. Index = serviceFeeIndex,
  10801. FeeName = $"服务费",
  10802. UnitPrice = infoView.Service,
  10803. Currency = $"CNY",
  10804. Quantity = 1,
  10805. PplNum = pplNum,
  10806. TotalAmt = infoView.Service * pplNum,
  10807. Remark = "",
  10808. });
  10809. }
  10810. #endregion
  10811. #endregion
  10812. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10813. result.Rates = eecRates.ToArray();
  10814. if (result.FeeItems.Any())
  10815. {
  10816. result.FeeItems.Select(x =>
  10817. {
  10818. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10819. if (feeInfos.Any()) x.Infos = feeInfos;
  10820. return x;
  10821. }
  10822. )
  10823. .OrderBy(x => x.Index)
  10824. .ToList();
  10825. }
  10826. return Ok(JsonView(result));
  10827. }
  10828. /// <summary>
  10829. /// 团组模块 - 出入境费用报价表 - Info
  10830. /// </summary>
  10831. /// <returns></returns>
  10832. [HttpPost]
  10833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10834. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10835. {
  10836. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10837. if (!info.Rates.Any())
  10838. {
  10839. var rates = await GeneralMethod.EnterExitCostInitRate();
  10840. info.Rates = rates.ToArray();
  10841. }
  10842. return Ok(JsonView(info));
  10843. }
  10844. /// <summary>
  10845. /// 团组模块 - 出入境费用报价表 - OP
  10846. /// </summary>
  10847. /// <returns></returns>
  10848. [HttpPost]
  10849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10850. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10851. {
  10852. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10853. }
  10854. /// <summary>
  10855. /// 团组模块 - 出入境费用报价表 - 删除 项
  10856. /// </summary>
  10857. /// <returns></returns>
  10858. [HttpPost]
  10859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10860. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10861. {
  10862. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10863. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10864. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10865. }
  10866. /// <summary>
  10867. /// 团组模块 - 出入境费用报价表 - 导出
  10868. /// </summary>
  10869. /// <returns></returns>
  10870. [HttpPost]
  10871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10872. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10873. {
  10874. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10875. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10876. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  10877. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10878. var rates = info.Rates;
  10879. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10880. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10881. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10882. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10883. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10884. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10885. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10886. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10887. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10888. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10889. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10890. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10891. //获取模板
  10892. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  10893. var designer = new WorkbookDesigner();
  10894. designer.Workbook = new Workbook(tempPath);
  10895. designer.SetDataSource("QuoteName", info.Name);
  10896. designer.SetDataSource("CompanyTitle", "公司名称");
  10897. designer.SetDataSource("CompanyLabel", "");
  10898. #region 国际旅费
  10899. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10900. if (intTravelCosts.Infos.Any())
  10901. {
  10902. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  10903. StringBuilder label = new StringBuilder();
  10904. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10905. if (infos.Any())
  10906. {
  10907. label.Append(infos.Sum(x => x.PplNum));
  10908. label.Append("人全程机票:");
  10909. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  10910. label.AppendLine("元");
  10911. }
  10912. foreach (var item in intTravelCosts.Infos)
  10913. {
  10914. label.Append(item.FeeName);
  10915. label.Append(":");
  10916. label.Append(item.UnitPrice.TruncDecimals(2));
  10917. label.Append("元/人*");
  10918. label.Append(item.PplNum);
  10919. label.AppendLine("人");
  10920. }
  10921. if (label.HasValue())
  10922. {
  10923. label.Append("\r\n以上小计:");
  10924. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  10925. label.Append("元");
  10926. }
  10927. designer.SetDataSource("IntTravelLabel", label.ToString());
  10928. }
  10929. #endregion
  10930. #region 住宿费
  10931. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10932. if (accomCosts.Infos.Any())
  10933. {
  10934. string currencyName = string.Empty;
  10935. decimal rate = 1.0000M;
  10936. StringBuilder label = new StringBuilder();
  10937. label.AppendLine("全程五星酒店,每人1间房");
  10938. foreach (var item in accomCosts.Infos)
  10939. {
  10940. string hotelName = string.Empty;
  10941. if (item.FeeName.Contains("-"))
  10942. {
  10943. var feeName = item.FeeName.Split('-');
  10944. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10945. }
  10946. else hotelName = $"\r\n{item.FeeName}:";
  10947. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10948. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10949. rate = rateInfo?.Rate ?? 1.0000M;
  10950. label.Append(hotelName);
  10951. label.Append(item.UnitPrice.TruncDecimals(2));
  10952. label.Append(currencyName);
  10953. label.Append("/间/晚*");
  10954. label.Append(item.Quantity.ToString("#0"));
  10955. label.AppendLine("人");
  10956. }
  10957. if (label.HasValue())
  10958. {
  10959. label.Append("\r\n以上小计:");
  10960. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  10961. label.Append("元(");
  10962. label.Append(currencyName);
  10963. label.Append("汇率:");
  10964. label.Append(rate.TruncDecimals(4));
  10965. label.Append(")");
  10966. }
  10967. designer.SetDataSource("AccomLabel", label.ToString());
  10968. }
  10969. #endregion
  10970. #region 餐饮费
  10971. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  10972. if (mealCosts.Infos.Any())
  10973. {
  10974. string currencyName = string.Empty;
  10975. decimal rate = 1.0000M;
  10976. StringBuilder label = new StringBuilder();
  10977. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  10978. foreach (var item in mealCosts.Infos)
  10979. {
  10980. string name = string.Empty;
  10981. if (item.FeeName.Contains("-"))
  10982. {
  10983. var feeName = item.FeeName.Split('-');
  10984. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10985. }
  10986. else name = $"\r\n{item.FeeName}:";
  10987. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10988. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10989. rate = rateInfo?.Rate ?? 1.0000M;
  10990. label.Append(name);
  10991. label.Append(item.UnitPrice.TruncDecimals(2));
  10992. label.Append(currencyName);
  10993. label.Append("/天*");
  10994. label.Append(item.Quantity.ToString("#0"));
  10995. label.Append("*");
  10996. label.Append(item.PplNum);
  10997. label.Append("人\r\n");
  10998. }
  10999. if (label.HasValue())
  11000. {
  11001. label.Append("\r\n以上小计:");
  11002. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11003. label.Append("元\r\n(");
  11004. label.Append("汇率:");
  11005. label.Append(rate.TruncDecimals(4));
  11006. label.Append(")");
  11007. }
  11008. designer.SetDataSource("MealLabel", label.ToString());
  11009. }
  11010. #endregion
  11011. #region 车辆安排
  11012. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  11013. if (vehArranges.Infos.Any())
  11014. {
  11015. string currencyName = string.Empty;
  11016. //decimal rate = 1.0000M;
  11017. StringBuilder label = new StringBuilder();
  11018. foreach (var item in vehArranges.Infos)
  11019. {
  11020. label.Append(item.Remark);
  11021. label.AppendLine();
  11022. label.AppendLine();
  11023. label.Append(item.FeeName);
  11024. label.Append("\r\n\r\n费用:");
  11025. label.Append(item.FeeName);
  11026. label.Append(item.TotalAmt.TruncDecimals(2));
  11027. }
  11028. designer.SetDataSource("VehArrangeLabel", label.ToString());
  11029. }
  11030. #endregion
  11031. #region 邀请函发放对象
  11032. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  11033. #endregion
  11034. designer.Process();
  11035. //文件名
  11036. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11037. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  11038. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  11039. return Ok(JsonView(true, "成功", url));
  11040. }
  11041. #endregion
  11042. #region 签证费用录入
  11043. /// <summary>
  11044. /// 根据diid查询签证费用列表
  11045. /// </summary>
  11046. /// <param name="dto"></param>
  11047. /// <returns></returns>
  11048. [HttpPost]
  11049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11050. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  11051. {
  11052. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  11053. if (groupData.Code != 0)
  11054. {
  11055. return Ok(JsonView(false, groupData.Msg));
  11056. }
  11057. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11058. }
  11059. /// <summary>
  11060. /// 根据签证费用Id查询单条数据及c表数据
  11061. /// </summary>
  11062. /// <param name="dto"></param>
  11063. /// <returns></returns>
  11064. [HttpPost]
  11065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11066. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  11067. {
  11068. Result groupData = await _visaPriceRep.PostVisaById(dto);
  11069. if (groupData.Code != 0)
  11070. {
  11071. return Ok(JsonView(false, groupData.Msg));
  11072. }
  11073. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11074. }
  11075. /// <summary>
  11076. /// 签证费用删除
  11077. /// </summary>
  11078. /// <param name="dto"></param>
  11079. /// <returns></returns>
  11080. [HttpPost]
  11081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11082. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  11083. {
  11084. _sqlSugar.BeginTran();
  11085. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  11086. if (!res)
  11087. {
  11088. _sqlSugar.RollbackTran();
  11089. return Ok(JsonView(false, "删除失败"));
  11090. }
  11091. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  11092. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  11093. .SetColumns(a => new Grp_CreditCardPayment()
  11094. {
  11095. IsDel = 1,
  11096. DeleteUserId = dto.DeleteUserId,
  11097. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11098. })
  11099. .ExecuteCommand();
  11100. if (resSub < 1)
  11101. {
  11102. _sqlSugar.RollbackTran();
  11103. return Ok(JsonView(false, "删除失败"));
  11104. }
  11105. _sqlSugar.CommitTran();
  11106. return Ok(JsonView(true, "删除成功!"));
  11107. }
  11108. /// <summary>
  11109. /// 签证费用录入下拉框初始化
  11110. /// </summary>
  11111. /// <returns></returns>
  11112. [HttpPost]
  11113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11114. public async Task<IActionResult> VisaPriceAddSelect()
  11115. {
  11116. //支付方式
  11117. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  11118. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  11119. //币种
  11120. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  11121. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  11122. //乘客类型
  11123. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  11124. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  11125. //卡类型
  11126. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  11127. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  11128. //代办费类型
  11129. var agencyFeeTypeData = new List<dynamic>() {
  11130. new { id = 0 , Text = "未选择" },
  11131. new { id = 1 , Text = "小公务" },
  11132. new { id = 2 , Text = "大公务" },
  11133. };
  11134. //签证费用标准国家Data
  11135. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  11136. var data = new
  11137. {
  11138. Payment = _Payment,
  11139. CurrencyList = _CurrencyList,
  11140. PassengerType = _PassengerType,
  11141. BankCard = _BankCard,
  11142. AgencyFeeType = agencyFeeTypeData,
  11143. CountryFeeData = visaCountryFeeData
  11144. };
  11145. return Ok(JsonView(true, "查询成功!", data));
  11146. }
  11147. /// <summary>
  11148. /// 签证费用录入操作(Status:1.新增,2.修改)
  11149. /// </summary>
  11150. /// <param name="dto"></param>
  11151. /// <returns></returns>
  11152. [HttpPost]
  11153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11154. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  11155. {
  11156. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  11157. if (groupData.Code != 0)
  11158. {
  11159. return Ok(JsonView(false, groupData.Msg));
  11160. }
  11161. #region 应用推送
  11162. try
  11163. {
  11164. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11165. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11166. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11167. //2024-10-21 新增LZ UID
  11168. var userIds = new List<int>() { 21 };
  11169. string title = $"系统通知";
  11170. string content = "";
  11171. var diId = dto.DiId;
  11172. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11173. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11174. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  11175. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  11176. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11177. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11178. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11179. }
  11180. catch (Exception ex)
  11181. {
  11182. }
  11183. #endregion
  11184. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11185. }
  11186. #endregion
  11187. #region 签证提成录入
  11188. /// <summary>
  11189. /// 签证提成录入
  11190. /// 基础数据
  11191. /// </summary>
  11192. /// <returns></returns>
  11193. [HttpGet]
  11194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11195. public async Task<IActionResult> VisaCommissionInit()
  11196. {
  11197. return Ok(await _visaCommissionRep.Init());
  11198. }
  11199. /// <summary>
  11200. /// 签证提成录入
  11201. /// Item
  11202. /// </summary>
  11203. /// <param name="_dto"></param>
  11204. /// <returns></returns>
  11205. [HttpPost]
  11206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11207. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  11208. {
  11209. var validator = new VisaCommissionItemDtoValidator();
  11210. var validatorRes = await validator.ValidateAsync(_dto);
  11211. if (!validatorRes.IsValid)
  11212. {
  11213. StringBuilder sb = new StringBuilder();
  11214. foreach (var item in validatorRes.Errors)
  11215. {
  11216. sb.AppendLine(item.ErrorMessage);
  11217. }
  11218. return Ok(JsonView(false, sb.ToString()));
  11219. }
  11220. return Ok(await _visaCommissionRep.Item(_dto));
  11221. }
  11222. /// <summary>
  11223. /// 签证提成录入
  11224. /// Save
  11225. /// </summary>
  11226. /// <param name="_dto"></param>
  11227. /// <returns></returns>
  11228. [HttpPost]
  11229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11230. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  11231. {
  11232. //参数验证
  11233. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  11234. foreach (var item in _dto.Items)
  11235. {
  11236. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  11237. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  11238. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  11239. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  11240. }
  11241. return Ok(await _visaCommissionRep.Save(_dto));
  11242. }
  11243. /// <summary>
  11244. /// 签证提成录入
  11245. /// Create
  11246. /// </summary>
  11247. /// <param name="_dto"></param>
  11248. /// <returns></returns>
  11249. [HttpPost]
  11250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11251. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  11252. {
  11253. var validator = new VisaCommissionCreateDtoValidator();
  11254. var validatorRes = await validator.ValidateAsync(_dto);
  11255. if (!validatorRes.IsValid)
  11256. {
  11257. StringBuilder sb = new StringBuilder();
  11258. foreach (var item in validatorRes.Errors)
  11259. {
  11260. sb.AppendLine(item.ErrorMessage);
  11261. }
  11262. return Ok(JsonView(false, sb.ToString()));
  11263. }
  11264. return Ok(await _visaCommissionRep.Create(_dto));
  11265. }
  11266. /// <summary>
  11267. /// 签证提成录入
  11268. /// Put(编辑)
  11269. /// </summary>
  11270. /// <param name="id"></param>
  11271. /// <param name="_dto"></param>
  11272. /// <returns></returns>
  11273. [HttpPut]
  11274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11275. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  11276. {
  11277. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11278. var validator = new VisaCommissionCreateDtoValidator();
  11279. var validatorRes = await validator.ValidateAsync(_dto);
  11280. if (!validatorRes.IsValid)
  11281. {
  11282. StringBuilder sb = new StringBuilder();
  11283. foreach (var item in validatorRes.Errors)
  11284. {
  11285. sb.AppendLine(item.ErrorMessage);
  11286. }
  11287. return Ok(JsonView(false, sb.ToString()));
  11288. }
  11289. return Ok(await _visaCommissionRep.Edit(id, _dto));
  11290. }
  11291. /// <summary>
  11292. /// 签证提成录入
  11293. /// Del
  11294. /// </summary>
  11295. /// <param name="id"></param>
  11296. /// <param name="currUserId"></param>
  11297. /// <returns></returns>
  11298. [HttpPost]
  11299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11300. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  11301. {
  11302. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11303. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  11304. return Ok(await _visaCommissionRep.Del(id, currUserId));
  11305. }
  11306. #endregion
  11307. #region op费用录入
  11308. /// <summary>
  11309. /// 根据diid查询op费用列表
  11310. /// </summary>
  11311. /// <param name="dto"></param>
  11312. /// <returns></returns>
  11313. [HttpPost]
  11314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11315. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  11316. {
  11317. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  11318. if (groupData.Code != 0)
  11319. {
  11320. return Ok(JsonView(false, groupData.Msg));
  11321. }
  11322. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11323. }
  11324. /// <summary>
  11325. /// 根据op费用Id查询单条数据及c表数据
  11326. /// </summary>
  11327. /// <param name="dto"></param>
  11328. /// <returns></returns>
  11329. [HttpPost]
  11330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11331. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11332. {
  11333. try
  11334. {
  11335. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11336. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11337. var data = new
  11338. {
  11339. CarTouristGuideGround = _groupData,
  11340. CreditCardPayment = _creditCardPayment
  11341. };
  11342. return Ok(JsonView(true, "查询成功!", data));
  11343. }
  11344. catch (Exception ex)
  11345. {
  11346. return Ok(JsonView(false, "程序错误!"));
  11347. }
  11348. }
  11349. /// <summary>
  11350. /// op费用删除
  11351. /// </summary>
  11352. /// <param name="dto"></param>
  11353. /// <returns></returns>
  11354. [HttpPost]
  11355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11356. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11357. {
  11358. try
  11359. {
  11360. _sqlSugar.BeginTran();
  11361. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11362. if (!res)
  11363. {
  11364. return Ok(JsonView(false, "删除失败"));
  11365. }
  11366. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11367. {
  11368. IsDel = 1,
  11369. DeleteUserId = dto.DeleteUserId,
  11370. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11371. }).ExecuteCommandAsync();
  11372. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11373. {
  11374. IsDel = 1,
  11375. DeleteUserId = dto.DeleteUserId,
  11376. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11377. }).ExecuteCommandAsync();
  11378. #region 删除超支相关数据
  11379. //删除导入的超支数据
  11380. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11381. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11382. {
  11383. IsDel = 1,
  11384. DeleteUserId = dto.DeleteUserId,
  11385. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11386. }).ExecuteCommand();
  11387. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11388. {
  11389. IsDel = 1,
  11390. DeleteUserId = dto.DeleteUserId,
  11391. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11392. }).ExecuteCommand();
  11393. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11394. {
  11395. IsDel = 1,
  11396. DeleteUserId = dto.DeleteUserId,
  11397. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11398. }).ExecuteCommand();
  11399. #endregion
  11400. _sqlSugar.CommitTran();
  11401. return Ok(JsonView(true, "删除成功!"));
  11402. }
  11403. catch (Exception ex)
  11404. {
  11405. _sqlSugar.RollbackTran();
  11406. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11407. }
  11408. }
  11409. /// <summary>
  11410. /// op费用录入操作(Status:1.新增,2.修改)
  11411. /// </summary>
  11412. /// <param name="dto"></param>
  11413. /// <returns></returns>
  11414. [HttpPost]
  11415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11416. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11417. {
  11418. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11419. if (groupData.Code != 0)
  11420. {
  11421. return Ok(JsonView(false, groupData.Msg));
  11422. }
  11423. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11424. }
  11425. /// <summary>
  11426. /// 填写费用详细页面初始化绑定
  11427. /// </summary>
  11428. /// <param name="dto"></param>
  11429. /// <returns></returns>
  11430. [HttpPost]
  11431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11432. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11433. {
  11434. try
  11435. {
  11436. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11437. if (groupData.Code != 0)
  11438. {
  11439. return Ok(JsonView(false, groupData.Msg));
  11440. }
  11441. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11442. }
  11443. catch (Exception ex)
  11444. {
  11445. return Ok(JsonView(false, ex.Message));
  11446. }
  11447. }
  11448. /// <summary>
  11449. /// 根据op费用Id查询详细数据
  11450. /// </summary>
  11451. /// <param name="dto"></param>
  11452. /// <returns></returns>
  11453. [HttpPost]
  11454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11455. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11456. {
  11457. try
  11458. {
  11459. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11460. if (groupData.Code != 0)
  11461. {
  11462. return Ok(JsonView(false, groupData.Msg));
  11463. }
  11464. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11465. }
  11466. catch (Exception ex)
  11467. {
  11468. return Ok(JsonView(false, ex.Message));
  11469. }
  11470. }
  11471. /// <summary>
  11472. /// OP费用录入填写详情
  11473. /// </summary>
  11474. /// <param name="dto"></param>
  11475. /// <returns></returns>
  11476. [HttpPost]
  11477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11478. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11479. {
  11480. try
  11481. {
  11482. #region 参数校验
  11483. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11484. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11485. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11486. #endregion
  11487. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11488. if (groupData.Code != 0)
  11489. {
  11490. return Ok(JsonView(false, groupData.Msg));
  11491. }
  11492. //自动审核
  11493. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11494. #region 应用推送
  11495. try
  11496. {
  11497. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11498. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11499. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11500. //2024-10-21 新增LZ UID
  11501. var userIds = new List<int>() { 21 };
  11502. string title = $"系统通知";
  11503. var diId = dto.DiId;
  11504. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11505. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11506. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11507. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11508. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11509. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11510. }
  11511. catch (Exception ex)
  11512. {
  11513. }
  11514. #endregion
  11515. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11516. }
  11517. catch (Exception ex)
  11518. {
  11519. return Ok(JsonView(false, ex.Message));
  11520. }
  11521. }
  11522. /// <summary>
  11523. /// 获取三公详细所有城市
  11524. /// </summary>
  11525. /// <returns></returns>
  11526. [HttpGet]
  11527. public IActionResult OpCarCityResult()
  11528. {
  11529. var jw = JsonView(false);
  11530. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11531. {
  11532. x.Id,
  11533. x.Country,
  11534. x.City,
  11535. }).ToList();
  11536. if (data.Count > 0)
  11537. {
  11538. jw = JsonView(true, "获取成功!", data);
  11539. }
  11540. else
  11541. {
  11542. jw.Msg = "城市数据为空!";
  11543. jw.Data = new string[0];
  11544. }
  11545. return Ok(jw);
  11546. }
  11547. /// <summary>
  11548. /// 导出地接费用明细
  11549. /// </summary>
  11550. /// <param name="dto"></param>
  11551. /// <returns></returns>
  11552. [HttpPost]
  11553. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11554. {
  11555. var jw = JsonView(false);
  11556. if (dto.Diid < 1)
  11557. {
  11558. jw.Msg = "请输入正确的diid!";
  11559. return Ok(jw);
  11560. }
  11561. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11562. if (group == null)
  11563. {
  11564. jw.Msg = "未找到团组信息!";
  11565. return Ok(jw);
  11566. }
  11567. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11568. if (localGuideArr.Count == 0)
  11569. {
  11570. jw.Msg = "该团组暂无地接信息!";
  11571. return Ok(jw);
  11572. }
  11573. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11574. var overspendSoure = new Dictionary<int, int>
  11575. {
  11576. { 91, 982 }, //车
  11577. { 92 , 1059} ,//导游
  11578. { 994 , 1073}, //翻译
  11579. { 988 , 1074 }, //早餐
  11580. { 93 , 1075 }, //午餐
  11581. { 989 , 1076 }, //晚餐
  11582. };
  11583. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11584. foreach (var groupArr in localGroup)
  11585. {
  11586. var keyValue = groupArr.Key;
  11587. if (int.TryParse(keyValue, out int cityid))
  11588. {
  11589. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11590. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11591. }
  11592. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11593. foreach (var item in groupArr)
  11594. {
  11595. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11596. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11597. new Grp_CarTouristGuideGroundReservationsContentExtend
  11598. {
  11599. Count = a.Count,
  11600. CreateTime = a.CreateTime,
  11601. CreateUserId = a.CreateUserId,
  11602. CTGGRId = a.CTGGRId,
  11603. Currency = a.Currency,
  11604. DatePrice = a.DatePrice,
  11605. DeleteTime = a.DeleteTime,
  11606. DeleteUserId = a.DeleteUserId,
  11607. DiId = a.DiId,
  11608. Id = a.Id,
  11609. IsDel = a.IsDel,
  11610. Price = a.Price,
  11611. PriceContent = a.PriceContent,
  11612. Remark = a.Remark,
  11613. SId = a.SId,
  11614. SidName = b.Name,
  11615. Units = a.Units,
  11616. }
  11617. ).ToList();
  11618. if (content.Count > 0)
  11619. {
  11620. contentArr.Add(content);
  11621. }
  11622. }
  11623. //open excel
  11624. //set excel
  11625. //save excel
  11626. try
  11627. {
  11628. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11629. IWorkbook workbook;
  11630. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11631. {
  11632. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11633. }
  11634. else
  11635. {
  11636. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11637. }
  11638. ISheet sheet = workbook.GetSheetAt(0);
  11639. var rowStartIndex = 2;
  11640. var clounmCount = 10;
  11641. var initStyleRow = sheet.GetRow(2);
  11642. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11643. //var overspendArrDetail =
  11644. var existsId = new List<CarCompare>();
  11645. var lastElem = arr.Last();
  11646. var thisSid = -1;
  11647. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11648. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11649. {
  11650. Name = "未知币种!",
  11651. Remark = "未知币种!",
  11652. };
  11653. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11654. Action cloneRowFn = () =>
  11655. {
  11656. rowStartIndex++;
  11657. var cloneRow = sheet.CreateRow(rowStartIndex);
  11658. // 复制样式
  11659. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11660. {
  11661. ICell sourceCell = initStyleRow.GetCell(i);
  11662. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11663. // 确保单元格存在样式
  11664. if (sourceCell.CellStyle != null)
  11665. {
  11666. targetCell.CellStyle = sourceCell.CellStyle;
  11667. }
  11668. }
  11669. };
  11670. var mergeRow = () =>
  11671. {
  11672. for (int i = 2; i < sheet.LastRowNum; i++)
  11673. {
  11674. var row = sheet.GetRow(i);
  11675. var cellFirst = row.GetCell(0);
  11676. var thisIndex = i + 1;
  11677. while (thisIndex < sheet.LastRowNum)
  11678. {
  11679. var nextRow = sheet.GetRow(thisIndex);
  11680. var nextCellFirst = nextRow.GetCell(0);
  11681. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11682. {
  11683. thisIndex++;
  11684. }
  11685. else
  11686. {
  11687. break;
  11688. }
  11689. }
  11690. thisIndex--;
  11691. if (thisIndex != i)
  11692. {
  11693. //合并row
  11694. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11695. i, // 起始行索引(0-based)
  11696. thisIndex, // 结束行索引(0-based)
  11697. 0, // 起始列索引(0-based)
  11698. 0 // 结束列索引(0-based)
  11699. );
  11700. sheet.AddMergedRegion(cellRangeAddress);
  11701. i = thisIndex;
  11702. }
  11703. }
  11704. };
  11705. var chaoshiNumber = 0;
  11706. var totalNumber = 0.00M;
  11707. string lastStr = "";
  11708. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11709. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11710. {
  11711. b.IsAuditGM,
  11712. x.Id,
  11713. x.Area,
  11714. b.PayPercentage,
  11715. b.PayMoney,
  11716. }).ToList();
  11717. string yesPayment = "", noPayment = "";
  11718. foreach (var item in queryCarArrByCityAndDiid)
  11719. {
  11720. if (item.IsAuditGM == 1)
  11721. {
  11722. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11723. }
  11724. else
  11725. {
  11726. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11727. }
  11728. }
  11729. lastStr = yesPayment + noPayment;
  11730. foreach (var item in arr)
  11731. {
  11732. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11733. {
  11734. if (thisSid != item.SId)
  11735. {
  11736. if (thisSid == -1)
  11737. {
  11738. thisSid = item.SId;
  11739. }
  11740. else
  11741. {
  11742. //合并小计行
  11743. //创建合并区域的实例
  11744. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11745. rowStartIndex, // 起始行索引(0-based)
  11746. rowStartIndex, // 结束行索引(0-based)
  11747. 0, // 起始列索引(0-based)
  11748. 3 // 结束列索引(0-based)
  11749. );
  11750. sheet.AddMergedRegion(cellRangeAddress);
  11751. var CellStyle = workbook.CreateCellStyle();
  11752. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11753. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11754. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  11755. for (int i = 0; i <= clounmCount; i++)
  11756. {
  11757. if (i > 6)
  11758. {
  11759. var CellStyle1 = workbook.CreateCellStyle();
  11760. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11761. IFont Font = workbook.CreateFont(); // 创建字体
  11762. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11763. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11764. CellStyle1.SetFont(Font);
  11765. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11766. }
  11767. else
  11768. {
  11769. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11770. }
  11771. }
  11772. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11773. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11774. //超时合计
  11775. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11776. //超时数
  11777. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11778. //超时合计费用
  11779. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11780. thisSid = item.SId;
  11781. cloneRowFn();
  11782. chaoshiNumber = 0;
  11783. totalNumber = 0;
  11784. }
  11785. }
  11786. IRow row = sheet.GetRow(rowStartIndex);
  11787. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11788. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11789. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11790. if (isOpenOverspendSoure)
  11791. {
  11792. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11793. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11794. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11795. }
  11796. for (int i = 0; i <= clounmCount; i++)
  11797. {
  11798. var cell = row.GetCell(i);
  11799. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11800. if (cell == null)
  11801. {
  11802. cell = row.CreateCell(i);
  11803. }
  11804. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11805. fontRed.CloneStyleFrom(cell.CellStyle);
  11806. IFont Font = workbook.CreateFont(); // 创建字体
  11807. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11808. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11809. fontRed.SetFont(Font);
  11810. byte[] rgb = new byte[3] { 255, 242, 204 };
  11811. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11812. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11813. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11814. if (workbook is XSSFWorkbook)
  11815. {
  11816. BackgroundColor255_242_204.FillForegroundColor = 0;
  11817. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11818. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  11819. }
  11820. else
  11821. {
  11822. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11823. }
  11824. if (i == 1 || i > 6)
  11825. {
  11826. if (i > 6)
  11827. {
  11828. fontRed.FillForegroundColor = 0;
  11829. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11830. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  11831. }
  11832. cell.CellStyle = fontRed;
  11833. }
  11834. if (i > 2 && i < 7)
  11835. {
  11836. cell.CellStyle = BackgroundColor255_242_204;
  11837. }
  11838. cell.SetCellValue(setCellValue); //写入单元格
  11839. }
  11840. if (overspendSoure.ContainsKey(thisSid))
  11841. {
  11842. var overspendId = overspendSoure[thisSid];
  11843. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11844. }
  11845. cloneRowFn();
  11846. existsId.Add(new CarCompare
  11847. {
  11848. DataPrice = item.DatePrice.ObjToDate(),
  11849. Sid = item.SId
  11850. });
  11851. }
  11852. if (item.Equals(lastElem))
  11853. {
  11854. //合并小计行
  11855. //创建合并区域的实例
  11856. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11857. rowStartIndex, // 起始行索引(0-based)
  11858. rowStartIndex, // 结束行索引(0-based)
  11859. 0, // 起始列索引(0-based)
  11860. 3 // 结束列索引(0-based)
  11861. );
  11862. sheet.AddMergedRegion(cellRangeAddress);
  11863. var CellStyle = workbook.CreateCellStyle();
  11864. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11865. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11866. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  11867. for (int i = 0; i <= clounmCount; i++)
  11868. {
  11869. if (i > 6)
  11870. {
  11871. var CellStyle1 = workbook.CreateCellStyle();
  11872. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11873. IFont Font = workbook.CreateFont(); // 创建字体
  11874. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11875. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11876. CellStyle1.SetFont(Font);
  11877. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11878. }
  11879. else
  11880. {
  11881. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11882. }
  11883. }
  11884. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11885. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11886. //超时合计
  11887. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11888. //超时数
  11889. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11890. //超时合计费用
  11891. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11892. cloneRowFn();
  11893. // 创建合并区域的实例
  11894. cellRangeAddress = new CellRangeAddress(
  11895. rowStartIndex, // 起始行索引(0-based)
  11896. rowStartIndex, // 结束行索引(0-based)
  11897. 0, // 起始列索引(0-based)
  11898. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11899. );
  11900. // 添加合并区域
  11901. sheet.AddMergedRegion(cellRangeAddress);
  11902. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11903. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11904. }
  11905. }
  11906. mergeRow();
  11907. // 保存修改后的Excel文件到新文件
  11908. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11909. // new FileStream(newFilePath, FileMode.CreateNew)
  11910. using (var stream = new MemoryStream())
  11911. {
  11912. workbook.Write(stream, true);
  11913. stream.Flush();
  11914. stream.Seek(0, SeekOrigin.Begin);
  11915. MemoryStream memoryStream = new MemoryStream();
  11916. stream.CopyTo(memoryStream);
  11917. memoryStream.Seek(0, SeekOrigin.Begin);
  11918. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11919. }
  11920. workbook.Close();
  11921. workbook.Dispose();
  11922. }
  11923. catch (Exception ex)
  11924. {
  11925. jw.Msg = "出现异常!" + ex.Message;
  11926. return Ok(jw);
  11927. }
  11928. }
  11929. if (Zips.Count > 0)
  11930. {
  11931. IOOperatorHelper io = new IOOperatorHelper();
  11932. var byts = io.ConvertZipStream(Zips);
  11933. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11934. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11935. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11936. }
  11937. else
  11938. {
  11939. jw.Msg = "暂无生成文件!";
  11940. }
  11941. return Ok(jw);
  11942. }
  11943. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11944. {
  11945. string outStr = string.Empty;
  11946. switch (i)
  11947. {
  11948. case 0:
  11949. outStr = arr[0].SidName;
  11950. break;
  11951. case 1:
  11952. outStr = arr[0].DataPriceStr;
  11953. break;
  11954. case 2:
  11955. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11956. break;
  11957. case 4:
  11958. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11959. break;
  11960. case 7:
  11961. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11962. {
  11963. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11964. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11965. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11966. }
  11967. break;
  11968. case 8:
  11969. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11970. {
  11971. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11972. }
  11973. break;
  11974. case 9:
  11975. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11976. {
  11977. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11978. }
  11979. break;
  11980. case 10:
  11981. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11982. {
  11983. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11984. }
  11985. break;
  11986. }
  11987. return outStr;
  11988. }
  11989. #region OP行程单
  11990. /// <summary>
  11991. /// OP行程单初始化
  11992. /// </summary>
  11993. /// <param name="dto"></param>
  11994. /// <returns></returns>
  11995. [HttpPost]
  11996. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11997. {
  11998. var jw = JsonView(false);
  11999. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  12000. var group = groupList.First();
  12001. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12002. if (group == null)
  12003. {
  12004. jw.Msg = "暂无团组!";
  12005. return Ok(jw);
  12006. }
  12007. group = groupList.Find(x => x.Id == diid);
  12008. if (group == null)
  12009. {
  12010. jw.Msg = "请输入正确的团组ID!";
  12011. return Ok(jw);
  12012. }
  12013. string city = string.Empty;
  12014. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  12015. if (blackCode.Count > 0)
  12016. {
  12017. var black = blackCode.First();
  12018. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  12019. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  12020. if (blackSp.Length > 0)
  12021. {
  12022. try
  12023. {
  12024. var cityArrCode = new List<string>(20);
  12025. foreach (var item in blackSp)
  12026. {
  12027. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  12028. var IndexSelect = itemSp[2];
  12029. var cityArrCodeLength = cityArrCode.Count - 1;
  12030. var startCity = IndexSelect.Substring(0, 3);
  12031. if (cityArrCodeLength > 0)
  12032. {
  12033. var arrEndCity = cityArrCode[cityArrCodeLength];
  12034. if (arrEndCity != startCity)
  12035. {
  12036. cityArrCode.Add(startCity.ToUpper());
  12037. }
  12038. }
  12039. else
  12040. {
  12041. cityArrCode.Add(startCity.ToUpper());
  12042. }
  12043. var endCity = IndexSelect.Substring(3, 3);
  12044. cityArrCode.Add(endCity.ToUpper());
  12045. }
  12046. var cityThree = string.Empty;
  12047. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  12048. cityThree = cityThree.TrimEnd(',');
  12049. if (string.IsNullOrWhiteSpace(cityThree))
  12050. {
  12051. throw new
  12052. Exception("error");
  12053. }
  12054. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  12055. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  12056. foreach (var item in cityArrCode)
  12057. {
  12058. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  12059. if (find != null)
  12060. {
  12061. city += find.City + "/";
  12062. }
  12063. else
  12064. {
  12065. city += item + "三字码未收入/";
  12066. }
  12067. }
  12068. city = city.TrimEnd('/');
  12069. }
  12070. catch (Exception e)
  12071. {
  12072. city = "黑屏代码格式不正确!";
  12073. }
  12074. }
  12075. }
  12076. else
  12077. {
  12078. city = "未录入黑屏代码";
  12079. }
  12080. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  12081. {
  12082. Date = x.Date,
  12083. Days = x.Days,
  12084. Diffgroup = x.Diffgroup,
  12085. Diid = x.Diid,
  12086. Traffic_First = x.Traffic_First,
  12087. Traffic_Second = x.Traffic_Second,
  12088. Trip = x.Trip,
  12089. WeekDay = x.WeekDay,
  12090. Id = x.Id
  12091. }).ToList();
  12092. jw.Data = new
  12093. {
  12094. groupList = groupList.Select(x => new
  12095. {
  12096. x.Id,
  12097. x.TeamName,
  12098. x.TourCode
  12099. }).ToList(),
  12100. groupInfo = new
  12101. {
  12102. group.VisitDays,
  12103. group.TourCode,
  12104. group.VisitPNumber,
  12105. group.TeamName,
  12106. city
  12107. },
  12108. OpTravelList
  12109. };
  12110. jw.Code = 200;
  12111. jw.Msg = "操作成功!";
  12112. return Ok(jw);
  12113. }
  12114. /// <summary>
  12115. /// 删除团组行程单
  12116. /// </summary>
  12117. /// <returns></returns>
  12118. [HttpPost]
  12119. public IActionResult DelTravel(DelOpTravelDto dto)
  12120. {
  12121. var jw = JsonView(false);
  12122. if (dto.UserId <= 0 || dto.Diid <= 0)
  12123. {
  12124. jw.Msg = "请输入正确的参数!";
  12125. return Ok(jw);
  12126. }
  12127. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  12128. .SetColumns(x => new Grp_TravelList
  12129. {
  12130. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  12131. DeleteUserId = dto.UserId,
  12132. IsDel = 1,
  12133. }).ExecuteCommand();
  12134. jw = JsonView(true);
  12135. return Ok(jw);
  12136. }
  12137. /// <summary>
  12138. /// 行程单保存
  12139. /// </summary>
  12140. /// <returns></returns>
  12141. [HttpPost]
  12142. public IActionResult TravelSave(TravelSaveDto dto)
  12143. {
  12144. var jw = JsonView(false);
  12145. if (dto.Arr.Count > 0)
  12146. {
  12147. try
  12148. {
  12149. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  12150. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  12151. .ToList();
  12152. _sqlSugar.BeginTran();
  12153. foreach (var item in dto.Arr)
  12154. {
  12155. if (item.Id == 0)
  12156. {
  12157. throw new Exception("请传入正确的Id");
  12158. }
  12159. //比较上一次的差异
  12160. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  12161. if (findTravel != null)
  12162. {
  12163. item.Trip = item.Trip.Replace("[++]", string.Empty);
  12164. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  12165. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  12166. }
  12167. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  12168. .SetColumns(x => new Grp_TravelList
  12169. {
  12170. Trip = item.Trip
  12171. }).ExecuteCommand();
  12172. }
  12173. _sqlSugar.CommitTran();
  12174. jw = JsonView(true);
  12175. }
  12176. catch (Exception ex)
  12177. {
  12178. _sqlSugar.RollbackTran();
  12179. jw.Msg = "程序异常!" + ex.Message;
  12180. }
  12181. }
  12182. else
  12183. {
  12184. jw.Msg = "请传入正确的参数!";
  12185. }
  12186. return Ok(jw);
  12187. }
  12188. private string CheckStr(string original, string changed)
  12189. {
  12190. // 创建diff_match_patch对象
  12191. var dmp = new diff_match_patch();
  12192. // 计算差异
  12193. List<Diff> diffs = dmp.diff_main(original, changed);
  12194. // 清理和合并差异
  12195. dmp.diff_cleanupSemantic(diffs);
  12196. // 使用StringBuilder构建最终的字符串
  12197. StringBuilder finalString = new StringBuilder();
  12198. // 输出差异结果,并构建变动后的字符串
  12199. foreach (Diff diff in diffs)
  12200. {
  12201. switch (diff.operation)
  12202. {
  12203. case Operation.EQUAL:
  12204. // 相等的部分,直接添加到最终字符串
  12205. finalString.Append(diff.text);
  12206. break;
  12207. case Operation.INSERT:
  12208. // 插入的部分,添加标记并添加到最终字符串
  12209. finalString.Append("[++]" + diff.text + "[++]");
  12210. break;
  12211. case Operation.DELETE:
  12212. // 删除的部分,不添加到最终字符串
  12213. //finalString.Append("[++]" + diff.text + "[++]");
  12214. break;
  12215. }
  12216. }
  12217. // 输出变动后的字符串
  12218. return finalString.ToString();
  12219. }
  12220. private class tagContent
  12221. {
  12222. public DateTime Date { get; set; }
  12223. public string StartTag { get; set; }
  12224. public string EndTag { get; set; }
  12225. public string Content { get; set; }
  12226. public static int tagLength { get { return 3; } }
  12227. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  12228. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  12229. public bool IsFinally { get; set; }
  12230. }
  12231. private List<string> ExtractContentBetweenTags(string input, string tag)
  12232. {
  12233. List<string> results = new List<string>();
  12234. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  12235. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  12236. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  12237. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  12238. string[] strValueArr = new string[1];
  12239. foreach (System.Text.RegularExpressions.Match match in matches)
  12240. {
  12241. var strValue = match.Groups[1].Value;
  12242. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  12243. }
  12244. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  12245. return results;
  12246. }
  12247. /// <summary>
  12248. /// 导出行程单
  12249. /// </summary>
  12250. /// <param name="dto"></param>
  12251. /// <returns></returns>
  12252. [HttpPost]
  12253. public IActionResult ExportTravel(ExportTravelDto dto)
  12254. {
  12255. var jw = JsonView(false);
  12256. jw.Data = "";
  12257. int diid = 0;
  12258. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  12259. if (Find == null)
  12260. {
  12261. jw.Msg = "请选择正确的团组!";
  12262. return Ok(jw);
  12263. }
  12264. else
  12265. {
  12266. diid = Find.Id;
  12267. }
  12268. //数据源
  12269. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  12270. DataTable dtBlack = null;
  12271. try
  12272. {
  12273. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  12274. }
  12275. catch (Exception)
  12276. {
  12277. jw.Msg = "机票黑屏代码有误!";
  12278. return Ok(jw);
  12279. }
  12280. string CityStr = string.Empty;
  12281. if (dtBlack.Rows.Count == 0)
  12282. {
  12283. jw.Msg = "机票黑屏代码有误!";
  12284. return Ok(jw);
  12285. }
  12286. else
  12287. {
  12288. foreach (DataRow row in dtBlack.Rows)
  12289. {
  12290. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12291. {
  12292. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  12293. return Ok(jw);
  12294. }
  12295. }
  12296. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  12297. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  12298. }
  12299. // 指定的文字
  12300. var targetTextDic = new Dictionary<string, List<string>>();
  12301. //创建数据源Table
  12302. DataTable dtSource = new DataTable();
  12303. dtSource.Columns.Add("Days", typeof(string));
  12304. dtSource.Columns.Add("Date", typeof(string));
  12305. dtSource.Columns.Add("Week", typeof(string));
  12306. dtSource.Columns.Add("Traffic", typeof(string));
  12307. dtSource.Columns.Add("Trip", typeof(string));
  12308. //获取数据,放到datatable
  12309. foreach (var item in _travelList)
  12310. {
  12311. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  12312. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  12313. .Replace(tagContent.TagFormat.Item2, string.Empty)
  12314. .Replace("[++]", string.Empty);
  12315. DataRow dr = dtSource.NewRow();
  12316. dr["Days"] = item.Days;
  12317. dr["Date"] = item.Date;
  12318. dr["Week"] = item.WeekDay;
  12319. dr["Traffic"] = item.Traffic_First
  12320. + "\r\n"
  12321. + item.Traffic_Second;
  12322. dr["Trip"] = item.Trip;
  12323. dtSource.Rows.Add(dr);
  12324. }
  12325. Dictionary<string, string> dic = new Dictionary<string, string>();
  12326. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12327. dic.Add("City", CityStr);
  12328. dic.Add("Days", Find.VisitDays.ToString());
  12329. dic.Add("DeleCode", Find.TourCode);
  12330. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12331. //模板路径
  12332. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12333. //载入模板
  12334. Document doc = null;
  12335. DocumentBuilder builder = null;
  12336. try
  12337. {
  12338. //载入模板
  12339. doc = new Document(tempPath);
  12340. builder = new DocumentBuilder(doc);
  12341. }
  12342. catch (Exception)
  12343. {
  12344. jw.Msg = "模板位置不存在!";
  12345. return Ok(jw);
  12346. }
  12347. foreach (var key in dic.Keys)
  12348. {
  12349. Bookmark bookmark = doc.Range.Bookmarks[key];
  12350. if (bookmark != null)
  12351. {
  12352. builder.MoveToBookmark(key);
  12353. builder.Write(dic[key]);
  12354. }
  12355. }
  12356. //获取word里所有表格
  12357. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12358. //获取所填表格的序数
  12359. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12360. try
  12361. {
  12362. //循环赋值
  12363. for (int i = 0; i < dtSource.Rows.Count; i++)
  12364. {
  12365. builder.MoveToCell(0, i + 1, 0, 0);
  12366. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12367. builder.MoveToCell(0, i + 1, 1, 0);
  12368. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12369. builder.MoveToCell(0, i + 1, 2, 0);
  12370. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12371. var trip = dtSource.Rows[i]["Trip"].ToString();
  12372. builder.MoveToCell(0, i + 1, 3, 0);
  12373. builder.Write(trip);
  12374. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12375. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12376. // 获取特定索引的段落
  12377. Paragraph paragraph = (Paragraph)paragraphs[0];
  12378. Run run = paragraph.Runs[0];
  12379. Aspose.Words.Font font = run.Font;
  12380. font.Name = "黑体";
  12381. //设置双休红色
  12382. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12383. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12384. paragraph = (Paragraph)paragraphs[1];
  12385. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12386. {
  12387. run = paragraph.Runs[0];
  12388. font = run.Font;
  12389. font.Color = Color.Red;
  12390. }
  12391. }
  12392. }
  12393. catch (Exception ex)
  12394. {
  12395. }
  12396. //删除多余行
  12397. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12398. {
  12399. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12400. }
  12401. var targetTextList = new List<string>();
  12402. // 遍历文档中的表格
  12403. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12404. {
  12405. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12406. {
  12407. var cellIndex = 0;
  12408. foreach (Cell cell in row.Cells)
  12409. {
  12410. if (cellIndex == 1 && row.Cells.Count == 4)
  12411. {
  12412. foreach (var target in targetTextDic.Keys)
  12413. {
  12414. if (cell.GetText().Contains(target))
  12415. {
  12416. targetTextList = targetTextDic[target];
  12417. break;
  12418. }
  12419. }
  12420. }
  12421. // 遍历单元格中的所有段落
  12422. foreach (Paragraph paragraph in cell.Paragraphs)
  12423. {
  12424. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12425. List<Run> runs = new List<Run>();
  12426. foreach (Run run in paragraph.Runs)
  12427. {
  12428. runs.Add(run);
  12429. }
  12430. foreach (Run run in runs)
  12431. {
  12432. foreach (var targetText in targetTextList)
  12433. {
  12434. // 检查文字是否包含指定文字
  12435. if (run.Text.Contains(targetText))
  12436. {
  12437. // 将包含的部分设置为红色
  12438. HighlightText(run, targetText, Color.Red);
  12439. }
  12440. }
  12441. }
  12442. }
  12443. cellIndex++;
  12444. }
  12445. }
  12446. }
  12447. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12448. if (!Directory.Exists(savePath))
  12449. {
  12450. try
  12451. {
  12452. Directory.CreateDirectory(savePath);
  12453. }
  12454. catch
  12455. {
  12456. }
  12457. }
  12458. string path = savePath + Find.TeamName + "出访日程";
  12459. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12460. try
  12461. {
  12462. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12463. string postfix = ".docx";
  12464. if (dto.IsPDF == 1)
  12465. {
  12466. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12467. postfix = ".pdf";
  12468. }
  12469. doc.Save(path + postfix, saveFormat);
  12470. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12471. }
  12472. catch (Exception)
  12473. {
  12474. jw = JsonView(false);
  12475. }
  12476. return Ok(jw);
  12477. }
  12478. /// <summary>
  12479. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12480. /// </summary>
  12481. /// <param name="num"></param>
  12482. /// <returns></returns>
  12483. string GetNum(string num)
  12484. {
  12485. string str = "";
  12486. switch (num)
  12487. {
  12488. case "1":
  12489. str = "一";
  12490. break;
  12491. case "2":
  12492. str = "二";
  12493. break;
  12494. case "3":
  12495. str = "三";
  12496. break;
  12497. case "4":
  12498. str = "四";
  12499. break;
  12500. case "5":
  12501. str = "五";
  12502. break;
  12503. case "6":
  12504. str = "六";
  12505. break;
  12506. case "7":
  12507. str = "七";
  12508. break;
  12509. case "8":
  12510. str = "八";
  12511. break;
  12512. case "9":
  12513. str = "九";
  12514. break;
  12515. case "10":
  12516. str = "十";
  12517. break;
  12518. case "11":
  12519. str = "十一";
  12520. break;
  12521. case "12":
  12522. str = "十二";
  12523. break;
  12524. case "一":
  12525. str = "1";
  12526. break;
  12527. case "二":
  12528. str = "2";
  12529. break;
  12530. case "三":
  12531. str = "3";
  12532. break;
  12533. case "四":
  12534. str = "4";
  12535. break;
  12536. case "五":
  12537. str = "5";
  12538. break;
  12539. case "六":
  12540. str = "6";
  12541. break;
  12542. case "七":
  12543. str = "7";
  12544. break;
  12545. case "八":
  12546. str = "8";
  12547. break;
  12548. case "九":
  12549. str = "9";
  12550. break;
  12551. case "十":
  12552. str = "10";
  12553. break;
  12554. case "十一":
  12555. str = "11";
  12556. break;
  12557. case "十二":
  12558. str = "12";
  12559. break;
  12560. }
  12561. return str;
  12562. }
  12563. // 高亮包含指定文字的部分
  12564. void HighlightText(Run run, string targetText, Color color)
  12565. {
  12566. string text = run.Text;
  12567. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12568. if (startIndex >= 0)
  12569. {
  12570. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12571. // 前部分
  12572. if (startIndex > 0)
  12573. {
  12574. Run beforeRun = (Run)run.Clone(true);
  12575. beforeRun.Text = text.Substring(0, startIndex);
  12576. parentParagraph.InsertBefore(beforeRun, run);
  12577. }
  12578. // 匹配部分
  12579. Run matchRun = (Run)run.Clone(true);
  12580. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12581. matchRun.Font.Color = color;
  12582. parentParagraph.InsertBefore(matchRun, run);
  12583. // 后部分
  12584. if (startIndex + targetText.Length < text.Length)
  12585. {
  12586. Run afterRun = (Run)run.Clone(true);
  12587. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12588. parentParagraph.InsertBefore(afterRun, run);
  12589. }
  12590. // 删除原始Run
  12591. run.Remove();
  12592. }
  12593. }
  12594. #endregion
  12595. #endregion
  12596. #region 团组成本
  12597. /// <summary>
  12598. /// 团组成本数据初始化
  12599. /// </summary>
  12600. /// <param name="dto"></param>
  12601. /// <returns></returns>
  12602. [HttpPost]
  12603. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12604. {
  12605. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12606. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12607. WHEN COUNT(*) >= 0 THEN 'True'
  12608. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12609. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12610. ").ToList(); //团组列表
  12611. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12612. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12613. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12614. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12615. if (groupinfoValue != null)
  12616. {
  12617. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12618. var spArr = new string[1] { countryArr };
  12619. if (countryArr.Contains("|"))
  12620. {
  12621. spArr = countryArr.Split("|");
  12622. }
  12623. else if (countryArr.Contains("、"))
  12624. {
  12625. spArr = countryArr.Split("、");
  12626. }
  12627. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12628. {
  12629. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12630. if (dbQueryCountry != null)
  12631. {
  12632. visaCountryInfoArr.Add(dbQueryCountry);
  12633. }
  12634. }
  12635. }
  12636. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12637. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12638. var create = _GroupCostRepository.
  12639. CreateGroupCostByBlackCode(dto.Diid);
  12640. if (groupCost.Count == 0 && create.Code == 0)
  12641. {
  12642. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12643. }
  12644. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12645. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12646. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12647. groupCostMap = groupCostMap.Select(x =>
  12648. {
  12649. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12650. {
  12651. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12652. }
  12653. return x;
  12654. }).ToList();
  12655. //GroupCostParameter.Add(new
  12656. // Grp_GroupCostParameter());
  12657. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12658. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12659. return Ok(JsonView(new
  12660. {
  12661. groupList,
  12662. groupInfo,
  12663. groupChecks,
  12664. groupCost = groupCostMap,
  12665. hotelNumber,
  12666. GroupCostParameter = GroupCostParameterMap,
  12667. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12668. {
  12669. x.VisaCountry,
  12670. x.VisaPrice,
  12671. x.Id,
  12672. }).ToList(),
  12673. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12674. blackCodeIsTrue = create.Code == 0 ? true : false,
  12675. hotelIsTrue = hotelIsTrue,
  12676. }));
  12677. }
  12678. /// <summary>
  12679. /// 团组成本信息保存
  12680. /// </summary>
  12681. /// <param name="dto"></param>
  12682. /// <returns></returns>
  12683. [HttpPost]
  12684. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12685. {
  12686. if (dto.Diid <= 0 || dto.Userid <= 0)
  12687. {
  12688. return Ok(JsonView(false));
  12689. }
  12690. JsonView jw = null;
  12691. bool isTrue = false;
  12692. #region 复制团组成本
  12693. //if (dto.Diid == 2581)
  12694. //{
  12695. // dto.Diid = 2599;
  12696. // dto.CheckBoxs.ForEach(x =>
  12697. // {
  12698. // x.Diid = 2599;
  12699. // });
  12700. // dto.GroupCosts.ForEach(x =>
  12701. // {
  12702. // x.Diid = 2599;
  12703. // });
  12704. // dto.CostTypeHotelNumbers.ForEach(x =>
  12705. // {
  12706. // x.Diid = 2599;
  12707. // });
  12708. // dto.GroupCostParameters.ForEach(x =>
  12709. // {
  12710. // x.DiId = 2599;
  12711. // });
  12712. //}
  12713. #endregion
  12714. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12715. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12716. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12717. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12718. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12719. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12720. try
  12721. {
  12722. _sqlSugar.BeginTran();
  12723. isTrue = await _GroupCostRepository.
  12724. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12725. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12726. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12727. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12728. _sqlSugar.CommitTran();
  12729. jw = JsonView(true, "保存成功!", isTrue);
  12730. }
  12731. catch (Exception)
  12732. {
  12733. _sqlSugar.RollbackTran();
  12734. jw = JsonView(false);
  12735. }
  12736. return Ok(jw);
  12737. }
  12738. /// <summary>
  12739. /// 司兼导数据
  12740. /// </summary>
  12741. /// <param name="dto"></param>
  12742. /// <returns></returns>
  12743. [HttpPost]
  12744. public IActionResult GetCarGuides(CarGuidesDto dto)
  12745. {
  12746. JsonView jw = null;
  12747. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12748. jw = JsonView(true, "获取成功!", Data);
  12749. return Ok(jw);
  12750. }
  12751. /// <summary>
  12752. /// 导游数据
  12753. /// </summary>
  12754. /// <param name="dto"></param>
  12755. /// <returns></returns>
  12756. [HttpPost]
  12757. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12758. {
  12759. JsonView jw = null;
  12760. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12761. // 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
  12762. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12763. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12764. jw = JsonView(true, "获取成功!", Data);
  12765. return Ok(jw);
  12766. }
  12767. /// <summary>
  12768. /// 成本车数据
  12769. /// </summary>
  12770. /// <param name="dto"></param>
  12771. /// <returns></returns>
  12772. [HttpPost]
  12773. public IActionResult GetCarInfo(CarGuidesDto dto)
  12774. {
  12775. JsonView jw = null;
  12776. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12777. jw = JsonView(true, "获取成功!", Data);
  12778. return Ok(jw);
  12779. }
  12780. /// <summary>
  12781. /// 景点数据
  12782. /// </summary>
  12783. /// <param name="dto"></param>
  12784. /// <returns></returns>
  12785. [HttpPost]
  12786. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12787. {
  12788. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12789. return Ok(JsonView(true, "获取成功!", Data));
  12790. }
  12791. /// <summary>
  12792. /// 成本通知
  12793. /// </summary>
  12794. /// <param name="dto"></param>
  12795. /// <returns></returns>
  12796. [HttpPost]
  12797. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12798. {
  12799. if (dto.Diid < 0)
  12800. {
  12801. return Ok(JsonView(false));
  12802. }
  12803. JsonView jw = null;
  12804. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12805. if (GroupCostParameter != null)
  12806. {
  12807. int IsShare = 0;
  12808. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12809. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12810. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12811. string msg = string.Empty;
  12812. if (isTrue)
  12813. {
  12814. if (IsShare == 0)
  12815. {
  12816. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12817. }
  12818. else
  12819. {
  12820. #region 企微通知对应岗位用户
  12821. try
  12822. {
  12823. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12824. }
  12825. catch (Exception ex)
  12826. {
  12827. }
  12828. #endregion
  12829. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12830. }
  12831. jw = JsonView(isTrue, msg, new { IsShare });
  12832. }
  12833. else
  12834. {
  12835. msg = "修改失败!";
  12836. jw = JsonView(isTrue, msg);
  12837. }
  12838. }
  12839. else
  12840. {
  12841. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12842. }
  12843. return Ok(jw);
  12844. }
  12845. /// <summary>
  12846. /// 导出报价单
  12847. /// </summary>
  12848. /// <param name="dto"></param>
  12849. /// <returns></returns>
  12850. [HttpPost]
  12851. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12852. {
  12853. if (dto.Diid == 0)
  12854. {
  12855. return Ok(JsonView(false, "请传递团组id"));
  12856. }
  12857. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12858. if (deleInfo.Code != 0)
  12859. {
  12860. return Ok(JsonView(false, "团组信息查询失败!"));
  12861. }
  12862. var di = deleInfo.Data as DelegationInfoWebView;
  12863. if (di != null)
  12864. {
  12865. di.TeamName = di.TeamName.Replace("|", "、");
  12866. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12867. //文件名
  12868. string strFileName = di.TeamName + "-收款账单.doc";
  12869. //获取模板
  12870. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12871. //载入模板
  12872. Document doc = new Document(tmppath);
  12873. decimal TotalPrice = 0.00M;
  12874. string itemStr = string.Empty;
  12875. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12876. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12877. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12878. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12879. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12880. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12881. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12882. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12883. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12884. foreach (var cost in groupCostType)
  12885. {
  12886. var List = cost.ToList();
  12887. if (cost.Key == "A")
  12888. {
  12889. foreach (var ListItem in List)
  12890. {
  12891. if (ListItem.number > 0)
  12892. {
  12893. if (ListItem.code.Contains("TBR"))
  12894. {
  12895. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12896. }
  12897. else
  12898. {
  12899. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12900. }
  12901. TotalPrice += (ListItem.number * ListItem.price);
  12902. }
  12903. }
  12904. }
  12905. else
  12906. {
  12907. itemStr = itemStr.Insert(0, "A段\r\n");
  12908. itemStr += "B段\r\n";
  12909. foreach (var ListItem in List)
  12910. {
  12911. if (ListItem.number > 0)
  12912. {
  12913. if (ListItem.code.Contains("TBR"))
  12914. {
  12915. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12916. }
  12917. else
  12918. {
  12919. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12920. }
  12921. TotalPrice += (ListItem.number * ListItem.price);
  12922. }
  12923. }
  12924. }
  12925. }
  12926. #region 替换Word模板书签内容
  12927. Dictionary<string, string> marks = new Dictionary<string, string>();
  12928. marks.Add("To", di.ClientUnit);//付款方
  12929. marks.Add("ToTel", di.TellPhone);//付款方电话
  12930. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12931. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12932. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12933. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12934. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12935. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12936. marks.Add("PayItemContent", itemStr);//详细信息
  12937. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12938. #endregion
  12939. ////注
  12940. //if (doc.Range.Bookmarks["Attention"] != null)
  12941. //{
  12942. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12943. // mark.Text = frList[0].Attention;
  12944. //}
  12945. foreach (var item in marks.Keys)
  12946. {
  12947. if (doc.Range.Bookmarks[item] != null)
  12948. {
  12949. Bookmark mark = doc.Range.Bookmarks[item];
  12950. mark.Text = marks[item];
  12951. }
  12952. }
  12953. byte[] bytes = null;
  12954. using (MemoryStream stream = new MemoryStream())
  12955. {
  12956. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12957. bytes = stream.ToArray();
  12958. }
  12959. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12960. return Ok(JsonView(true, "", new
  12961. {
  12962. Data = bytes,
  12963. strFileName,
  12964. }));
  12965. }
  12966. else
  12967. {
  12968. return Ok(JsonView(false, "团组信息不存在!"));
  12969. }
  12970. }
  12971. /// <summary>
  12972. /// 导出团组成本
  12973. /// </summary>
  12974. /// <param name="dto"></param>
  12975. /// <returns></returns>
  12976. [HttpPost]
  12977. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12978. {
  12979. var jw = JsonView(false);
  12980. if (dto.Diid == 0)
  12981. {
  12982. return Ok(JsonView(false, "请传递团组id"));
  12983. }
  12984. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12985. if (deleInfo.Code != 0)
  12986. {
  12987. return Ok(JsonView(false, "团组信息查询失败!"));
  12988. }
  12989. var di = deleInfo.Data as DelegationInfoWebView;
  12990. if (di == null)
  12991. {
  12992. return Ok(JsonView(false, "团组信息查询失败!"));
  12993. }
  12994. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12995. WorkbookDesigner designer = new WorkbookDesigner();
  12996. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12997. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12998. for (int i = 0; i < List_GC.Count; i++)
  12999. {
  13000. GroupCost_Excel gc = new GroupCost_Excel();
  13001. gc.Id = List_GC[i].Id;
  13002. gc.Diid = List_GC[i].Diid.ToString();
  13003. gc.DAY = List_GC[i].DAY;
  13004. string week = "";
  13005. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  13006. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  13007. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  13008. gc.ITIN = List_GC[i].ITIN;
  13009. gc.CarType = List_GC[i].CarType;
  13010. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  13011. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  13012. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  13013. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  13014. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  13015. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  13016. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  13017. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  13018. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  13019. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  13020. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  13021. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  13022. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13023. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13024. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  13025. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  13026. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  13027. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  13028. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  13029. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  13030. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  13031. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  13032. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  13033. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  13034. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  13035. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  13036. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  13037. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  13038. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  13039. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  13040. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  13041. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  13042. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  13043. List_GC1.Add(gc);
  13044. }
  13045. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  13046. dt.TableName = "TB";
  13047. //报表标题等不用dt的值
  13048. designer.SetDataSource("TeamName", dto.title.TeamName);
  13049. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  13050. designer.SetDataSource("Tax", dto.title.Tax);
  13051. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  13052. designer.SetDataSource("Currency", dto.title.Currency);
  13053. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  13054. designer.SetDataSource("Rate", dto.title.Rate);
  13055. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  13056. var Aparams = hotels.Find(x => x.Type == "Default");
  13057. if (Aparams == null)
  13058. {
  13059. return Ok(jw);
  13060. }
  13061. //酒店数量
  13062. var txtSGRNumber = Aparams.SGR.ToString();
  13063. var txtTBRNumber = Aparams.TBR.ToString();
  13064. var txtJSESNumber = Aparams.JSES.ToString();
  13065. var txtSUITENumbe = Aparams.SUITE.ToString();
  13066. if (dto.costType == "B")
  13067. {
  13068. Aparams = hotels.Find(x => x.Type == "A");
  13069. var Bparams = hotels.Find(x => x.Type == "B");
  13070. if (Aparams == null || Bparams == null)
  13071. {
  13072. return Ok(jw);
  13073. }
  13074. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  13075. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  13076. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  13077. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  13078. }
  13079. designer.SetDataSource("SGRNumber", txtSGRNumber);
  13080. designer.SetDataSource("TBRNumber", txtTBRNumber);
  13081. designer.SetDataSource("JSESNumber", txtJSESNumber);
  13082. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  13083. var ws = designer.Workbook.Worksheets[0];
  13084. int Row = List_GC.Count;
  13085. int startIndex = 11;
  13086. int HideRows = 0;
  13087. List<int> hideRowsList = new List<int>();
  13088. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  13089. #region A段left数据
  13090. var left = dto.leftInfo.Find(x => x.Type == "A");
  13091. if (left == null)
  13092. {
  13093. return Ok(jw);
  13094. }
  13095. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  13096. if (leftBindData != null)
  13097. {
  13098. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  13099. designer.SetDataSource("VisaRS", leftBindData.rs);
  13100. designer.SetDataSource("VisaXS", leftBindData.xs);
  13101. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13102. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13103. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13104. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13105. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13106. }
  13107. else
  13108. {
  13109. hideRowsList.Add(Row + startIndex + HideRows);
  13110. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13111. }
  13112. HideRows += 2;
  13113. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  13114. if (leftBindData != null)
  13115. {
  13116. designer.SetDataSource("BXDRCB", leftBindData.cb);
  13117. designer.SetDataSource("BXRS", leftBindData.rs);
  13118. designer.SetDataSource("BXXS", leftBindData.xs);
  13119. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13120. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13121. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13122. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13123. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13124. }
  13125. else
  13126. {
  13127. hideRowsList.Add(Row + startIndex + HideRows);
  13128. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13129. }
  13130. HideRows += 2;
  13131. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13132. if (leftBindData != null)
  13133. {
  13134. designer.SetDataSource("HSDRCB", leftBindData.cb);
  13135. designer.SetDataSource("HSRS", leftBindData.rs);
  13136. designer.SetDataSource("HSXS", leftBindData.xs);
  13137. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13138. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13139. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13140. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13141. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13142. }
  13143. else
  13144. {
  13145. hideRowsList.Add(Row + startIndex + HideRows);
  13146. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13147. }
  13148. HideRows += 2;
  13149. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13150. if (leftBindData != null)
  13151. {
  13152. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  13153. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  13154. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  13155. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13156. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13157. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13158. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13159. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13160. }
  13161. else
  13162. {
  13163. hideRowsList.Add(Row + startIndex + HideRows);
  13164. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13165. }
  13166. HideRows += 2;
  13167. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13168. if (leftBindData != null)
  13169. {
  13170. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  13171. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  13172. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  13173. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13174. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13175. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13176. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13177. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13178. }
  13179. else
  13180. {
  13181. hideRowsList.Add(Row + startIndex + HideRows);
  13182. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13183. }
  13184. HideRows += 2;
  13185. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13186. if (leftBindData != null)
  13187. {
  13188. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  13189. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  13190. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  13191. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13192. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13193. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13194. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13195. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13196. }
  13197. else
  13198. {
  13199. hideRowsList.Add(Row + startIndex + HideRows);
  13200. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13201. }
  13202. HideRows += 2;
  13203. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13204. if (leftBindData != null)
  13205. {
  13206. ////TBR
  13207. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  13208. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  13209. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  13210. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13211. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13212. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13213. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13214. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13215. }
  13216. else
  13217. {
  13218. hideRowsList.Add(Row + startIndex + HideRows);
  13219. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13220. }
  13221. HideRows += 2;
  13222. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13223. if (leftBindData != null)
  13224. {
  13225. ////SGR
  13226. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  13227. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  13228. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  13229. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13230. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13231. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13232. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13233. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13234. }
  13235. else
  13236. {
  13237. hideRowsList.Add(Row + startIndex + HideRows);
  13238. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13239. }
  13240. HideRows += 2;
  13241. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13242. if (leftBindData != null)
  13243. {
  13244. ////JS/ES
  13245. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  13246. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  13247. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  13248. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13249. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13250. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13251. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13252. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13253. }
  13254. else
  13255. {
  13256. hideRowsList.Add(Row + startIndex + HideRows);
  13257. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13258. }
  13259. HideRows += 2;
  13260. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13261. if (leftBindData != null)
  13262. {
  13263. ////SUITE
  13264. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  13265. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  13266. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  13267. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13268. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13269. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13270. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13271. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13272. }
  13273. else
  13274. {
  13275. hideRowsList.Add(Row + startIndex + HideRows);
  13276. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13277. }
  13278. HideRows += 2;
  13279. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13280. if (leftBindData != null)
  13281. {
  13282. designer.SetDataSource("DJDRCB", leftBindData.cb);
  13283. designer.SetDataSource("DJRS", leftBindData.rs);
  13284. designer.SetDataSource("DJXS", leftBindData.xs);
  13285. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13286. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13287. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13288. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13289. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13290. }
  13291. else
  13292. {
  13293. hideRowsList.Add(Row + startIndex + HideRows);
  13294. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13295. }
  13296. HideRows += 2;
  13297. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13298. if (leftBindData != null)
  13299. {
  13300. designer.SetDataSource("HCPCB", leftBindData.cb);
  13301. designer.SetDataSource("HCPRS", leftBindData.rs);
  13302. designer.SetDataSource("HCPXS", leftBindData.xs);
  13303. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13304. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13305. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13306. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13307. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13308. }
  13309. else
  13310. {
  13311. hideRowsList.Add(Row + startIndex + HideRows);
  13312. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13313. }
  13314. HideRows += 2;
  13315. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13316. if (leftBindData != null)
  13317. {
  13318. designer.SetDataSource("CPCB", leftBindData.cb);
  13319. designer.SetDataSource("CPRS", leftBindData.rs);
  13320. designer.SetDataSource("CPXS", leftBindData.xs);
  13321. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13322. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13323. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13324. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13325. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13326. }
  13327. else
  13328. {
  13329. hideRowsList.Add(Row + startIndex + HideRows);
  13330. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13331. }
  13332. HideRows += 2;
  13333. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13334. if (leftBindData != null)
  13335. {
  13336. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13337. designer.SetDataSource("GWRS", leftBindData.rs);
  13338. designer.SetDataSource("GWXS", leftBindData.xs);
  13339. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13340. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13341. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13342. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13343. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13344. }
  13345. else
  13346. {
  13347. hideRowsList.Add(Row + startIndex + HideRows);
  13348. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13349. }
  13350. HideRows += 2;
  13351. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13352. if (leftBindData != null)
  13353. {
  13354. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13355. designer.SetDataSource("LYJRS", leftBindData.rs);
  13356. designer.SetDataSource("LYJXS", leftBindData.xs);
  13357. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13358. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13359. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13360. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13361. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13362. }
  13363. else
  13364. {
  13365. hideRowsList.Add(Row + startIndex + HideRows);
  13366. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13367. }
  13368. #endregion
  13369. #region A段Right信息
  13370. var right = dto.rightInfo.Find(x => x.Type == "A");
  13371. if (right == null)
  13372. {
  13373. return Ok(jw);
  13374. }
  13375. HideRows += 4;
  13376. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13377. if (rightBindData != null)
  13378. {
  13379. //经济舱 + 双人间 TBR
  13380. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13381. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13382. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13383. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13384. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13385. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13386. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13387. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13388. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13389. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13390. }
  13391. else
  13392. {
  13393. hideRowsList.Add(Row + startIndex + HideRows);
  13394. }
  13395. HideRows += 2;
  13396. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13397. if (rightBindData != null)
  13398. {
  13399. //经济舱 + 单人间 SGR
  13400. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13401. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13402. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13403. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13404. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13405. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13406. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13407. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13408. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13409. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13410. }
  13411. else
  13412. {
  13413. hideRowsList.Add(Row + startIndex + HideRows);
  13414. }
  13415. HideRows += 2;
  13416. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13417. if (rightBindData != null)
  13418. {
  13419. //公务舱 + 单人间 SGR
  13420. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13421. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13422. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13423. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13424. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13425. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13426. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13427. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13428. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13429. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13430. }
  13431. else
  13432. {
  13433. hideRowsList.Add(Row + startIndex + HideRows);
  13434. }
  13435. HideRows += 2;
  13436. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13437. if (rightBindData != null)
  13438. {
  13439. //公务舱 + 小套房 JSES
  13440. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13441. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13442. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13443. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13444. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13445. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13446. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13447. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13448. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13449. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13450. }
  13451. else
  13452. {
  13453. hideRowsList.Add(Row + startIndex + HideRows);
  13454. }
  13455. HideRows += 2;
  13456. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13457. if (rightBindData != null)
  13458. {
  13459. //公务舱 + 小套房 JSES
  13460. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13461. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13462. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13463. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13464. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13465. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13466. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13467. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13468. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13469. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13470. }
  13471. else
  13472. {
  13473. hideRowsList.Add(Row + startIndex + HideRows);
  13474. }
  13475. HideRows += 2;
  13476. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13477. if (rightBindData != null)
  13478. {
  13479. //经济舱 + 大套房
  13480. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13481. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13482. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13483. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13484. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13485. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13486. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13487. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13488. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13489. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13490. }
  13491. else
  13492. {
  13493. hideRowsList.Add(Row + startIndex + HideRows);
  13494. }
  13495. HideRows += 2;
  13496. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13497. if (rightBindData != null)
  13498. {
  13499. //头等舱 + 小套房 JSES
  13500. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13501. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13502. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13503. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13504. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13505. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13506. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13507. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13508. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13509. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13510. }
  13511. else
  13512. {
  13513. hideRowsList.Add(Row + startIndex + HideRows);
  13514. }
  13515. HideRows += 2;
  13516. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13517. if (rightBindData != null)
  13518. {
  13519. //头等舱 + 大套房
  13520. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13521. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13522. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13523. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13524. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13525. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13526. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13527. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13528. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13529. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13530. }
  13531. else
  13532. {
  13533. hideRowsList.Add(Row + startIndex + HideRows);
  13534. }
  13535. #endregion
  13536. #region B段标题清空
  13537. designer.SetDataSource("CostBDRCB", "");
  13538. designer.SetDataSource("CostBRS", "");
  13539. designer.SetDataSource("CostBXS", "");
  13540. designer.SetDataSource("CostBZCB", "");
  13541. designer.SetDataSource("CostBDRBJ", "");
  13542. designer.SetDataSource("CostBZBJ", "");
  13543. designer.SetDataSource("CostBDRLR", "");
  13544. designer.SetDataSource("CostBZLR", "");
  13545. designer.SetDataSource("CostBDRCBOM", "");
  13546. designer.SetDataSource("CostBRSOM", "");
  13547. designer.SetDataSource("CostBZCBOM", "");
  13548. designer.SetDataSource("CostBDRBJOM", "");
  13549. designer.SetDataSource("CostBZBJOM", "");
  13550. designer.SetDataSource("CostBDRLROM", "");
  13551. designer.SetDataSource("CostBZLROM", "");
  13552. #endregion
  13553. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13554. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13555. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13556. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13557. designer.SetDataSource("DJName", "地接(CNY)");
  13558. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13559. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13560. designer.SetDataSource("GWName", "公务(CNY)");
  13561. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13562. designer.SetDataSource("LYJName", "零用金(CNY)");
  13563. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13564. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13565. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13566. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13567. designer.SetDataSource("BXName", "保险(CNY)");
  13568. designer.SetDataSource("VisaName", "签证(CNY)");
  13569. #region B段基本数据
  13570. if (dto.costType == "B")
  13571. {
  13572. left = dto.leftInfo.Find(x => x.Type == "B");
  13573. if (left == null)
  13574. {
  13575. return Ok(jw);
  13576. }
  13577. #region B段left数据
  13578. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13579. if (leftBindData != null)
  13580. {
  13581. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13582. designer.SetDataSource("BHSRS", leftBindData.rs);
  13583. designer.SetDataSource("BHSXS", leftBindData.xs);
  13584. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13585. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13586. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13587. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13588. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13589. }
  13590. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13591. if (leftBindData != null)
  13592. {
  13593. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13594. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13595. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13596. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13597. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13598. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13599. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13600. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13601. }
  13602. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13603. if (leftBindData != null)
  13604. {
  13605. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13606. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13607. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13608. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13609. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13610. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13611. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13612. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13613. }
  13614. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13615. if (leftBindData != null)
  13616. {
  13617. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13618. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13619. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13620. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13621. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13622. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13623. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13624. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13625. }
  13626. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13627. if (leftBindData != null)
  13628. {
  13629. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13630. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13631. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13632. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13633. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13634. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13635. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13636. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13637. }
  13638. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13639. if (leftBindData != null)
  13640. {
  13641. designer.SetDataSource("BCPCB", leftBindData.cb);
  13642. designer.SetDataSource("BCPRS", leftBindData.rs);
  13643. designer.SetDataSource("BCPXS", leftBindData.xs);
  13644. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13645. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13646. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13647. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13648. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13649. }
  13650. //TBR
  13651. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13652. if (leftBindData != null)
  13653. {
  13654. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13655. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13656. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13657. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13658. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13659. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13660. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13661. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13662. }
  13663. //SGR
  13664. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13665. if (leftBindData != null)
  13666. {
  13667. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13668. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13669. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13670. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13671. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13672. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13673. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13674. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13675. }
  13676. //JS/ES
  13677. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13678. if (leftBindData != null)
  13679. {
  13680. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13681. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13682. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13683. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13684. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13685. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13686. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13687. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13688. }
  13689. //SUITE
  13690. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13691. if (leftBindData != null)
  13692. {
  13693. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13694. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13695. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13696. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13697. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13698. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13699. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13700. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13701. }
  13702. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13703. if (leftBindData != null)
  13704. {
  13705. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13706. designer.SetDataSource("BDJRS", leftBindData.rs);
  13707. designer.SetDataSource("BDJXS", leftBindData.xs);
  13708. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13709. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13710. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13711. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13712. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13713. }
  13714. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13715. if (leftBindData != null)
  13716. {
  13717. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13718. designer.SetDataSource("BGWRS", leftBindData.rs);
  13719. designer.SetDataSource("BGWXS", leftBindData.xs);
  13720. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13721. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13722. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13723. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13724. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13725. }
  13726. #region 优化方案
  13727. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13728. //excelBind.Add("零用金", new {
  13729. //cb="",
  13730. //rs="",
  13731. //xs ="",
  13732. //zcb = "",
  13733. //});
  13734. #endregion
  13735. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13736. if (leftBindData != null)
  13737. {
  13738. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13739. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13740. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13741. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13742. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13743. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13744. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13745. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13746. }
  13747. #endregion
  13748. #region B段Right信息
  13749. right = dto.rightInfo.Find(x => x.Type == "B");
  13750. if (right == null)
  13751. {
  13752. return Ok(jw);
  13753. }
  13754. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13755. if (rightBindData != null)
  13756. {
  13757. //经济舱 + 双人间 TBR
  13758. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13759. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13760. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13761. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13762. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13763. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13764. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13765. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13766. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13767. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13768. }
  13769. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13770. if (rightBindData != null)
  13771. {
  13772. //经济舱 + 单人间 SGR
  13773. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13774. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13775. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13776. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13777. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13778. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13779. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13780. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13781. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13782. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13783. }
  13784. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13785. if (rightBindData != null)
  13786. {
  13787. //公务舱 + 单人间 SGR
  13788. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13789. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13790. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13791. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13792. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13793. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13794. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13795. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13796. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13797. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13798. }
  13799. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13800. if (rightBindData != null)
  13801. {
  13802. //公务舱 + 小套房 JSES
  13803. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13804. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13805. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13806. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13807. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13808. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13809. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13810. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13811. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13812. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13813. }
  13814. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13815. if (rightBindData != null)
  13816. {
  13817. //公务舱 + 小套房 JSES
  13818. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13819. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13820. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13821. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13822. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13823. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13824. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13825. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13826. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13827. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13828. }
  13829. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13830. if (rightBindData != null)
  13831. {
  13832. //经济舱 + 大套房
  13833. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13834. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13835. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13836. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13837. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13838. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13839. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13840. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13841. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13842. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13843. }
  13844. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13845. if (rightBindData != null)
  13846. {
  13847. //头等舱 + 小套房 JSES
  13848. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13849. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13850. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13851. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13852. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13853. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13854. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13855. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13856. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13857. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13858. }
  13859. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13860. if (rightBindData != null)
  13861. {
  13862. //头等舱 + 大套房
  13863. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13864. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13865. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13866. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13867. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13868. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13869. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13870. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13871. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13872. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13873. }
  13874. #endregion
  13875. #region 标题
  13876. designer.SetDataSource("CostBDRCB", "单人成本");
  13877. designer.SetDataSource("CostBRS", "人数");
  13878. designer.SetDataSource("CostBXS", "系数");
  13879. designer.SetDataSource("CostBZCB", "总成本");
  13880. designer.SetDataSource("CostBDRBJ", "单人报价");
  13881. designer.SetDataSource("CostBZBJ", "总报价");
  13882. designer.SetDataSource("CostBDRLR", "单人利润");
  13883. designer.SetDataSource("CostBZLR", "总利润");
  13884. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13885. designer.SetDataSource("CostBRSOM", "人数");
  13886. designer.SetDataSource("CostBZCBOM", "总成本");
  13887. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13888. designer.SetDataSource("CostBZBJOM", "总报价");
  13889. designer.SetDataSource("CostBDRLROM", "单人利润");
  13890. designer.SetDataSource("CostBZLROM", "总利润");
  13891. #endregion
  13892. }
  13893. #endregion
  13894. designer.SetDataSource("TzZCB2", TzZCB2);
  13895. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13896. designer.SetDataSource("TzZLR2", TzZLR2);
  13897. string[] dataSourceKeys = new string[]
  13898. {
  13899. "VF",
  13900. "TGS",
  13901. "TGOF",
  13902. "TGM",
  13903. "TGA",
  13904. "TGTF",
  13905. "TGEF",
  13906. "CFM",
  13907. "CFOF",
  13908. "B",
  13909. "L",
  13910. "D",
  13911. "TBR",
  13912. "SGR",
  13913. "JSES",
  13914. "Suite",
  13915. "TV",
  13916. "1L",
  13917. "IF",
  13918. "EF",
  13919. "BRF",
  13920. "TE",
  13921. "TGT",
  13922. "DRVT",
  13923. "PC",
  13924. "TLF",
  13925. "ECT"
  13926. };
  13927. foreach (var item in dataSourceKeys)
  13928. {
  13929. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13930. if (find != null)
  13931. {
  13932. designer.SetDataSource(item, find.text);
  13933. }
  13934. else
  13935. {
  13936. designer.SetDataSource(item, 0);
  13937. }
  13938. }
  13939. designer.SetDataSource(dt);
  13940. //根据数据源处理生成报表内容
  13941. designer.Process();
  13942. designer.Workbook.Worksheets[0].Name = "清单";
  13943. Worksheet sheet = designer.Workbook.Worksheets[0];
  13944. foreach (var Rowindex in hideRowsList)
  13945. {
  13946. ws.Cells.HideRows(Rowindex, 2);
  13947. }
  13948. byte[] bytes = null;
  13949. string strFileName = di.TeamName + "-团组-成本.xls";
  13950. using (MemoryStream stream = new MemoryStream())
  13951. {
  13952. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13953. bytes = stream.ToArray();
  13954. }
  13955. return Ok(JsonView(true, "", new
  13956. {
  13957. Data = bytes,
  13958. strFileName,
  13959. }));
  13960. }
  13961. /// <summary>
  13962. /// 导出客户报表
  13963. /// </summary>
  13964. /// <returns></returns>
  13965. [HttpPost]
  13966. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13967. {
  13968. var jw = JsonView(false);
  13969. if (dto.Diid == 0)
  13970. {
  13971. return Ok(JsonView(false, "请传递团组id"));
  13972. }
  13973. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13974. if (deleInfo.Code != 0)
  13975. {
  13976. return Ok(JsonView(false, "团组信息查询失败!"));
  13977. }
  13978. var di = deleInfo.Data as DelegationInfoWebView;
  13979. if (di == null)
  13980. {
  13981. return Ok(JsonView(false, "团组信息查询失败!"));
  13982. }
  13983. //文件名
  13984. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13985. //获取模板
  13986. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13987. //载入模板
  13988. Document doc = new Document(tmppath);
  13989. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13990. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13991. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13992. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13993. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13994. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13995. if (AParameter == null)
  13996. {
  13997. return Ok(JsonView(false, "系数不存在!"));
  13998. }
  13999. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  14000. , TzAirDesc, TzZCost;
  14001. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  14002. = TzAirDesc = TzZCost = string.Empty;
  14003. TzNumber = AParameter.CostTypenumber.ToString();
  14004. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  14005. CarGuides1 = dto.CarGuides1;
  14006. Meal = dto.Meal;
  14007. SubsidizedMeals = dto.SubsidizedMeals;
  14008. NightRepair = dto.NightRepair;
  14009. AttractionsTickets = dto.AttractionsTickets;
  14010. MiscellaneousFees = dto.MiscellaneousFees;
  14011. ATip = dto.ATip;
  14012. TzHotelDesc = "";
  14013. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  14014. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  14015. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  14016. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  14017. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  14018. TzAirDesc = "";
  14019. TzZCost = dto.TzZCost;
  14020. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  14021. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  14022. var index = 1;
  14023. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  14024. foreach (var item in TzHotelDescArr)
  14025. {
  14026. if (AinfoArr != null)
  14027. {
  14028. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14029. if (Ainfo != null)
  14030. {
  14031. if (int.Parse(Ainfo.rs) <= 0)
  14032. {
  14033. continue;
  14034. }
  14035. var hotelText = string.Empty;
  14036. switch (item)
  14037. {
  14038. case "SGR":
  14039. hotelText = "单人间";
  14040. break;
  14041. case "JSES":
  14042. hotelText = "小套房";
  14043. break;
  14044. case "SUITE":
  14045. hotelText = "套房";
  14046. break;
  14047. case "TBR":
  14048. hotelText = "双人间";
  14049. break;
  14050. }
  14051. if (item != "TBR")
  14052. {
  14053. 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";
  14054. }
  14055. else
  14056. {
  14057. 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";
  14058. }
  14059. index++;
  14060. }
  14061. }
  14062. }
  14063. index = 1;
  14064. foreach (var item in TzAirDescArr)
  14065. {
  14066. if (AinfoArr != null)
  14067. {
  14068. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14069. if (Ainfo != null)
  14070. {
  14071. if (int.Parse(Ainfo.rs) <= 0)
  14072. {
  14073. continue;
  14074. }
  14075. 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";
  14076. index++;
  14077. }
  14078. }
  14079. }
  14080. if (dto.costType == "B")
  14081. {
  14082. if (BParameter == null)
  14083. {
  14084. return Ok(JsonView(false, "B段系数不存在!"));
  14085. }
  14086. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  14087. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  14088. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  14089. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  14090. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  14091. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  14092. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  14093. foreach (var item in TzHotelDescArr)
  14094. {
  14095. if (AinfoArr != null)
  14096. {
  14097. TzHotelDesc += "B段信息 \r\n";
  14098. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14099. if (Ainfo != null)
  14100. {
  14101. if (int.Parse(Ainfo.rs) <= 0)
  14102. {
  14103. continue;
  14104. }
  14105. var hotelText = string.Empty;
  14106. switch (item)
  14107. {
  14108. case "SGR":
  14109. hotelText = "单人间";
  14110. break;
  14111. case "JSES":
  14112. hotelText = "小套房";
  14113. break;
  14114. case "SUITE":
  14115. hotelText = "套房";
  14116. break;
  14117. case "TBR":
  14118. hotelText = "双人间";
  14119. break;
  14120. }
  14121. if (item != "TBR")
  14122. {
  14123. 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";
  14124. }
  14125. else
  14126. {
  14127. 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";
  14128. }
  14129. index++;
  14130. }
  14131. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  14132. }
  14133. }
  14134. index = 1;
  14135. foreach (var item in TzAirDescArr)
  14136. {
  14137. if (AinfoArr != null)
  14138. {
  14139. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14140. if (Ainfo != null)
  14141. {
  14142. if (int.Parse(Ainfo.rs) <= 0)
  14143. {
  14144. continue;
  14145. }
  14146. 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";
  14147. index++;
  14148. }
  14149. }
  14150. }
  14151. }
  14152. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  14153. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  14154. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  14155. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  14156. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  14157. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  14158. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  14159. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  14160. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  14161. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  14162. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  14163. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  14164. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  14165. DickeyValue.Add("Visa", Visa); // 签证单人报价
  14166. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  14167. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  14168. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  14169. DickeyValue.Add("TzZCost", TzZCost);
  14170. foreach (var key in DickeyValue.Keys)
  14171. {
  14172. if (doc.Range.Bookmarks[key] != null)
  14173. {
  14174. Bookmark mark = doc.Range.Bookmarks[key];
  14175. mark.Text = DickeyValue[key];
  14176. }
  14177. }
  14178. byte[] bytes = null;
  14179. string strFileName = di.TeamName + "-客户报价.doc";
  14180. using (MemoryStream stream = new MemoryStream())
  14181. {
  14182. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14183. bytes = stream.ToArray();
  14184. }
  14185. return Ok(JsonView(true, "", new
  14186. {
  14187. Data = bytes,
  14188. strFileName,
  14189. }));
  14190. }
  14191. /// <summary>
  14192. /// 团组成本 各模块(酒店,地接,机票)成本提示
  14193. /// </summary>
  14194. /// <param name="dto"></param>
  14195. /// <returns></returns>
  14196. [HttpPost]
  14197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14198. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  14199. {
  14200. try
  14201. {
  14202. #region 参数验证
  14203. if (dto.DiId < 0)
  14204. {
  14205. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  14206. }
  14207. List<int> cTableIds = new List<int>() {
  14208. 76 ,//酒店预订
  14209. 77 ,//行程
  14210. 79 ,//车/导游地接
  14211. 80 ,//签证
  14212. 81 ,//邀请/公务活
  14213. 82 ,//团组客户保险
  14214. 85 ,//机票预订
  14215. 98 ,//其他款项
  14216. 285 ,//收款退还
  14217. 751 ,//酒店早餐
  14218. 1015 // 超支费用
  14219. };
  14220. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  14221. {
  14222. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  14223. }
  14224. #endregion
  14225. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  14226. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  14227. if (_GroupCostParameters.Count <= 0)
  14228. {
  14229. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  14230. }
  14231. if (_GroupCostParameters[0].IsShare == 0)
  14232. {
  14233. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  14234. }
  14235. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14236. //处理date为空问题
  14237. if (_GroupCosts.Count > 0)
  14238. {
  14239. for (int i = 0; i < _GroupCosts.Count; i++)
  14240. {
  14241. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  14242. {
  14243. if (i > 0)
  14244. {
  14245. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  14246. }
  14247. }
  14248. }
  14249. }
  14250. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  14251. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  14252. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  14253. string currCode = "";
  14254. #region currCode 验证
  14255. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  14256. if (isInt)
  14257. {
  14258. var currData = currDatas.Find(it => it.Id == intCurrency);
  14259. if (currData != null)
  14260. {
  14261. currCode = currData.Name;
  14262. }
  14263. }
  14264. else
  14265. {
  14266. currCode = _GroupCostParameters[0].Currency.Trim();
  14267. }
  14268. #endregion
  14269. //op,酒店单段模式存储
  14270. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  14271. {
  14272. CurrencyCode = currCode,
  14273. Rate = _GroupCostParameters[0].Rate,
  14274. CostType = _GroupCostParameters[0].CostType,
  14275. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  14276. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  14277. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  14278. };
  14279. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  14280. if (_GroupCostParameters.Count == 2)
  14281. {
  14282. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  14283. }
  14284. foreach (var item in _GroupCostParameters)
  14285. {
  14286. decimal _rate = 1;
  14287. decimal _rate1 = item.Rate;
  14288. decimal _scale = 1;
  14289. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  14290. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  14291. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  14292. //if (userInfo != null)
  14293. //{
  14294. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  14295. // {
  14296. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  14297. // {
  14298. // _scale = 1.00M;
  14299. // }
  14300. // }
  14301. //}
  14302. #endregion
  14303. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  14304. {
  14305. CurrencyCode = currCode,
  14306. Rate = _rate1,
  14307. CostType = item.CostType,
  14308. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  14309. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  14310. CostTypeNumber = item.CostTypenumber
  14311. };
  14312. if (_GroupCostParameters.Count > 1)
  14313. {
  14314. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  14315. }
  14316. else
  14317. {
  14318. modulePromptInfo.CostTypeNumber = item.LYJRS;
  14319. }
  14320. if (dto.CTable == 79)//
  14321. {
  14322. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14323. modulePromptInfo.TotalCost = item.DJCB;
  14324. }
  14325. List<string> costTypes = new List<string>() { "A", "B" };
  14326. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14327. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14328. if (_GroupCostsDuplicates.Count() == 1)
  14329. {
  14330. _GroupCostsTypeData = _GroupCosts;
  14331. }
  14332. else
  14333. {
  14334. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14335. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14336. }
  14337. /*
  14338. * 76 酒店预订
  14339. * 77 行程
  14340. * 79 车/导游地接
  14341. * 80 签证
  14342. * 81 邀请/公务活动
  14343. * 82 团组客户保险
  14344. * 85 机票预订
  14345. * 98 其他款项
  14346. * 285 收款退还
  14347. * 751 酒店早餐
  14348. * 1015 超支费用
  14349. */
  14350. switch (dto.CTable)
  14351. {
  14352. case 76: // 酒店预订
  14353. _ModuleSubPromptInfo.AddRange(
  14354. _GroupCostsTypeData.Select(it => new
  14355. {
  14356. it.DAY,
  14357. it.Date,
  14358. it.ACCON,
  14359. it.ITIN,
  14360. it.SGR,
  14361. it.TBR,
  14362. it.JS_ES,
  14363. it.Suite
  14364. })
  14365. );
  14366. break;
  14367. case 79: // 车/导游地接
  14368. _ModuleSubPromptInfo.AddRange(
  14369. _GroupCostsTypeData.Select(it => new
  14370. {
  14371. Date = it.Date, //日期
  14372. CarFee = it.CarCost * _rate * _scale, //车费用
  14373. CarType = it.CarType, //车型
  14374. DriverFee = it.CFS * _rate * _scale, //司机工资
  14375. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14376. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14377. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14378. GuideFee = it.TGS * _rate * _scale, //导游费用
  14379. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14380. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14381. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14382. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14383. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14384. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14385. Breakfast = it.B * _rate * _scale, //早餐费
  14386. Lunch = it.L * _rate * _scale, //午餐费
  14387. Dinner = it.D * _rate * _scale, //晚餐费
  14388. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14389. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14390. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14391. TicketFee = it.EF * _rate * _scale, //门票费
  14392. TicketRemark = it.EFR, //门票费描述
  14393. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14394. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14395. SpentCash = it.PC * _rate * _scale, //零用金
  14396. LeadersFee = it.TLF * _rate * _scale, //领队费
  14397. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14398. })
  14399. );
  14400. break;
  14401. case 85: // 机票
  14402. List<dynamic> datas = new List<dynamic>();
  14403. datas.Add(
  14404. new
  14405. {
  14406. AirType = "经济舱",
  14407. AirNum = item.JJCRS,
  14408. AirDRCB = item.JJCCB,
  14409. AirZCB = (item.JJCRS * item.JJCCB)
  14410. }
  14411. );
  14412. datas.Add(
  14413. new
  14414. {
  14415. AirType = "公务舱",
  14416. AirNum = item.GWCRS,
  14417. AirDRCB = item.GWCCB,
  14418. AirZCB = (item.GWCRS * item.GWCCB)
  14419. }
  14420. );
  14421. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14422. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14423. modulePromptInfo.Data = new
  14424. {
  14425. airFeeData = datas,
  14426. airInitData = initDatas
  14427. };
  14428. _ModulePromptInfos.Add(modulePromptInfo);
  14429. break;
  14430. default:
  14431. break;
  14432. }
  14433. }
  14434. if (dto.CTable != 85)
  14435. {
  14436. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14437. _ModulePromptInfos.Add(_ModulePromptInfo);
  14438. }
  14439. _view.ModulePromptInfos = _ModulePromptInfos;
  14440. return Ok(JsonView(true, "操作成功!", _view));
  14441. }
  14442. catch (Exception ex)
  14443. {
  14444. return Ok(JsonView(false, ex.Message));
  14445. }
  14446. }
  14447. /// <summary>
  14448. /// 根据黑屏代码重新生成行程
  14449. /// </summary>
  14450. /// <param name="dto"></param>
  14451. /// <returns></returns>
  14452. [HttpPost]
  14453. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14454. {
  14455. var jw = JsonView(false);
  14456. var Create = _GroupCostRepository.
  14457. CreateGroupCostByBlackCode(dto.Diid);
  14458. jw.Msg = Create.Msg;
  14459. if (Create.Code == 0)
  14460. {
  14461. jw.Code = 200;
  14462. jw.Data = new
  14463. {
  14464. groupCost = Create.Data,
  14465. blackCodeIsTrue = true
  14466. };
  14467. }
  14468. else
  14469. {
  14470. jw.Code = 400;
  14471. jw.Data = new
  14472. {
  14473. groupCost = Create.Data,
  14474. blackCodeIsTrue = false,
  14475. };
  14476. }
  14477. return Ok(jw);
  14478. }
  14479. /// <summary>
  14480. /// 成本获取OP历史车费用
  14481. /// </summary>
  14482. /// <param name="dto"></param>
  14483. /// <returns></returns>
  14484. [HttpPost]
  14485. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14486. {
  14487. var jw = JsonView(false);
  14488. try
  14489. {
  14490. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14491. //获取现有所有车的数据
  14492. if (!dto.Param.IsNullOrWhiteSpace())
  14493. {
  14494. string sql = $@"
  14495. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14496. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14497. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14498. 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
  14499. AND gctggr.ServiceEndTime is not NULL
  14500. ORDER by gctggrc.id DESC
  14501. ";
  14502. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14503. var numeberResult = await Task.Run(() =>
  14504. {
  14505. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14506. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14507. return numberArr;
  14508. });
  14509. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14510. foreach (var item in numeberResult)
  14511. {
  14512. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14513. {
  14514. Country = "数据异常!",
  14515. City = string.Empty,
  14516. };
  14517. item.Area = find.Country + " " + find.City;
  14518. }
  14519. dbResult.AddRange(numeberResult);
  14520. if (dto.Param.Contains("、"))
  14521. {
  14522. var sp = dto.Param.Split("、");
  14523. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14524. .Where(x =>
  14525. {
  14526. return System.Array.Exists(sp, e =>
  14527. {
  14528. bool where = false;
  14529. if (x.Area != null)
  14530. {
  14531. where = x.Area.Contains(e);
  14532. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14533. {
  14534. return false;
  14535. }
  14536. }
  14537. if (x.PriceName != null && !where)
  14538. {
  14539. where = x.PriceName.Contains(e);
  14540. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14541. {
  14542. return false;
  14543. }
  14544. }
  14545. return where;
  14546. });
  14547. }).ToList();
  14548. }
  14549. else
  14550. {
  14551. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14552. .Where(x =>
  14553. {
  14554. bool where = false;
  14555. if (x.Area != null)
  14556. {
  14557. where = x.Area.Contains(dto.Param);
  14558. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14559. {
  14560. return false;
  14561. }
  14562. }
  14563. if (x.PriceName != null && !where)
  14564. {
  14565. where = x.PriceName.Contains(dto.Param);
  14566. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14567. {
  14568. return false;
  14569. }
  14570. }
  14571. return where;
  14572. }
  14573. )
  14574. .ToList();
  14575. }
  14576. }
  14577. var view = dbResult.Select(x =>
  14578. {
  14579. decimal dp = 0.00M;
  14580. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14581. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14582. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14583. {
  14584. if (startB && endB)
  14585. {
  14586. var timesp = endD.Subtract(startD);
  14587. if ((timesp.Days + 1) != 0)
  14588. {
  14589. dp = x.Price / (timesp.Days + 1);
  14590. }
  14591. }
  14592. }
  14593. else
  14594. {
  14595. dp = x.Price;
  14596. }
  14597. return new
  14598. {
  14599. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14600. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14601. x.Area,
  14602. x.id,
  14603. price = x.Price.ToString("F2"),
  14604. x.PriceName,
  14605. x.PriceContent,
  14606. x.TeamName,
  14607. x.DatePrice,
  14608. dayPrice = dp.ToString("F2"),
  14609. };
  14610. }).OrderByDescending(x => x.id).ToList();
  14611. jw = JsonView(true, "获取成功!", view);
  14612. }
  14613. catch (Exception e)
  14614. {
  14615. jw = JsonView(false, e.Message);
  14616. }
  14617. return Ok(jw);
  14618. }
  14619. #endregion
  14620. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14621. /// <summary>
  14622. /// 酒店预订
  14623. /// 酒店费用列表 根据团组Id查询
  14624. /// </summary>
  14625. /// <param name="_dto"></param>
  14626. /// <returns></returns>
  14627. [HttpPost]
  14628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14629. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14630. {
  14631. #region 参数验证
  14632. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14633. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14634. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14635. #region 团组操作权限验证 76 酒店预定模块
  14636. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14637. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14638. #endregion
  14639. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14640. #region 页面操作权限验证
  14641. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14642. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14643. #endregion
  14644. #endregion
  14645. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14646. }
  14647. /// <summary>
  14648. /// 酒店预订
  14649. /// 基础数据
  14650. /// </summary>
  14651. /// <param name="_dto"></param>
  14652. /// <returns></returns>
  14653. [HttpPost]
  14654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14655. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14656. {
  14657. #region 参数验证
  14658. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14659. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14660. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14661. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14662. #region 页面操作权限验证
  14663. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14664. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14665. #endregion
  14666. #region 团组操作权限验证 76 酒店预定模块
  14667. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14668. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14669. #endregion
  14670. #endregion
  14671. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14672. }
  14673. /// <summary>
  14674. /// 酒店预订
  14675. /// 创建 入住卷号码
  14676. /// </summary>
  14677. /// <param name="_dto"></param>
  14678. /// <returns></returns>
  14679. [HttpPost]
  14680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14681. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14682. {
  14683. #region 参数验证
  14684. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14685. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14686. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14687. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14688. #region 页面操作权限验证
  14689. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14690. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14691. #endregion
  14692. #region 团组操作权限验证 76 酒店预定模块
  14693. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14694. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14695. #endregion
  14696. #endregion
  14697. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14698. if (data.Code != 0)
  14699. {
  14700. return Ok(JsonView(false, data.Msg));
  14701. }
  14702. return Ok(JsonView(true, data.Msg, data.Data));
  14703. }
  14704. /// <summary>
  14705. /// 酒店预订
  14706. /// 详情
  14707. /// </summary>
  14708. /// <param name="_dto"></param>
  14709. /// <returns></returns>
  14710. [HttpPost]
  14711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14712. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14713. {
  14714. #region 参数验证
  14715. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14716. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14717. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14718. #region 团组操作权限验证 76 酒店预定模块
  14719. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14720. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14721. #endregion
  14722. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14723. #region 页面操作权限验证
  14724. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14725. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14726. #endregion
  14727. #endregion
  14728. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14729. }
  14730. /// <summary>
  14731. /// 酒店预订
  14732. /// Add Or Edit
  14733. /// </summary>
  14734. /// <param name="_dto"></param>
  14735. /// <returns></returns>
  14736. [HttpPost]
  14737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14738. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14739. {
  14740. #region 参数验证
  14741. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14742. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14743. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14744. #region 团组操作权限验证 76 酒店预定模块
  14745. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14746. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14747. #endregion
  14748. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14749. #region 页面操作权限验证
  14750. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14751. if (_dto.Id == 0) // Add
  14752. {
  14753. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14754. }
  14755. else if (_dto.Id > 1) // Edit
  14756. {
  14757. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14758. }
  14759. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14760. #endregion
  14761. #endregion
  14762. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14763. if (_view.Code != 200)
  14764. {
  14765. return Ok(_view);
  14766. }
  14767. #region 成本无酒店价格数据进入超支
  14768. _sqlSugar.BeginTran();
  14769. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14770. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14771. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14772. for (int i = 0; i < groupCost.Count; i++)
  14773. {
  14774. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14775. {
  14776. groupCost[i].Date = groupCost[i - 1].Date;
  14777. }
  14778. }
  14779. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14780. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14781. List<Fin_GroupExtraCostDto_OP>();
  14782. if (start_Bool && end_Bool)
  14783. {
  14784. while (start_Time < end_Time)
  14785. {
  14786. foreach (var item in groupCost_Grp)
  14787. {
  14788. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14789. {
  14790. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14791. {
  14792. extraCostList.Add(new
  14793. Fin_GroupExtraCostDto_OP
  14794. {
  14795. Area = _dto.AreaId,
  14796. coefficient = 1.5M,
  14797. createUser = _dto.UserId,
  14798. currency = _dto.CardPriceCurrency,
  14799. diId = _dto.DiId,
  14800. ManagerConfirm = 0,
  14801. SupervisorConfirm = 0,
  14802. SYsupervisorConfirm = 0,
  14803. editType = 1,
  14804. PortType = 1,
  14805. price = _dto.CardPrice,
  14806. PriceCount = 1,
  14807. priceType = 1027,
  14808. priceDetailType = 1044,
  14809. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14810. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14811. });
  14812. }
  14813. }
  14814. }
  14815. start_Time = start_Time.AddDays(1);
  14816. }
  14817. }
  14818. if (extraCostList.Any())
  14819. {
  14820. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14821. }
  14822. _sqlSugar.CommitTran();
  14823. #endregion
  14824. #region 应用推送
  14825. try
  14826. {
  14827. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14828. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14829. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14830. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14831. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14832. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14833. var diId = _dto.DiId;
  14834. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14835. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14836. #region 操作记录
  14837. var opInfo = new Crm_TableOperationRecord()
  14838. {
  14839. TableName = "Grp_HotelReservations",
  14840. PortType = _dto.PortType,
  14841. DataId = hotelId,
  14842. CreateUserId = _dto.UserId
  14843. };
  14844. //var opStatus = OperationEnum.NoOperation;
  14845. if (_dto.Id < 1) //添加操作
  14846. {
  14847. opInfo.OperationItem = OperationEnum.Add;
  14848. }
  14849. else if (_dto.Id > 0)
  14850. {
  14851. opInfo.OperationItem = OperationEnum.Edit;
  14852. }
  14853. string opRemark = string.Empty;
  14854. if (ccpInfo != null)
  14855. {
  14856. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14857. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14858. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14859. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14860. }
  14861. opInfo.Remark = opRemark;
  14862. await _tableorRep.AddAsync(opInfo);
  14863. #endregion
  14864. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14865. //2024-10-21 新增LZ UID
  14866. var userIds = new List<int>() { 21 };
  14867. string title = $"费用审核";
  14868. string content = "";
  14869. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14870. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14871. try
  14872. {
  14873. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14874. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14875. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14876. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14877. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14878. }
  14879. catch (Exception ex)
  14880. {
  14881. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14882. }
  14883. }
  14884. catch (Exception ex)
  14885. {
  14886. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14887. }
  14888. try
  14889. {
  14890. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14891. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14892. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14893. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14894. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14895. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14896. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14897. //自动审核
  14898. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14899. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14900. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14901. //2024-10-21 新增LZ UID
  14902. var userIds = new List<int>() { 21 };
  14903. string title = $"系统通知";
  14904. var diId = _dto.DiId;
  14905. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14906. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14907. string content = "";
  14908. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14909. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14910. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14911. }
  14912. catch (Exception ex)
  14913. {
  14914. }
  14915. #endregion
  14916. return Ok(_view);
  14917. }
  14918. /// <summary>
  14919. /// 酒店自动审核测试
  14920. /// Add Or Edit
  14921. /// </summary>
  14922. /// <param name="diid"></param>
  14923. /// <param name="dataId"></param>
  14924. /// <returns></returns>
  14925. [HttpPost]
  14926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14927. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14928. {
  14929. #region 应用推送
  14930. try
  14931. {
  14932. //自动审核
  14933. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14934. }
  14935. catch (Exception ex)
  14936. {
  14937. return Ok(JsonView(false, "操作失败"));
  14938. }
  14939. #endregion
  14940. return Ok(JsonView(false, "操作成功"));
  14941. }
  14942. /// <summary>
  14943. /// 酒店预订
  14944. /// Del
  14945. /// </summary>
  14946. /// <param name="_dto"></param>
  14947. /// <returns></returns>
  14948. [HttpPost]
  14949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14950. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14951. {
  14952. #region 参数验证
  14953. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14954. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14955. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14956. #region 团组操作权限验证 76 酒店预定模块
  14957. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14958. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14959. #endregion
  14960. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14961. #region 页面操作权限验证
  14962. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14963. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14964. #endregion
  14965. #endregion
  14966. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14967. #region 操作记录
  14968. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14969. {
  14970. TableName = "Grp_HotelReservations",
  14971. PortType = _dto.PortType,
  14972. OperationItem = OperationEnum.Del,
  14973. DataId = _dto.Id,
  14974. CreateUserId = _dto.UserId
  14975. });
  14976. #endregion
  14977. return Ok(data);
  14978. }
  14979. /// <summary>
  14980. /// 酒店预订
  14981. /// 生成VOUCHER
  14982. /// 2024.05.06 之前版本
  14983. /// </summary>
  14984. /// <param name="_dto"></param>
  14985. /// <returns></returns>
  14986. [HttpPost]
  14987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14988. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14989. {
  14990. try
  14991. {
  14992. #region 参数验证
  14993. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14994. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14995. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14996. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14997. #region 团组操作权限验证 76 酒店预定模块
  14998. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14999. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15000. #endregion
  15001. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15002. #region 页面操作权限验证
  15003. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15004. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15005. #endregion
  15006. #endregion
  15007. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  15008. //判断数据是否完整
  15009. if (hr != null)
  15010. {
  15011. if (!string.IsNullOrEmpty(hr.DetermineNo))
  15012. {
  15013. string strFileName = "HotelStatement/";
  15014. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15015. if (dele != null)
  15016. strFileName += dele.TourCode;
  15017. //载入模板
  15018. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  15019. Document doc = new Document(sss);
  15020. DocumentBuilder builder = new DocumentBuilder(doc);
  15021. #region 替换Word模板书签内容
  15022. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  15023. //入住卷预定号码
  15024. if (doc.Range.Bookmarks["VNO"] != null)
  15025. {
  15026. Bookmark mark = doc.Range.Bookmarks["VNO"];
  15027. mark.Text = hr.CheckNumber;
  15028. }
  15029. //酒店时间
  15030. if (doc.Range.Bookmarks["Date"] != null)
  15031. {
  15032. Bookmark mark = doc.Range.Bookmarks["Date"];
  15033. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  15034. }
  15035. //团号
  15036. if (doc.Range.Bookmarks["TNo"] != null)
  15037. {
  15038. Bookmark mark = doc.Range.Bookmarks["TNo"];
  15039. mark.Text = dele.TourCode;
  15040. }
  15041. //预定号码
  15042. if (doc.Range.Bookmarks["BookingId"] != null)
  15043. {
  15044. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  15045. mark.Text = hr.ReservationsNo;
  15046. }
  15047. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  15048. {
  15049. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  15050. mark.Text = hr.DetermineNo;
  15051. }
  15052. //酒店城市
  15053. if (doc.Range.Bookmarks["City"] != null)
  15054. {
  15055. Bookmark mark = doc.Range.Bookmarks["City"];
  15056. mark.Text = hr.City;
  15057. }
  15058. //酒店名称
  15059. if (doc.Range.Bookmarks["HName"] != null)
  15060. {
  15061. Bookmark mark = doc.Range.Bookmarks["HName"];
  15062. mark.Text = hr.HotelName;
  15063. }
  15064. //酒店地址
  15065. if (doc.Range.Bookmarks["Address"] != null)
  15066. {
  15067. Bookmark mark = doc.Range.Bookmarks["Address"];
  15068. mark.Text = hr.HotelAddress;
  15069. }
  15070. //酒店电话
  15071. if (doc.Range.Bookmarks["Tel"] != null)
  15072. {
  15073. Bookmark mark = doc.Range.Bookmarks["Tel"];
  15074. mark.Text = hr.HotelTel;
  15075. }
  15076. //酒店传真
  15077. if (doc.Range.Bookmarks["Fax"] != null)
  15078. {
  15079. Bookmark mark = doc.Range.Bookmarks["Fax"];
  15080. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  15081. {
  15082. mark.Text = hr.HotelFax;
  15083. }
  15084. }
  15085. //入住时间
  15086. if (doc.Range.Bookmarks["CIn"] != null)
  15087. {
  15088. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  15089. Bookmark mark = doc.Range.Bookmarks["CIn"];
  15090. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  15091. }
  15092. //退房时间
  15093. if (doc.Range.Bookmarks["COut"] != null)
  15094. {
  15095. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  15096. Bookmark mark = doc.Range.Bookmarks["COut"];
  15097. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  15098. }
  15099. //客户名称
  15100. if (doc.Range.Bookmarks["GName"] != null)
  15101. {
  15102. string guestName = "";
  15103. string[] clients = new string[] { };
  15104. if (hr.GuestName.Contains(","))
  15105. {
  15106. clients = hr.GuestName.Split(",");
  15107. }
  15108. else
  15109. {
  15110. clients = new string[] { hr.GuestName };
  15111. }
  15112. List<int> clientIds_int = new List<int>();
  15113. if (clients.Length > 0)
  15114. {
  15115. foreach (var item in clients)
  15116. {
  15117. if (item.IsNumeric())
  15118. {
  15119. clientIds_int.Add(int.Parse(item));
  15120. }
  15121. }
  15122. }
  15123. if (clientIds_int.Count > 0)
  15124. {
  15125. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  15126. foreach (var client in _clientDatas)
  15127. {
  15128. //男
  15129. if (client.Sex == 0) guestName += $"Mr.";
  15130. //女
  15131. else if (client.Sex == 1) guestName += $"Ms.";
  15132. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  15133. {
  15134. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  15135. }
  15136. //guestName += $"{client.Pinyin},";
  15137. }
  15138. if (guestName.Length > 0)
  15139. {
  15140. guestName = guestName.Substring(0, guestName.Length - 1);
  15141. }
  15142. }
  15143. else
  15144. {
  15145. guestName = hr.GuestName;
  15146. }
  15147. Bookmark mark = doc.Range.Bookmarks["GName"];
  15148. mark.Text = guestName;
  15149. }
  15150. //房间介绍
  15151. if (doc.Range.Bookmarks["ROOM"] != null)
  15152. {
  15153. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  15154. mark.Text = hr.RoomExplanation;
  15155. }
  15156. //报价描述
  15157. if (doc.Range.Bookmarks["NOTE"] != null)
  15158. {
  15159. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  15160. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  15161. if (ss != null)
  15162. mark.Text = ss.Name;
  15163. }
  15164. //入住时间
  15165. if (doc.Range.Bookmarks["CheckIn"] != null)
  15166. {
  15167. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  15168. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  15169. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15170. }
  15171. //退房时间
  15172. if (doc.Range.Bookmarks["CheckOut"] != null)
  15173. {
  15174. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  15175. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  15176. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  15177. }
  15178. //日期
  15179. if (doc.Range.Bookmarks["DT"] != null)
  15180. {
  15181. Bookmark mark = doc.Range.Bookmarks["DT"];
  15182. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  15183. }
  15184. //名称
  15185. if (doc.Range.Bookmarks["VName"] != null)
  15186. {
  15187. Bookmark mark = doc.Range.Bookmarks["VName"];
  15188. mark.Text = hr.HotelName;
  15189. }
  15190. //号码
  15191. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  15192. {
  15193. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  15194. mark.Text = hr.CheckNumber;
  15195. }
  15196. #endregion
  15197. strFileName += "VOUCHER.doc";
  15198. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15199. doc.Save(fileDir);
  15200. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15201. return Ok(JsonView(true, "操作成功!", Url));
  15202. }
  15203. else
  15204. {
  15205. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  15206. }
  15207. }
  15208. else
  15209. {
  15210. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  15211. }
  15212. }
  15213. catch (Exception ex)
  15214. {
  15215. return Ok(JsonView(false, ex.Message));
  15216. }
  15217. }
  15218. /// <summary>
  15219. /// 酒店预订
  15220. /// 生成VOUCHER
  15221. /// 2024.05.06 之后版本
  15222. /// </summary>
  15223. /// <param name="_dto"></param>
  15224. /// <returns></returns>
  15225. [HttpPost]
  15226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15227. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  15228. {
  15229. #region 参数验证
  15230. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15231. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15232. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15233. #region 团组操作权限验证 76 酒店预定模块
  15234. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15235. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15236. #endregion
  15237. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15238. #region 页面操作权限验证
  15239. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15240. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15241. #endregion
  15242. #endregion
  15243. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  15244. //判断数据是否完整
  15245. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15246. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15247. string strFileName = "HotelStatement/";
  15248. string guestNames = ""; //格式Mr.xxx Ms.xxx
  15249. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  15250. #region 数据处理
  15251. List<int> guestIds = new List<int>();
  15252. //int index = 0;
  15253. foreach (var item in hrDtas)
  15254. {
  15255. if (item.GuestName.Contains(","))
  15256. {
  15257. string[] guestIdArr = item.GuestName.Split(',');
  15258. foreach (var guestIdStr in guestIdArr)
  15259. {
  15260. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  15261. if (guestBool)
  15262. {
  15263. guestIds.Add(guestId);
  15264. }
  15265. }
  15266. }
  15267. else guestNames += item.GuestName;
  15268. var voucherInfo = new HotelVoucherInfoView()
  15269. {
  15270. HotelName = item.HotelName,
  15271. CheckInDate = item.CheckInDate,
  15272. CheckOutDate = item.CheckOutDate,
  15273. ConfirmationNumber = item.DetermineNo.Trim(),
  15274. RoomType = item.RoomExplanation
  15275. };
  15276. vouchers.Add(voucherInfo);
  15277. }
  15278. if (guestIds.Count > 0)
  15279. {
  15280. guestIds = guestIds.Distinct().ToList();
  15281. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  15282. if (guestDatas.Count > 0)
  15283. {
  15284. guestNames = "";
  15285. foreach (var guest in guestDatas)
  15286. {
  15287. string guestName = "";
  15288. if (guest.Sex == 0) guestName += @"MR.";
  15289. else if (guest.Sex == 1) guestName += @"MS.";
  15290. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15291. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15292. guestNames += @$"{guestName.Trim()}、";
  15293. }
  15294. if (guestNames.Length > 0)
  15295. {
  15296. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15297. }
  15298. }
  15299. }
  15300. #endregion
  15301. //载入模板
  15302. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  15303. Document doc = new Document(sss);
  15304. DocumentBuilder builder = new DocumentBuilder(doc);
  15305. if (doc.Range.Bookmarks["GuestName"] != null)
  15306. {
  15307. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  15308. mark.Text = guestNames;
  15309. }
  15310. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15311. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  15312. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  15313. for (int i = 1; i <= vouchers.Count; i++)
  15314. {
  15315. HotelVoucherInfoView hviv = vouchers[i - 1];
  15316. builder.MoveToCell(0, i, 0, 0);
  15317. builder.Write(hviv.HotelName);
  15318. builder.MoveToCell(0, i, 1, 0);
  15319. builder.Write(hviv.CheckInDate);
  15320. builder.MoveToCell(0, i, 2, 0);
  15321. builder.Write(hviv.CheckOutDate);
  15322. builder.MoveToCell(0, i, 3, 0);
  15323. builder.Write(hviv.RoomType);
  15324. builder.MoveToCell(0, i, 4, 0);
  15325. builder.Write(hviv.ConfirmationNumber);
  15326. }
  15327. //删除多余行
  15328. int currRowIndex = vouchers.Count + 1;
  15329. int delRows = 21 - currRowIndex;
  15330. if (delRows > 0)
  15331. {
  15332. for (int i = 0; i < delRows; i++)
  15333. {
  15334. table.Rows.RemoveAt(currRowIndex);
  15335. //cultivateRowIndex++;
  15336. }
  15337. }
  15338. strFileName += "VOUCHER.docx";
  15339. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15340. doc.Save(fileDir);
  15341. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15342. return Ok(JsonView(true, "操作成功!", Url));
  15343. }
  15344. /// <summary>
  15345. /// 酒店预订
  15346. /// 生成VOUCHER 批量生成
  15347. /// New
  15348. /// </summary>
  15349. /// <param name="_dto"></param>
  15350. /// <returns></returns>
  15351. [HttpPost]
  15352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15353. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15354. {
  15355. #region 参数验证
  15356. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15357. if (_dto.PageId < 1) _dto.PageId = 28;
  15358. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15359. #region 团组操作权限验证 76 酒店预定模块
  15360. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15361. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15362. #endregion
  15363. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15364. #region 页面操作权限验证
  15365. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15366. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15367. #endregion
  15368. #endregion
  15369. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15370. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15371. .OrderBy(x => x.CheckInDate)
  15372. .ToListAsync();
  15373. //判断数据是否完整
  15374. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15375. string strFileName = "HotelStatement/";
  15376. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15377. if (dele != null)
  15378. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15379. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15380. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15381. .Where(it => it.IsDel == 0)
  15382. .ToListAsync();
  15383. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15384. for (int i = 0; i < hrDtas.Count; i++)
  15385. {
  15386. string guestNames = string.Empty;
  15387. List<int> guestIds = new List<int>();
  15388. var item = hrDtas[i];
  15389. //处理客户姓名
  15390. if (item.GuestName.Contains(","))
  15391. {
  15392. string[] guestIdArr = item.GuestName.Split(',');
  15393. foreach (var guestIdStr in guestIdArr)
  15394. if (int.TryParse(guestIdStr, out int guestId))
  15395. guestIds.Add(guestId);
  15396. }
  15397. else
  15398. {
  15399. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15400. if (guestIdBool)
  15401. {
  15402. guestIds.Add(guestId);
  15403. }
  15404. //NaN
  15405. if (item.GuestName.Contains("NaN"))
  15406. {
  15407. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15408. }
  15409. }
  15410. if (guestIds.Count > 0)
  15411. {
  15412. guestIds = guestIds.Distinct().ToList();
  15413. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15414. if (guestDatas1.Count > 0)
  15415. {
  15416. guestNames = "";
  15417. foreach (var guest in guestDatas1)
  15418. {
  15419. string guestName = "";
  15420. if (guest.Sex == 0) guestName += @"MR.";
  15421. else if (guest.Sex == 1) guestName += @"MS.";
  15422. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15423. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15424. guestNames += @$"{guestName.Trim()}、";
  15425. }
  15426. if (guestNames.Length > 0)
  15427. {
  15428. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15429. }
  15430. }
  15431. }
  15432. //if (!string.IsNullOrEmpty(guestNames))
  15433. //{
  15434. hrDtas[i].GuestName = guestNames;
  15435. //}
  15436. }
  15437. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15438. Document doc = new Document();
  15439. DocumentBuilder builder = new DocumentBuilder(doc);
  15440. try
  15441. {
  15442. builder.MoveToDocumentStart();
  15443. foreach (var item in hrDtas)
  15444. {
  15445. //标题
  15446. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15447. builder.ParagraphFormat.LineSpacing = 1;
  15448. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15449. builder.ParagraphFormat.Style.Font.Size = 9;
  15450. builder.ParagraphFormat.Style.Font.Bold = true;
  15451. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15452. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15453. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15454. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15455. builder.ParagraphFormat.LineSpacing = 1;
  15456. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15457. builder.ParagraphFormat.Style.Font.Size = 9;
  15458. builder.ParagraphFormat.Style.Font.Bold = true;
  15459. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15460. builder.StartTable();
  15461. // 设置边框颜色
  15462. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15463. //设置边框样式
  15464. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15465. //表格
  15466. #region 第一行
  15467. builder.InsertCell();
  15468. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15469. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15470. //builder.CellFormat.AllowAutoFit = false;
  15471. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15472. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15473. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15474. builder.CellFormat.WrapText = true; //自动换行
  15475. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15476. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15477. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15478. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15479. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15480. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15481. builder.Write("TOUR NO:");
  15482. builder.InsertCell();
  15483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15484. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15485. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15486. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15487. builder.ParagraphFormat.Style.Font.Bold = false;
  15488. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15489. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15490. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15491. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15492. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15493. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15494. builder.Write($"{dele?.TourCode ?? "-"}");
  15495. builder.InsertCell();
  15496. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15497. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15498. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15499. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15500. builder.ParagraphFormat.Style.Font.Bold = false;
  15501. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15502. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15503. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15504. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15505. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15506. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15507. builder.Write($"CITY:");
  15508. builder.InsertCell();
  15509. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15510. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15511. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15512. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15513. builder.ParagraphFormat.Style.Font.Bold = false;
  15514. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15515. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15516. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15517. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15518. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15519. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15520. builder.Write($"{item.City}");
  15521. builder.EndRow();
  15522. #endregion
  15523. #region 第二行
  15524. builder.InsertCell();
  15525. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15526. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15527. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15528. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15529. builder.ParagraphFormat.Style.Font.Bold = false;
  15530. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15531. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15532. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15533. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15534. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15535. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15536. builder.Write("CONFIRMATION NO:");
  15537. builder.InsertCell();
  15538. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15539. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15540. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15541. builder.ParagraphFormat.Style.Font.Bold = false;
  15542. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15543. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15544. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15545. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15546. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15547. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15548. builder.CellFormat.VerticalMerge = CellMerge.None;
  15549. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15550. builder.Write($"{item.DetermineNo}");
  15551. builder.InsertCell();
  15552. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15553. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15554. builder.InsertCell();
  15555. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15556. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15557. builder.EndRow();
  15558. #endregion
  15559. #region 第三行
  15560. builder.InsertCell();
  15561. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15562. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15563. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15564. builder.ParagraphFormat.Style.Font.Bold = false;
  15565. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15566. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15567. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15568. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15569. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15570. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15571. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15572. builder.Write($"HOTEL NAME:");
  15573. builder.InsertCell();
  15574. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15575. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15576. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15577. builder.ParagraphFormat.Style.Font.Bold = false;
  15578. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15579. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15580. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15581. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15582. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15583. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15584. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15585. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15586. builder.Write($"{item.HotelName}");
  15587. builder.InsertCell();
  15588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15589. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15590. builder.InsertCell();
  15591. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15592. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15593. builder.EndRow();
  15594. #endregion
  15595. #region 第四行
  15596. builder.InsertCell();
  15597. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15598. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15599. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15600. builder.ParagraphFormat.Style.Font.Bold = false;
  15601. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15602. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15603. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15604. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15605. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15606. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15607. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15608. builder.Write($"HOTEL ADDRESS:");
  15609. builder.InsertCell();
  15610. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15611. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15612. builder.ParagraphFormat.Style.Font.Size = 8;
  15613. builder.ParagraphFormat.Style.Font.Bold = false;
  15614. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15615. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15616. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15617. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15618. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15619. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15620. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15621. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15622. builder.Write($"{item.HotelAddress}");
  15623. builder.InsertCell();
  15624. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15625. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15626. builder.InsertCell();
  15627. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15628. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15629. builder.EndRow();
  15630. #endregion
  15631. #region 第五行
  15632. builder.InsertCell();
  15633. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15634. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15635. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15636. builder.ParagraphFormat.Style.Font.Bold = false;
  15637. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15638. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15639. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15640. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15641. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15642. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15643. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15644. builder.Write("TEL:");
  15645. builder.InsertCell();
  15646. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15647. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15648. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15649. builder.ParagraphFormat.Style.Font.Bold = false;
  15650. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15651. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15652. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15653. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15654. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15655. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15656. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15657. builder.Write($"{item.HotelTel}");
  15658. builder.InsertCell();
  15659. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15660. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15661. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15662. builder.ParagraphFormat.Style.Font.Bold = false;
  15663. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15664. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15665. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15666. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15667. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15668. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15669. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15670. builder.Write($"FAX:");
  15671. builder.InsertCell();
  15672. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15673. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15674. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15675. builder.ParagraphFormat.Style.Font.Bold = false;
  15676. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15677. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15678. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15679. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15680. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15681. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15682. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15683. builder.Write($"{item.HotelFax}");
  15684. builder.EndRow();
  15685. #endregion
  15686. #region 第六行
  15687. builder.InsertCell();
  15688. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15689. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15690. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15691. builder.ParagraphFormat.Style.Font.Bold = false;
  15692. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15693. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15694. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15695. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15696. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15697. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15698. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15699. builder.Write("CHECK IN:");
  15700. builder.InsertCell();
  15701. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15702. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15703. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15704. builder.ParagraphFormat.Style.Font.Bold = false;
  15705. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15706. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15707. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15708. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15709. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15710. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15711. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15712. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15713. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15714. builder.Write($"{checkInStr}");
  15715. builder.InsertCell();
  15716. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15717. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15718. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15719. builder.ParagraphFormat.Style.Font.Bold = false;
  15720. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15721. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15722. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15723. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15724. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15725. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15726. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15727. builder.Write($"CHECK OUT:");
  15728. builder.InsertCell();
  15729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15730. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15731. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15732. builder.ParagraphFormat.Style.Font.Bold = false;
  15733. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15734. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15735. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15736. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15737. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15738. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15739. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15740. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15741. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15742. builder.Write($"{checkOutStr}");
  15743. builder.EndRow();
  15744. #endregion
  15745. #region 第七行
  15746. builder.InsertCell();
  15747. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15748. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15749. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15750. builder.ParagraphFormat.Style.Font.Bold = false;
  15751. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15752. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15753. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15754. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15755. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15756. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15757. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15758. builder.Write($"GUEST NAME:");
  15759. builder.InsertCell();
  15760. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15761. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15762. builder.ParagraphFormat.Style.Font.Size = 8;
  15763. builder.ParagraphFormat.Style.Font.Bold = false;
  15764. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15765. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15766. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15767. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15768. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15769. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15770. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15771. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15772. builder.Write($"{item.GuestName}");
  15773. builder.InsertCell();
  15774. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15775. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15776. builder.InsertCell();
  15777. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15778. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15779. builder.EndRow();
  15780. #endregion
  15781. #region 第八行
  15782. builder.InsertCell();
  15783. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15784. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15785. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15786. builder.ParagraphFormat.Style.Font.Bold = false;
  15787. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15788. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15789. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15790. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15791. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15792. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15793. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15794. builder.Write($"ROOM TYPE:");
  15795. builder.InsertCell();
  15796. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15797. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15798. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15799. builder.ParagraphFormat.Style.Font.Bold = false;
  15800. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15801. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15802. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15803. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15804. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15805. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15806. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15807. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15808. builder.Write($"{item.RoomExplanation}");
  15809. builder.InsertCell();
  15810. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15811. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15812. builder.InsertCell();
  15813. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15814. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15815. builder.EndRow();
  15816. #endregion
  15817. #region 第九行
  15818. builder.InsertCell();
  15819. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15820. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15821. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15822. builder.ParagraphFormat.Style.Font.Bold = false;
  15823. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15824. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15825. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15826. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15827. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15828. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15829. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15830. builder.Write($"NOTE:");
  15831. builder.InsertCell();
  15832. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15833. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15834. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15835. builder.ParagraphFormat.Style.Font.Bold = false;
  15836. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15837. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15838. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15839. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15840. 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.");
  15841. builder.InsertCell();
  15842. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15843. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15844. builder.InsertCell();
  15845. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15846. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15847. builder.EndRow();
  15848. #endregion
  15849. builder.EndTable();
  15850. //换行
  15851. builder.Writeln("");
  15852. builder.Writeln("");
  15853. }
  15854. #region 获取文档中的所有表格 设置文字自适应
  15855. // 获取文档中的所有表格。
  15856. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15857. {
  15858. // 遍历表格中的所有行。
  15859. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15860. {
  15861. foreach (Cell cell in row.Cells)
  15862. {
  15863. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15864. cellFormat.Width = 0;
  15865. }
  15866. }
  15867. }
  15868. #endregion
  15869. #region 设置页眉
  15870. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15871. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15872. if (System.IO.File.Exists(voucherHeaderPath))
  15873. {
  15874. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15875. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15876. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15877. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  15878. // 调整图片位置
  15879. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15880. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15881. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15882. shape.Left = 0; // 将图片距离页面左边缘的距离
  15883. shape.Width = 81; // 设置图片宽度
  15884. shape.Height = 36; // 设置图片高度
  15885. }
  15886. //靠右
  15887. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15888. //// 设置页脚上下边距
  15889. //builder.PageSetup.HeaderDistance = 42;
  15890. // 添加页眉线
  15891. Aspose.Words.Border borderHeader = null;
  15892. try
  15893. {
  15894. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15895. }
  15896. catch (Exception e)
  15897. {
  15898. // TODO Auto-generated catch block
  15899. //e.printStackTrace();
  15900. }
  15901. borderHeader.Shadow = true;
  15902. borderHeader.DistanceFromText = 2;
  15903. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15904. #endregion
  15905. }
  15906. catch (Exception ex)
  15907. {
  15908. }
  15909. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15910. doc.Save(fileDir);
  15911. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15912. return Ok(JsonView(true, "操作成功!", Url));
  15913. }
  15914. /// <summary>
  15915. /// 酒店预订
  15916. /// 生成 预定成本 Excel
  15917. /// </summary>
  15918. /// <param name="_dto"></param>
  15919. /// <returns></returns>
  15920. [HttpPost]
  15921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15922. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15923. {
  15924. #region 参数验证
  15925. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15926. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15927. if (!vadalitorRes.IsValid)
  15928. {
  15929. var errors = new StringBuilder();
  15930. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15931. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15932. }
  15933. #region 团组操作权限验证 76 酒店预定模块
  15934. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15935. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15936. #endregion
  15937. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15938. #region 页面操作权限验证
  15939. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15940. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15941. #endregion
  15942. #endregion
  15943. decimal _rate = 1.00M;
  15944. string _currency = string.Empty;
  15945. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15946. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15947. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15948. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15949. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15950. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15951. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15952. if (_GroupCostParameter == null)
  15953. {
  15954. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15955. bool isIntType = int.TryParse(_currency, out int currId);
  15956. if (isIntType)
  15957. {
  15958. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15959. }
  15960. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15961. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15962. if (currInfo == null)
  15963. {
  15964. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15965. }
  15966. else _rate = currInfo.Rate;
  15967. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15968. {
  15969. _rate = _GroupCostParameter.Rate;
  15970. }
  15971. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15972. //string strFileName = "HotelStatement/";
  15973. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15974. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15975. var rateDatas = new List<dynamic>();
  15976. #region 数据处理
  15977. foreach (var item in hrDtas)
  15978. {
  15979. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15980. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15981. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15982. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15983. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15984. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15985. {
  15986. continue;
  15987. }
  15988. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15989. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15990. string singleRoomFeeStr = string.Empty,
  15991. doubleRoomFeeStr = string.Empty,
  15992. suiteRoomFeeStr = string.Empty,
  15993. otherRoomFeeStr = string.Empty,
  15994. payMoneyStr = string.Empty,
  15995. cardPriceStr = string.Empty;
  15996. if (roomCurr.Equals("CNY"))
  15997. {
  15998. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15999. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16000. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16001. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16002. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16003. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  16004. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  16005. }
  16006. else
  16007. {
  16008. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16009. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16010. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16011. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16012. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16013. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16014. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16015. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16016. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16017. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16018. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  16019. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  16020. if (ccpPaymentCurrency.Equals("CNY"))
  16021. {
  16022. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  16023. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16024. }
  16025. else
  16026. {
  16027. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  16028. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  16029. }
  16030. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  16031. if (hotelcardPriceCurrency.Equals("CNY"))
  16032. {
  16033. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16034. }
  16035. else
  16036. {
  16037. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  16038. }
  16039. }
  16040. string breakfastPriceStr = string.Empty,
  16041. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  16042. governmentRentStr = string.Empty,
  16043. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  16044. cityTaxStr = string.Empty,
  16045. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16046. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  16047. if (!string.IsNullOrEmpty(breakfastCurrency1))
  16048. {
  16049. if (breakfastCurrency1.Equals("CNY"))
  16050. {
  16051. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  16052. }
  16053. else
  16054. {
  16055. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  16056. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  16057. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  16058. }
  16059. }
  16060. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  16061. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  16062. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  16063. {
  16064. if (governmentRentCurrency.Equals("CNY"))
  16065. {
  16066. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  16067. }
  16068. else
  16069. {
  16070. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  16071. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  16072. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  16073. }
  16074. }
  16075. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  16076. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  16077. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  16078. {
  16079. if (cityTaxStrCurrency1.Equals("CNY"))
  16080. {
  16081. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  16082. }
  16083. else
  16084. {
  16085. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  16086. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  16087. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  16088. }
  16089. }
  16090. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  16091. int payDId = roomInfo?.PayDId ?? 0;
  16092. pcfds.Add(new HotelReservations_PCFD_View()
  16093. {
  16094. City = item.City,
  16095. HotelName = item.HotelName,
  16096. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16097. // SingleRoomCount = item.SingleRoomCount,
  16098. SingleRoomPrice = singleRoomFeeStr,
  16099. // DoubleRoomCount = item.DoubleRoomCount,
  16100. DoubleRoomPrice = doubleRoomFeeStr,
  16101. //SuiteRoomCount = item.SuiteRoomCount,
  16102. SuiteRoomPrice = suiteRoomFeeStr,
  16103. OtherRoomPrice = otherRoomFeeStr,
  16104. //OtherRoomCount = item.OtherRoomCount,
  16105. BreakfastPrice = breakfastPriceStr,
  16106. GovernmentRent = governmentRentStr,
  16107. CityTax = cityTaxStr,
  16108. RoomExplanation = item.RoomExplanation,
  16109. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16110. PayTime = roomInfo?.ConsumptionDate,
  16111. BankNo = roomInfo?.BankNo,
  16112. PayMoney = payMoneyStr,
  16113. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16114. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16115. CardPrice = cardPriceStr,
  16116. Remark = ccpInfo.Remark
  16117. });
  16118. }
  16119. #endregion
  16120. //载入模板
  16121. WorkbookDesigner designer = new WorkbookDesigner();
  16122. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16123. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16124. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16125. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16126. var rateDatas1 = rateDatas.Distinct();
  16127. var rateStr = string.Empty;
  16128. foreach (var item in rateDatas1)
  16129. {
  16130. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  16131. }
  16132. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  16133. designer.SetDataSource("Opertor", userInfo.CnName);
  16134. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16135. dt.TableName = "ViewMyHotelReservations";
  16136. designer.SetDataSource(dt);
  16137. designer.Process();
  16138. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16139. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16140. designer.Workbook.Save(serverPath);
  16141. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16142. #region 删除指定行
  16143. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16144. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16145. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16146. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16147. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16148. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16149. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16150. cssIndex = dt.Columns["CityTax"].Ordinal,
  16151. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16152. remarkIndex = dt.Columns["Remark"].Ordinal;
  16153. //删除指定列
  16154. foreach (DataRow item in dt.Rows)
  16155. {
  16156. string singleStr = item["SingleRoomPrice"].ToString();
  16157. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16158. if (containsDigitButNotZero1) singleDel = false;
  16159. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16160. string doubleStr = item["DoubleRoomPrice"].ToString();
  16161. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16162. if (containsDigitButNotZero2) doubleDel = false;
  16163. string suiteStr = item["SuiteRoomPrice"].ToString();
  16164. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16165. if (containsDigitButNotZero3) suiteDel = false;
  16166. string otherStr = item["OtherRoomPrice"].ToString();
  16167. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16168. if (containsDigitButNotZero4) otherDel = false;
  16169. string zcStr = item["BreakfastPrice"].ToString();
  16170. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16171. if (containsDigitButNotZero5) zcDel = false;
  16172. string dsStr = item["GovernmentRent"].ToString();
  16173. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16174. if (containsDigitButNotZero6) dsDel = false;
  16175. string cssStr = item["CityTax"].ToString();
  16176. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16177. if (containsDigitButNotZero7) cssDel = false;
  16178. string cpStr = item["ConsumptionPatterns"].ToString();
  16179. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16180. string remarkStr = item["Remark"].ToString();
  16181. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16182. }
  16183. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16184. DeleteColumn(serverPath, cpIndex, cpDel);
  16185. DeleteColumn(serverPath, dsIndex, dsDel);
  16186. DeleteColumn(serverPath, cssIndex, cssDel);
  16187. DeleteColumn(serverPath, zcIndex, zcDel);
  16188. DeleteColumn(serverPath, otherIndex, otherDel);
  16189. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16190. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16191. DeleteColumn(serverPath, singleIndex, singleDel);
  16192. #endregion
  16193. //只保留第一个表格
  16194. DeleteSheet(serverPath);
  16195. return Ok(JsonView(true, "操作成功", url = rst));
  16196. }
  16197. else
  16198. {
  16199. _currency = _GroupCostParameter.Currency;
  16200. bool isIntType = int.TryParse(_currency, out int currId);
  16201. if (isIntType)
  16202. {
  16203. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16204. }
  16205. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16206. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16207. if (currInfo == null)
  16208. {
  16209. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16210. }
  16211. if (!_currency.ToUpper().Equals("CNY"))
  16212. {
  16213. _rate = _GroupCostParameter.Rate;
  16214. }
  16215. _rate = currInfo.Rate;
  16216. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16217. //string strFileName = "HotelStatement/";
  16218. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16219. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16220. #region 数据处理
  16221. foreach (var item in hrDtas)
  16222. {
  16223. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16224. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16225. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16226. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16227. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16228. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16229. string singleRoomFeeStr = string.Empty,
  16230. doubleRoomFeeStr = string.Empty,
  16231. suiteRoomFeeStr = string.Empty,
  16232. otherRoomFeeStr = string.Empty,
  16233. payMoneyStr = string.Empty,
  16234. cardPriceStr = string.Empty;
  16235. if (roomCurr.Equals(_currency))
  16236. {
  16237. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  16238. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  16239. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  16240. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  16241. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  16242. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  16243. }
  16244. else
  16245. {
  16246. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16247. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16248. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16249. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16250. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16251. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16252. }
  16253. string breakfastPriceStr = string.Empty,
  16254. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  16255. governmentRentStr = string.Empty,
  16256. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  16257. cityTaxStrStr = string.Empty,
  16258. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16259. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  16260. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  16261. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  16262. int payDId = roomInfo?.PayDId ?? 0;
  16263. pcfds.Add(new HotelReservations_PCFD_View()
  16264. {
  16265. City = item.City,
  16266. HotelName = item.HotelName,
  16267. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16268. // SingleRoomCount = item.SingleRoomCount,
  16269. SingleRoomPrice = singleRoomFeeStr,
  16270. // DoubleRoomCount = item.DoubleRoomCount,
  16271. DoubleRoomPrice = doubleRoomFeeStr,
  16272. //SuiteRoomCount = item.SuiteRoomCount,
  16273. SuiteRoomPrice = suiteRoomFeeStr,
  16274. OtherRoomPrice = otherRoomFeeStr,
  16275. //OtherRoomCount = item.OtherRoomCount,
  16276. BreakfastPrice = breakfastPriceStr,
  16277. GovernmentRent = governmentRentStr,
  16278. CityTax = cityTaxStrStr,
  16279. RoomExplanation = item.RoomExplanation,
  16280. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16281. PayTime = roomInfo?.ConsumptionDate,
  16282. BankNo = roomInfo?.BankNo,
  16283. PayMoney = payMoneyStr,
  16284. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16285. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16286. CardPrice = cardPriceStr,
  16287. Remark = ccpInfo.Remark
  16288. });
  16289. }
  16290. #endregion
  16291. //载入模板
  16292. WorkbookDesigner designer = new WorkbookDesigner();
  16293. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16294. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16295. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16296. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16297. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  16298. designer.SetDataSource("Opertor", userInfo.CnName);
  16299. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16300. dt.TableName = "ViewMyHotelReservations";
  16301. designer.SetDataSource(dt);
  16302. designer.Process();
  16303. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16304. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16305. designer.Workbook.Save(serverPath);
  16306. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16307. #region 删除指定行
  16308. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16309. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16310. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16311. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16312. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16313. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16314. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16315. cssIndex = dt.Columns["CityTax"].Ordinal,
  16316. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16317. remarkIndex = dt.Columns["Remark"].Ordinal;
  16318. //删除指定列
  16319. foreach (DataRow item in dt.Rows)
  16320. {
  16321. string singleStr = item["SingleRoomPrice"].ToString();
  16322. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16323. if (containsDigitButNotZero1) singleDel = false;
  16324. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16325. string doubleStr = item["DoubleRoomPrice"].ToString();
  16326. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16327. if (containsDigitButNotZero2) doubleDel = false;
  16328. string suiteStr = item["SuiteRoomPrice"].ToString();
  16329. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16330. if (containsDigitButNotZero3) suiteDel = false;
  16331. string otherStr = item["OtherRoomPrice"].ToString();
  16332. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16333. if (containsDigitButNotZero4) otherDel = false;
  16334. string zcStr = item["BreakfastPrice"].ToString();
  16335. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16336. if (containsDigitButNotZero5) zcDel = false;
  16337. string dsStr = item["GovernmentRent"].ToString();
  16338. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16339. if (containsDigitButNotZero6) dsDel = false;
  16340. string cssStr = item["CityTax"].ToString();
  16341. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16342. if (containsDigitButNotZero7) cssDel = false;
  16343. string cpStr = item["ConsumptionPatterns"].ToString();
  16344. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16345. string remarkStr = item["Remark"].ToString();
  16346. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16347. }
  16348. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16349. DeleteColumn(serverPath, cpIndex, cpDel);
  16350. DeleteColumn(serverPath, dsIndex, dsDel);
  16351. DeleteColumn(serverPath, cssIndex, cssDel);
  16352. DeleteColumn(serverPath, zcIndex, zcDel);
  16353. DeleteColumn(serverPath, otherIndex, otherDel);
  16354. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16355. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16356. DeleteColumn(serverPath, singleIndex, singleDel);
  16357. #endregion
  16358. //只保留第一个表格
  16359. DeleteSheet(serverPath);
  16360. return Ok(JsonView(true, "操作成功", url = rst));
  16361. }
  16362. //return Ok(JsonView(false));
  16363. }
  16364. /// <summary>
  16365. /// 删除指定列
  16366. /// </summary>
  16367. /// <param name="file"></param>
  16368. /// <param name="columnIndex"></param>
  16369. /// <param name="isDel"></param>
  16370. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16371. {
  16372. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16373. //wb.Save(file);
  16374. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16375. if (sheet1 != null)
  16376. {
  16377. if (isDel)
  16378. {
  16379. Cells cells = sheet1.Cells;
  16380. cells.DeleteColumn(columnIndex);
  16381. }
  16382. }
  16383. wb.Save(file);
  16384. }
  16385. /// <summary>
  16386. /// 删除sheet
  16387. /// </summary>
  16388. /// <param name="file"></param>
  16389. /// <param name="sheetName"></param>
  16390. private void DeleteSheet(string file, string sheetName = "")
  16391. {
  16392. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16393. //wb.Save(file);
  16394. List<string> sheets = new List<string>();
  16395. foreach (var item in wb.Worksheets)
  16396. {
  16397. sheets.Add(item.Name);
  16398. }
  16399. if (sheets.Count > 0)
  16400. {
  16401. sheets.RemoveAt(0);//不删除第一个sheet
  16402. foreach (var item in sheets)
  16403. {
  16404. wb.Worksheets.RemoveAt(item);
  16405. }
  16406. }
  16407. wb.Save(file);
  16408. }
  16409. /// <summary>
  16410. /// 酒店预订
  16411. /// 确认单
  16412. /// </summary>
  16413. /// <param name="_dto"></param>
  16414. /// <returns></returns>
  16415. [HttpPost]
  16416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16417. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16418. {
  16419. try
  16420. {
  16421. #region 参数验证
  16422. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16423. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16424. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16425. #region 团组操作权限验证 76 酒店预定模块
  16426. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16427. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16428. #endregion
  16429. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16430. #region 页面操作权限验证
  16431. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16432. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16433. #endregion
  16434. #endregion
  16435. //团组信息
  16436. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16437. //酒店数据
  16438. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16439. if (listhoteldata.Count < 0)
  16440. {
  16441. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16442. }
  16443. //利datatable存储
  16444. DataTable dt = new DataTable();
  16445. dt.Columns.Add("CheckInDate", typeof(string));
  16446. dt.Columns.Add("City", typeof(string));
  16447. dt.Columns.Add("Hotel", typeof(string));
  16448. dt.Columns.Add("Room", typeof(string));
  16449. for (int i = 0; i < listhoteldata.Count; i++)
  16450. {
  16451. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16452. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16453. while (dayStart < dayEnd)
  16454. {
  16455. string temp = "";
  16456. DataRow row = dt.NewRow();
  16457. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16458. row["City"] = listhoteldata[i].City;
  16459. row["Hotel"] = listhoteldata[i].HotelName;
  16460. if (listhoteldata[i].SingleRoomCount > 0)
  16461. {
  16462. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16463. }
  16464. if (listhoteldata[i].DoubleRoomCount > 0)
  16465. {
  16466. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16467. }
  16468. if (listhoteldata[i].SuiteRoomCount > 0)
  16469. {
  16470. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16471. }
  16472. if (listhoteldata[i].OtherRoomCount > 0)
  16473. {
  16474. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16475. }
  16476. row["Room"] = temp;
  16477. dt.Rows.Add(row);
  16478. dayStart = dayStart.AddDays(1);
  16479. }
  16480. }
  16481. Dictionary<string, string> dic = new Dictionary<string, string>();
  16482. dic.Add("Dele", di.TeamName);
  16483. dic.Add("City", di.VisitCountry);
  16484. //模板路径
  16485. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16486. //载入模板
  16487. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16488. DocumentBuilder builder = new DocumentBuilder(doc);
  16489. foreach (var key in dic.Keys)
  16490. {
  16491. builder.MoveToBookmark(key);
  16492. builder.Write(dic[key]);
  16493. }
  16494. //获取word里所有表格
  16495. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16496. //获取所填表格的序数
  16497. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16498. var rowStart = tableOne.Rows[0]; //获取第1行
  16499. //循环赋值
  16500. for (int i = 0; i < dt.Rows.Count; i++)
  16501. {
  16502. builder.MoveToCell(0, i + 1, 0, 0);
  16503. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16504. builder.MoveToCell(0, i + 1, 1, 0);
  16505. builder.Write(dt.Rows[i]["City"].ToString());
  16506. builder.MoveToCell(0, i + 1, 2, 0);
  16507. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16508. builder.MoveToCell(0, i + 1, 3, 0);
  16509. builder.Write(dt.Rows[i]["Room"].ToString());
  16510. }
  16511. //删除多余行
  16512. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16513. {
  16514. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16515. }
  16516. string strFileName = di.TeamName + "酒店确认单.doc";
  16517. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16518. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16519. return Ok(JsonView(true, "成功", url));
  16520. }
  16521. catch (Exception ex)
  16522. {
  16523. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16524. }
  16525. }
  16526. #endregion
  16527. #region 团组状态
  16528. /// <summary>
  16529. /// 团组状态列表 Page
  16530. /// </summary>
  16531. /// <param name="dto">团组列表请求dto</param>
  16532. /// <returns></returns>
  16533. [HttpPost]
  16534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16535. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16536. {
  16537. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16538. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16539. {
  16540. string sqlWhere = string.Empty;
  16541. if (dto.IsSure == 0) //未完成
  16542. {
  16543. sqlWhere += string.Format(@" And IsSure = 0");
  16544. }
  16545. else if (dto.IsSure == 1) //已完成
  16546. {
  16547. sqlWhere += string.Format(@" And IsSure = 1");
  16548. }
  16549. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16550. {
  16551. string tj = dto.SearchCriteria;
  16552. 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}%')",
  16553. tj, tj, tj, tj, tj);
  16554. }
  16555. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16556. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16557. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16558. From (
  16559. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16560. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16561. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16562. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16563. From Grp_DelegationInfo gdi
  16564. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16565. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16566. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16567. Where gdi.IsDel = 0 {0}
  16568. ) temp ", sqlWhere);
  16569. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16570. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16571. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16572. }
  16573. else
  16574. {
  16575. return Ok(JsonView(false, "查询失败"));
  16576. }
  16577. }
  16578. /// <summary>
  16579. /// 团组状态
  16580. /// 设置操作完成
  16581. /// </summary>
  16582. /// <param name="dto">团组列表请求dto</param>
  16583. /// <returns></returns>
  16584. [HttpPost]
  16585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16586. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16587. {
  16588. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16589. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16590. {
  16591. Id = dto.Id,
  16592. IsSure = 1
  16593. };
  16594. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16595. .UpdateColumns(it => new { it.IsSure })
  16596. .WhereColumns(it => new { it.Id })
  16597. .ExecuteCommandAsync();
  16598. if (result > 0)
  16599. {
  16600. return Ok(JsonView(true, "操作完成!"));
  16601. }
  16602. return Ok(JsonView(false, "操作失败!"));
  16603. }
  16604. #endregion
  16605. #region 保险费用录入
  16606. /// <summary>
  16607. /// 根据团组Id查询保险费用列表
  16608. /// </summary>
  16609. /// <param name="dto"></param>
  16610. /// <returns></returns>
  16611. [HttpPost]
  16612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16613. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16614. {
  16615. Result groupData = await _customersRep.CustomersByDiId(dto);
  16616. if (groupData.Code != 0)
  16617. {
  16618. return Ok(JsonView(false, groupData.Msg));
  16619. }
  16620. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16621. }
  16622. /// <summary>
  16623. /// 根据保险费用Id查询保险费用详细
  16624. /// </summary>
  16625. /// <param name="dto"></param>
  16626. /// <returns></returns>
  16627. [HttpPost]
  16628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16629. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16630. {
  16631. try
  16632. {
  16633. Result groupData = await _customersRep.CustomersById(dto);
  16634. if (groupData.Code != 0)
  16635. {
  16636. return Ok(JsonView(false, groupData.Msg));
  16637. }
  16638. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16639. }
  16640. catch (Exception ex)
  16641. {
  16642. return Ok(JsonView(false, ex.Message));
  16643. }
  16644. }
  16645. /// <summary>
  16646. /// 保险费用录入页面初始化绑定
  16647. /// </summary>
  16648. /// <param name="dto"></param>
  16649. /// <returns></returns>
  16650. [HttpPost]
  16651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16652. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16653. {
  16654. try
  16655. {
  16656. Result groupData = await _customersRep.CustomersInitialize(dto);
  16657. if (groupData.Code != 0)
  16658. {
  16659. return Ok(JsonView(false, groupData.Msg));
  16660. }
  16661. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16662. }
  16663. catch (Exception ex)
  16664. {
  16665. return Ok(JsonView(false, ex.Message));
  16666. }
  16667. }
  16668. /// <summary>
  16669. /// 保险费用操作(Status:1.新增,2.修改)
  16670. /// </summary>
  16671. /// <param name="dto"></param>
  16672. /// <returns></returns>
  16673. [HttpPost]
  16674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16675. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16676. {
  16677. Result groupData = await _customersRep.OpCustomers(dto);
  16678. if (groupData.Code != 0)
  16679. {
  16680. return Ok(JsonView(false, groupData.Msg));
  16681. }
  16682. #region 应用推送
  16683. try
  16684. {
  16685. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16686. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16687. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16688. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16689. //自动审核
  16690. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16691. //2024-10-21 新增LZ UID
  16692. var userIds = new List<int>() { 21 };
  16693. string title = $"系统通知";
  16694. var diId = dto.DiId;
  16695. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16696. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16697. string content = "";
  16698. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16699. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16700. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16701. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16702. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16703. }
  16704. catch (Exception ex)
  16705. {
  16706. }
  16707. #endregion
  16708. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16709. }
  16710. /// <summary>
  16711. /// 保险文件上传
  16712. /// </summary>
  16713. /// <param name="file"></param>
  16714. /// <returns></returns>
  16715. [HttpPost]
  16716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16717. public async Task<IActionResult> UploadCus(IFormFile file)
  16718. {
  16719. try
  16720. {
  16721. if (file != null)
  16722. {
  16723. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16724. //文件名称
  16725. string projectFileName = file.FileName;
  16726. //上传的文件的路径
  16727. string filePath = "";
  16728. if (!Directory.Exists(fileDir))
  16729. {
  16730. Directory.CreateDirectory(fileDir);
  16731. }
  16732. //上传的文件的路径
  16733. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16734. using (FileStream fs = System.IO.File.Create(filePath))
  16735. {
  16736. file.CopyTo(fs);
  16737. fs.Flush();
  16738. }
  16739. return Ok(JsonView(true, "上传成功!", projectFileName));
  16740. }
  16741. else
  16742. {
  16743. return Ok(JsonView(false, "上传失败!"));
  16744. }
  16745. }
  16746. catch (Exception ex)
  16747. {
  16748. return Ok(JsonView(false, "程序错误!"));
  16749. throw;
  16750. }
  16751. }
  16752. /// <summary>
  16753. /// 保险删除指定文件
  16754. /// </summary>
  16755. /// <param name="dto"></param>
  16756. /// <returns></returns>
  16757. [HttpPost]
  16758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16759. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16760. {
  16761. try
  16762. {
  16763. string filePath = "";
  16764. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16765. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16766. //int id = 0;
  16767. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16768. // 删除该文件
  16769. try
  16770. {
  16771. System.IO.File.Delete(filePath);
  16772. 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()
  16773. {
  16774. Attachment = "",
  16775. }).ExecuteCommandAsync();
  16776. if (result != 0)
  16777. {
  16778. return Ok(JsonView(true, "成功!"));
  16779. }
  16780. else
  16781. {
  16782. return Ok(JsonView(false, "失败!"));
  16783. }
  16784. }
  16785. catch (Exception)
  16786. {
  16787. 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()
  16788. {
  16789. Attachment = "",
  16790. }).ExecuteCommandAsync();
  16791. if (result != 0)
  16792. {
  16793. return Ok(JsonView(true, "成功!"));
  16794. }
  16795. else
  16796. {
  16797. return Ok(JsonView(false, "失败!"));
  16798. }
  16799. }
  16800. }
  16801. catch (Exception ex)
  16802. {
  16803. return Ok(JsonView(false, "程序错误!"));
  16804. throw;
  16805. }
  16806. }
  16807. /// <summary>
  16808. /// 保险费用操作(删除)
  16809. /// </summary>
  16810. /// <param name="dto"></param>
  16811. /// <returns></returns>
  16812. [HttpPost]
  16813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16814. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16815. {
  16816. try
  16817. {
  16818. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16819. if (!res)
  16820. {
  16821. return Ok(JsonView(false, "删除失败"));
  16822. }
  16823. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16824. {
  16825. IsDel = 1,
  16826. DeleteUserId = dto.DeleteUserId,
  16827. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16828. }).ExecuteCommandAsync();
  16829. return Ok(JsonView(true, "删除成功!"));
  16830. }
  16831. catch (Exception ex)
  16832. {
  16833. return Ok(JsonView(false, "程序错误!"));
  16834. throw;
  16835. }
  16836. }
  16837. #endregion
  16838. #region 接团客户名单 PageId 104
  16839. /// <summary>
  16840. /// 接团客户名单
  16841. /// 迁移数据(慎用!)
  16842. /// </summary>
  16843. /// <returns></returns>
  16844. [HttpPost]
  16845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16846. public async Task<IActionResult> PostTourClientListChange()
  16847. {
  16848. try
  16849. {
  16850. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16851. //var groupClinetData1
  16852. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16853. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16854. int updateCount = 0;
  16855. if (oldOAClientList.Count > 0)
  16856. {
  16857. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16858. _sqlSugar.BeginTran();
  16859. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16860. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16861. foreach (var item in oldOAClientList)
  16862. {
  16863. int comId = 0;
  16864. string format = "yyyy-MM-dd HH:mm:ss";
  16865. string data11 = "1990-01-01 00:00";
  16866. var data1 = IsValidDate(item.OPdate, format);
  16867. if (data1) data11 = item.OPdate;
  16868. //客户公司验证
  16869. if (!string.IsNullOrEmpty(item.Company))
  16870. {
  16871. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16872. if (clientComInfo == null) // add
  16873. {
  16874. var addInfo = new Crm_CustomerCompany()
  16875. {
  16876. CompanyAbbreviation = "",
  16877. CompanyFullName = item.Company,
  16878. Address = "",
  16879. PostCodes = "",
  16880. LastedOpUserId = item.OPer,
  16881. LastedOpDt = Convert.ToDateTime(data11),
  16882. CreateUserId = item.OPer,
  16883. CreateTime = Convert.ToDateTime(data11),
  16884. IsDel = 0
  16885. };
  16886. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16887. if (comId1 > 0) comId = comId1;
  16888. }
  16889. else comId = clientComInfo.Id;
  16890. }
  16891. //客户人员验证
  16892. int clientId = 0;
  16893. string name = item.LastName + item.Name;
  16894. if (!string.IsNullOrEmpty(name))
  16895. {
  16896. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16897. if (clientInfo == null)
  16898. {
  16899. DateTime? dateTime = null;
  16900. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16901. if (isDt) dateTime = birthDayDt;
  16902. var addInfo1 = new Crm_DeleClient()
  16903. {
  16904. CrmCompanyId = comId,
  16905. DiId = -1,
  16906. LastName = item.LastName,
  16907. FirstName = item.Name,
  16908. OldName = "",
  16909. Pinyin = item.Pinyin,
  16910. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16911. Marriage = 0,
  16912. Phone = item.Phone,
  16913. Job = item.Job,
  16914. BirthDay = dateTime
  16915. };
  16916. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16917. if (clientId1 > 0) clientId = clientId1;
  16918. }
  16919. else clientId = clientInfo.Id;
  16920. }
  16921. if (clientId < 1)
  16922. {
  16923. continue;
  16924. }
  16925. int airType = 0;
  16926. if (item.AirType == "超经舱") airType = 459;
  16927. else if (item.AirType == "公务舱") airType = 458;
  16928. else if (item.AirType == "经济舱") airType = 460;
  16929. else if (item.AirType == "其他") airType = 565;
  16930. else if (item.AirType == "头等舱") airType = 457;
  16931. var _TourClientListEntity = new Grp_TourClientList()
  16932. {
  16933. DiId = item.Diid,
  16934. ClientId = clientId,
  16935. CreateUserId = item.OPer,
  16936. CreateTime = Convert.ToDateTime(data11),
  16937. Remark = item.Remark,
  16938. IsDel = item.Isdel,
  16939. ShippingSpaceTypeId = airType,
  16940. ShippingSpaceSpecialNeeds = item.AirRemark,
  16941. HotelSpecialNeeds = item.RoomType
  16942. };
  16943. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16944. if (_TourClientList > 0)
  16945. {
  16946. updateCount++;
  16947. }
  16948. }
  16949. _sqlSugar.CommitTran();
  16950. }
  16951. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16952. }
  16953. catch (Exception ex)
  16954. {
  16955. _sqlSugar.RollbackTran();
  16956. return Ok(JsonView(false, ex.Message));
  16957. }
  16958. //return Ok(JsonView(true));
  16959. }
  16960. private bool IsValidDate(string dateString, string format)
  16961. {
  16962. DateTime dateValue;
  16963. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16964. return valid;
  16965. }
  16966. /// <summary>
  16967. /// 接团客户名单
  16968. /// 根据团组Id查询List
  16969. /// </summary>
  16970. /// <param name="_dto"></param>
  16971. /// <returns></returns>
  16972. [HttpPost]
  16973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16974. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16975. {
  16976. #region 参数验证
  16977. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16978. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16979. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16980. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16981. #region 页面操作权限验证
  16982. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16983. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16984. #endregion
  16985. #endregion
  16986. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16987. if (viewData.Code != 0)
  16988. {
  16989. return Ok(JsonView(false, viewData.Msg));
  16990. }
  16991. return Ok(JsonView(viewData.Data));
  16992. }
  16993. /// <summary>
  16994. /// 接团客户名单
  16995. /// 基础数据 Init
  16996. /// </summary>
  16997. /// <param name="_dto"></param>
  16998. /// <returns></returns>
  16999. [HttpPost]
  17000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17001. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  17002. {
  17003. #region 参数验证
  17004. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17005. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17006. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17007. #region 页面操作权限验证
  17008. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17009. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17010. #endregion
  17011. #endregion
  17012. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  17013. }
  17014. /// <summary>
  17015. /// 接团客户名单
  17016. /// 根据 Id查询 Details
  17017. /// </summary>
  17018. /// <param name="_dto"></param>
  17019. /// <returns></returns>
  17020. [HttpPost]
  17021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17022. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  17023. {
  17024. #region 参数验证
  17025. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17026. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17027. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  17028. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17029. #region 页面操作权限验证
  17030. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17031. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17032. #endregion
  17033. #endregion
  17034. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  17035. if (viewData.Code != 0)
  17036. {
  17037. return Ok(JsonView(false, viewData.Msg));
  17038. }
  17039. return Ok(JsonView(viewData.Data));
  17040. }
  17041. /// <summary>
  17042. /// 接团客户名单
  17043. /// Add Or Edit
  17044. /// </summary>
  17045. /// <param name="_dto"></param>
  17046. /// <returns></returns>
  17047. [HttpPost]
  17048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17049. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  17050. {
  17051. #region 参数验证
  17052. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17053. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17054. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  17055. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17056. #region 页面操作权限验证
  17057. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17058. if (_dto.Id == 0) //添加
  17059. {
  17060. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17061. }
  17062. else if (_dto.Id >= 0) //修改
  17063. {
  17064. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17065. }
  17066. #endregion
  17067. #endregion
  17068. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  17069. if (viewData.Code != 0)
  17070. {
  17071. return Ok(JsonView(false, viewData.Msg));
  17072. }
  17073. return Ok(JsonView(true));
  17074. }
  17075. /// <summary>
  17076. /// 接团客户名单
  17077. /// json字符串 AddMultiple(添加多个)
  17078. /// </summary>
  17079. /// <param name="_dto"></param>
  17080. /// <returns></returns>
  17081. [HttpPost]
  17082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17083. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  17084. {
  17085. #region 参数验证
  17086. string jsonLabel = _dto.JsonLabel;
  17087. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17088. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17089. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17090. #region 页面操作权限验证
  17091. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17092. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17093. #endregion
  17094. #endregion
  17095. var request = new TourClientListAddMultipleDto();
  17096. request.DiId = _dto.DiId;
  17097. request.UserId = _dto.UserId;
  17098. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  17099. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  17100. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  17101. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  17102. var infos = new List<TourClientListInfo>();
  17103. foreach (var data in datas)
  17104. {
  17105. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  17106. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  17107. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  17108. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  17109. {
  17110. continue;
  17111. }
  17112. infos.Add(new TourClientListInfo()
  17113. {
  17114. IsAccompany = 1,
  17115. LastName = lastName,
  17116. FirstName = firstName,
  17117. Pinyin = lastNameEn + @"/" + firstNameEn,
  17118. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  17119. CompanyFullName = data.CompanyFullName,
  17120. Job = data.Job
  17121. });
  17122. }
  17123. if (infos.Any())
  17124. {
  17125. var viewData = await _tourClientListRep._AddMultiple(request);
  17126. if (viewData.Code != 0)
  17127. {
  17128. return Ok(JsonView(false, viewData.Msg));
  17129. }
  17130. return Ok(JsonView(true));
  17131. }
  17132. return Ok(JsonView(false));
  17133. }
  17134. /// <summary>
  17135. /// 接团客户名单
  17136. /// AddMultiple(添加多个)
  17137. /// </summary>
  17138. /// <param name="_dto"></param>
  17139. /// <returns></returns>
  17140. [HttpPost]
  17141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17142. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  17143. {
  17144. #region 参数验证
  17145. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17146. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17147. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17148. #region 页面操作权限验证
  17149. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17150. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17151. #endregion
  17152. #endregion
  17153. var viewData = await _tourClientListRep._AddMultiple(_dto);
  17154. if (viewData.Code != 0)
  17155. {
  17156. return Ok(JsonView(false, viewData.Msg));
  17157. }
  17158. return Ok(JsonView(true));
  17159. }
  17160. /// <summary>
  17161. /// 接团客户名单
  17162. /// Del
  17163. /// </summary>
  17164. /// <param name="_dto"></param>
  17165. /// <returns></returns>
  17166. [HttpPost]
  17167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17168. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  17169. {
  17170. #region 参数验证
  17171. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17172. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17173. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17174. #region 页面操作权限验证
  17175. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17176. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17177. #endregion
  17178. #endregion
  17179. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  17180. if (viewData.Code != 0)
  17181. {
  17182. return Ok(JsonView(false, viewData.Msg));
  17183. }
  17184. return Ok(JsonView(true));
  17185. }
  17186. /// <summary>
  17187. /// 接团客户名单
  17188. /// 文件下载 客户名单
  17189. /// </summary>
  17190. /// <param name="_dto"></param>
  17191. /// <returns></returns>
  17192. [HttpPost]
  17193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17194. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  17195. {
  17196. #region 参数验证
  17197. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17198. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17199. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  17200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17201. #region 页面操作权限验证
  17202. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17203. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17204. #endregion
  17205. #endregion
  17206. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  17207. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  17208. From Grp_TourClientList tcl
  17209. Left Join
  17210. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  17211. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  17212. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  17213. From Crm_DeleClient dc
  17214. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  17215. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  17216. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  17217. Where dc.IsDel = 0) temp
  17218. On temp.DcId =tcl.ClientId
  17219. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  17220. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  17221. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  17222. //载入模板
  17223. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  17224. if (_dto.Language == 1)
  17225. {
  17226. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  17227. }
  17228. //载入模板
  17229. var doc = new Document(tempPath);
  17230. DocumentBuilder builder = new DocumentBuilder(doc);
  17231. //获取word里所有表格
  17232. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17233. //获取所填表格的序数
  17234. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17235. var rowStart = tableOne.Rows[0]; //获取第1行
  17236. if (_dto.Language == 0)
  17237. {
  17238. //循环赋值
  17239. for (int i = 0; i < DcList.Count; i++)
  17240. {
  17241. EncryptionProcessor.DecryptProperties(DcList[i]);
  17242. builder.MoveToCell(0, i + 1, 0, 0);
  17243. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  17244. builder.MoveToCell(0, i + 1, 1, 0);
  17245. int sex = DcList[i].Sex;
  17246. string sexStr = string.Empty;
  17247. if (sex == 0) sexStr = "男";
  17248. else if (sex == 1) sexStr = "女";
  17249. else sexStr = "未设置";
  17250. builder.Write(sexStr);
  17251. builder.MoveToCell(0, i + 1, 2, 0);
  17252. string birthDay = DcList[i].BirthDay;
  17253. string birthDayStr = string.Empty;
  17254. if (!string.IsNullOrEmpty(birthDay))
  17255. {
  17256. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  17257. }
  17258. builder.Write(birthDayStr);
  17259. builder.MoveToCell(0, i + 1, 3, 0);
  17260. string company = "";
  17261. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17262. {
  17263. company = DcList[i].CompanyFullName.ToString();
  17264. }
  17265. builder.Write(company);
  17266. builder.MoveToCell(0, i + 1, 4, 0);
  17267. builder.Write(DcList[i].Job);
  17268. }
  17269. }
  17270. else if (_dto.Language == 1)
  17271. {
  17272. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  17273. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  17274. List<string> transArrayStr = new List<string>();
  17275. string transStrRes1 = "";
  17276. for (int i = 0; i < DcList.Count; i++)
  17277. {
  17278. var dc = DcList[i];
  17279. EncryptionProcessor.DecryptProperties(dc);
  17280. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  17281. if (dc.Job.Equals("暂无")) dc.Job = "-";
  17282. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  17283. if (DcList.Count - 1 == i) transStrRes1 += str1;
  17284. else transStrRes1 += $"{str1}|";
  17285. }
  17286. //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";
  17287. string transStrRes = "";
  17288. if (transStrRes1.Length > 0)
  17289. {
  17290. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  17291. }
  17292. //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
  17293. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  17294. //List<string> transArray = new List<string> { };
  17295. List<TranslateInfo> transArray = new List<TranslateInfo>();
  17296. if (transStrRes.Contains("|"))
  17297. {
  17298. string[] transArray1 = transStrRes.Split('|');
  17299. if (transArray1.Length > 0)
  17300. {
  17301. foreach (var item in transArray1)
  17302. {
  17303. if (item.Contains("&"))
  17304. {
  17305. string[] transArray2 = item.Split('&');
  17306. int index = 0;
  17307. string companyName = "", job = "";
  17308. if (transArray2.Length > 0)
  17309. {
  17310. bool success = int.TryParse(transArray2[0].Trim(), out index);
  17311. if (1 < transArray2.Length) companyName = transArray2[1];
  17312. if (2 < transArray2.Length) job = transArray2[2];
  17313. }
  17314. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  17315. }
  17316. }
  17317. }
  17318. }
  17319. //循环赋值
  17320. for (int i = 0; i < DcList.Count; i++)
  17321. {
  17322. string PYName = "";
  17323. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17324. {
  17325. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17326. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17327. PYName = PY_First + " " + PY_Last;
  17328. }
  17329. else
  17330. {
  17331. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17332. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17333. PYName = PY_First + " " + PY_Last;
  17334. }
  17335. builder.MoveToCell(0, i + 1, 0, 0);
  17336. builder.Write(PYName);
  17337. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17338. builder.MoveToCell(0, i + 1, 1, 0);
  17339. builder.Write(sex);
  17340. DateTime birthDt;
  17341. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17342. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17343. builder.MoveToCell(0, i + 1, 2, 0);
  17344. builder.Write(birthday);
  17345. string company = string.Empty, job = string.Empty;
  17346. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17347. if (dcTransInfo != null)
  17348. {
  17349. company = dcTransInfo.CompanyName;
  17350. job = dcTransInfo.Job;
  17351. }
  17352. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17353. {
  17354. //查询对照表
  17355. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17356. if (tempCec != null)
  17357. {
  17358. company = tempCec.enName;
  17359. }
  17360. //翻译
  17361. else
  17362. {
  17363. }
  17364. }
  17365. builder.MoveToCell(0, i + 1, 3, 0);
  17366. builder.Write(company);
  17367. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17368. {
  17369. //查询对照表
  17370. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17371. if (tempPec != null)
  17372. {
  17373. job = tempPec.enName;
  17374. }
  17375. //翻译
  17376. else
  17377. {
  17378. }
  17379. }
  17380. builder.MoveToCell(0, i + 1, 4, 0);
  17381. builder.Write(job);
  17382. }
  17383. }
  17384. //删除多余行
  17385. while (tableOne.Rows.Count > DcList.Count + 1)
  17386. {
  17387. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17388. }
  17389. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17390. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17391. doc.Save(fileDir);
  17392. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17393. return Ok(JsonView(true, "操作成功!", Url));
  17394. }
  17395. private class TranslateInfo
  17396. {
  17397. public int Index { get; set; }
  17398. public string CompanyName { get; set; }
  17399. public string Job { get; set; }
  17400. }
  17401. #endregion
  17402. #region 团组倒推表
  17403. /// <summary>
  17404. /// 倒推表基础数据
  17405. /// Init
  17406. /// </summary>
  17407. /// <returns></returns>
  17408. [HttpPost]
  17409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17410. public async Task<IActionResult> PostInvertedListInit()
  17411. {
  17412. var viewData = await _invertedListRep._Init();
  17413. if (viewData.Code != 0)
  17414. {
  17415. return Ok(JsonView(false, viewData.Msg));
  17416. }
  17417. return Ok(JsonView(viewData.Data));
  17418. }
  17419. /// <summary>
  17420. /// 倒推表
  17421. /// Info
  17422. /// </summary>
  17423. /// <param name="dto"></param>
  17424. /// <returns></returns>
  17425. [HttpPost]
  17426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17427. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17428. {
  17429. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17430. if (viewData.Code != 0)
  17431. {
  17432. return Ok(JsonView(false, viewData.Msg));
  17433. }
  17434. return Ok(JsonView(viewData.Data));
  17435. }
  17436. /// <summary>
  17437. /// 倒推表
  17438. /// Create
  17439. /// </summary>
  17440. /// <param name="dto"></param>
  17441. /// <returns></returns>
  17442. [HttpPost]
  17443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17444. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17445. {
  17446. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17447. if (viewData.Code != 0)
  17448. {
  17449. return Ok(JsonView(false, viewData.Msg));
  17450. }
  17451. return Ok(JsonView(viewData.Data));
  17452. }
  17453. /// <summary>
  17454. /// 倒推表
  17455. /// Update
  17456. /// </summary>
  17457. /// <param name="dto"></param>
  17458. /// <returns></returns>
  17459. [HttpPost]
  17460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17461. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17462. {
  17463. var viewData = await _invertedListRep._Update(dto);
  17464. if (viewData.Code != 0)
  17465. {
  17466. return Ok(JsonView(false, viewData.Msg));
  17467. }
  17468. return Ok(JsonView(viewData.Data));
  17469. }
  17470. /// <summary>
  17471. /// 倒推表
  17472. /// File Download
  17473. /// </summary>
  17474. /// <param name="dto"></param>
  17475. /// <returns></returns>
  17476. [HttpPost]
  17477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17478. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17479. {
  17480. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17481. if (info2.Code != 0)
  17482. {
  17483. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17484. }
  17485. var info1 = info2.Data as InvertedListInfoView;
  17486. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17487. string teamName = "";
  17488. if (info != null) teamName = info.TeamName;
  17489. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17490. var doc = new Document();
  17491. var builder = new DocumentBuilder(doc);
  17492. #region old insert
  17493. ////载入模板
  17494. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17495. //Document doc = new Document(tempPath);
  17496. //DocumentBuilder builder = new DocumentBuilder(doc);
  17497. //利用键值对存放数据
  17498. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17499. //dic.Add("TeamName", teamName);
  17500. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17501. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17502. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17503. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17504. //dic.Add("SQRemark", info1.ApprovalRemark);
  17505. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17506. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17507. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17508. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17509. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17510. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17511. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17512. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17513. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17514. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17515. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17516. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17517. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17518. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17519. //#region 填充word模板书签内容
  17520. //foreach (var key in dic.Keys)
  17521. //{
  17522. // builder.MoveToBookmark(key);
  17523. // builder.Write(dic[key]);
  17524. //}
  17525. //#endregion
  17526. #endregion
  17527. #region New Insert
  17528. string titleFont = $"仿宋",
  17529. contentFont = $"仿宋";
  17530. var fontColor = Color.FromArgb(64, 64, 64);
  17531. //设置标题 团组名称
  17532. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17533. builder.Font.Name = titleFont;
  17534. builder.Font.Color = fontColor;
  17535. builder.Font.Size = 12;
  17536. builder.Font.Bold = true;
  17537. builder.Writeln(teamName);
  17538. //设置副标题 团组出访时间
  17539. builder.Font.Size = 12;
  17540. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17541. builder.Writeln();
  17542. var backgroundColor = Color.FromArgb(199, 199, 199);
  17543. var table = builder.StartTable();
  17544. builder.InsertCell();
  17545. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17546. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17547. builder.CellFormat.Borders.LineWidth = 1;
  17548. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17549. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17550. builder.RowFormat.Height = 40;
  17551. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17552. builder.Font.Name = contentFont;
  17553. builder.Font.Size = 12;
  17554. builder.Font.Bold = true;
  17555. builder.Font.Color = fontColor;
  17556. builder.Write("时间");
  17557. builder.InsertCell();
  17558. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17559. builder.Write("流程");
  17560. builder.InsertCell();
  17561. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17562. builder.Write("说明");
  17563. builder.EndRow();
  17564. //报批资料准备
  17565. if (info1.IsSelectedAirportd)
  17566. {
  17567. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17568. }
  17569. //报批/提供送签资料
  17570. if (info1.IsSelectedApprovalData)
  17571. {
  17572. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17573. }
  17574. //出批件护照办理
  17575. if (info1.IsSelectedIssueApproval)
  17576. {
  17577. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17578. }
  17579. //签证资料准备
  17580. if (info1.IsSelectedVisaInfo)
  17581. {
  17582. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17583. }
  17584. //送签
  17585. if (info1.IsSelectedSendVisa)
  17586. {
  17587. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17588. }
  17589. //出签
  17590. if (info1.IsSelectedIssueVisa)
  17591. {
  17592. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17593. }
  17594. //机票
  17595. if (info1.IsSelectedAirTicket)
  17596. {
  17597. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17598. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17599. }
  17600. //酒店
  17601. if (info1.IsSelectedHotel)
  17602. {
  17603. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17604. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17605. }
  17606. //开行前会
  17607. if (info1.IsSelectedPreTripMeeting)
  17608. {
  17609. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17610. }
  17611. //送机
  17612. if (info1.IsSelectedAirportdDropOff)
  17613. {
  17614. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17615. }
  17616. builder.EndTable();
  17617. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17618. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17619. for (int i = 0; i < table.Rows.Count; i++)
  17620. {
  17621. var row = table.Rows[i];
  17622. //设置宽度
  17623. row.Cells[0].CellFormat.Width = 20.00;
  17624. row.Cells[1].CellFormat.Width = 30.00;
  17625. row.Cells[2].CellFormat.Width = 50.00;
  17626. if (i != 0)
  17627. {
  17628. //边框设置
  17629. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17630. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17631. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17632. }
  17633. }
  17634. #region 页脚插入图片
  17635. // 创建页脚
  17636. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17637. doc.FirstSection.HeadersFooters.Add(footer);
  17638. Paragraph para = new Paragraph(doc);
  17639. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17640. footer.AppendChild(para);
  17641. builder.MoveTo(para);
  17642. string imagePath = "./Images/FMGJ_Log.png";
  17643. builder.InsertImage(imagePath);
  17644. #endregion
  17645. #endregion
  17646. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17647. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17648. string filePath = fileDir + $@"InvertedList/{fileName}";
  17649. doc.Save(filePath);
  17650. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17651. return Ok(JsonView(true, "操作成功!", Url));
  17652. }
  17653. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  17654. {
  17655. var fontColor = Color.FromArgb(64, 64, 64);
  17656. builder.InsertCell();
  17657. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17658. builder.RowFormat.Height = 40;
  17659. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17660. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17661. builder.Font.Name = fontName;
  17662. builder.Font.Size = 8;
  17663. builder.Font.Bold = true;
  17664. builder.Font.Color = fontColor;
  17665. builder.Write(dateTime);
  17666. builder.InsertCell();
  17667. builder.Font.Size = 9;
  17668. builder.Font.Bold = true;
  17669. builder.Font.Color = fontColor;
  17670. builder.Write(content);
  17671. builder.InsertCell();
  17672. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17673. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17674. builder.Font.Size = 9;
  17675. builder.Font.Bold = false;
  17676. builder.Font.Color = fontColor;
  17677. builder.Write(reamrk);
  17678. builder.EndRow();
  17679. }
  17680. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  17681. {
  17682. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17683. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17684. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17685. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17686. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17687. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17688. }
  17689. #endregion
  17690. #region 会务倒推表
  17691. /// <summary>
  17692. /// 会务倒推表
  17693. /// Init
  17694. /// </summary>
  17695. /// <returns></returns>
  17696. [HttpPost]
  17697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17698. public async Task<IActionResult> InforRetrogressTableInit()
  17699. {
  17700. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17701. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17702. return Ok(JsonView(false, groupData.Msg));
  17703. }
  17704. /// <summary>
  17705. /// 会务倒推表
  17706. /// ExcelDownload
  17707. /// </summary>
  17708. /// <param name="dto"></param>
  17709. /// <returns></returns>
  17710. [HttpPost]
  17711. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17713. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17714. {
  17715. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17716. var validatorRes = await validator.ValidateAsync(dto);
  17717. if (!validatorRes.IsValid)
  17718. {
  17719. StringBuilder sb = new StringBuilder();
  17720. foreach (var item in validatorRes.Errors)
  17721. {
  17722. sb.AppendLine(item.ErrorMessage);
  17723. }
  17724. return Ok(JsonView(false, sb.ToString()));
  17725. }
  17726. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17727. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17728. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17729. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17730. #region Excel
  17731. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17732. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17733. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17734. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17735. var fileNamePrefix = string.Empty;
  17736. if (days >= 30)
  17737. {
  17738. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17739. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17740. }
  17741. else if (days < 30 && days > 7)
  17742. {
  17743. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17744. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17745. }
  17746. else if (days <= 7)
  17747. {
  17748. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17749. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17750. }
  17751. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17752. fileName = CommonFun.ValidFileName(fileName);
  17753. //载入模板
  17754. WorkbookDesigner designer = new WorkbookDesigner();
  17755. designer.Workbook = new Workbook(tempPath);
  17756. designer.Process();
  17757. if (!Directory.Exists(savePath))
  17758. {
  17759. Directory.CreateDirectory(savePath);
  17760. }
  17761. string serverPath = $"{savePath}{fileName}";
  17762. designer.Workbook.Save(serverPath);
  17763. string rst = $"{servicePath}{ftpPath}{fileName}";
  17764. #endregion
  17765. return Ok(JsonView(new { url = rst }));
  17766. }
  17767. #endregion
  17768. #region 三公签证费用(签证费、代办费)
  17769. /// <summary>
  17770. /// 三公签证费用(签证费、代办费)
  17771. /// List
  17772. /// </summary>
  17773. /// <returns></returns>
  17774. [HttpPost]
  17775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17776. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17777. {
  17778. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17779. if (_view.Code != 0)
  17780. {
  17781. return Ok(JsonView(false, _view.Msg));
  17782. }
  17783. return Ok(JsonView(true, "操作成功!", _view.Data));
  17784. }
  17785. /// <summary>
  17786. /// 三公签证费用(签证费、代办费)
  17787. /// Add Or Update
  17788. /// </summary>
  17789. /// <returns></returns>
  17790. [HttpPost]
  17791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17792. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17793. {
  17794. var _view = await _visaFeeInfoRep._Update(_dto);
  17795. if (_view.Code != 0)
  17796. {
  17797. return Ok(JsonView(false, _view.Msg));
  17798. }
  17799. return Ok(JsonView(true, _view.Msg));
  17800. }
  17801. #endregion
  17802. #region 酒店询价
  17803. /// <summary>
  17804. /// 酒店询价
  17805. /// Init
  17806. /// </summary>
  17807. /// <returns></returns>
  17808. [HttpPost]
  17809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17810. public async Task<IActionResult> PostHotelInquiryInit()
  17811. {
  17812. var res = await _hotelInquiryRep._Init();
  17813. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17814. return Ok(JsonView(true, res.Msg, res.Data));
  17815. }
  17816. /// <summary>
  17817. /// 酒店询价
  17818. /// page Item
  17819. /// </summary>
  17820. /// <param name="_dto"></param>
  17821. /// <returns></returns>
  17822. [HttpPost]
  17823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17824. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17825. {
  17826. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17827. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17828. var view = res.Data as PageDataViewBase;
  17829. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17830. }
  17831. /// <summary>
  17832. /// 酒店询价
  17833. /// info
  17834. /// </summary>
  17835. /// <param name="_dto"></param>
  17836. /// <returns></returns>
  17837. [HttpPost]
  17838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17839. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17840. {
  17841. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17842. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17843. return Ok(JsonView(true, res.Msg, res.Data));
  17844. }
  17845. /// <summary>
  17846. /// 酒店询价
  17847. /// Add Or Edit
  17848. /// </summary>
  17849. /// <param name="_dto"></param>
  17850. /// <returns></returns>
  17851. [HttpPost]
  17852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17853. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17854. {
  17855. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17856. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17857. return Ok(JsonView(true, res.Msg, res.Data));
  17858. }
  17859. /// <summary>
  17860. /// 酒店询价
  17861. /// Del
  17862. /// </summary>
  17863. /// <param name="_dto"></param>
  17864. /// <returns></returns>
  17865. [HttpPost]
  17866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17867. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17868. {
  17869. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17870. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17871. return Ok(JsonView(true, res.Msg, res.Data));
  17872. }
  17873. #endregion
  17874. #region 下载匹配op行程单
  17875. /// <summary>
  17876. /// 匹配op行程单
  17877. /// Init
  17878. /// </summary>
  17879. /// <param name="dto">团组列表请求dto</param>
  17880. /// <returns></returns>
  17881. [HttpPost]
  17882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17883. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17884. {
  17885. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17886. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17887. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17888. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17889. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17890. .Where(it => it.IsDel == 0)
  17891. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17892. .OrderByDescending(it => it.VisitStartDate)
  17893. .ToList();
  17894. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17895. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17896. var diids = groupInfos.Select(it => it.Id).ToList();
  17897. List<string> countrys = new List<string>();
  17898. foreach (var item in country)
  17899. {
  17900. var data = _groupRepository.FormartTeamName(item);
  17901. var dataArray = _groupRepository.GroupSplitCountry(data);
  17902. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17903. }
  17904. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17905. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17906. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17907. foreach (var item in areaItem)
  17908. {
  17909. string areaStr = item.Value;
  17910. if (!string.IsNullOrEmpty(areaStr))
  17911. {
  17912. string[] str1 = areaStr.Split("-");
  17913. if (str1.Length > 0)
  17914. {
  17915. areaArray.AddRange(str1);
  17916. }
  17917. }
  17918. }
  17919. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17920. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17921. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17922. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17923. .ToList();
  17924. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17925. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17926. .Where(it => countriesIds.Contains(it.Id))
  17927. .Select(it => new { it.Id, Name = it.Name_CN })
  17928. .ToList();
  17929. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17930. .Select(it => it.TeamName).ToList();
  17931. stopwatch.Stop();
  17932. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17933. }
  17934. ///// <summary>
  17935. ///// 匹配op行程单
  17936. ///// Init 查询区域数据
  17937. ///// </summary>
  17938. ///// <param name="dto">团组列表请求dto</param>
  17939. ///// <returns></returns>
  17940. //[HttpPost]
  17941. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17942. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17943. //{
  17944. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17945. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17946. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17947. // if (string.IsNullOrEmpty(countriesDataStr))
  17948. // {
  17949. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17950. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17951. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17952. // }
  17953. // else
  17954. // {
  17955. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17956. // }
  17957. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17958. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17959. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17960. // List<dynamic> childList = new List<dynamic>();
  17961. // int parentId = dto.CountriesId;
  17962. // if (provinceData.Count > 1)
  17963. // {
  17964. // foreach (var item1 in provinceData)
  17965. // {
  17966. // List<dynamic> childList1 = new List<dynamic>();
  17967. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17968. // foreach (var item2 in citiesData1)
  17969. // {
  17970. // List<dynamic> childList2 = new List<dynamic>();
  17971. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17972. // foreach (var item3 in countiesData1)
  17973. // {
  17974. // childList2.Add(new
  17975. // {
  17976. // id = item3.Id,
  17977. // parentId = item2.Id,
  17978. // level = "district",
  17979. // name = item3.Name_CN,
  17980. // });
  17981. // }
  17982. // childList1.Add(new
  17983. // {
  17984. // id = item2.Id,
  17985. // parentId = item1.Id,
  17986. // level = "city",
  17987. // name = item2.Name_CN,
  17988. // childList = childList2
  17989. // });
  17990. // }
  17991. // childList.Add(new
  17992. // {
  17993. // id = item1.Id,
  17994. // parentId = parentId,
  17995. // level = "province",
  17996. // name = item1.Name_CN,
  17997. // childList = childList1
  17998. // });
  17999. // }
  18000. // //城市
  18001. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  18002. // foreach (var item2 in citiesData2)
  18003. // {
  18004. // List<dynamic> childList22 = new List<dynamic>();
  18005. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18006. // foreach (var item3 in countiesData1)
  18007. // {
  18008. // childList22.Add(new
  18009. // {
  18010. // id = item3.Id,
  18011. // parentId = item2.Id,
  18012. // level = "district",
  18013. // name = item3.Name_CN,
  18014. // });
  18015. // }
  18016. // childList.Add(new
  18017. // {
  18018. // id = item2.Id,
  18019. // parentId = parentId,
  18020. // level = "city",
  18021. // name = item2.Name_CN,
  18022. // childList = childList22
  18023. // });
  18024. // }
  18025. // }
  18026. // else
  18027. // {
  18028. // foreach (var item2 in citiesData)
  18029. // {
  18030. // string cname = item2.Name_CN;
  18031. // List<dynamic> childList1 = new List<dynamic>();
  18032. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18033. // foreach (var item3 in countiesData1)
  18034. // {
  18035. // childList1.Add(new
  18036. // {
  18037. // Id = item3.Id,
  18038. // parentId = item2.Id,
  18039. // level = "district",
  18040. // name = item3.Name_CN
  18041. // });
  18042. // }
  18043. // childList.Add(new
  18044. // {
  18045. // id = item2.Id,
  18046. // parentId = parentId,
  18047. // level = "city",
  18048. // name = item2.Name_CN,
  18049. // childList = childList1
  18050. // });
  18051. // }
  18052. // }
  18053. // stopwatch.Stop();
  18054. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  18055. //}
  18056. /// <summary>
  18057. /// 匹配op行程单
  18058. /// 接团信息列表 Page
  18059. /// </summary>
  18060. /// <param name="dto">团组列表请求dto</param>
  18061. /// <returns></returns>
  18062. [HttpPost]
  18063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18064. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  18065. {
  18066. var swatch = new Stopwatch();
  18067. swatch.Start();
  18068. #region 参数验证
  18069. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18070. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  18071. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18072. #region 页面操作权限验证
  18073. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  18074. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  18075. #endregion
  18076. #endregion
  18077. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  18078. {
  18079. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  18080. //string sqlWhere = "";
  18081. if (!string.IsNullOrEmpty(dto.Country))
  18082. {
  18083. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  18084. }
  18085. if (!string.IsNullOrEmpty(dto.Area))
  18086. {
  18087. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  18088. }
  18089. if (!string.IsNullOrEmpty(dto.TeamName))
  18090. {
  18091. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  18092. }
  18093. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  18094. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  18095. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  18096. swatch.Stop();
  18097. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  18098. }
  18099. else
  18100. {
  18101. return Ok(JsonView(false, "查询失败"));
  18102. }
  18103. }
  18104. /// <summary>
  18105. /// 匹配op行程单
  18106. /// 行程单下载
  18107. /// </summary>
  18108. /// <param name="dto">团组列表请求dto</param>
  18109. /// <returns></returns>
  18110. [HttpPost]
  18111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18112. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  18113. {
  18114. #region 参数验证
  18115. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18116. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  18117. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18118. #region 页面操作权限验证
  18119. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  18120. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  18121. #endregion
  18122. #endregion
  18123. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  18124. {
  18125. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  18126. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  18127. }
  18128. else
  18129. {
  18130. return Ok(JsonView(false, "下载失败!"));
  18131. }
  18132. }
  18133. #endregion
  18134. #region 国家信息 数据 注释
  18135. //[HttpPost]
  18136. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  18137. //{
  18138. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  18139. // foreach (var item in dto)
  18140. // {
  18141. // infos.Add(new Grp_GroupsTaskAssignment()
  18142. // {
  18143. // DIId = item,
  18144. // CTId = 82,
  18145. // UId = 248,
  18146. // IsEnable = 1,
  18147. // CreateUserId = 233,
  18148. // CreateTime = DateTime.Now,
  18149. // IsDel = 0
  18150. // });
  18151. // infos.Add(new Grp_GroupsTaskAssignment()
  18152. // {
  18153. // DIId = item,
  18154. // CTId = 82,
  18155. // UId = 286,
  18156. // IsEnable = 1,
  18157. // CreateUserId = 233,
  18158. // CreateTime = DateTime.Now,
  18159. // IsDel = 0
  18160. // });
  18161. // }
  18162. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  18163. // return Ok("操作成功");
  18164. //}
  18165. //public class paramJsonDto
  18166. //{
  18167. // public List<CountriesInfo> str { get; set; }
  18168. //}
  18169. //[HttpPost]
  18170. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  18171. //{
  18172. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  18173. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  18174. // List<Sys_Cities> cities = new List<Sys_Cities>();
  18175. // List<Sys_Cities> districts = new List<Sys_Cities>();
  18176. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18177. // _sqlSugar.BeginTran();
  18178. // int countitiesIndex = 0;
  18179. // foreach (var item in dto.str)
  18180. // {
  18181. // dynamic data = item.c;
  18182. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  18183. // if (data != null)
  18184. // {
  18185. // countitiesIndex++;
  18186. // foreach (var item1 in data)
  18187. // {
  18188. // string cnname = item1.cn;
  18189. // string enname = item1.en;
  18190. // Sys_Cities provinceInfo = new Sys_Cities()
  18191. // {
  18192. // CountriesId = countriesId,
  18193. // Name_CN = cnname,
  18194. // Name_EN = enname,
  18195. // ParentId = 0,
  18196. // IsCapital = 1,
  18197. // CreateUserId = 208,
  18198. // CreateTime = DateTime.Now,
  18199. // IsDel = 0
  18200. // };
  18201. // if (item1.lv == "province") //省份
  18202. // {
  18203. // provinceInfo.Level = 1;
  18204. // int provinceId = 0;
  18205. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  18206. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  18207. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18208. // var data1 = item1.c;
  18209. // foreach (var item2 in data1)
  18210. // {
  18211. // if (item2.lv == "city")
  18212. // {
  18213. // string citycnname = item2.cn;
  18214. // string cityenname = item2.en;
  18215. // Sys_Cities cityInfo = new Sys_Cities()
  18216. // {
  18217. // CountriesId = countriesId,
  18218. // ParentId = provinceId,
  18219. // Level = 2,
  18220. // Name_CN = citycnname,
  18221. // Name_EN = cityenname,
  18222. // IsCapital = 1,
  18223. // CreateUserId = 208,
  18224. // CreateTime = DateTime.Now,
  18225. // IsDel = 0
  18226. // };
  18227. // if (item2.c != null)
  18228. // {
  18229. // int cityId = 0;
  18230. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  18231. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18232. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  18233. // foreach (var item3 in item2.c)
  18234. // {
  18235. // if (item3.lv == "district")
  18236. // {
  18237. // var districtInfo = new Sys_Cities()
  18238. // {
  18239. // CountriesId = countriesId,
  18240. // Name_CN = item3.cn,
  18241. // Name_EN = item3.en,
  18242. // Level = 3,
  18243. // ParentId = cityId,
  18244. // IsCapital = 1,
  18245. // CreateUserId = 208,
  18246. // CreateTime = DateTime.Now,
  18247. // IsDel = 0
  18248. // };
  18249. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18250. // //{
  18251. // districts.Add(districtInfo);
  18252. // //}
  18253. // }
  18254. // }
  18255. // }
  18256. // else
  18257. // {
  18258. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  18259. // //{
  18260. // cities.Add(cityInfo);
  18261. // //}
  18262. // }
  18263. // }
  18264. // }
  18265. // }
  18266. // else if (item1.lv == "city")//城市
  18267. // {
  18268. // provinceInfo.Level = 2;
  18269. // if (item1.c != null)
  18270. // {
  18271. // int cityId = 0;
  18272. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  18273. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18274. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18275. // foreach (var item3 in item1.c)
  18276. // {
  18277. // if (item3.lv == "district")
  18278. // {
  18279. // var districtInfo = new Sys_Cities()
  18280. // {
  18281. // CountriesId = countriesId,
  18282. // Name_CN = item3.cn,
  18283. // Name_EN = item3.en,
  18284. // Level = 3,
  18285. // ParentId = cityId,
  18286. // IsCapital = 1,
  18287. // CreateUserId = 208,
  18288. // CreateTime = DateTime.Now,
  18289. // IsDel = 0
  18290. // };
  18291. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18292. // //{
  18293. // districts.Add(districtInfo);
  18294. // //}
  18295. // }
  18296. // }
  18297. // }
  18298. // else
  18299. // {
  18300. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  18301. // //{
  18302. // cities.Add(provinceInfo);
  18303. // //}
  18304. // }
  18305. // }
  18306. // }
  18307. // }
  18308. // }
  18309. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  18310. // cities = cities.Distinct().ToList();
  18311. // districts = districts.Distinct().ToList();
  18312. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  18313. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  18314. // cities.AddRange(districts);
  18315. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  18316. // //_sqlSugar.RollbackTran();
  18317. // _sqlSugar.CommitTran();
  18318. // return Ok(JsonView(false, "操作成功!"));
  18319. //}
  18320. //[HttpPost]
  18321. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18322. //{
  18323. // List<CountitiesInfo> infos = dto.MyProperty;
  18324. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18325. // _sqlSugar.BeginTran();
  18326. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18327. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18328. // foreach (var item in infos)
  18329. // {
  18330. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18331. // if (countryInfo != null)
  18332. // {
  18333. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18334. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18335. // if (cityInfo1 != null)
  18336. // {
  18337. // cityInfo1.IsCapital = 0;
  18338. // cityInfos.Add(cityInfo1);
  18339. // }
  18340. // }
  18341. // }
  18342. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18343. // .UpdateColumns(it => it.IsCapital)
  18344. // .WhereColumns(it => it.Id)
  18345. // .ExecuteCommand();
  18346. // //_sqlSugar.RollbackTran();
  18347. // _sqlSugar.CommitTran();
  18348. // return Ok(JsonView(false, "操作成功!"));
  18349. //}
  18350. //public class CounrtiesDto
  18351. //{
  18352. // public List<CountitiesInfo> MyProperty { get; set; }
  18353. //}
  18354. //public class CountitiesInfo
  18355. //{
  18356. // /// <summary>
  18357. // /// 圣约翰
  18358. // /// </summary>
  18359. // public string capital_name_chinese { get; set; }
  18360. // /// <summary>
  18361. // ///
  18362. // /// </summary>
  18363. // public string capital_name { get; set; }
  18364. // /// <summary>
  18365. // ///
  18366. // /// </summary>
  18367. // public string country_type { get; set; }
  18368. // /// <summary>
  18369. // /// 安提瓜和巴布达
  18370. // /// </summary>
  18371. // public string country_name_chinese { get; set; }
  18372. // /// <summary>
  18373. // /// 安提瓜和巴布达
  18374. // /// </summary>
  18375. // public string country_name_chinese_short { get; set; }
  18376. // /// <summary>
  18377. // /// 安提瓜和巴布达
  18378. // /// </summary>
  18379. // public string country_name_chinese_UN { get; set; }
  18380. // /// <summary>
  18381. // ///
  18382. // /// </summary>
  18383. // public string country_name_english_abbreviation { get; set; }
  18384. // /// <summary>
  18385. // ///
  18386. // /// </summary>
  18387. // public string country_name_english_formal { get; set; }
  18388. // /// <summary>
  18389. // ///
  18390. // /// </summary>
  18391. // public string country_name_english_UN { get; set; }
  18392. // /// <summary>
  18393. // ///
  18394. // /// </summary>
  18395. // public string continent_name { get; set; }
  18396. // /// <summary>
  18397. // ///
  18398. // /// </summary>
  18399. // public string subregion_name { get; set; }
  18400. // /// <summary>
  18401. // ///
  18402. // /// </summary>
  18403. // public string country_code2 { get; set; }
  18404. // /// <summary>
  18405. // ///
  18406. // /// </summary>
  18407. // public string country_code3 { get; set; }
  18408. // /// <summary>
  18409. // ///
  18410. // /// </summary>
  18411. // public string phone_code { get; set; }
  18412. //}
  18413. //public class CountriesInfo : BasicInfo
  18414. //{
  18415. // public List<CitiesInfo> c { get; set; }
  18416. //}
  18417. //public class CitiesInfo : BasicInfo
  18418. //{
  18419. // public List<AreaInfo> c { get; set; }
  18420. //}
  18421. //public class AreaInfo : BasicInfo
  18422. //{
  18423. // public List<AreaInfo> c { get; set; }
  18424. //}
  18425. //public class BasicInfo
  18426. //{
  18427. // public string code { get; set; }
  18428. // public string cn { get; set; }
  18429. // public string lv { get; set; }
  18430. // public string en { get; set; }
  18431. //}
  18432. #endregion
  18433. #region 查看邀请方
  18434. /// <summary>
  18435. /// 查看邀请方
  18436. /// 邀请方信息 Init
  18437. /// </summary>
  18438. /// <param name="dto"></param>
  18439. /// <returns></returns>
  18440. [HttpPost]
  18441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18442. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18443. {
  18444. string sqlWhere = string.Empty;
  18445. if (!string.IsNullOrEmpty(dto.Search))
  18446. {
  18447. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18448. }
  18449. string sql = string.Format($@"Select
  18450. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18451. Id,
  18452. UnitName
  18453. From Res_InvitationOfficialActivityData
  18454. Where IsDel = 0
  18455. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18456. RefAsync<int> total = 0;
  18457. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18458. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18459. }
  18460. /// <summary>
  18461. /// 查看邀请方
  18462. /// 国家信息 Init
  18463. /// </summary>
  18464. /// <param name="dto"></param>
  18465. /// <returns></returns>
  18466. [HttpPost]
  18467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18468. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18469. {
  18470. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18471. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18472. var diids = groupInfos.Select(it => it.Id).ToList();
  18473. List<string> countrys = new List<string>();
  18474. foreach (var item in country)
  18475. {
  18476. var data = _groupRepository.FormartTeamName(item);
  18477. var dataArray = _groupRepository.GroupSplitCountry(data);
  18478. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18479. }
  18480. countrys = countrys.Distinct().ToList();
  18481. for (int i = 0; i < countrys.Count; i++)
  18482. {
  18483. string item = countrys[i];
  18484. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18485. {
  18486. countrys.Remove(item);
  18487. i--;
  18488. }
  18489. }
  18490. RefAsync<int> total = 0;
  18491. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18492. .Where(it => countrys.Contains(it.Name_CN))
  18493. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18494. .Select(it => new { id = it.Id, name = it.Name_CN })
  18495. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18496. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18497. }
  18498. /// <summary>
  18499. /// 查看邀请方
  18500. /// 城市信息 Init
  18501. /// </summary>
  18502. /// <param name="dto"></param>
  18503. /// <returns></returns>
  18504. [HttpPost]
  18505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18506. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18507. {
  18508. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18509. RefAsync<int> total = 0;
  18510. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18511. .Where(it => it.CountriesId == dto.CountiesId)
  18512. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18513. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18514. .Select(it => new { id = it.Id, name = it.Name_CN })
  18515. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18516. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18517. }
  18518. /// <summary>
  18519. /// 查看邀请方
  18520. /// 团组名称 Init
  18521. /// </summary>
  18522. /// <param name="dto"></param>
  18523. /// <returns></returns>
  18524. [HttpPost]
  18525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18526. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18527. {
  18528. var watch = new Stopwatch();
  18529. watch.Start();
  18530. RefAsync<int> total = 0;
  18531. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18532. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18533. .Where((oa, di) => oa.IsDel == 0)
  18534. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18535. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18536. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18537. .Distinct()
  18538. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18539. watch.Stop();
  18540. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18541. }
  18542. /// <summary>
  18543. /// 查看邀请方
  18544. /// 团组 & 邀请方信息
  18545. /// </summary>
  18546. /// <param name="dto"></param>
  18547. /// <returns></returns>
  18548. [HttpPost]
  18549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18550. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18551. {
  18552. var watch = new Stopwatch();
  18553. watch.Start();
  18554. RefAsync<int> total = 0;
  18555. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18556. .AS("Grp_DelegationInfo")
  18557. .Includes(x => x.InvitingInfos)
  18558. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18559. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18560. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18561. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18562. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18563. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18564. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18565. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18566. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18567. infos.ForEach(x =>
  18568. {
  18569. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18570. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18571. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18572. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18573. });
  18574. watch.Stop();
  18575. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18576. }
  18577. #endregion
  18578. #region 报批行程
  18579. /// <summary>
  18580. /// 报批行程初始化
  18581. /// </summary>
  18582. /// <param name="dto"></param>
  18583. /// <returns></returns>
  18584. [HttpPost]
  18585. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18586. {
  18587. const int chiNumber = 5;
  18588. var jw = JsonView(false);
  18589. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18590. var group = groupList.First();
  18591. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18592. group = groupList.First(x => x.Id == diid);
  18593. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18594. .Where(x => x.DiId == diid && x.IsDel == 0)
  18595. .ToArray();
  18596. var count = 1;
  18597. foreach (var item in blackCodeList)
  18598. {
  18599. if (string.IsNullOrWhiteSpace(item.Title))
  18600. {
  18601. item.Title = "未设置名称数据" + count;
  18602. }
  18603. count++;
  18604. };
  18605. if (group == null)
  18606. {
  18607. jw.Msg = "暂无团组!";
  18608. return Ok(jw);
  18609. }
  18610. var data = new
  18611. {
  18612. groupList = groupList.Select(x => new
  18613. {
  18614. x.TeamName,
  18615. x.Id
  18616. }),
  18617. content = new ArrayList(),
  18618. groupInfo = new
  18619. {
  18620. group.VisitDays,
  18621. group.TourCode,
  18622. group.VisitPNumber,
  18623. group.TeamName,
  18624. group.Id,
  18625. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18626. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18627. },
  18628. blackCodeList = blackCodeList.Select(x => new
  18629. {
  18630. x.Title,
  18631. x.Id
  18632. }),
  18633. FileTempList = new ArrayList()
  18634. {
  18635. new { Index = 1,FileName = "旧模板" },
  18636. new { Index = 2,FileName = "省外办" },
  18637. new { Index = 3,FileName = "市外办" },
  18638. }
  18639. };
  18640. var resultArr = new ArrayList();
  18641. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18642. #region 默认不生成行程
  18643. //if (content.Count == 0)
  18644. //{
  18645. // var stay = "-";
  18646. // var cityPath = "-";
  18647. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18648. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18649. // .ToList();
  18650. // //添加城市路径以及住宿地
  18651. // //黑屏代码数据
  18652. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18653. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18654. // {
  18655. // jw = JsonView(true, "黑屏代码有误!", data);
  18656. // return Ok(jw);
  18657. // }
  18658. // data = data with
  18659. // {
  18660. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18661. // {
  18662. // x.Title,
  18663. // x.Id,
  18664. // }).ToArray())
  18665. // };
  18666. // foreach (DataRow row in dtBlack.Rows)
  18667. // {
  18668. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18669. // {
  18670. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18671. // return Ok(jw);
  18672. // }
  18673. // }
  18674. // //黑屏代码获取时间区间
  18675. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18676. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18677. // _sqlSugar.BeginTran();
  18678. // for (int i = 0; i < timeArr.Count; i++)
  18679. // {
  18680. // stay = "-";
  18681. // cityPath = "-";
  18682. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18683. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18684. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18685. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18686. // if (tbSelect.Length > 0)
  18687. // {
  18688. // List<string> threeCodeStr = new List<string>();
  18689. // foreach (var item in tbSelect)
  18690. // {
  18691. // var threeCode = item["Three"].ToString() ?? "";
  18692. // if (threeCode.Length == 6)
  18693. // {
  18694. // var start = threeCode.Substring(0, 3);
  18695. // var end = threeCode.Substring(3, 3);
  18696. // if (threeCodeStr.Count == 0)
  18697. // {
  18698. // threeCodeStr.Add(start);
  18699. // threeCodeStr.Add(end);
  18700. // }
  18701. // else
  18702. // {
  18703. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18704. // {
  18705. // threeCodeStr.Add(end);
  18706. // }
  18707. // else
  18708. // {
  18709. // threeCodeStr.Add(start);
  18710. // threeCodeStr.Add(end);
  18711. // }
  18712. // }
  18713. // }
  18714. // }
  18715. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18716. // var last = threeCodeStr.Last();
  18717. // foreach (var item in threeCodeStr)
  18718. // {
  18719. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18720. // if (item.Equals(last))
  18721. // {
  18722. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18723. // }
  18724. // }
  18725. // cityPath = cityPath.Trim('-');
  18726. // }
  18727. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18728. // appro.Diid = diid ?? -1;
  18729. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18730. // appro.Id = thisId;
  18731. // appro.CreateUserId = dto.UserId;
  18732. // appro.CreateTime = DateTime.Now;
  18733. // content.Add(appro);
  18734. // }
  18735. // _sqlSugar.CommitTran();
  18736. //}
  18737. #endregion
  18738. foreach (var x in content)
  18739. {
  18740. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18741. if (chiList.Count < chiNumber)
  18742. {
  18743. for (int i = chiList.Count; i < chiNumber; i++)
  18744. {
  18745. chiList.Add(new Grp_ApprovalTravelDetails());
  18746. }
  18747. }
  18748. resultArr.Add(new
  18749. {
  18750. x.Id,
  18751. x.Date,
  18752. x.Diid,
  18753. chiList = chiList.Select(x1 => new
  18754. {
  18755. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18756. x1.Details,
  18757. x1.ParentId,
  18758. x1.Id
  18759. })
  18760. });
  18761. }
  18762. data = data with
  18763. {
  18764. content = resultArr,
  18765. };
  18766. jw = JsonView(true, "获取成功!", data);
  18767. return Ok(jw);
  18768. }
  18769. /// <summary>
  18770. /// 报批行程删除
  18771. /// </summary>
  18772. /// <param name="dto"></param>
  18773. /// <returns></returns>
  18774. [HttpPost]
  18775. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18776. {
  18777. var jw = JsonView(false);
  18778. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18779. if (group == null)
  18780. {
  18781. jw.Msg = "团组参数有误!";
  18782. return Ok(jw);
  18783. }
  18784. try
  18785. {
  18786. _sqlSugar.BeginTran();
  18787. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18788. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18789. {
  18790. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18791. DeleteUserId = dto.uesrId,
  18792. IsDel = 1
  18793. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18794. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18795. {
  18796. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18797. DeleteUserId = dto.uesrId,
  18798. IsDel = 1
  18799. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18800. _sqlSugar.CommitTran();
  18801. jw = JsonView(true, "删除成功");
  18802. }
  18803. catch (Exception ex)
  18804. {
  18805. jw = JsonView(false, ex.Message);
  18806. }
  18807. return Ok(jw);
  18808. }
  18809. /// <summary>
  18810. /// 报批行程保存
  18811. /// </summary>
  18812. /// <param name="dto"></param>
  18813. /// <returns></returns>
  18814. [HttpPost]
  18815. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18816. {
  18817. var jw = JsonView(false);
  18818. var Find = dto.Arr.Find(x => x.id == 0);
  18819. if (Find != null)
  18820. {
  18821. jw.Msg = "生成的ID为0!";
  18822. return Ok(jw);
  18823. }
  18824. foreach (var item in dto.Arr)
  18825. {
  18826. foreach (var chi in item.chiList)
  18827. {
  18828. if (chi.parentId == 0)
  18829. {
  18830. chi.parentId = item.id;
  18831. }
  18832. }
  18833. }
  18834. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18835. _sqlSugar.BeginTran();
  18836. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18837. {
  18838. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18839. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18840. {
  18841. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18842. DeleteUserId = dto.UserId,
  18843. IsDel = 1
  18844. }).ExecuteCommand();
  18845. }
  18846. try
  18847. {
  18848. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18849. {
  18850. CreateTime = DateTime.Now,
  18851. CreateUserId = dto.UserId,
  18852. Details = x.details,
  18853. ParentId = x.parentId,
  18854. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18855. Remark = "",
  18856. IsDel = 0
  18857. }).ToList()).ExecuteCommand();
  18858. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18859. {
  18860. Id = x.id,
  18861. Details = x.details,
  18862. ParentId = x.parentId,
  18863. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18864. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18865. {
  18866. Details = x.Details,
  18867. ParentId = x.ParentId,
  18868. Time = x.Time
  18869. }).ExecuteCommand();
  18870. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18871. {
  18872. Id = x.id,
  18873. Date = x.date,
  18874. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18875. {
  18876. Date = x.Date
  18877. }).ExecuteCommand();
  18878. _sqlSugar.CommitTran();
  18879. jw = JsonView(true, "保存成功!");
  18880. }
  18881. catch (Exception ex)
  18882. {
  18883. _sqlSugar.RollbackTran();
  18884. jw = JsonView(false, "保存失败!" + ex.Message);
  18885. }
  18886. return Ok(jw);
  18887. }
  18888. /// <summary>
  18889. /// 报批行程生成
  18890. /// </summary>
  18891. /// <param name="dto"></param>
  18892. /// <returns></returns>
  18893. [HttpPost]
  18894. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18895. {
  18896. var jw = JsonView(false);
  18897. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18898. if (group == null)
  18899. {
  18900. jw.Msg = "暂无该团组!";
  18901. return Ok(jw);
  18902. }
  18903. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18904. //黑屏代码数据
  18905. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18906. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18907. {
  18908. jw.Msg = "黑屏代码有误!";
  18909. return Ok(jw);
  18910. }
  18911. foreach (DataRow row in dtBlack.Rows)
  18912. {
  18913. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18914. {
  18915. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18916. return Ok(jw);
  18917. }
  18918. }
  18919. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18920. var resultArr = new ArrayList();
  18921. //if (officialActivitiesArr.Count == 0)
  18922. //{
  18923. // jw.Msg = "暂无公务出访信息!";
  18924. // return Ok(jw);
  18925. //}
  18926. try
  18927. {
  18928. _sqlSugar.BeginTran();
  18929. DeleteApprovalJourney(new
  18930. Domain.Dtos.Groups.DeleteApprovalJourney
  18931. {
  18932. Diid = dto.Diid,
  18933. uesrId = dto.Userid
  18934. });
  18935. var stay = "-";
  18936. var cityPath = "-";
  18937. //添加城市路径以及住宿地
  18938. //黑屏代码获取时间区间
  18939. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18940. var empty = "【未收入该三字码!请机票同事录入】";
  18941. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18942. for (int i = 0; i < timeArr.Count; i++)
  18943. {
  18944. stay = "-";
  18945. cityPath = "-";
  18946. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18947. DateTime NewData = DateTime.Parse(timeArr[i]);
  18948. //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();
  18949. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18950. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18951. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18952. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18953. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18954. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18955. if (tbSelect.Length > 0)
  18956. {
  18957. List<string> threeCodeStr = new List<string>();
  18958. bool isTrade = false;
  18959. string trip = string.Empty;
  18960. var rowLast = tbSelect.Last();
  18961. var rowFirst = tbSelect.First();
  18962. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18963. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18964. var takeOffTime = DateTime.Parse(timeArr[i]);
  18965. var fallToTime = DateTime.Parse(timeArr[i]);
  18966. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18967. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18968. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18969. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18970. foreach (var item in tbSelect)
  18971. {
  18972. var start = string.Empty;
  18973. var end = string.Empty;
  18974. var threeCode = item["Three"].ToString() ?? "";
  18975. if (threeCode.Length == 6)
  18976. {
  18977. start = threeCode.Substring(0, 3);
  18978. end = threeCode.Substring(3, 3);
  18979. if (threeCodeStr.Count == 0)
  18980. {
  18981. threeCodeStr.Add(start);
  18982. threeCodeStr.Add(end);
  18983. }
  18984. else
  18985. {
  18986. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18987. {
  18988. threeCodeStr.Add(end);
  18989. }
  18990. else
  18991. {
  18992. threeCodeStr.Add(start);
  18993. threeCodeStr.Add(end);
  18994. }
  18995. }
  18996. }
  18997. //处理机票信息
  18998. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18999. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  19000. if (start_Object == null)
  19001. {
  19002. start_Object = new Res_ThreeCode()
  19003. {
  19004. AirPort = empty,
  19005. AirPort_En = empty,
  19006. City = empty,
  19007. Country = empty,
  19008. Four = empty,
  19009. Three = empty,
  19010. };
  19011. }
  19012. if (end_Object == null)
  19013. {
  19014. end_Object = new Res_ThreeCode()
  19015. {
  19016. AirPort = empty,
  19017. AirPort_En = empty,
  19018. City = empty,
  19019. Country = empty,
  19020. Four = empty,
  19021. Three = empty,
  19022. };
  19023. }
  19024. //机型判断
  19025. string airModel = item["AirModel"].ToString();
  19026. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  19027. string flightTime = item["FlightTime"].ToString();
  19028. if (flightTime!.Contains(":"))
  19029. {
  19030. flightTime = flightTime.Replace(":", "小时");
  19031. flightTime += "分钟";
  19032. }
  19033. if (flightTime.Contains("H"))
  19034. {
  19035. flightTime = flightTime.Replace("H", "小时");
  19036. }
  19037. if (flightTime.Contains("M"))
  19038. {
  19039. flightTime = flightTime.Replace("M", "分钟");
  19040. }
  19041. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  19042. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  19043. {
  19044. flightTime = flightDataTime.Hour > 0
  19045. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  19046. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  19047. ? flightDataTime.Minute.ToString() + "分钟" : "";
  19048. }
  19049. //航班号
  19050. string flightcode = item["Fliagtcode"].ToString();
  19051. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  19052. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  19053. if (aircompany == null)
  19054. {
  19055. aircompany = new Res_AirCompany
  19056. {
  19057. CnName = hsEmpty,
  19058. EnName = hsEmpty,
  19059. ShortCode = hsEmpty,
  19060. };
  19061. }
  19062. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  19063. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  19064. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  19065. if (isTrade)
  19066. {
  19067. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  19068. }
  19069. else
  19070. {
  19071. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  19072. }
  19073. }
  19074. chiarr.Add(new Grp_ApprovalTravelDetails
  19075. {
  19076. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  19077. CreateTime = DateTime.Now,
  19078. CreateUserId = dto.Userid,
  19079. ParentId = 0,
  19080. Details = trip
  19081. });
  19082. //添加乘车语句
  19083. chiarr.Add(new Grp_ApprovalTravelDetails
  19084. {
  19085. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  19086. CreateTime = DateTime.Now,
  19087. CreateUserId = dto.Userid,
  19088. ParentId = 0,
  19089. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  19090. });
  19091. if (i != timeArr.Count - 1)
  19092. {
  19093. fallToTime = fallToTime.AddHours(2.5);
  19094. foreach (var item in Times)
  19095. {
  19096. //排列公务时间
  19097. if (fallToTime.Hour < item.Item1)
  19098. {
  19099. chiarr.Add(new Grp_ApprovalTravelDetails
  19100. {
  19101. Time = $"{item.Item2} - {item.Item3}",
  19102. CreateTime = DateTime.Now,
  19103. CreateUserId = dto.Userid,
  19104. ParentId = 0,
  19105. Details = "公务活动"
  19106. });
  19107. }
  19108. }
  19109. }
  19110. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19111. var last = threeCodeStr.Last();
  19112. foreach (var item in threeCodeStr)
  19113. {
  19114. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19115. if (item.Equals(last))
  19116. {
  19117. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19118. }
  19119. }
  19120. cityPath = cityPath.Trim('-');
  19121. }
  19122. else
  19123. {
  19124. foreach (var item in Times)
  19125. {
  19126. chiarr.Add(new Grp_ApprovalTravelDetails
  19127. {
  19128. Time = $"{item.Item2} - {item.Item3}",
  19129. CreateTime = DateTime.Now,
  19130. CreateUserId = dto.Userid,
  19131. ParentId = 0,
  19132. Details = "公务活动"
  19133. });
  19134. }
  19135. }
  19136. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19137. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19138. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  19139. appro.Diid = dto.Diid;
  19140. appro.CreateUserId = dto.Userid;
  19141. appro.CreateTime = DateTime.Now;
  19142. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19143. appro.Id = thisId;
  19144. //foreach (var item in gwinfo)
  19145. //{
  19146. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  19147. // chi.Details = "拜访" + item.Client;
  19148. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  19149. // {
  19150. // chi.Details += "," + item.ReqSample;
  19151. // }
  19152. // chi.ParentId = thisId;
  19153. // chi.Time = item.Time;
  19154. // chiarr.Add(chi);
  19155. //}
  19156. if (chiarr.Count < 6)
  19157. {
  19158. for (int j = chiarr.Count; j < 6; j++)
  19159. {
  19160. chiarr.Add(new
  19161. Grp_ApprovalTravelDetails());
  19162. }
  19163. }
  19164. resultArr.Add(new
  19165. {
  19166. appro.Id,
  19167. appro.Date,
  19168. appro.Diid,
  19169. chiList = chiarr.Select(x1 => new
  19170. {
  19171. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19172. x1.Details,
  19173. x1.ParentId,
  19174. x1.Id
  19175. })
  19176. });
  19177. }
  19178. _sqlSugar.CommitTran();
  19179. jw = JsonView(true, "生成成功!", resultArr);
  19180. }
  19181. catch (Exception ex)
  19182. {
  19183. jw.Code = 400;
  19184. jw.Msg = "生成失败!" + ex.Message;
  19185. }
  19186. return Ok(jw);
  19187. }
  19188. /// <summary>
  19189. /// 报批行程word导出
  19190. /// </summary>
  19191. /// <param name="dto"></param>
  19192. /// <returns></returns>
  19193. [HttpPost]
  19194. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  19195. {
  19196. var jw = JsonView(false);
  19197. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19198. if (group == null)
  19199. {
  19200. jw.Msg = "暂无该团组!";
  19201. return Ok(jw);
  19202. }
  19203. //模板路径
  19204. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  19205. var fileName = string.Empty;
  19206. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  19207. bool bold = false;
  19208. if (dto.FileIndex == 1)
  19209. {
  19210. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  19211. }
  19212. else if (dto.FileIndex == 2)
  19213. {
  19214. fileName = "省外办-报批.docx";
  19215. bold = false;
  19216. titleFont = "方正黑体简体";
  19217. timeFont = "Times New Roman";
  19218. contentFont = "方正仿宋_GBK";
  19219. }
  19220. else if (dto.FileIndex == 3)
  19221. {
  19222. fileName = "市外办-报批.docx";
  19223. titleFont = "方正黑体简体";
  19224. timeFont = "Times New Roman";
  19225. contentFont = "方正仿宋简体";
  19226. }
  19227. tempPath = tempPath + fileName;
  19228. //载入模板
  19229. Document doc = new Document(tempPath);
  19230. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19231. //获取所填表格的序数
  19232. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19233. Aspose.Words.Tables.Row titleRowClone = null;
  19234. Aspose.Words.Tables.Row CenterRowClone = null;
  19235. int index = 0;
  19236. int indexChi = 0;
  19237. int SetIndex = 0;
  19238. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  19239. //获取数据,放到datatable
  19240. foreach (var item in ApprovalTravelArr)
  19241. {
  19242. if (index > 0)
  19243. {
  19244. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  19245. tableOne.AppendChild(titleRowClone);
  19246. }
  19247. var textTime = item.Date;
  19248. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  19249. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  19250. SetIndex++;
  19251. if (ChiRep.Count > 0)
  19252. {
  19253. foreach (var itemChi in ChiRep)
  19254. {
  19255. var txtTime = itemChi.Time;
  19256. var txtDetail = itemChi.Details;
  19257. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  19258. {
  19259. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  19260. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19261. //indexChi++;
  19262. //SetIndex++;
  19263. break;
  19264. }
  19265. if (indexChi > 0)
  19266. {
  19267. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19268. tableOne.AppendChild(CenterRowClone);
  19269. }
  19270. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  19271. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  19272. indexChi++;
  19273. SetIndex++;
  19274. }
  19275. }
  19276. //else
  19277. //{
  19278. // if (indexChi > 0)
  19279. // {
  19280. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19281. // tableOne.AppendChild(CenterRowClone);
  19282. // }
  19283. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  19284. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19285. // indexChi++;
  19286. // SetIndex++;
  19287. //}
  19288. index++;
  19289. }
  19290. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  19291. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19292. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19293. jw.Code = 200;
  19294. jw.Msg = "";
  19295. return Ok(jw);
  19296. }
  19297. private string intToString(int numberVal)
  19298. {
  19299. string numberval = numberVal.ToString();
  19300. Dictionary<char, string> Number = new Dictionary<char, string>();
  19301. Number.Add('1', "一");
  19302. Number.Add('2', "二");
  19303. Number.Add('3', "三");
  19304. Number.Add('4', "四");
  19305. Number.Add('5', "五");
  19306. Number.Add('6', "六");
  19307. Number.Add('7', "七");
  19308. Number.Add('8', "八");
  19309. Number.Add('9', "九");
  19310. string stringNumberVal = string.Empty;
  19311. for (int i = 0; i < numberval.Length; i++)
  19312. {
  19313. if (i == 0)
  19314. {
  19315. stringNumberVal += Number[numberval[i]];
  19316. }
  19317. else if (i >= 1)
  19318. {
  19319. if (numberval[i] == '0')
  19320. {
  19321. stringNumberVal = "十";
  19322. }
  19323. else
  19324. {
  19325. stringNumberVal += "十" + Number[numberval[i]];
  19326. }
  19327. }
  19328. }
  19329. return stringNumberVal;
  19330. }
  19331. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  19332. {
  19333. //获取table中的某个单元格,从0开始
  19334. Cell lshCell = table.Rows[rows].Cells[cells];
  19335. //将单元格中段落移除
  19336. foreach (Paragraph item in lshCell.Paragraphs)
  19337. {
  19338. lshCell.Paragraphs.Remove(item);
  19339. }
  19340. if (val.Contains("\r\n"))
  19341. {
  19342. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19343. foreach (var item in spArr)
  19344. {
  19345. //新建一个段落
  19346. Paragraph p = new Paragraph(doc);
  19347. var r = new Run(doc, item);
  19348. //设置字体
  19349. if (!string.IsNullOrEmpty(font))
  19350. {
  19351. r.Font.Name = font;
  19352. }
  19353. r.Font.Bold = bold;
  19354. //把设置的值赋给之前新建的段落
  19355. p.AppendChild(r);
  19356. //将此段落加到单元格内
  19357. lshCell.AppendChild(p);
  19358. }
  19359. }
  19360. else
  19361. {
  19362. //新建一个段落
  19363. Paragraph p = new Paragraph(doc);
  19364. var r = new Run(doc, val);
  19365. //设置字体
  19366. if (!string.IsNullOrEmpty(font))
  19367. {
  19368. r.Font.Name = font;
  19369. }
  19370. r.Font.Bold = bold;
  19371. //把设置的值赋给之前新建的段落
  19372. p.AppendChild(r);
  19373. //将此段落加到单元格内
  19374. lshCell.AppendChild(p);
  19375. }
  19376. }
  19377. [HttpPost]
  19378. public async Task<IActionResult> ServerHttp(string paramStr)
  19379. {
  19380. paramStr = paramStr.TrimEnd('\'');
  19381. paramStr = paramStr.TrimStart('\'');
  19382. JsonView jw = JsonView(false);
  19383. JObject param = JObject.Parse(paramStr);
  19384. if (!param.ContainsKey("url"))
  19385. {
  19386. jw.Msg = "url null";
  19387. return Ok(jw);
  19388. }
  19389. string url = param["url"]!.ToString();
  19390. var methon = "get";
  19391. Dictionary<string, string> headValues = null;
  19392. string bodyStr = string.Empty;
  19393. if (param.ContainsKey("methon"))
  19394. {
  19395. methon = param["methon"]!.ToString().ToLower();
  19396. }
  19397. if (param.ContainsKey("header"))
  19398. {
  19399. var header = param["header"]!.ToString();
  19400. JObject headerJobject = JObject.Parse(header);
  19401. headValues = new Dictionary<string, string>();
  19402. foreach (JProperty item in headerJobject.Properties())
  19403. {
  19404. var value = item.Value.ToString();
  19405. var head = item.Path;
  19406. headValues.Add(head, value);
  19407. }
  19408. }
  19409. HttpClient client = new HttpClient();
  19410. string responseString = string.Empty;
  19411. StringContent content = null;
  19412. if (headValues != null)
  19413. {
  19414. foreach (var item in headValues.Keys)
  19415. {
  19416. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19417. {
  19418. if (param.ContainsKey("body"))
  19419. {
  19420. bodyStr = param["body"]!.ToString();
  19421. }
  19422. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19423. }
  19424. else
  19425. {
  19426. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19427. }
  19428. }
  19429. }
  19430. try
  19431. {
  19432. if (methon == "get")
  19433. {
  19434. responseString = await client.GetStringAsync(url);
  19435. }
  19436. else if (methon == "post")
  19437. {
  19438. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19439. {
  19440. Content = content
  19441. };
  19442. var response = await client.SendAsync(request);
  19443. try
  19444. {
  19445. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19446. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19447. {
  19448. using (StreamReader reader = new StreamReader(gzipStream))
  19449. {
  19450. responseString = await reader.ReadToEndAsync();
  19451. }
  19452. }
  19453. }
  19454. catch (Exception)
  19455. {
  19456. responseString = await response.Content.ReadAsStringAsync();
  19457. }
  19458. }
  19459. else
  19460. {
  19461. responseString = "methon error";
  19462. }
  19463. jw = JsonView(true, "success", responseString);
  19464. }
  19465. catch (Exception ex)
  19466. {
  19467. jw.Msg = "error " + ex.Message;
  19468. jw.Data = ex.StackTrace;
  19469. }
  19470. finally
  19471. {
  19472. client.Dispose();
  19473. }
  19474. return Ok(jw);
  19475. }
  19476. #endregion
  19477. #region 团组接待意见调查
  19478. /// <summary>
  19479. /// 团组接待意见调查 - 信息管理
  19480. /// 基础数据(团组)
  19481. /// </summary>
  19482. /// <returns></returns>
  19483. [HttpGet]
  19484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19485. public async Task<IActionResult> OpinionaireInit()
  19486. {
  19487. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19488. .Select(x => new
  19489. {
  19490. x.Id,
  19491. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19492. })
  19493. .OrderByDescending(x => x.Id)
  19494. .ToListAsync();
  19495. return Ok(JsonView(groupData, groupData.Count));
  19496. }
  19497. /// <summary>
  19498. /// 团组接待意见调查 - 信息管理
  19499. /// 列表
  19500. /// </summary>
  19501. /// <param name="groupId"></param>
  19502. /// <returns></returns>
  19503. [HttpGet("{groupId}")]
  19504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19505. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19506. {
  19507. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19508. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19509. .Select(x => new
  19510. {
  19511. x.Id,
  19512. x.TourGuideName,
  19513. x.CityName,
  19514. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19515. x.CreateTime
  19516. })
  19517. .OrderBy(x => x.Id)
  19518. .ToListAsync();
  19519. return Ok(JsonView(data));
  19520. }
  19521. /// <summary>
  19522. /// 团组接待意见调查 - 信息管理
  19523. /// 保存
  19524. /// </summary>
  19525. /// <param name="dto"></param>
  19526. /// <returns></returns>
  19527. [HttpPost]
  19528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19529. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19530. {
  19531. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19532. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19533. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19534. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19535. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19536. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19537. _opinionaireRep.BeginTran();
  19538. if (addData != null && addData.Count > 0)
  19539. {
  19540. foreach (var item in addData)
  19541. {
  19542. item.CreateUserId = currUserInfo.UserId;
  19543. item.DiId = dto.DiId;
  19544. }
  19545. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19546. }
  19547. if (updData != null && updData.Count > 0)
  19548. {
  19549. var upd = await _opinionaireRep._sqlSugar
  19550. .Updateable(updData)
  19551. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19552. .WhereColumns(x => new { x.Id })
  19553. .ExecuteCommandAsync();
  19554. }
  19555. _opinionaireRep.CommitTran();
  19556. return Ok(JsonView("操作成功!"));
  19557. }
  19558. /// <summary>
  19559. /// 团组接待意见调查 - 信息管理
  19560. /// 删除
  19561. /// </summary>
  19562. /// <param name="id"></param>
  19563. /// <returns></returns>
  19564. [HttpDelete("{id}")]
  19565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19566. public async Task<IActionResult> OpinionaireManageDel(int id)
  19567. {
  19568. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19569. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19570. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19571. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19572. if (!del) return Ok(JsonView("操作失败!"));
  19573. return Ok(JsonView("操作成功!"));
  19574. }
  19575. /// <summary>
  19576. /// 团组接待意见调查 - 用户
  19577. /// 列表
  19578. /// </summary>
  19579. /// <param name="diId"></param>
  19580. /// <returns></returns>
  19581. [HttpGet("{diId}")]
  19582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19583. public async Task<IActionResult> OpinionaireUserList(int diId)
  19584. {
  19585. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19586. var sql = string.Format(@"
  19587. SELECT
  19588. o.Id,
  19589. o.DiId,
  19590. di.TeamName AS 'GroupName',
  19591. di.VisitPNumber AS 'PeopleNumber',
  19592. di.ClientName AS 'LeadGroup',
  19593. di.VisitCountry AS 'Travel',
  19594. di.VisitDays AS 'Days',
  19595. o.CityName,
  19596. o.TourGuideName,
  19597. o.Catering,
  19598. o.CateringReason,
  19599. o.Stay,
  19600. o.StayReason,
  19601. o.[Route],
  19602. o.RouteReason,
  19603. o.OfficialActivity,
  19604. o.OfficialActivityReason,
  19605. o.TourGuide,
  19606. o.TourGuideReason,
  19607. o.[Translate],
  19608. o.TranslateReason,
  19609. o.Trip,
  19610. o.TripReason,
  19611. o.ESFileName,
  19612. o.SignatureDate,
  19613. o.Remark
  19614. FROM
  19615. Grp_Opinionaire o
  19616. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19617. WHERE
  19618. o.IsDel = 0
  19619. AND o.DiId = {0}
  19620. ORDER BY
  19621. o.Id ASC", diId);
  19622. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19623. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19624. return Ok(JsonView(data));
  19625. }
  19626. /// <summary>
  19627. /// 团组接待意见调查 - 用户
  19628. /// 保存
  19629. /// </summary>
  19630. /// <param name="dto"></param>
  19631. /// <returns></returns>
  19632. [HttpPost]
  19633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19634. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19635. {
  19636. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19637. foreach (var item in dto)
  19638. {
  19639. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19640. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19641. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19642. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19643. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19644. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19645. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19646. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19647. }
  19648. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19649. if (!Directory.Exists(filePathBase))
  19650. {
  19651. Directory.CreateDirectory(filePathBase);
  19652. }
  19653. #region 上传文件
  19654. var filePaths = new List<string>();
  19655. foreach (var item in dto)
  19656. {
  19657. var file = item.File;
  19658. // 将文件保存到指定位置
  19659. var filePath = Path.Combine(filePathBase, file.FileName);
  19660. using (var stream = new FileStream(filePath, FileMode.Create))
  19661. {
  19662. await file.CopyToAsync(stream);
  19663. }
  19664. //验证文件是否上传成功
  19665. if (!System.IO.File.Exists(filePath))
  19666. {
  19667. foreach (var filePathStr in filePaths)
  19668. {
  19669. System.IO.File.Delete(filePathStr);
  19670. }
  19671. return Ok(JsonView(false, "文件上传失败!"));
  19672. }
  19673. item.ESFileName = file.FileName;
  19674. }
  19675. #endregion
  19676. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19677. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19678. .UpdateColumns(x => new
  19679. {
  19680. x.Catering,
  19681. x.CateringReason,
  19682. x.Stay,
  19683. x.StayReason,
  19684. x.Route,
  19685. x.RouteReason,
  19686. x.OfficialActivity,
  19687. x.OfficialActivityReason,
  19688. x.TourGuide,
  19689. x.TourGuideReason,
  19690. x.Translate,
  19691. x.TranslateReason,
  19692. x.Trip,
  19693. x.TripReason,
  19694. x.ESFileName,
  19695. x.SignatureDate,
  19696. x.Remark
  19697. })
  19698. .WhereColumns(x => new { x.Id })
  19699. .ExecuteCommandAsync();
  19700. if (upd < 1)
  19701. {
  19702. foreach (var filePathStr in filePaths)
  19703. {
  19704. System.IO.File.Delete(filePathStr);
  19705. }
  19706. return Ok(JsonView(false));
  19707. }
  19708. return Ok(JsonView(true));
  19709. }
  19710. #endregion
  19711. #region 团组餐厅相关信息
  19712. /// <summary>
  19713. /// 团组相关餐厅信息
  19714. /// 基础数据(团组)
  19715. /// </summary>
  19716. /// <returns></returns>
  19717. [HttpGet]
  19718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19719. public async Task<IActionResult> RestaurantInit()
  19720. {
  19721. return Ok(await _restaurantRep.InitAsync());
  19722. }
  19723. /// <summary>
  19724. /// 团组相关餐厅信息
  19725. /// Item
  19726. /// </summary>
  19727. /// <param name="dto"></param>
  19728. /// <returns></returns>
  19729. [HttpPost]
  19730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19731. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19732. {
  19733. int portType = dto.PortType,
  19734. groupId = dto.GroupId;
  19735. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19736. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19737. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19738. }
  19739. /// <summary>
  19740. /// 团组相关餐厅信息
  19741. /// List
  19742. /// </summary>
  19743. /// <param name="dto"></param>
  19744. /// <returns></returns>
  19745. [HttpPost]
  19746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19747. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19748. {
  19749. int portType = dto.PortType,
  19750. groupId = dto.GroupId;
  19751. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19752. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19753. var sql = string.Format(@" SELECT
  19754. ri.Id,
  19755. ri.GroupId,
  19756. ri.Date,
  19757. ri.StartTime,
  19758. ri.EndTime,
  19759. CASE WHEN ri.Type = 1 THEN '早餐'
  19760. WHEN ri.Type = 2 THEN '午餐'
  19761. WHEN ri.Type = 3 THEN '晚餐'
  19762. ELSE '其他'
  19763. END AS 'Type',
  19764. ri.Name,
  19765. ri.Address,
  19766. ri.Tel,
  19767. ri.Remark,
  19768. ri.CreateTime,
  19769. u.CnName AS CreateUserName
  19770. FROM
  19771. Grp_RestaurantInfo ri
  19772. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19773. WHERE
  19774. ri.IsDel = 0
  19775. AND ri.GroupId = {0}
  19776. ORDER BY
  19777. ri.Date ASC
  19778. ", groupId);
  19779. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19780. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19781. return Ok(JsonView(infos));
  19782. }
  19783. /// <summary>
  19784. /// 团组相关餐厅信息
  19785. /// Info
  19786. /// </summary>
  19787. /// <param name="dto"></param>
  19788. /// <returns></returns>
  19789. [HttpPost]
  19790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19791. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19792. {
  19793. int portType = dto.PortType,
  19794. id = dto.Id;
  19795. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19796. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19797. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19798. }
  19799. /// <summary>
  19800. /// 团组相关餐厅信息
  19801. /// Op
  19802. /// </summary>
  19803. /// <param name="dto"></param>
  19804. /// <returns></returns>
  19805. [HttpPost]
  19806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19807. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19808. {
  19809. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19810. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19811. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19812. return Ok(await _restaurantRep.OpAsync(dto));
  19813. }
  19814. /// <summary>
  19815. /// 团组相关餐厅信息
  19816. /// Del
  19817. /// </summary>
  19818. /// <param name="dto"></param>
  19819. /// <returns></returns>
  19820. [HttpPost]
  19821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19822. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19823. {
  19824. int userId = dto.DeleteUserId;
  19825. var id = dto.Id;
  19826. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19827. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19828. return Ok(await _restaurantRep.DelAsync(dto));
  19829. }
  19830. #endregion
  19831. // /// <summary>
  19832. // ///
  19833. // /// </summary>
  19834. // /// <param name="_dto"></param>
  19835. // /// <returns></returns>
  19836. // [HttpPost]
  19837. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19838. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19839. // {
  19840. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19841. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19842. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19843. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19844. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19845. // dic_psg.Add("客人", 974);
  19846. // dic_psg.Add("司机", 975);
  19847. // dic_psg.Add("导游", 976);
  19848. // dic_psg.Add("公司内部人员", 977);
  19849. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19850. // foreach (var item in list_visa)
  19851. // {
  19852. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19853. // temp.Id = item.Id;
  19854. // temp.DIId = item.DIId;
  19855. // temp.VisaClient = item.VisaClient;
  19856. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19857. // temp.VisaCurrency = item.VisaCurrency;
  19858. // temp.IsThird = item.IsThird;
  19859. // if (dic_psg.ContainsKey(item.PassengerType))
  19860. // {
  19861. // temp.PassengerType = dic_psg[item.PassengerType];
  19862. // }
  19863. // else {
  19864. // temp.PassengerType = -1;
  19865. // }
  19866. // temp.VisaNumber = item.VisaNumber;
  19867. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19868. // temp.CreateUserId = item.Operators;
  19869. // DateTime dt_ct;
  19870. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19871. // if (b_ct)
  19872. // {
  19873. // temp.CreateTime = dt_ct;
  19874. // }
  19875. // else
  19876. // {
  19877. // temp.CreateTime = DateTime.Now;
  19878. // }
  19879. // temp.DeleteTime = "";
  19880. // temp.DeleteUserId = 0;
  19881. // temp.Remark = item.Remark;
  19882. // if (string.IsNullOrEmpty(temp.Remark)) {
  19883. // temp.Remark = "";
  19884. // }
  19885. // temp.IsDel = item.IsDel;
  19886. // temp.VisaDescription = item.VisaAttachment;
  19887. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19888. //([Id]
  19889. // ,[DIId]
  19890. // ,[VisaClient]
  19891. // ,[VisaPrice]
  19892. // ,[VisaCurrency]
  19893. // ,[IsThird]
  19894. // ,[PassengerType]
  19895. // ,[VisaNumber]
  19896. // ,[VisaFreeNumber]
  19897. // ,[CreateUserId]
  19898. // ,[CreateTime]
  19899. // ,[DeleteTime]
  19900. // ,[DeleteUserId]
  19901. // ,[Remark]
  19902. // ,[IsDel]
  19903. // ,[visaDescription])
  19904. // VALUES
  19905. // ({0},{1},'{2}',{3},{4}
  19906. //,{5},{6},{7},{8},{9}
  19907. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19908. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19909. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19910. //);
  19911. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19912. // }
  19913. // return Ok(JsonView(true, "操作成功!"));
  19914. // }
  19915. /// <summary>
  19916. /// 123132123
  19917. /// </summary>
  19918. /// <param name="_dto"></param>
  19919. /// <returns></returns>
  19920. [HttpPost]
  19921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19922. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19923. {
  19924. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19925. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19926. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19927. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19928. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19929. dicDetail.Add(789, 1034);
  19930. dicDetail.Add(790, 1035);
  19931. dicDetail.Add(791, 1036);
  19932. dicDetail.Add(792, 1037);
  19933. dicDetail.Add(793, 1038);
  19934. dicDetail.Add(794, 1039);
  19935. dicDetail.Add(795, 1040);
  19936. dicDetail.Add(796, 1041);
  19937. dicDetail.Add(797, 1042);
  19938. dicDetail.Add(798, 1043);
  19939. dicDetail.Add(801, 1044);
  19940. dicDetail.Add(802, 1045);
  19941. dicDetail.Add(803, 1046);
  19942. Dictionary<int, int> dic = new Dictionary<int, int>();
  19943. dic.Add(806, 1027);
  19944. dic.Add(807, 1028);
  19945. dic.Add(808, 1029);
  19946. dic.Add(809, 1030);
  19947. dic.Add(810, 1031);
  19948. dic.Add(811, 1032);
  19949. dic.Add(812, 1033);
  19950. foreach (var item in list_visa)
  19951. {
  19952. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19953. temp.Coefficient = item.coefficient;
  19954. DateTime dtCrt;
  19955. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19956. if (b1)
  19957. {
  19958. temp.CreateTime = dtCrt;
  19959. }
  19960. else
  19961. {
  19962. temp.CreateTime = DateTime.Now;
  19963. }
  19964. temp.CreateUserId = item.Operators;
  19965. temp.DeleteTime = "";
  19966. temp.DeleteUserId = 0;
  19967. temp.DiId = int.Parse(item.DIID);
  19968. temp.FilePath = item.FilePath;
  19969. temp.IsDel = item.IsDel;
  19970. temp.Price = item.Price;
  19971. temp.PriceCount = 1;
  19972. temp.PriceCurrency = item.Currency;
  19973. int detailId = 0;
  19974. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19975. {
  19976. detailId = dicDetail[item.PriceTypeDetail];
  19977. }
  19978. temp.PriceDetailType = detailId;
  19979. temp.PriceDt = DateTime.Now;
  19980. temp.PriceName = item.PriceName;
  19981. temp.PriceSum = item.Price;
  19982. int tid = 0;
  19983. if (dic.ContainsKey(item.PriceType))
  19984. {
  19985. tid = dic[item.PriceType];
  19986. }
  19987. temp.PriceType = tid;
  19988. temp.Remark = item.Remark;
  19989. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19990. }
  19991. return Ok(JsonView(true, "操作成功!"));
  19992. }
  19993. [HttpPost]
  19994. public IActionResult TimeTest()
  19995. {
  19996. var jw = JsonView(false, "error");
  19997. _sqlSugar.BeginTran();
  19998. try
  19999. {
  20000. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  20001. .Select(x => new Crm_NewClientData
  20002. {
  20003. Id = x.Id,
  20004. Client = x.Client,
  20005. Contact = x.Contact,
  20006. Location = x.Location,
  20007. })
  20008. .ToList();
  20009. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  20010. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  20011. Stopwatch stopwatch = new Stopwatch();
  20012. // 开始计时
  20013. stopwatch.Start();
  20014. foreach (var item in clientList)
  20015. {
  20016. EncryptionProcessor.DecryptProperties(item);
  20017. }
  20018. stopwatch.Stop();
  20019. jw.Code = 200;
  20020. jw.Data = stopwatch.ElapsedMilliseconds;
  20021. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  20022. }
  20023. catch (Exception ex)
  20024. {
  20025. jw.Code = 400;
  20026. jw.Msg = ex.Message;
  20027. }
  20028. return Ok(jw);
  20029. }
  20030. }
  20031. }