GroupsController.cs 1.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216
  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. [HttpGet]
  4939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4940. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  4941. {
  4942. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  4943. }
  4944. /// <summary>
  4945. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4946. /// </summary>
  4947. /// <returns></returns>
  4948. [HttpPost]
  4949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4950. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  4951. {
  4952. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4953. var groupNamFirst = groupNameData.FirstOrDefault();
  4954. //SetDataInfoView
  4955. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  4956. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4957. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4958. //验证城市归属并给默认值
  4959. int provinceId = 122;
  4960. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  4961. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  4962. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4963. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4964. return Ok(JsonView(true, "查询成功!", new
  4965. {
  4966. GroupNameData = groupNameData,
  4967. CurrencyData = _CurrencyData,
  4968. WordTypeData = wordTypeData,
  4969. ExcelTypeData = excelTypeData,
  4970. CurrencyInit = _currencyInfos,
  4971. ViewPermissionData = viewPermissionData
  4972. }));
  4973. }
  4974. /// <summary>
  4975. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  4976. /// </summary>
  4977. /// <returns></returns>
  4978. [HttpGet("{provinceId}")]
  4979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4980. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  4981. {
  4982. //验证城市归属并给默认值
  4983. if (provinceId < 1) provinceId = 122;
  4984. /*
  4985. * 122 四川
  4986. * 108 贵州
  4987. * 103 重庆
  4988. * 132 云南
  4989. */
  4990. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  4991. return Ok(JsonView(true, "查询成功!", new
  4992. {
  4993. WordTypeData = wordTypeData,
  4994. ExcelTypeData = excelTypeData,
  4995. }));
  4996. }
  4997. /// <summary>
  4998. /// 团组模块 - 出入境费用
  4999. /// 实时汇率 tips
  5000. /// 签证费用 tips
  5001. /// 机票费用 tips
  5002. /// </summary>
  5003. /// <returns></returns>
  5004. [HttpPost]
  5005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5006. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5007. {
  5008. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5009. //默认币种显示
  5010. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5011. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5012. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  5013. return Ok(JsonView(true, "查询成功!", new
  5014. {
  5015. //GroupNameData = groupNameData.Data,
  5016. visaData = visaData.Data,
  5017. airData = airData.Data,
  5018. reteInfos = reteInfos
  5019. }));
  5020. }
  5021. /// <summary>
  5022. /// 团组模块 - 出入境费用 - Info
  5023. /// </summary>
  5024. /// <returns></returns>
  5025. [HttpPost]
  5026. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5028. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5029. {
  5030. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5031. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5032. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5033. }
  5034. /// <summary>
  5035. /// 团组模块 - 出入境费用 - 设置view权限
  5036. /// </summary>
  5037. /// <returns></returns>
  5038. [HttpPost]
  5039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5040. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5041. {
  5042. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5043. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5044. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5045. var permissions = new List<Grp_EnterExitCostPermission>();
  5046. foreach (var userId in dto.UserIds)
  5047. {
  5048. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5049. }
  5050. if (permissions.Any())
  5051. {
  5052. _sqlSugar.BeginTran();
  5053. try
  5054. {
  5055. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5056. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5057. if (result < 1)
  5058. {
  5059. _sqlSugar.RollbackTran();
  5060. return Ok(JsonView(false));
  5061. }
  5062. }
  5063. catch (Exception ex)
  5064. {
  5065. _sqlSugar.RollbackTran();
  5066. return Ok(JsonView(false, ex.Message));
  5067. }
  5068. _sqlSugar.CommitTran();
  5069. return Ok(JsonView(true));
  5070. }
  5071. return Ok(JsonView(false));
  5072. }
  5073. /// <summary>
  5074. /// 团组模块 - 出入境费用 - Add And Update
  5075. /// </summary>
  5076. /// <returns></returns>
  5077. [HttpPost]
  5078. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5080. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5081. {
  5082. try
  5083. {
  5084. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5085. if (dto.DayOtherPriceData.Any())
  5086. {
  5087. var inserList = dto.DayOtherPriceData
  5088. .Where(x => x.Id == 0)
  5089. .Select(x => new Grp_DayOtherPrice
  5090. {
  5091. Cost = x.Cost,
  5092. Id = x.Id,
  5093. CreateTime = DateTime.Now,
  5094. CreateUserId = dto.UserId,
  5095. Currency = x.Currency,
  5096. Diid = x.DiId,
  5097. Index = x.Index,
  5098. IsDel = 0,
  5099. SetDataId = x.SetDataId,
  5100. SubTotal = x.SubTotal,
  5101. Remark = x.Remark
  5102. })
  5103. .ToList();
  5104. var updateList = dto.DayOtherPriceData
  5105. .Where(x => x.Id != 0)
  5106. .Select(x => new Grp_DayOtherPrice
  5107. {
  5108. Cost = x.Cost,
  5109. Id = x.Id,
  5110. CreateTime = DateTime.Now,
  5111. CreateUserId = dto.UserId,
  5112. Currency = x.Currency,
  5113. Diid = x.DiId,
  5114. Index = x.Index,
  5115. IsDel = 0,
  5116. SetDataId = x.SetDataId,
  5117. SubTotal = x.SubTotal,
  5118. Remark = x.Remark
  5119. })
  5120. .ToList();
  5121. //添加
  5122. _sqlSugar.BeginTran();
  5123. if (inserList.Any())
  5124. {
  5125. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5126. }
  5127. if (updateList.Any())
  5128. {
  5129. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5130. }
  5131. _sqlSugar.CommitTran();
  5132. }
  5133. if (data.Code != 0)
  5134. {
  5135. return Ok(JsonView(false, data.Msg));
  5136. }
  5137. //生成默认文件pdf并且通知人员
  5138. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5139. {
  5140. DiId = dto.DiId,
  5141. ExportType = 1,
  5142. SubTypeId = 1005
  5143. }, "pdf");
  5144. //发送通知
  5145. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5146. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5147. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5148. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5149. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5150. //汇率信息记录
  5151. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5152. return Ok(JsonView(true, data.Msg, data.Data));
  5153. }
  5154. catch (Exception ex)
  5155. {
  5156. return Ok(JsonView(false, ex.Message));
  5157. }
  5158. }
  5159. /// <summary>
  5160. /// 团组模块 - 出入境费用 - Confirm 费用
  5161. /// </summary>
  5162. /// <returns></returns>
  5163. [HttpPost]
  5164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5165. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5166. {
  5167. //TODO:测试完毕需把对应的用户ID更改
  5168. //1、数据表添加字段
  5169. //2、更改字段接口()
  5170. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5171. //3、确认成功 给财务发送消息
  5172. if (_view.Code == 200)
  5173. {
  5174. if (dto.Type == 1)
  5175. {
  5176. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5177. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5178. }
  5179. }
  5180. return Ok(_view);
  5181. }
  5182. /// <summary>
  5183. /// 团组模块 - 出入境费用 - File download
  5184. /// </summary>
  5185. /// <param name="dto"></param>
  5186. /// <returns></returns>
  5187. [HttpPost]
  5188. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5190. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5191. {
  5192. try
  5193. {
  5194. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5195. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5196. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5197. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5198. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5199. 3 团组成员名单 1 团组成员名单", ""));
  5200. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5201. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5202. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5203. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5204. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5205. //数据源
  5206. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5207. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5208. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5209. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5210. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5211. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5212. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5213. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5214. .Select((x, a, b) => new
  5215. {
  5216. x.Index,
  5217. itemName = a.Name,
  5218. CurrencyStr = b.Name,
  5219. x.Cost,
  5220. x.SubTotal,
  5221. x.Remark
  5222. })
  5223. .OrderBy((x) => x.Index)
  5224. .ToList(); //其他款项费用
  5225. var peiceItemCurrencys = new List<string>();
  5226. if (_DayAndCosts.Any())
  5227. {
  5228. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5229. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5230. }
  5231. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5232. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5233. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5234. {
  5235. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5236. }
  5237. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5238. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5239. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5240. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5241. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5242. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5243. .Select((tcl, dc, cc) => new ClientInfo
  5244. {
  5245. LastName = dc.LastName,
  5246. FirstName = dc.FirstName,
  5247. Sex = dc.Sex,
  5248. Birthday = dc.BirthDay,
  5249. Company = cc.CompanyFullName,
  5250. Job = dc.Job
  5251. })
  5252. .ToList();
  5253. foreach (var item in DeleClientList)
  5254. {
  5255. EncryptionProcessor.DecryptProperties(item);
  5256. }
  5257. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5258. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5259. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5260. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5261. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5262. if (dto.ExportType == 1) //明细表
  5263. {
  5264. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5265. {
  5266. //获取模板
  5267. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5268. //载入模板
  5269. Document doc = new Document(tempPath);
  5270. DocumentBuilder builder = new DocumentBuilder(doc);
  5271. //利用键值对存放数据
  5272. Dictionary<string, string> dic = new Dictionary<string, string>();
  5273. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5274. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5275. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5276. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5277. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5278. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5279. //境内费用(其他费用)
  5280. if (_EnterExitCosts.ChoiceOne == 1)
  5281. {
  5282. string row1_1 = "";
  5283. if (_EnterExitCosts.Visa > 0)
  5284. {
  5285. //insidePayTotal += _EnterExitCosts.Visa;
  5286. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5287. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5288. {
  5289. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5290. }
  5291. }
  5292. string row1_2 = "";
  5293. if (_EnterExitCosts.YiMiao > 0)
  5294. {
  5295. //insidePayTotal += _EnterExitCosts.YiMiao;
  5296. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5297. }
  5298. if (_EnterExitCosts.HeSuan > 0)
  5299. {
  5300. //insidePayTotal += _EnterExitCosts.HeSuan;
  5301. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5302. }
  5303. if (_EnterExitCosts.Service > 0)
  5304. {
  5305. //insidePayTotal += _EnterExitCosts.Service;
  5306. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5307. }
  5308. string row1_3 = "";
  5309. if (_EnterExitCosts.Safe > 0)
  5310. {
  5311. //insidePayTotal += _EnterExitCosts.Safe;
  5312. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5313. }
  5314. if (_EnterExitCosts.Ticket > 0)
  5315. {
  5316. //insidePayTotal += _EnterExitCosts.Ticket;
  5317. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5318. }
  5319. string row1 = "";
  5320. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5321. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5322. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5323. row1 += $"备注:{_EnterExitCosts.Remark}";
  5324. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5325. dic.Add("Row1Str", row1);
  5326. }
  5327. string airTotalStr = string.Empty,
  5328. airPriceStr = string.Empty;
  5329. //经济舱
  5330. if (_EnterExitCosts.SumJJC == 1)
  5331. {
  5332. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5333. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5334. }
  5335. //公务舱
  5336. if (_EnterExitCosts.SumGWC == 1)
  5337. {
  5338. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5339. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5340. }
  5341. //头等舱
  5342. if (_EnterExitCosts.SumTDC == 1)
  5343. {
  5344. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5345. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5346. }
  5347. //汇率描述
  5348. string rateStr = "";
  5349. if (peiceItemCurrencyInfos.Any())
  5350. {
  5351. rateStr = "\r\n汇率描述:";
  5352. foreach (var item in peiceItemCurrencyInfos)
  5353. {
  5354. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5355. }
  5356. }
  5357. string twoItemRemark = "备注:";
  5358. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5359. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5360. dic.Add("AirTotalStr", airTotalStr);
  5361. dic.Add("AirPriceStr", airPriceStr);
  5362. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5363. dic.Add("TwoItemRemark", twoItemRemark);
  5364. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5365. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5366. int table1Row = 0,
  5367. table2Row = 0,
  5368. table3Row = 0,
  5369. table4Row = 0,
  5370. table5Row = 0;
  5371. //住宿费
  5372. if (_EnterExitCosts.ChoiceThree == 1)
  5373. {
  5374. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5375. table1Row = dac1.Count;
  5376. #region 填充word表格内容
  5377. for (int i = 0; i < dac1.Count; i++)
  5378. {
  5379. Grp_DayAndCost dac = dac1[i];
  5380. if (dac == null) continue;
  5381. builder.MoveToCell(0, i, 0, 0);
  5382. builder.Write("第" + dac.Days.ToString() + "晚:");
  5383. builder.MoveToCell(0, i, 1, 0);
  5384. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5385. //builder.Write(dac.Place == null ? "" : dac.Place);
  5386. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5387. builder.MoveToCell(0, i, 2, 0);
  5388. builder.Write("费用标准:");
  5389. string curr = "";
  5390. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5391. if (currData != null)
  5392. {
  5393. curr = currData.Name;
  5394. }
  5395. builder.MoveToCell(0, i, 3, 0);
  5396. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5397. builder.MoveToCell(0, i, 4, 0);
  5398. builder.Write("费用小计:");
  5399. builder.MoveToCell(0, i, 5, 0);
  5400. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5401. }
  5402. #endregion
  5403. }
  5404. else dic.Add("SubZS", "0.00");
  5405. //删除多余行
  5406. while (table1.Rows.Count > table1Row)
  5407. {
  5408. table1.Rows.RemoveAt(table1Row);
  5409. }
  5410. //伙食费
  5411. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5412. if (_EnterExitCosts.ChoiceFour == 1)
  5413. {
  5414. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5415. table2Row = dac2.Count;
  5416. #region 填充word表格内容
  5417. for (int i = 0; i < dac2.Count; i++)
  5418. {
  5419. Grp_DayAndCost dac = dac2[i];
  5420. if (dac == null) continue;
  5421. builder.MoveToCell(1, i, 0, 0);
  5422. builder.Write("第" + dac.Days.ToString() + "天:");
  5423. builder.MoveToCell(1, i, 1, 0);
  5424. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5425. builder.MoveToCell(1, i, 2, 0);
  5426. builder.Write("费用标准:");
  5427. string curr = "";
  5428. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5429. if (currData != null)
  5430. {
  5431. curr = currData.Name;
  5432. }
  5433. builder.MoveToCell(1, i, 3, 0);
  5434. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5435. builder.MoveToCell(1, i, 4, 0);
  5436. builder.Write("费用小计:");
  5437. builder.MoveToCell(1, i, 5, 0);
  5438. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5439. }
  5440. #endregion
  5441. }
  5442. else dic.Add("SubHS", "0.00");
  5443. //删除多余行
  5444. while (table2.Rows.Count > table2Row)
  5445. {
  5446. table2.Rows.RemoveAt(table2Row);
  5447. }
  5448. //公杂费
  5449. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5450. if (_EnterExitCosts.ChoiceFive == 1)
  5451. {
  5452. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5453. table3Row = dac3.Count;
  5454. #region 填充word表格内容
  5455. for (int i = 0; i < dac3.Count; i++)
  5456. {
  5457. Grp_DayAndCost dac = dac3[i];
  5458. if (dac == null) continue;
  5459. builder.MoveToCell(2, i, 0, 0);
  5460. builder.Write("第" + dac.Days.ToString() + "天:");
  5461. builder.MoveToCell(2, i, 1, 0);
  5462. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5463. builder.MoveToCell(2, i, 2, 0);
  5464. builder.Write("费用标准:");
  5465. string curr = "";
  5466. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5467. if (currData != null)
  5468. {
  5469. curr = currData.Name;
  5470. }
  5471. builder.MoveToCell(2, i, 3, 0);
  5472. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5473. builder.MoveToCell(2, i, 4, 0);
  5474. builder.Write("费用小计:");
  5475. builder.MoveToCell(2, i, 5, 0);
  5476. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5477. }
  5478. //删除多余行
  5479. while (table3.Rows.Count > table3Row)
  5480. {
  5481. table3.Rows.RemoveAt(table3Row);
  5482. }
  5483. #endregion
  5484. }
  5485. else dic.Add("SubGZF", "0.00");
  5486. //删除多余行
  5487. while (table3.Rows.Count > table3Row)
  5488. {
  5489. table3.Rows.RemoveAt(table3Row);
  5490. }
  5491. //培训费
  5492. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5493. if (_EnterExitCosts.ChoiceSix == 1)
  5494. {
  5495. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5496. dic.Add("SubPX", pxStr);
  5497. table4Row = dac4.Count;
  5498. #region 填充word表格内容
  5499. for (int i = 0; i < dac4.Count; i++)
  5500. {
  5501. Grp_DayAndCost dac = dac4[i];
  5502. if (dac == null) continue;
  5503. builder.MoveToCell(3, i, 0, 0);
  5504. builder.Write("第" + dac.Days.ToString() + "天:");
  5505. builder.MoveToCell(3, i, 1, 0);
  5506. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5507. builder.MoveToCell(3, i, 2, 0);
  5508. builder.Write("费用标准:");
  5509. string curr = "";
  5510. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5511. if (currData != null)
  5512. {
  5513. curr = currData.Name;
  5514. }
  5515. builder.MoveToCell(3, i, 3, 0);
  5516. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5517. builder.MoveToCell(3, i, 4, 0);
  5518. builder.Write("费用小计:");
  5519. builder.MoveToCell(3, i, 5, 0);
  5520. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5521. }
  5522. #endregion
  5523. }
  5524. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5525. //删除多余行
  5526. while (table4.Rows.Count > table4Row)
  5527. {
  5528. table4.Rows.RemoveAt(table4Row);
  5529. }
  5530. //其他费用
  5531. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5532. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5533. {
  5534. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5535. dic.Add("titleQi", qtStr);
  5536. table5Row = dac5.Count;
  5537. #region 填充word表格内容
  5538. for (int i = 0; i < dac5.Count; i++)
  5539. {
  5540. var dac = dac5[i];
  5541. if (dac == null) continue;
  5542. builder.MoveToCell(4, i, 0, 0);
  5543. builder.Write("第" + dac.Index.ToString() + "项:");
  5544. builder.MoveToCell(4, i, 1, 0);
  5545. builder.Write(dac.itemName);
  5546. builder.MoveToCell(4, i, 2, 0);
  5547. builder.Write("费用标准:");
  5548. builder.MoveToCell(4, i, 3, 0);
  5549. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5550. builder.MoveToCell(4, i, 4, 0);
  5551. builder.Write("费用小计:");
  5552. builder.MoveToCell(4, i, 5, 0);
  5553. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5554. builder.MoveToCell(4, i, 6, 0);
  5555. builder.Write("备注:");
  5556. builder.MoveToCell(4, i, 7, 0);
  5557. builder.Write(dac.Remark);
  5558. }
  5559. #endregion
  5560. }
  5561. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5562. //删除多余行
  5563. while (table5.Rows.Count > table5Row)
  5564. {
  5565. table5.Rows.RemoveAt(table5Row);
  5566. }
  5567. //加上其他费用
  5568. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5569. decimal subJJC = 0.00M,
  5570. subGWC = 0.00M,
  5571. subTDC = 0.00M;
  5572. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5573. string totalLabel = string.Format("全部费用总计:");
  5574. //经济舱
  5575. if (_EnterExitCosts.SumJJC == 1)
  5576. {
  5577. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5578. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5579. }
  5580. //公务舱
  5581. if (_EnterExitCosts.SumGWC == 1)
  5582. {
  5583. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5584. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5585. }
  5586. //头等舱
  5587. if (_EnterExitCosts.SumTDC == 1)
  5588. {
  5589. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5590. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5591. }
  5592. //TotalLabel
  5593. dic.Add("TotalLabel", totalLabel);
  5594. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5595. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5596. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5597. #region 填充word模板书签内容
  5598. foreach (var key in dic.Keys)
  5599. {
  5600. Bookmark bookmark = doc.Range.Bookmarks[key];
  5601. if (bookmark != null)
  5602. {
  5603. builder.MoveToBookmark(key);
  5604. builder.Write(dic[key]);
  5605. }
  5606. }
  5607. #endregion
  5608. #region 设置页眉
  5609. string userLabel = string.Empty;
  5610. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5611. if (currUserInfo != null)
  5612. {
  5613. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5614. if (userInfo != null)
  5615. {
  5616. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5617. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5618. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5619. }
  5620. }
  5621. //设置页脚
  5622. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5623. #endregion
  5624. //文件名
  5625. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5626. AsposeHelper.removewatermark_v2180();
  5627. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5628. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5629. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5630. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5631. }
  5632. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5633. {
  5634. //获取模板
  5635. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5636. //载入模板
  5637. Document doc = new Document(tempPath);
  5638. DocumentBuilder builder = new DocumentBuilder(doc);
  5639. Dictionary<string, string> dic = new Dictionary<string, string>();
  5640. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5641. {
  5642. List<string> list = new List<string>();
  5643. try
  5644. {
  5645. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5646. foreach (var item in spilitArr)
  5647. {
  5648. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5649. var depCode = spDotandEmpty[2].Substring(0, 3);
  5650. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5651. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5652. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5653. list.Add(depName);
  5654. list.Add(arrName);
  5655. }
  5656. list = list.Distinct().ToList();
  5657. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5658. }
  5659. catch (Exception)
  5660. {
  5661. dic.Add("ReturnCode", "行程录入不正确!");
  5662. }
  5663. }
  5664. else
  5665. {
  5666. dic.Add("ReturnCode", "未录入行程!");
  5667. }
  5668. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5669. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5670. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5671. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5672. {
  5673. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5674. dic.Add("Day", sp.Days.ToString());
  5675. }
  5676. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5677. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5678. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5679. //dic.Add("Names", Names);
  5680. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5681. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5682. decimal dac1totalPrice = 0.00M;
  5683. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5684. foreach (var dac in dac1)
  5685. {
  5686. if (dac.SubTotal == 0.00M)
  5687. {
  5688. continue;
  5689. }
  5690. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5691. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5692. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5693. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5694. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5695. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5696. builder.Write(currency);//币种
  5697. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5698. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5699. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5700. builder.Write("");//人数
  5701. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5702. builder.Write("");//天数
  5703. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5704. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5705. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5706. decimal rate = 0.00M;
  5707. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5708. builder.Write(rate.ToString("#0.0000"));//汇率
  5709. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5710. decimal rbmPrice = dac.SubTotal;
  5711. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5712. accommodationStartIndex++;
  5713. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5714. }
  5715. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5716. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5717. {
  5718. table1.Rows.RemoveAt(i - 1);
  5719. foodandotherStartIndex--;
  5720. }
  5721. if (dac2.Count == dac3.Count)//国家 币种 金额
  5722. {
  5723. for (int i = 0; i < dac2.Count; i++)
  5724. {
  5725. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5726. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5727. }
  5728. }
  5729. decimal dac2totalPrice = 0.00M;
  5730. foreach (var dac in dac2)
  5731. {
  5732. if (dac.SubTotal == 0)
  5733. {
  5734. continue;
  5735. }
  5736. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5737. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5738. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5739. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5740. builder.Write(currency);//币种
  5741. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5742. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5743. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5744. builder.Write("");//人数
  5745. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5746. builder.Write("");//天数
  5747. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5748. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5749. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5750. decimal rate = 0.00M;
  5751. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5752. builder.Write(rate.ToString("#0.0000"));//汇率
  5753. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5754. decimal rbmPrice = dac.SubTotal;
  5755. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5756. foodandotherStartIndex++;
  5757. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5758. }
  5759. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5760. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5761. {
  5762. table1.Rows.RemoveAt(i - 1);
  5763. }
  5764. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5765. string otherFeeStr = "";
  5766. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5767. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5768. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5769. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5770. foreach (var otherInfo in dac5)
  5771. {
  5772. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5773. }
  5774. #endregion
  5775. if (otherFeeStr.Length > 0)
  5776. {
  5777. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5778. otherFeeStr = $"({otherFeeStr})";
  5779. dic.Add("OtherFeeStr", otherFeeStr);
  5780. }
  5781. //总计
  5782. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5783. //国际旅费
  5784. string outsideAir = string.Empty;
  5785. string allPriceAir = string.Empty;
  5786. if (_EnterExitCosts.SumJJC == 1)
  5787. {
  5788. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5789. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5790. }
  5791. if (_EnterExitCosts.SumGWC == 1)
  5792. {
  5793. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5794. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5795. }
  5796. if (_EnterExitCosts.SumTDC == 1)
  5797. {
  5798. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5799. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5800. }
  5801. dic.Add("InTravelPrice", $"({outsideAir})");
  5802. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5803. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5804. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5805. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5806. foreach (var key in dic.Keys)
  5807. {
  5808. builder.MoveToBookmark(key);
  5809. builder.Write(dic[key]);
  5810. }
  5811. //模板文件名
  5812. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5813. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5814. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5815. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5816. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5817. }
  5818. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5819. {
  5820. //获取模板
  5821. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5822. //载入模板
  5823. WorkbookDesigner designer = new WorkbookDesigner();
  5824. designer.Workbook = new Workbook(tempPath);
  5825. Dictionary<string, string> dic = new Dictionary<string, string>();
  5826. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5827. {
  5828. List<string> list = new List<string>();
  5829. try
  5830. {
  5831. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5832. foreach (var item in spilitArr)
  5833. {
  5834. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5835. var depCode = spDotandEmpty[2].Substring(0, 3);
  5836. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5837. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5838. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5839. list.Add(depName);
  5840. list.Add(arrName);
  5841. }
  5842. list = list.Distinct().ToList();
  5843. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5844. }
  5845. catch (Exception)
  5846. {
  5847. dic.Add("ReturnCode", "行程录入不正确!");
  5848. }
  5849. }
  5850. else
  5851. {
  5852. dic.Add("ReturnCode", "未录入行程!");
  5853. }
  5854. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5855. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5856. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5857. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5858. {
  5859. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5860. dic.Add("Day", sp.Days.ToString());
  5861. }
  5862. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5863. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5864. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5865. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5866. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5867. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5868. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5869. designer.SetDataSource("Name", Names);
  5870. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5871. designer.SetDataSource("Day", dic["Day"] + "天");
  5872. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5873. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5874. int startIndex = 10;
  5875. const int startIndexcopy = 10;
  5876. if (dac2.Count == dac3.Count)//国家 币种 金额
  5877. {
  5878. for (int i = 0; i < dac2.Count; i++)
  5879. {
  5880. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5881. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5882. }
  5883. }
  5884. DataTable dtdac1 = new DataTable();
  5885. List<string> place = new List<string>();
  5886. dtdac1.Columns.AddRange(new DataColumn[] {
  5887. new DataColumn(){ ColumnName = "city"},
  5888. new DataColumn(){ ColumnName = "curr"},
  5889. new DataColumn(){ ColumnName = "criterion"},
  5890. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5891. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5892. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5893. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5894. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5895. });
  5896. DataTable dtdac2 = new DataTable();
  5897. dtdac2.Columns.AddRange(new DataColumn[] {
  5898. new DataColumn(){ ColumnName = "city"},
  5899. new DataColumn(){ ColumnName = "curr"},
  5900. new DataColumn(){ ColumnName = "criterion"},
  5901. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5902. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5903. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5904. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5905. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5906. });
  5907. dtdac1.TableName = "tb1";
  5908. dtdac2.TableName = "tb2";
  5909. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5910. foreach (var item in dac1)
  5911. {
  5912. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5913. if (place.Contains(item.Place))
  5914. {
  5915. continue;
  5916. }
  5917. DataRow row = dtdac1.NewRow();
  5918. row["city"] = item.Place;
  5919. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5920. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5921. row["curr"] = currency;
  5922. row["rate"] = rate.ToString("#0.0000");
  5923. row["criterion"] = item.Cost.ToString("#0.00");
  5924. row["number"] = 1;
  5925. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5926. //row["costRMB"] = rbmPrice;
  5927. dtdac1.Rows.Add(row);
  5928. place.Add(item.Place);
  5929. }
  5930. place = new List<string>();
  5931. foreach (var item in dac2)
  5932. {
  5933. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5934. if (place.Contains(item.Place))
  5935. {
  5936. continue;
  5937. }
  5938. DataRow row = dtdac2.NewRow();
  5939. row["city"] = item.Place;
  5940. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5941. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5942. row["curr"] = currency;
  5943. row["rate"] = rate.ToString("#0.0000");
  5944. row["criterion"] = item.Cost.ToString("#0.00");
  5945. row["number"] = 1;
  5946. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5947. //row["cost"] = item.SubTotal;
  5948. //row["costRMB"] = rbmPrice;
  5949. dtdac2.Rows.Add(row);
  5950. place.Add(item.Place);
  5951. //dac2totalPrice += rbmPrice;
  5952. }
  5953. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5954. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5955. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5956. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5957. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5958. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5959. string cell4Str1 = string.Empty;
  5960. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5961. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5962. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5963. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5964. string cellStr = $" 5.其他费用(";
  5965. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5966. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5967. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5968. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5969. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5970. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5971. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5972. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5973. foreach (var otherInfo in dac5)
  5974. {
  5975. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5976. }
  5977. #endregion
  5978. if (cellStr.Length > 8)
  5979. {
  5980. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5981. }
  5982. cellStr += ")";
  5983. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5984. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5985. decimal pxFee = dac4.Sum(it => it.Cost);
  5986. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5987. string celllastStr1 = "";
  5988. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5989. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5990. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5991. celllastStr1 += $",国际旅费 元";
  5992. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5993. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5994. designer.SetDataSource("cell4Str", cell4Str);
  5995. designer.SetDataSource("cellStr", cellStr);
  5996. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5997. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5998. designer.SetDataSource("celllastStr", celllastStr);
  5999. Workbook wb = designer.Workbook;
  6000. var sheet = wb.Worksheets[0];
  6001. //绑定datatable数据集
  6002. designer.SetDataSource(dtdac1);
  6003. designer.SetDataSource(dtdac2);
  6004. designer.Process();
  6005. var rowStart = dtdac1.Rows.Count;
  6006. while (rowStart > 0)
  6007. {
  6008. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6009. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6010. startIndex++;
  6011. rowStart--;
  6012. }
  6013. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6014. startIndex += 1; //总计行
  6015. rowStart = dtdac2.Rows.Count;
  6016. while (rowStart > 0)
  6017. {
  6018. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6019. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6020. startIndex++;
  6021. rowStart--;
  6022. }
  6023. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6024. wb.CalculateFormula(true);
  6025. //模板文件名
  6026. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6027. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6028. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6029. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6030. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6031. }
  6032. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6033. {
  6034. //获取模板
  6035. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6036. //载入模板
  6037. Document doc = new Document(tempPath);
  6038. DocumentBuilder builder = new DocumentBuilder(doc);
  6039. Dictionary<string, string> dic = new Dictionary<string, string>();
  6040. dic.Add("GroupName", _DelegationInfo.TeamName);
  6041. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6042. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6043. string missionLeaderJob = "";//负责人job
  6044. //int groupNumber = 0; //团人数
  6045. if (DeleClientList.Count > 0)
  6046. {
  6047. missionLeader = DeleClientList[0]?.Name ?? "";
  6048. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6049. }
  6050. dic.Add("MissionLeader", missionLeader); //团负责人
  6051. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6052. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6053. #region MyRegion
  6054. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6055. //{
  6056. // List<string> list = new List<string>();
  6057. // try
  6058. // {
  6059. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6060. // foreach (var item in spilitArr)
  6061. // {
  6062. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6063. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6064. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6065. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6066. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6067. // list.Add(depName);
  6068. // list.Add(arrName);
  6069. // }
  6070. // list = list.Distinct().ToList();
  6071. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6072. // }
  6073. // catch (Exception)
  6074. // {
  6075. // dic.Add("ReturnCode", "行程录入不正确!");
  6076. // }
  6077. //}
  6078. //else
  6079. //{
  6080. // dic.Add("ReturnCode", "未录入行程!");
  6081. //}
  6082. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6083. dic.Add("ReturnCode", string.Join("、", countrys));
  6084. #endregion
  6085. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6086. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6087. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6088. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6089. //{
  6090. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6091. // dic.Add("Day", sp.Days.ToString());
  6092. //}
  6093. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6094. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6095. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6096. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6097. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6098. //培训人员名单
  6099. int cultivateRowIndex = 7;
  6100. foreach (var item in DeleClientList)
  6101. {
  6102. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6103. builder.Write(item.Name);
  6104. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6105. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6106. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6107. string birthDay = "";
  6108. if (item.Birthday != null)
  6109. {
  6110. DateTime dt = Convert.ToDateTime(item.Birthday);
  6111. birthDay = $"{dt.Year}.{dt.Month}";
  6112. }
  6113. builder.Write(birthDay);
  6114. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6115. builder.Write(item.Company);
  6116. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6117. builder.Write(item.Job);
  6118. cultivateRowIndex++;
  6119. }
  6120. //删除多余行
  6121. //cultivateRowIndex -= 2;
  6122. int delRows = 10 + 7 - cultivateRowIndex;
  6123. if (delRows > 0)
  6124. {
  6125. for (int i = 0; i < delRows; i++)
  6126. {
  6127. table1.Rows.RemoveAt(cultivateRowIndex);
  6128. //cultivateRowIndex++;
  6129. }
  6130. }
  6131. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6132. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6133. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6134. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6135. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6136. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6137. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6138. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6139. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6140. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6141. //其他费用
  6142. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6143. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6144. //其他费用合计
  6145. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6146. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6147. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6148. //公务舱合计
  6149. //国际旅费
  6150. //string outsideJJ = "";
  6151. //string allPriceJJ = "";
  6152. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6153. {
  6154. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6155. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6156. }
  6157. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6158. {
  6159. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6160. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6161. }
  6162. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6163. {
  6164. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6165. dic.Add("AirFeeTotal", airFeeTotalStr);
  6166. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6167. dic.Add("FeeTotal", feeTotalStr);
  6168. }
  6169. foreach (var key in dic.Keys)
  6170. {
  6171. builder.MoveToBookmark(key);
  6172. builder.Write(dic[key]);
  6173. }
  6174. //模板文件名
  6175. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6176. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6177. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6178. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6179. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6180. }
  6181. }
  6182. else if (dto.ExportType == 2) //表格
  6183. {
  6184. //利用键值对存放数据
  6185. Dictionary<string, string> dic = new Dictionary<string, string>();
  6186. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6187. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6188. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6189. dic.Add("Day", sp.Days.ToString());
  6190. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6191. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6192. {
  6193. //获取模板
  6194. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6195. //载入模板
  6196. Document doc = new Document(tempPath);
  6197. DocumentBuilder builder = new DocumentBuilder(doc);
  6198. dic.Add("TeamName", _DelegationInfo.TeamName);
  6199. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6200. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6201. string missionLeaderName = "",
  6202. missionLeaderJob = "";
  6203. if (DeleClientList.Count > 0)
  6204. {
  6205. missionLeaderName = DeleClientList[0].Name;
  6206. missionLeaderJob = DeleClientList[0].Job;
  6207. }
  6208. dic.Add("MissionLeaderName", missionLeaderName);
  6209. dic.Add("MissionLeaderJob", missionLeaderJob);
  6210. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6211. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6212. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6213. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6214. int rowCount = 10;//总人数行
  6215. int startRowIndex = 7; //起始行
  6216. for (int i = 0; i < DeleClientList.Count; i++)
  6217. {
  6218. builder.MoveToCell(0, startRowIndex, 0, 0);
  6219. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6220. builder.MoveToCell(0, startRowIndex, 1, 0);
  6221. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6222. builder.Write(sex);//性别
  6223. builder.MoveToCell(0, startRowIndex, 2, 0);
  6224. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6225. builder.MoveToCell(0, startRowIndex, 3, 0);
  6226. builder.Write(DeleClientList[i].Company);//工作单位
  6227. builder.MoveToCell(0, startRowIndex, 4, 0);
  6228. builder.Write(DeleClientList[i].Job);//职务及级别
  6229. builder.MoveToCell(0, startRowIndex, 5, 0);
  6230. builder.Write("");//人员属性
  6231. builder.MoveToCell(0, startRowIndex, 6, 0);
  6232. builder.Write("");//上次出国时间
  6233. startRowIndex++;
  6234. }
  6235. int nullRow = rowCount - DeleClientList.Count;//空行
  6236. for (int i = 0; i < nullRow; i++)
  6237. {
  6238. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6239. }
  6240. foreach (var key in dic.Keys)
  6241. {
  6242. builder.MoveToBookmark(key);
  6243. builder.Write(dic[key]);
  6244. }
  6245. //模板文件名
  6246. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6247. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6248. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6249. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6250. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6251. }
  6252. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6253. {
  6254. //获取模板
  6255. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6256. //载入模板
  6257. Document doc = new Document(tempPath);
  6258. DocumentBuilder builder = new DocumentBuilder(doc);
  6259. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6260. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6261. dic.Add("Names", Names);
  6262. int accommodationRows = 12;
  6263. //int foodandotherRows = 12;
  6264. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6265. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6266. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6267. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6268. int accommodationStartIndex = 6;
  6269. decimal dac1totalPrice = 0.00M;
  6270. foreach (var dac in dac1)
  6271. {
  6272. if (dac.SubTotal == 0)
  6273. {
  6274. continue;
  6275. }
  6276. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6277. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6278. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6279. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6280. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6281. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6282. builder.Write(currency);//币种
  6283. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6284. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6285. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6286. builder.Write("");//人数
  6287. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6288. builder.Write("");//天数
  6289. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6290. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6291. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6292. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6293. builder.Write(rate.ToString("#0.0000"));//汇率
  6294. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6295. decimal rbmPrice = rate * dac.SubTotal;
  6296. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6297. accommodationStartIndex++;
  6298. dac1totalPrice += rbmPrice;
  6299. }
  6300. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6301. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6302. builder.Write("小计");
  6303. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6304. builder.Write(dac1totalPrice.ToString("#0.00"));
  6305. accommodationStartIndex++;
  6306. int nullRow = accommodationRows - dac1.Count;
  6307. //删除空行
  6308. //if (nullRow > 0)
  6309. //{
  6310. // int rowIndex = accommodationStartIndex;
  6311. // for (int i = 0; i < nullRow; i++)
  6312. // {
  6313. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6314. // row.Remove();
  6315. // rowIndex++;
  6316. // }
  6317. //}
  6318. if (dac2.Count == dac3.Count)//国家 币种 金额
  6319. {
  6320. for (int i = 0; i < dac2.Count; i++)
  6321. {
  6322. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6323. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6324. }
  6325. }
  6326. int foodandotherStartIndex = 19;//
  6327. decimal dac2totalPrice = 0.00M;
  6328. foreach (var dac in dac2)
  6329. {
  6330. if (dac.SubTotal == 0)
  6331. {
  6332. continue;
  6333. }
  6334. //foodandotherStartIndex = 12;
  6335. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6336. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6337. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6338. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6339. builder.Write(currency);//币种
  6340. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6341. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6342. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6343. builder.Write("");//人数
  6344. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6345. builder.Write("");//天数
  6346. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6347. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6348. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6349. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6350. builder.Write(rate.ToString("#0.0000"));//汇率
  6351. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6352. decimal rbmPrice = rate * dac.SubTotal;
  6353. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6354. foodandotherStartIndex++;
  6355. dac2totalPrice += rbmPrice;
  6356. }
  6357. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6358. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6359. //删除空行
  6360. //if (dac2.Count < foodandotherRows)
  6361. //{
  6362. // while (table2.Rows.Count > dac2.Count)
  6363. // {
  6364. // table2.Rows.RemoveAt(dac2.Count);
  6365. // }
  6366. //}
  6367. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6368. string otherFeeStr = "";
  6369. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6370. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6371. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6372. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6373. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6374. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6375. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6376. foreach (var otherInfo in dac5)
  6377. {
  6378. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6379. }
  6380. #endregion
  6381. if (otherFeeStr.Length > 0)
  6382. {
  6383. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6384. otherFeeStr = $"({otherFeeStr})";
  6385. dic.Add("OtherFeeStr", otherFeeStr);
  6386. }
  6387. foreach (var key in dic.Keys)
  6388. {
  6389. builder.MoveToBookmark(key);
  6390. builder.Write(dic[key]);
  6391. }
  6392. //模板文件名
  6393. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6394. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6395. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6396. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6397. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6398. }
  6399. }
  6400. else if (dto.ExportType == 3)
  6401. {
  6402. if (dto.SubTypeId == 1) //团组成员名单
  6403. {
  6404. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6405. //获取模板
  6406. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6407. //载入模板
  6408. Document doc = new Document(tempPath);
  6409. DocumentBuilder builder = new DocumentBuilder(doc);
  6410. //获取word里所有表格
  6411. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6412. //获取所填表格的序数
  6413. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6414. var rowStart = tableOne.Rows[0]; //获取第1行
  6415. //循环赋值
  6416. for (int i = 0; i < DeleClientList.Count; i++)
  6417. {
  6418. builder.MoveToCell(0, i + 1, 0, 0);
  6419. builder.Write(DeleClientList[i].Name);
  6420. builder.MoveToCell(0, i + 1, 1, 0);
  6421. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6422. builder.Write(sex);
  6423. builder.MoveToCell(0, i + 1, 2, 0);
  6424. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6425. builder.MoveToCell(0, i + 1, 3, 0);
  6426. builder.Write(DeleClientList[i].Company);
  6427. builder.MoveToCell(0, i + 1, 4, 0);
  6428. builder.Write(DeleClientList[i].Job);
  6429. }
  6430. //删除多余行
  6431. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6432. {
  6433. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6434. }
  6435. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6436. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6437. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6438. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6439. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6440. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6441. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6442. }
  6443. }
  6444. return Ok(JsonView(400, "操作失败!", ""));
  6445. }
  6446. catch (Exception ex)
  6447. {
  6448. return Ok(JsonView(400, ex.Message, ""));
  6449. }
  6450. }
  6451. /// <summary>
  6452. /// 获取三公费用标准city
  6453. /// </summary>
  6454. /// <param name="placeData"></param>
  6455. /// <param name="nationalTravelFeeId"></param>
  6456. /// <returns></returns>
  6457. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6458. {
  6459. string _city = string.Empty;
  6460. if (placeData.Count < 1) return _city;
  6461. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6462. if (data == null) return _city;
  6463. string country = data.Country;
  6464. string city = data.City;
  6465. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6466. else _city = city;
  6467. return _city;
  6468. }
  6469. ///// <summary>
  6470. ///// 团组模块 - 出入境费用 - 明细表导出
  6471. ///// </summary>
  6472. ///// <returns></returns>
  6473. //[HttpPost]
  6474. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6475. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6476. //{
  6477. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6478. // if (data.Code != 0)
  6479. // {
  6480. // return Ok(JsonView(false, data.Msg));
  6481. // }
  6482. // return Ok(JsonView(true, data.Msg, data.Data));
  6483. //}
  6484. /// <summary>
  6485. /// 团组模块 - 出入境费用 - 一键清空
  6486. /// </summary>
  6487. /// <returns></returns>
  6488. [HttpPost]
  6489. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6491. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6492. {
  6493. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6494. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6495. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6496. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6497. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6498. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6499. .SetColumns(x => new Grp_DayOtherPrice
  6500. {
  6501. IsDel = 1,
  6502. DeleteUserId = dto.UserId,
  6503. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6504. })
  6505. .ExecuteCommandAsync();
  6506. if (_view.Code == 0)
  6507. {
  6508. return Ok(JsonView(true, "操作成功"));
  6509. }
  6510. return Ok(JsonView(false, "操作失败"));
  6511. }
  6512. /// <summary>
  6513. /// 团组模块 - 出入境费用 - 子项删除
  6514. /// </summary>
  6515. /// <returns></returns>
  6516. [HttpPost]
  6517. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6519. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6520. {
  6521. try
  6522. {
  6523. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6524. if (data.Code != 0)
  6525. {
  6526. return Ok(JsonView(false, data.Msg));
  6527. }
  6528. return Ok(JsonView(true, "操作成功!", data.Data));
  6529. }
  6530. catch (Exception ex)
  6531. {
  6532. return Ok(JsonView(false, ex.Message));
  6533. }
  6534. }
  6535. /// <summary>
  6536. /// 删除三公其他费用
  6537. /// </summary>
  6538. /// <param name="dto"></param>
  6539. /// <returns></returns>
  6540. [HttpPost]
  6541. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6542. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6543. {
  6544. var jw = JsonView(false, "删除失败!");
  6545. var data = new Grp_DayOtherPrice()
  6546. {
  6547. Id = dto.Id,
  6548. IsDel = 1,
  6549. DeleteUserId = dto.DeleteUserId,
  6550. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6551. };
  6552. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6553. if (del > 0)
  6554. {
  6555. jw.Code = 200;
  6556. jw.Msg = "删除成功!";
  6557. }
  6558. return Ok(jw);
  6559. }
  6560. /// <summary>
  6561. /// 团组模块 - 出入境国家费用标准 List
  6562. /// </summary>
  6563. /// <returns></returns>
  6564. [HttpPost]
  6565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6566. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  6567. {
  6568. int provinceId = dto.ProvinceId;
  6569. if (provinceId < 1) provinceId = 122; //默认四川省数据
  6570. var nftData = await _sqlSugar
  6571. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  6572. JoinType.Left, ntf.Currency == sd1.Id,
  6573. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  6574. JoinType.Left, ntf.ProvinceId == c.Id
  6575. ))
  6576. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  6577. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  6578. {
  6579. Id = ntf.Id,
  6580. ProvinceId = ntf.ProvinceId,
  6581. ProvinceName = c.Name_CN,
  6582. Continent = ntf.Continent,
  6583. Country = ntf.Country,
  6584. City = ntf.City,
  6585. Currency = ntf.Currency,
  6586. CurrencyCode = sd1.Name,
  6587. CurrencyName = sd1.Remark,
  6588. RoomCost = ntf.RoomCost,
  6589. FoodCost = ntf.FoodCost,
  6590. PublicCost = ntf.PublicCost,
  6591. LastUpdateUserId = ntf.LastUpdateUserId,
  6592. LastUpdateUserName = u.CnName,
  6593. LastUpdateTime = ntf.LastUpdateTime
  6594. })
  6595. .ToListAsync();
  6596. return Ok(JsonView(true, "查询成功!", nftData));
  6597. }
  6598. /// <summary>
  6599. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6600. /// </summary>
  6601. /// <returns></returns>
  6602. [HttpPost]
  6603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6604. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6605. {
  6606. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6607. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6608. List<string> countryData = new List<string>();
  6609. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6610. countryData = countryData.Distinct().ToList();
  6611. List<dynamic> dataSource = new List<dynamic>();
  6612. foreach (var item in countryData)
  6613. {
  6614. var cityData1 = new List<string>();
  6615. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6616. var countryData2 = new
  6617. {
  6618. CountryName = item,
  6619. CityData = cityData1
  6620. };
  6621. if (!dataSource.Contains(countryData2))
  6622. {
  6623. dataSource.Add(countryData2);
  6624. }
  6625. }
  6626. return Ok(JsonView(true, "查询成功!", dataSource));
  6627. }
  6628. /// <summary>
  6629. /// 团组模块 - 出入境国家费用标准 Page List
  6630. /// </summary>
  6631. /// <returns></returns>
  6632. [HttpPost]
  6633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6634. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6635. {
  6636. int portId = dto.PortType,
  6637. pageIndex = dto.PageIndex,
  6638. pageSize = dto.PageSize;
  6639. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6640. if (pageIndex == 0) pageIndex = 1;
  6641. if (pageSize == 0) pageSize = 10;
  6642. RefAsync<int> total = 0;
  6643. var nationalTravelFeeData = await _sqlSugar
  6644. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  6645. JoinType.Left, ntf.Currency == sd1.Id,
  6646. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  6647. JoinType.Left, ntf.ProvinceId == sd2.Id
  6648. ))
  6649. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  6650. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  6651. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  6652. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  6653. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  6654. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  6655. {
  6656. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  6657. Id = ntf.Id,
  6658. ProvinceId = ntf.ProvinceId,
  6659. ProvinceName = sd2.Name_CN,
  6660. Continent = ntf.Continent,
  6661. Country = ntf.Country,
  6662. City = ntf.City,
  6663. Currency = ntf.Currency,
  6664. CurrencyCode = sd1.Name,
  6665. CurrencyName = sd1.Remark,
  6666. RoomCost = ntf.RoomCost,
  6667. FoodCost = ntf.FoodCost,
  6668. PublicCost = ntf.PublicCost,
  6669. LastUpdateUserId = ntf.LastUpdateUserId,
  6670. LastUpdateUserName = u.CnName,
  6671. LastUpdateTime = ntf.LastUpdateTime
  6672. })
  6673. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6674. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6675. }
  6676. /// <summary>
  6677. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6678. /// </summary>
  6679. /// <returns></returns>
  6680. [HttpPost]
  6681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6682. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6683. {
  6684. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6685. int portId = dto.PortType;
  6686. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6687. string whereSql = string.Empty;
  6688. if (!string.IsNullOrEmpty(dto.Country))
  6689. {
  6690. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6691. }
  6692. if (!string.IsNullOrEmpty(dto.City))
  6693. {
  6694. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6695. }
  6696. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6697. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  6698. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6699. From Grp_NationalTravelFee gntf
  6700. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6701. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6702. Where gntf.Isdel = 0 {0} ", whereSql);
  6703. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6704. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6705. }
  6706. /// <summary>
  6707. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6708. /// </summary>
  6709. /// <returns></returns>
  6710. [HttpPost]
  6711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6712. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6713. {
  6714. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  6715. }
  6716. /// <summary>
  6717. /// 团组模块 - 出入境国家费用标准 - Del
  6718. /// </summary>
  6719. /// <returns></returns>
  6720. [HttpPost]
  6721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6722. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6723. {
  6724. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6725. {
  6726. Id = dto.Id,
  6727. DeleteUserId = dto.DeleteUserId,
  6728. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6729. IsDel = 1
  6730. };
  6731. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6732. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6733. .WhereColumns(it => new { it.Id })
  6734. .ExecuteCommandAsync();
  6735. if (delStatus <= 0)
  6736. {
  6737. return Ok(JsonView(false, "删除失败!"));
  6738. }
  6739. return Ok(JsonView(true, "操作成功!"));
  6740. }
  6741. /// <summary>
  6742. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6743. /// 注:Get 请求Headers 加 Token
  6744. /// </summary>
  6745. /// <param name="groupId"></param>
  6746. /// <returns></returns>
  6747. [HttpGet("{groupId}")]
  6748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6749. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6750. {
  6751. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6752. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6753. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6754. data.ForEach(x =>
  6755. {
  6756. x.CreateUserId = _currUserInfo.UserId;
  6757. });
  6758. if (data.Any())
  6759. {
  6760. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6761. if (add > 0)
  6762. {
  6763. return Ok(JsonView(true, "操作成功!"));
  6764. }
  6765. }
  6766. return Ok(JsonView(false, "未操作!"));
  6767. }
  6768. #endregion
  6769. #region 团组经理模块 出入境费用-草稿
  6770. /// <summary>
  6771. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  6772. /// </summary>
  6773. /// <returns></returns>
  6774. [HttpGet]
  6775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6776. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  6777. {
  6778. var provData = await _groupRepository.ProvinceBasicSource();
  6779. return Ok(JsonView(true, "查询成功!", provData));
  6780. }
  6781. /// <summary>
  6782. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  6783. /// </summary>
  6784. /// <returns></returns>
  6785. [HttpGet("{provinceId}")]
  6786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6787. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  6788. {
  6789. //验证城市归属并给默认值
  6790. if (provinceId < 1) provinceId = 122;
  6791. /*
  6792. * 122 四川
  6793. * 108 贵州
  6794. * 103 重庆
  6795. * 132 云南
  6796. */
  6797. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6798. return Ok(JsonView(true, "查询成功!", new
  6799. {
  6800. WordTypeData = wordTypeData,
  6801. ExcelTypeData = excelTypeData,
  6802. }));
  6803. }
  6804. /// <summary>
  6805. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6806. /// </summary>
  6807. /// <returns></returns>
  6808. [HttpPost]
  6809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6810. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  6811. {
  6812. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6813. .Where(x => x.IsDel == 0)
  6814. .OrderByDescending(x => x.CreateTime)
  6815. .Select(x => new { x.Id, x.DraftName })
  6816. .ToListAsync();
  6817. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6818. //SetDataInfoView
  6819. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6820. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6821. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6822. int provinceId = dto.ProvinceId;
  6823. if (provinceId < 1) provinceId = 122;
  6824. /*
  6825. * 122 四川
  6826. * 108 贵州
  6827. * 103 重庆
  6828. * 132 云南
  6829. */
  6830. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6831. //默认币种显示
  6832. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6833. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6834. return Ok(JsonView(true, "查询成功!", new
  6835. {
  6836. DraftNameDatas = draftNameDatas,
  6837. CurrencyData = _CurrencyData,
  6838. WordTypeData = wordTypeData,
  6839. ExcelTypeData = excelTypeData,
  6840. CurrencyInit = _currencyInfos,
  6841. ViewPermissionData = viewPermissionData
  6842. }));
  6843. }
  6844. /// <summary>
  6845. /// 团组模块 - 出入境费用-草稿
  6846. /// 实时汇率 tips
  6847. /// 机票费用 tips
  6848. /// </summary>
  6849. /// <returns></returns>
  6850. [HttpPost]
  6851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6852. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6853. {
  6854. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6855. return Ok(JsonView(true, "查询成功!", new
  6856. {
  6857. //GroupNameData = groupNameData.Data,
  6858. //visaData = visaData.Data,
  6859. //airData = airData.Data,
  6860. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6861. }));
  6862. }
  6863. /// <summary>
  6864. /// 团组模块 - 出入境费用-草稿
  6865. /// 签证费用 tips
  6866. /// </summary>
  6867. /// <returns></returns>
  6868. [HttpPost]
  6869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6870. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6871. {
  6872. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6873. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6874. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6875. .Select(x => x.NationalTravelFeeId)
  6876. .Distinct()
  6877. .ToListAsync();
  6878. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6879. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6880. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6881. .Select(x => x.Country)
  6882. .Distinct()
  6883. .ToArrayAsync();
  6884. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6885. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6886. return Ok(JsonView(true, "查询成功!", new
  6887. {
  6888. totalAmt = totalAmt,
  6889. remark = remark
  6890. }));
  6891. }
  6892. /// <summary>
  6893. /// 团组模块 - 出入境费用-草稿 - Info
  6894. /// </summary>
  6895. /// <returns></returns>
  6896. [HttpPost]
  6897. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6899. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6900. {
  6901. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6902. }
  6903. /// <summary>
  6904. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6905. /// </summary>
  6906. /// <returns></returns>
  6907. [HttpPost]
  6908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6909. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6910. {
  6911. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6912. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6913. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6914. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6915. foreach (var userId in dto.UserIds)
  6916. {
  6917. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6918. }
  6919. if (permissions.Any())
  6920. {
  6921. _sqlSugar.BeginTran();
  6922. try
  6923. {
  6924. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6925. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6926. if (result < 1)
  6927. {
  6928. _sqlSugar.RollbackTran();
  6929. return Ok(JsonView(false));
  6930. }
  6931. }
  6932. catch (Exception ex)
  6933. {
  6934. _sqlSugar.RollbackTran();
  6935. return Ok(JsonView(false, ex.Message));
  6936. }
  6937. _sqlSugar.CommitTran();
  6938. return Ok(JsonView(true));
  6939. }
  6940. return Ok(JsonView(false));
  6941. }
  6942. /// <summary>
  6943. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6944. /// </summary>
  6945. /// <returns></returns>
  6946. [HttpPost]
  6947. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6949. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6950. {
  6951. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6952. if (data.Code != 0)
  6953. {
  6954. return Ok(JsonView(false, data.Msg));
  6955. }
  6956. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6957. //汇率信息记录
  6958. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6959. return Ok(JsonView(true, data.Msg, data.Data));
  6960. }
  6961. /// <summary>
  6962. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6963. /// </summary>
  6964. /// <param name="dto"></param>
  6965. /// <returns></returns>
  6966. [HttpPost]
  6967. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6969. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6970. {
  6971. try
  6972. {
  6973. var id = dto.Id;
  6974. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6975. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6976. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6977. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6978. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6979. 3 团组成员名单 1 团组成员名单", ""));
  6980. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6981. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6982. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6983. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6984. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6985. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6986. //数据源
  6987. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6988. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6989. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6990. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6991. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6992. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6993. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6994. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6995. .Select((x, a, b) => new
  6996. {
  6997. x.Index,
  6998. itemName = a.Name,
  6999. CurrencyStr = b.Name,
  7000. x.Cost,
  7001. x.SubTotal,
  7002. x.Remark
  7003. })
  7004. .OrderBy((x) => x.Index)
  7005. .ToList(); //其他款项费用
  7006. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7007. var peiceItemCurrencys = new List<string>();
  7008. if (_DayAndCosts.Any())
  7009. {
  7010. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7011. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7012. }
  7013. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7014. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7015. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7016. {
  7017. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7018. }
  7019. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7020. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7021. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7022. if (dto.ExportType == 1) //明细表
  7023. {
  7024. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7025. {
  7026. //获取模板
  7027. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7028. //载入模板
  7029. Document doc = new Document(tempPath);
  7030. DocumentBuilder builder = new DocumentBuilder(doc);
  7031. //利用键值对存放数据
  7032. Dictionary<string, string> dic = new Dictionary<string, string>();
  7033. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7034. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7035. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7036. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7037. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7038. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7039. //境内费用(其他费用)
  7040. if (_EnterExitCosts.ChoiceOne == 1)
  7041. {
  7042. string row1_1 = "";
  7043. if (_EnterExitCosts.Visa > 0)
  7044. {
  7045. //insidePayTotal += _EnterExitCosts.Visa;
  7046. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7047. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7048. {
  7049. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  7050. }
  7051. }
  7052. string row1_2 = "";
  7053. if (_EnterExitCosts.YiMiao > 0)
  7054. {
  7055. //insidePayTotal += _EnterExitCosts.YiMiao;
  7056. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7057. }
  7058. if (_EnterExitCosts.HeSuan > 0)
  7059. {
  7060. //insidePayTotal += _EnterExitCosts.HeSuan;
  7061. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7062. }
  7063. if (_EnterExitCosts.Service > 0)
  7064. {
  7065. //insidePayTotal += _EnterExitCosts.Service;
  7066. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7067. }
  7068. string row1_3 = "";
  7069. if (_EnterExitCosts.Safe > 0)
  7070. {
  7071. //insidePayTotal += _EnterExitCosts.Safe;
  7072. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7073. }
  7074. if (_EnterExitCosts.Ticket > 0)
  7075. {
  7076. //insidePayTotal += _EnterExitCosts.Ticket;
  7077. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7078. }
  7079. string row1 = "";
  7080. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7081. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7082. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7083. row1 += $"备注:{_EnterExitCosts.Remark}";
  7084. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7085. dic.Add("Row1Str", row1);
  7086. }
  7087. string airTotalStr = string.Empty,
  7088. airPriceStr = string.Empty;
  7089. //经济舱
  7090. if (_EnterExitCosts.SumJJC == 1)
  7091. {
  7092. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  7093. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  7094. }
  7095. //公务舱
  7096. if (_EnterExitCosts.SumGWC == 1)
  7097. {
  7098. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  7099. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  7100. }
  7101. //头等舱
  7102. if (_EnterExitCosts.SumTDC == 1)
  7103. {
  7104. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7105. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7106. }
  7107. //汇率描述
  7108. string rateStr = "";
  7109. if (peiceItemCurrencyInfos.Any())
  7110. {
  7111. rateStr = "\r\n汇率描述:";
  7112. foreach (var item in peiceItemCurrencyInfos)
  7113. {
  7114. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7115. }
  7116. }
  7117. string twoItemRemark = "备注:";
  7118. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7119. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7120. dic.Add("AirTotalStr", airTotalStr);
  7121. dic.Add("AirPriceStr", airPriceStr);
  7122. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7123. dic.Add("TwoItemRemark", twoItemRemark);
  7124. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7125. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7126. int table1Row = 0,
  7127. table2Row = 0,
  7128. table3Row = 0,
  7129. table4Row = 0,
  7130. table5Row = 0;
  7131. //住宿费
  7132. if (_EnterExitCosts.ChoiceThree == 1)
  7133. {
  7134. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7135. table1Row = dac1.Count;
  7136. #region 填充word表格内容
  7137. for (int i = 0; i < dac1.Count; i++)
  7138. {
  7139. var dac = dac1[i];
  7140. if (dac == null) continue;
  7141. builder.MoveToCell(0, i, 0, 0);
  7142. builder.Write("第" + dac.Days.ToString() + "晚:");
  7143. builder.MoveToCell(0, i, 1, 0);
  7144. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7145. //builder.Write(dac.Place == null ? "" : dac.Place);
  7146. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7147. builder.MoveToCell(0, i, 2, 0);
  7148. builder.Write("费用标准:");
  7149. string curr = "";
  7150. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7151. if (currData != null)
  7152. {
  7153. curr = currData.Name;
  7154. }
  7155. builder.MoveToCell(0, i, 3, 0);
  7156. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7157. builder.MoveToCell(0, i, 4, 0);
  7158. builder.Write("费用小计:");
  7159. builder.MoveToCell(0, i, 5, 0);
  7160. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7161. }
  7162. #endregion
  7163. }
  7164. else dic.Add("SubZS", "0.00");
  7165. //删除多余行
  7166. while (table1.Rows.Count > table1Row)
  7167. {
  7168. table1.Rows.RemoveAt(table1Row);
  7169. }
  7170. //伙食费
  7171. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7172. if (_EnterExitCosts.ChoiceFour == 1)
  7173. {
  7174. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7175. table2Row = dac2.Count;
  7176. #region 填充word表格内容
  7177. for (int i = 0; i < dac2.Count; i++)
  7178. {
  7179. var dac = dac2[i];
  7180. if (dac == null) continue;
  7181. builder.MoveToCell(1, i, 0, 0);
  7182. builder.Write("第" + dac.Days.ToString() + "天:");
  7183. builder.MoveToCell(1, i, 1, 0);
  7184. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7185. builder.MoveToCell(1, i, 2, 0);
  7186. builder.Write("费用标准:");
  7187. string curr = "";
  7188. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7189. if (currData != null)
  7190. {
  7191. curr = currData.Name;
  7192. }
  7193. builder.MoveToCell(1, i, 3, 0);
  7194. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7195. builder.MoveToCell(1, i, 4, 0);
  7196. builder.Write("费用小计:");
  7197. builder.MoveToCell(1, i, 5, 0);
  7198. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7199. }
  7200. #endregion
  7201. }
  7202. else dic.Add("SubHS", "0.00");
  7203. //删除多余行
  7204. while (table2.Rows.Count > table2Row)
  7205. {
  7206. table2.Rows.RemoveAt(table2Row);
  7207. }
  7208. //公杂费
  7209. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7210. if (_EnterExitCosts.ChoiceFive == 1)
  7211. {
  7212. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7213. table3Row = dac3.Count;
  7214. #region 填充word表格内容
  7215. for (int i = 0; i < dac3.Count; i++)
  7216. {
  7217. var dac = dac3[i];
  7218. if (dac == null) continue;
  7219. builder.MoveToCell(2, i, 0, 0);
  7220. builder.Write("第" + dac.Days.ToString() + "天:");
  7221. builder.MoveToCell(2, i, 1, 0);
  7222. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7223. builder.MoveToCell(2, i, 2, 0);
  7224. builder.Write("费用标准:");
  7225. string curr = "";
  7226. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7227. if (currData != null)
  7228. {
  7229. curr = currData.Name;
  7230. }
  7231. builder.MoveToCell(2, i, 3, 0);
  7232. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7233. builder.MoveToCell(2, i, 4, 0);
  7234. builder.Write("费用小计:");
  7235. builder.MoveToCell(2, i, 5, 0);
  7236. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7237. }
  7238. //删除多余行
  7239. while (table3.Rows.Count > table3Row)
  7240. {
  7241. table3.Rows.RemoveAt(table3Row);
  7242. }
  7243. #endregion
  7244. }
  7245. else dic.Add("SubGZF", "0.00");
  7246. //删除多余行
  7247. while (table3.Rows.Count > table3Row)
  7248. {
  7249. table3.Rows.RemoveAt(table3Row);
  7250. }
  7251. //培训费
  7252. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7253. if (_EnterExitCosts.ChoiceSix == 1)
  7254. {
  7255. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7256. dic.Add("SubPX", pxStr);
  7257. table4Row = dac4.Count;
  7258. #region 填充word表格内容
  7259. for (int i = 0; i < dac4.Count; i++)
  7260. {
  7261. var dac = dac4[i];
  7262. if (dac == null) continue;
  7263. builder.MoveToCell(3, i, 0, 0);
  7264. builder.Write("第" + dac.Days.ToString() + "天:");
  7265. builder.MoveToCell(3, i, 1, 0);
  7266. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7267. builder.MoveToCell(3, i, 2, 0);
  7268. builder.Write("费用标准:");
  7269. string curr = "";
  7270. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7271. if (currData != null)
  7272. {
  7273. curr = currData.Name;
  7274. }
  7275. builder.MoveToCell(3, i, 3, 0);
  7276. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7277. builder.MoveToCell(3, i, 4, 0);
  7278. builder.Write("费用小计:");
  7279. builder.MoveToCell(3, i, 5, 0);
  7280. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7281. }
  7282. #endregion
  7283. }
  7284. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7285. //删除多余行
  7286. while (table4.Rows.Count > table4Row)
  7287. {
  7288. table4.Rows.RemoveAt(table4Row);
  7289. }
  7290. //其他费用
  7291. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7292. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7293. {
  7294. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7295. dic.Add("titleQi", qtStr);
  7296. table5Row = dac5.Count;
  7297. #region 填充word表格内容
  7298. for (int i = 0; i < dac5.Count; i++)
  7299. {
  7300. var dac = dac5[i];
  7301. if (dac == null) continue;
  7302. builder.MoveToCell(4, i, 0, 0);
  7303. builder.Write("第" + dac.Index.ToString() + "项:");
  7304. builder.MoveToCell(4, i, 1, 0);
  7305. builder.Write(dac.itemName);
  7306. builder.MoveToCell(4, i, 2, 0);
  7307. builder.Write("费用标准:");
  7308. builder.MoveToCell(4, i, 3, 0);
  7309. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7310. builder.MoveToCell(4, i, 4, 0);
  7311. builder.Write("费用小计:");
  7312. builder.MoveToCell(4, i, 5, 0);
  7313. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7314. builder.MoveToCell(4, i, 6, 0);
  7315. builder.Write("备注:");
  7316. builder.MoveToCell(4, i, 7, 0);
  7317. builder.Write(dac.Remark);
  7318. }
  7319. #endregion
  7320. }
  7321. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7322. //删除多余行
  7323. while (table5.Rows.Count > table5Row)
  7324. {
  7325. table5.Rows.RemoveAt(table5Row);
  7326. }
  7327. //加上其他费用
  7328. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7329. decimal subJJC = 0.00M,
  7330. subGWC = 0.00M,
  7331. subTDC = 0.00M;
  7332. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7333. string totalLabel = string.Format("全部费用总计:");
  7334. //经济舱
  7335. if (_EnterExitCosts.SumJJC == 1)
  7336. {
  7337. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7338. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7339. }
  7340. //公务舱
  7341. if (_EnterExitCosts.SumGWC == 1)
  7342. {
  7343. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7344. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7345. }
  7346. //头等舱
  7347. if (_EnterExitCosts.SumTDC == 1)
  7348. {
  7349. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7350. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7351. }
  7352. //TotalLabel
  7353. dic.Add("TotalLabel", totalLabel);
  7354. #region 填充word模板书签内容
  7355. foreach (var key in dic.Keys)
  7356. {
  7357. Bookmark bookmark = doc.Range.Bookmarks[key];
  7358. if (bookmark != null)
  7359. {
  7360. builder.MoveToBookmark(key);
  7361. builder.Write(dic[key]);
  7362. }
  7363. }
  7364. #endregion
  7365. //文件名
  7366. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7367. strFileName = CommonFun.ValidFileName(strFileName);
  7368. AsposeHelper.removewatermark_v2180();
  7369. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7370. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7371. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7372. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7373. }
  7374. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7375. {
  7376. //获取模板
  7377. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7378. //载入模板
  7379. Document doc = new Document(tempPath);
  7380. DocumentBuilder builder = new DocumentBuilder(doc);
  7381. Dictionary<string, string> dic = new Dictionary<string, string>();
  7382. string returnCodeLabel = string.Empty;
  7383. if (nationalTravelFeeData.Any())
  7384. {
  7385. List<string> list = new List<string>();
  7386. foreach (var item in nationalTravelFeeData)
  7387. {
  7388. list.Add($"{item.Country}({item.City})");
  7389. }
  7390. list = list.Distinct().ToList();
  7391. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7392. }
  7393. var countryLabel = string.Empty;
  7394. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7395. if (countryData.Any())
  7396. {
  7397. countryLabel = string.Join("、", countryData);
  7398. }
  7399. dic.Add("ReturnCodeAir", returnCodeLabel);
  7400. dic.Add("VisitStartDate", "-");
  7401. dic.Add("VisitEndDate", "-");
  7402. dic.Add("Day", "-");
  7403. dic.Add("VisitCountry", countryLabel);
  7404. dic.Add("ClientUnit", "-");
  7405. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7406. //dic.Add("Names", Names);
  7407. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7408. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7409. decimal dac1totalPrice = 0.00M;
  7410. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7411. foreach (var dac in dac1)
  7412. {
  7413. if (dac.SubTotal == 0.00M)
  7414. {
  7415. continue;
  7416. }
  7417. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7418. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7419. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7420. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7421. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7422. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7423. builder.Write(currency);//币种
  7424. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7425. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7426. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7427. builder.Write("");//人数
  7428. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7429. builder.Write("");//天数
  7430. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7431. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7432. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7433. decimal rate = 0.00M;
  7434. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7435. builder.Write(rate.ToString("#0.0000"));//汇率
  7436. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7437. decimal rbmPrice = dac.SubTotal;
  7438. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7439. accommodationStartIndex++;
  7440. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7441. }
  7442. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7443. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7444. {
  7445. table1.Rows.RemoveAt(i - 1);
  7446. foodandotherStartIndex--;
  7447. }
  7448. if (dac2.Count == dac3.Count)//国家 币种 金额
  7449. {
  7450. for (int i = 0; i < dac2.Count; i++)
  7451. {
  7452. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7453. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7454. }
  7455. }
  7456. decimal dac2totalPrice = 0.00M;
  7457. foreach (var dac in dac2)
  7458. {
  7459. if (dac.SubTotal == 0)
  7460. {
  7461. continue;
  7462. }
  7463. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7464. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7465. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7466. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7467. builder.Write(currency);//币种
  7468. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7469. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7470. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7471. builder.Write("");//人数
  7472. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7473. builder.Write("");//天数
  7474. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7475. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7476. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7477. decimal rate = 0.00M;
  7478. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7479. builder.Write(rate.ToString("#0.0000"));//汇率
  7480. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7481. decimal rbmPrice = dac.SubTotal;
  7482. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7483. foodandotherStartIndex++;
  7484. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7485. }
  7486. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7487. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7488. {
  7489. table1.Rows.RemoveAt(i - 1);
  7490. }
  7491. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7492. string otherFeeStr = "";
  7493. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7494. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7495. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7496. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7497. foreach (var otherInfo in dac5)
  7498. {
  7499. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7500. }
  7501. #endregion
  7502. if (otherFeeStr.Length > 0)
  7503. {
  7504. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7505. otherFeeStr = $"({otherFeeStr})";
  7506. dic.Add("OtherFeeStr", otherFeeStr);
  7507. }
  7508. //总计
  7509. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7510. //国际旅费
  7511. string outsideAir = string.Empty;
  7512. string allPriceAir = string.Empty;
  7513. if (_EnterExitCosts.SumJJC == 1)
  7514. {
  7515. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7516. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7517. }
  7518. if (_EnterExitCosts.SumGWC == 1)
  7519. {
  7520. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7521. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7522. }
  7523. if (_EnterExitCosts.SumTDC == 1)
  7524. {
  7525. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7526. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7527. }
  7528. dic.Add("InTravelPrice", $"({outsideAir})");
  7529. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7530. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7531. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7532. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7533. foreach (var key in dic.Keys)
  7534. {
  7535. builder.MoveToBookmark(key);
  7536. builder.Write(dic[key]);
  7537. }
  7538. //模板文件名
  7539. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7540. strFileName = CommonFun.ValidFileName(strFileName);
  7541. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7542. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7543. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7544. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7545. }
  7546. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7547. {
  7548. //获取模板
  7549. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7550. //载入模板
  7551. WorkbookDesigner designer = new WorkbookDesigner();
  7552. designer.Workbook = new Workbook(tempPath);
  7553. Dictionary<string, string> dic = new Dictionary<string, string>();
  7554. string returnCodeLabel = string.Empty;
  7555. if (nationalTravelFeeData.Any())
  7556. {
  7557. List<string> list = new List<string>();
  7558. foreach (var item in nationalTravelFeeData)
  7559. {
  7560. list.Add($"{item.Country}({item.City})");
  7561. }
  7562. list = list.Distinct().ToList();
  7563. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7564. }
  7565. var countryLabel = string.Empty;
  7566. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7567. if (countryData.Any())
  7568. {
  7569. countryLabel = string.Join("、", countryData);
  7570. }
  7571. dic.Add("ReturnCodeAir", returnCodeLabel);
  7572. dic.Add("VisitStartDate", "-");
  7573. dic.Add("VisitEndDate", "-");
  7574. dic.Add("Day", "0");
  7575. dic.Add("VisitCountry", countryLabel);
  7576. dic.Add("ClientUnit", "-");
  7577. designer.SetDataSource("ClientUnit", "-");
  7578. designer.SetDataSource("VisitCountry", countryLabel);
  7579. designer.SetDataSource("Group", "-");
  7580. designer.SetDataSource("ClientUnitTitle", "-");
  7581. designer.SetDataSource("Name", "-");
  7582. designer.SetDataSource("VisitStartDate", "-");
  7583. designer.SetDataSource("Day", "0");
  7584. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7585. designer.SetDataSource("ReturnCodeAir", "-");
  7586. int startIndex = 10;
  7587. const int startIndexcopy = 10;
  7588. if (dac2.Count == dac3.Count)//国家 币种 金额
  7589. {
  7590. for (int i = 0; i < dac2.Count; i++)
  7591. {
  7592. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7593. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7594. }
  7595. }
  7596. DataTable dtdac1 = new DataTable();
  7597. List<string> place = new List<string>();
  7598. dtdac1.Columns.AddRange(new DataColumn[] {
  7599. new DataColumn(){ ColumnName = "city"},
  7600. new DataColumn(){ ColumnName = "curr"},
  7601. new DataColumn(){ ColumnName = "criterion"},
  7602. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7603. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7604. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7605. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7606. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7607. });
  7608. DataTable dtdac2 = new DataTable();
  7609. dtdac2.Columns.AddRange(new DataColumn[] {
  7610. new DataColumn(){ ColumnName = "city"},
  7611. new DataColumn(){ ColumnName = "curr"},
  7612. new DataColumn(){ ColumnName = "criterion"},
  7613. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7614. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7615. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7616. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7617. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7618. });
  7619. dtdac1.TableName = "tb1";
  7620. dtdac2.TableName = "tb2";
  7621. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7622. foreach (var item in dac1)
  7623. {
  7624. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7625. if (place.Contains(item.Place))
  7626. {
  7627. continue;
  7628. }
  7629. DataRow row = dtdac1.NewRow();
  7630. row["city"] = item.Place;
  7631. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7632. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7633. row["curr"] = currency;
  7634. row["rate"] = rate.ToString("#0.0000");
  7635. row["criterion"] = item.Cost.ToString("#0.00");
  7636. row["number"] = 1;
  7637. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7638. //row["costRMB"] = rbmPrice;
  7639. dtdac1.Rows.Add(row);
  7640. place.Add(item.Place);
  7641. }
  7642. place = new List<string>();
  7643. foreach (var item in dac2)
  7644. {
  7645. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7646. if (place.Contains(item.Place))
  7647. {
  7648. continue;
  7649. }
  7650. DataRow row = dtdac2.NewRow();
  7651. row["city"] = item.Place;
  7652. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7653. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7654. row["curr"] = currency;
  7655. row["rate"] = rate.ToString("#0.0000");
  7656. row["criterion"] = item.Cost.ToString("#0.00");
  7657. row["number"] = 1;
  7658. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7659. //row["cost"] = item.SubTotal;
  7660. //row["costRMB"] = rbmPrice;
  7661. dtdac2.Rows.Add(row);
  7662. place.Add(item.Place);
  7663. //dac2totalPrice += rbmPrice;
  7664. }
  7665. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7666. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7667. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7668. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7669. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7670. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7671. string cell4Str1 = string.Empty;
  7672. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7673. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7674. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7675. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7676. string cellStr = $" 5.其他费用(";
  7677. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7678. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7679. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7680. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7681. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7682. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7683. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7684. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7685. foreach (var otherInfo in dac5)
  7686. {
  7687. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7688. }
  7689. #endregion
  7690. if (cellStr.Length > 8)
  7691. {
  7692. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7693. }
  7694. cellStr += ")";
  7695. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7696. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7697. decimal pxFee = dac4.Sum(it => it.Cost);
  7698. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7699. string celllastStr1 = "";
  7700. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7701. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7702. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7703. celllastStr1 += $",国际旅费 元";
  7704. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7705. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7706. designer.SetDataSource("cell4Str", cell4Str);
  7707. designer.SetDataSource("cellStr", cellStr);
  7708. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7709. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7710. designer.SetDataSource("celllastStr", celllastStr);
  7711. Workbook wb = designer.Workbook;
  7712. var sheet = wb.Worksheets[0];
  7713. //绑定datatable数据集
  7714. designer.SetDataSource(dtdac1);
  7715. designer.SetDataSource(dtdac2);
  7716. designer.Process();
  7717. var rowStart = dtdac1.Rows.Count;
  7718. while (rowStart > 0)
  7719. {
  7720. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7721. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7722. startIndex++;
  7723. rowStart--;
  7724. }
  7725. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7726. startIndex += 1; //总计行
  7727. rowStart = dtdac2.Rows.Count;
  7728. while (rowStart > 0)
  7729. {
  7730. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7731. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7732. startIndex++;
  7733. rowStart--;
  7734. }
  7735. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7736. wb.CalculateFormula(true);
  7737. //模板文件名
  7738. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7739. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7740. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7741. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7742. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7743. }
  7744. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7745. {
  7746. //获取模板
  7747. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7748. //载入模板
  7749. Document doc = new Document(tempPath);
  7750. DocumentBuilder builder = new DocumentBuilder(doc);
  7751. Dictionary<string, string> dic = new Dictionary<string, string>();
  7752. dic.Add("GroupName", "-");
  7753. dic.Add("ClientUnit", "-");
  7754. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7755. //string missionLeaderJob = "";//负责人job
  7756. //int groupNumber = 0; //团人数
  7757. dic.Add("MissionLeader", "-"); //团负责人
  7758. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7759. dic.Add("GroupNumber", "0"); //团人数
  7760. dic.Add("Day", "0");
  7761. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7762. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7763. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7764. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7765. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7766. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7767. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7768. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7769. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7770. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7771. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7772. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7773. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7774. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7775. //其他费用
  7776. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7777. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7778. //其他费用合计
  7779. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7780. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7781. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7782. //公务舱合计
  7783. //国际旅费
  7784. //string outsideJJ = "";
  7785. //string allPriceJJ = "";
  7786. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7787. {
  7788. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7789. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7790. }
  7791. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7792. {
  7793. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7794. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7795. }
  7796. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7797. {
  7798. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7799. dic.Add("AirFeeTotal", airFeeTotalStr);
  7800. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7801. dic.Add("FeeTotal", feeTotalStr);
  7802. }
  7803. foreach (var key in dic.Keys)
  7804. {
  7805. builder.MoveToBookmark(key);
  7806. builder.Write(dic[key]);
  7807. }
  7808. //模板文件名
  7809. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7810. strFileName = CommonFun.ValidFileName(strFileName);
  7811. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7812. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7813. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7814. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7815. }
  7816. }
  7817. else if (dto.ExportType == 2) //表格
  7818. {
  7819. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7820. }
  7821. else if (dto.ExportType == 3)
  7822. {
  7823. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7824. }
  7825. return Ok(JsonView(400, "只可导出明细表!", ""));
  7826. }
  7827. catch (Exception ex)
  7828. {
  7829. return Ok(JsonView(400, ex.Message, ""));
  7830. }
  7831. }
  7832. /// <summary>
  7833. /// 获取三公费用标准city
  7834. /// </summary>
  7835. /// <param name="placeData"></param>
  7836. /// <param name="nationalTravelFeeId"></param>
  7837. /// <returns></returns>
  7838. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7839. {
  7840. string _city = string.Empty;
  7841. if (!placeData.Any()) return _city;
  7842. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7843. if (data == null) return _city;
  7844. string country = data.Country;
  7845. string city = data.City;
  7846. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7847. else _city = city;
  7848. return _city;
  7849. }
  7850. /// <summary>
  7851. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7852. /// </summary>
  7853. /// <returns></returns>
  7854. [HttpPost]
  7855. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7857. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7858. {
  7859. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7860. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7861. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7862. if (_view.Code == 0)
  7863. {
  7864. return Ok(JsonView(true, "操作成功"));
  7865. }
  7866. return Ok(JsonView(false, "操作失败"));
  7867. }
  7868. /// <summary>
  7869. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7870. /// </summary>
  7871. /// <returns></returns>
  7872. [HttpPost]
  7873. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7875. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7876. {
  7877. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7878. if (data.Code != 0)
  7879. {
  7880. return Ok(JsonView(false, data.Msg));
  7881. }
  7882. return Ok(JsonView(true, "操作成功!", data.Data));
  7883. }
  7884. /// <summary>
  7885. /// 三公其他费用草稿 删除
  7886. /// </summary>
  7887. /// <param name="dto"></param>
  7888. /// <returns></returns>
  7889. [HttpPost]
  7890. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7891. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7892. {
  7893. var jw = JsonView(false, "删除失败!");
  7894. var data = new Grp_DayOtherPriceDraft()
  7895. {
  7896. Id = dto.Id,
  7897. IsDel = 1,
  7898. DeleteUserId = dto.DeleteUserId,
  7899. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7900. };
  7901. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7902. if (del > 0)
  7903. {
  7904. jw.Code = 200;
  7905. jw.Msg = "删除成功!";
  7906. }
  7907. return Ok(jw);
  7908. }
  7909. /// <summary>
  7910. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7911. /// </summary>
  7912. /// <returns></returns>
  7913. [HttpPost]
  7914. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7915. {
  7916. var jw = JsonView(false);
  7917. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7918. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7919. jw.Code = StatusCodes.Status200OK;
  7920. jw.Msg = "操作成功!";
  7921. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  7922. return Ok(jw);
  7923. }
  7924. /// <summary>
  7925. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7926. /// </summary>
  7927. /// <param name="dto"></param>
  7928. /// <returns></returns>
  7929. [HttpPost]
  7930. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7931. {
  7932. int userId = dto.UserId,
  7933. portId = dto.PortType,
  7934. groupId = dto.GroupId,
  7935. draftId = dto.DraftId;
  7936. _portTypeData.Add(1);
  7937. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7938. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7939. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7940. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7941. _sqlSugar.BeginTran();
  7942. try
  7943. {
  7944. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7945. if (draftDatas == null)
  7946. {
  7947. _sqlSugar.RollbackTran();
  7948. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7949. }
  7950. //验证可覆盖已有数据 两边创建人需为同一人;
  7951. int draftCreateUserId = draftDatas.CreateUserId,
  7952. formalCreateUserId = 0;
  7953. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7954. if (formalData != null)
  7955. {
  7956. formalCreateUserId = formalData.CreateUserId;
  7957. if (draftCreateUserId != formalCreateUserId)
  7958. {
  7959. _sqlSugar.RollbackTran();
  7960. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7961. }
  7962. }
  7963. //默认添加查看、编辑权限(创建人、自己)
  7964. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  7965. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7966. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7967. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7968. newExterData.DiId = groupId;
  7969. newExterData.CreateUserId = userId;
  7970. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7971. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7972. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7973. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7974. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7975. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7976. //数据如果存在执行删除
  7977. if (enterExitCostInfo != null)
  7978. {
  7979. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7980. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7981. .Where(x => x.Id == enterExitCostInfo.Id)
  7982. .ExecuteCommand();
  7983. _sqlSugar.Updateable<Grp_DayAndCost>()
  7984. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7985. .Where(x => x.DiId == groupId)
  7986. .ExecuteCommand();
  7987. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7988. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7989. .Where(x => x.Diid == groupId)
  7990. .ExecuteCommand();
  7991. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7992. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7993. .Where(x => x.GroupId == groupId)
  7994. .ExecuteCommand();
  7995. }
  7996. //执行insert
  7997. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7998. if (insertId < 1)
  7999. {
  8000. _sqlSugar.RollbackTran();
  8001. return Ok(JsonView(false, "草稿数据导入失败!"));
  8002. }
  8003. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8004. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8005. #region 默认添加权限
  8006. #endregion
  8007. _sqlSugar.CommitTran();
  8008. //执行操作之后
  8009. //生成默认文件pdf并且通知人员
  8010. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8011. {
  8012. DiId = groupId,
  8013. ExportType = 1,
  8014. SubTypeId = 1005
  8015. }, "pdf");
  8016. //发送通知
  8017. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8018. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8019. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8020. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8021. //汇率信息记录
  8022. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8023. return Ok(JsonView(true));
  8024. }
  8025. catch (Exception ex)
  8026. {
  8027. _sqlSugar.RollbackTran();
  8028. return Ok(JsonView(false, ex.Message));
  8029. }
  8030. }
  8031. #endregion
  8032. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8033. /// <summary>
  8034. /// 获取币种基础数据(含逻辑处理)
  8035. /// </summary>
  8036. /// <returns></returns>
  8037. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8038. {
  8039. return await GeneralMethod.EnterExitCostInitRate();
  8040. }
  8041. /// <summary>
  8042. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8043. /// </summary>
  8044. /// <returns></returns>
  8045. [HttpPost]
  8046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8047. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8048. {
  8049. //验证城市归属并给默认值
  8050. int provinceId = dto.ProvinceId;
  8051. if (provinceId < 1) provinceId = 122;
  8052. var dataSource = await _sqlSugar
  8053. .Queryable<Sys_SetData>()
  8054. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8055. .ToListAsync();
  8056. var fileTypes = new List<EecSetDataInfoView>();
  8057. //三公费用-Word明细类型
  8058. var wordTypeData = dataSource
  8059. .Where(it => it.STid == 72)
  8060. .Select(x => new EecSetDataInfoView
  8061. {
  8062. ParentId = 1,
  8063. Id = x.Id,
  8064. Name = x.Name
  8065. })
  8066. .ToArray();
  8067. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8068. var excelTypeData = dataSource
  8069. .Where(it => it.STid == 73)
  8070. .Select(x => new EecSetDataInfoView
  8071. {
  8072. ParentId = 2,
  8073. Id = x.Id,
  8074. Name = x.Name
  8075. })
  8076. .ToArray();
  8077. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8078. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8079. fileTypes.Add(groupNameList);
  8080. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  8081. //默认币种显示
  8082. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8083. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8084. return Ok(JsonView(true, "查询成功!", new
  8085. {
  8086. FileTypeData = fileTypes,
  8087. CurrencyInit = _currencyInfos,
  8088. viewPermissionData = viewPermissionData
  8089. }));
  8090. }
  8091. /// <summary>
  8092. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  8093. /// </summary>
  8094. /// <returns></returns>
  8095. [HttpPost]
  8096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8097. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  8098. {
  8099. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8100. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8101. RefAsync<int> total = 0;
  8102. int diId = 0;
  8103. var status = int.TryParse(dto.GroupName, out diId);
  8104. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  8105. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8106. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8107. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8108. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8109. .OrderByDescending(x => x.VisitStartDate)
  8110. .Select(x => new EnterExitCostMobileGroupView()
  8111. {
  8112. Id = x.Id,
  8113. GroupName = x.TeamName,
  8114. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8115. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8116. ProvinceId = x.CityId
  8117. })
  8118. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8119. //处理省份Id
  8120. if (data.Any())
  8121. {
  8122. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8123. if (provCityDatas.Any())
  8124. {
  8125. foreach (var item in data)
  8126. {
  8127. var provinceId = item.ProvinceId;
  8128. var isDefualtVal = true;
  8129. if (provinceId > 0)
  8130. {
  8131. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  8132. if (parentId != null)
  8133. {
  8134. isDefualtVal = false;
  8135. item.ProvinceId = (int)parentId;
  8136. }
  8137. }
  8138. if (isDefualtVal)
  8139. {
  8140. item.ProvinceId = 122; //默认四川
  8141. }
  8142. }
  8143. }
  8144. }
  8145. //处理是否显示
  8146. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  8147. {
  8148. foreach (var item in data)
  8149. {
  8150. item.IsView = true;
  8151. }
  8152. }
  8153. return Ok(JsonView(true, "查询成功!", data, total));
  8154. }
  8155. /// <summary>
  8156. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  8157. /// </summary>
  8158. /// <returns></returns>
  8159. [HttpPost]
  8160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8161. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  8162. {
  8163. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8164. RefAsync<int> total = 0;
  8165. var data = await _sqlSugar.Queryable<Sys_SetData>()
  8166. .Where(x => x.IsDel == 0 && x.STid == 66)
  8167. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  8168. .Select(x => new
  8169. {
  8170. id = x.Id,
  8171. name = x.Name,
  8172. remark = x.Remark,
  8173. })
  8174. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8175. return Ok(JsonView(true, "查询成功!", data, total));
  8176. }
  8177. /// <summary>
  8178. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  8179. /// </summary>
  8180. /// <returns></returns>
  8181. [HttpPost]
  8182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8183. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  8184. {
  8185. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8186. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8187. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  8188. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  8189. var groupOtherRateData = groupRateData.TeamRates;
  8190. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8191. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8192. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8193. groupOtherRateData = groupOtherRateData
  8194. .Select(x => new TeamRateDescAddCurrencyIdView
  8195. {
  8196. CurrencyId = x.CurrencyId,
  8197. CurrencyName = x.CurrencyName,
  8198. CurrencyCode = x.CurrencyCode,
  8199. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8200. }).ToList();
  8201. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8202. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8203. }
  8204. /// <summary>
  8205. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8206. /// </summary>
  8207. /// <returns></returns>
  8208. [HttpPost]
  8209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8210. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8211. {
  8212. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8213. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8214. var tipsData = new List<int>() { 1, 2, 3 };
  8215. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8216. if (dto.TipsType == 1)
  8217. {
  8218. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8219. }
  8220. else if (dto.TipsType == 2)
  8221. {
  8222. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8223. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8224. }
  8225. else if (dto.TipsType == 3)
  8226. {
  8227. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8228. return Ok(JsonView(true, "查询成功!", airData.Data));
  8229. }
  8230. return Ok(JsonView(false));
  8231. }
  8232. /// <summary>
  8233. /// 团组模块 - 出入境国家费用标准-移动端 List
  8234. /// </summary>
  8235. /// <returns></returns>
  8236. [HttpPost]
  8237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8238. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8239. {
  8240. Stopwatch sw = new Stopwatch();
  8241. sw.Start();
  8242. int provinceId = dto.ProvinceId;
  8243. if (provinceId < 1) provinceId = 122; // 默认四川
  8244. RefAsync<int> total = 0;
  8245. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8246. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8247. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8248. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  8249. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8250. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8251. .Select((ntf, sd, u, sd1) => new
  8252. {
  8253. Id = ntf.Id,
  8254. Area = $"{ntf.Country}-{ntf.City}",
  8255. Currency = ntf.Currency,
  8256. CurrencyCode = sd.Name,
  8257. CurrencyName = sd.Remark,
  8258. RoomCost = ntf.RoomCost,
  8259. FoodCost = ntf.FoodCost,
  8260. PublicCost = ntf.PublicCost,
  8261. TrainCost = ntf.TrainCost,
  8262. LastUpdateUserId = ntf.LastUpdateUserId,
  8263. LastUpdateUserName = u.CnName,
  8264. LastUpdateTime = ntf.LastUpdateTime
  8265. })
  8266. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8267. sw.Stop();
  8268. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8269. }
  8270. /// <summary>
  8271. /// 团组模块 - 出入境费用-移动端 - Info
  8272. /// </summary>
  8273. /// <returns></returns>
  8274. [HttpPost]
  8275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8276. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8277. {
  8278. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8279. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8280. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8281. return Ok(data);
  8282. }
  8283. /// <summary>
  8284. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8285. /// </summary>
  8286. /// <returns></returns>
  8287. [HttpPost]
  8288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8289. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8290. {
  8291. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8292. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8293. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8294. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8295. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8296. mobileInfo.DiId = dto.DiId;
  8297. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8298. if (eecInfo == null) return Ok(mobileInfo);
  8299. //验证查看权限
  8300. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8301. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8302. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8303. mobileInfo.IsAssignPerm = isSet;
  8304. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8305. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8306. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8307. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8308. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8309. {
  8310. SubId = dac.Id,
  8311. DiId = dac.DiId,
  8312. Type = dac.Type,
  8313. Days = dac.Days,
  8314. NationalTravelFeeId = dac.NationalTravelFeeId,
  8315. Arae = $"{ntf.Country}-{ntf.City}",
  8316. Cost = dac.Cost,
  8317. Currency = dac.Currency,
  8318. CurrencyName = sd.Name,
  8319. SubTotal = dac.SubTotal,
  8320. })
  8321. .ToList();
  8322. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8323. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8324. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8325. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8326. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8327. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8328. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8329. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8330. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8331. //其他款项
  8332. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8333. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8334. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8335. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8336. .OrderBy((dop, sd1, sd2) => dop.Index)
  8337. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8338. {
  8339. SubId = dop.Id,
  8340. DiId = dop.Diid,
  8341. Index = dop.Index,
  8342. SetDataId = dop.SetDataId,
  8343. SetDataName = sd1.Name,
  8344. Cost = dop.Cost,
  8345. Currency = dop.Currency,
  8346. CurrencyName = sd2.Remark,
  8347. SubTotal = dop.SubTotal,
  8348. Remark = dop.Remark,
  8349. })
  8350. .ToArray();
  8351. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8352. return Ok(mobileInfo);
  8353. }
  8354. /// <summary>
  8355. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8356. /// </summary>
  8357. /// <returns></returns>
  8358. [HttpPost]
  8359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8360. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8361. {
  8362. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8363. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8364. //验证查看权限
  8365. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8366. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8367. var userIds = await _sqlSugar
  8368. .Queryable<Grp_EnterExitCostPermission>()
  8369. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8370. .Select(x => x.UserId)
  8371. .ToArrayAsync();
  8372. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8373. var perUsersView = new List<dynamic>();
  8374. foreach (var item in perUsers)
  8375. {
  8376. bool isView1 = false;
  8377. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8378. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8379. }
  8380. return Ok(JsonView(perUsersView));
  8381. }
  8382. /// <summary>
  8383. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8384. /// </summary>
  8385. /// <returns></returns>
  8386. [HttpPost]
  8387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8388. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8389. {
  8390. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8391. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8392. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8393. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8394. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8395. //验证查看权限
  8396. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8397. //if (!isView) return Ok(JsonView(false, msg));
  8398. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8399. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8400. var subType = dto.SubType;
  8401. if (subType == 1) //1:境内费用
  8402. {
  8403. var oneData = new ChoiceOneMobileSubInfoView()
  8404. {
  8405. Id = eecInfo.Id,
  8406. ChoiceOne = eecInfo.ChoiceOne,
  8407. ChoiceOneTotalCost = eecInfo.InsidePay,
  8408. Visa = eecInfo.Visa,
  8409. VisaRemark = eecInfo.VisaRemark,
  8410. YiMiao = eecInfo.YiMiao,
  8411. HeSuan = eecInfo.HeSuan,
  8412. Service = eecInfo.Service,
  8413. Ticket = eecInfo.Ticket,
  8414. Safe = eecInfo.Safe,
  8415. FirstItemRemark = eecInfo.FirstItemRemark
  8416. };
  8417. return Ok(JsonView(oneData));
  8418. }
  8419. else if (subType == 2) //2:国际旅费
  8420. {
  8421. var twoData = new ChoiceTwoMobileSubInfoView()
  8422. {
  8423. Id = eecInfo.Id,
  8424. ChoiceTwoJJ = eecInfo.SumJJC,
  8425. OutsideJJPay = eecInfo.OutsideJJPay,
  8426. ChoiceTwoGW = eecInfo.SumGWC,
  8427. OutsideGWPay = eecInfo.OutsideGWPay,
  8428. ChoiceTwoTD = eecInfo.SumTDC,
  8429. OutsideTDPay = eecInfo.OutsideTDPay,
  8430. AirJJ = eecInfo.AirJJ,
  8431. AirGW = eecInfo.AirGW,
  8432. AirTD = eecInfo.AirTD,
  8433. CityTranffic = eecInfo.CityTranffic,
  8434. TwoItemRemark = eecInfo.TwoItemRemark
  8435. };
  8436. return Ok(JsonView(twoData));
  8437. }
  8438. else if (subType == 3) //3:住宿费
  8439. {
  8440. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8441. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8442. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8443. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8444. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8445. {
  8446. SubId = dac.Id,
  8447. DiId = dac.DiId,
  8448. Type = dac.Type,
  8449. Days = dac.Days,
  8450. NationalTravelFeeId = dac.NationalTravelFeeId,
  8451. Arae = $"{ntf.Country}-{ntf.City}",
  8452. Cost = dac.Cost,
  8453. Currency = dac.Currency,
  8454. CurrencyName = sd.Name,
  8455. SubTotal = dac.SubTotal,
  8456. })
  8457. .ToArray();
  8458. var data = new ChoiceMobileSubInfo3To6View()
  8459. {
  8460. ParentId = eecInfo.Id,
  8461. Choice = eecInfo.ChoiceThree,
  8462. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8463. Details = dayAndCostDatas
  8464. };
  8465. return Ok(JsonView(data));
  8466. }
  8467. else if (subType == 4) //4:伙食费
  8468. {
  8469. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8470. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8471. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8472. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8473. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8474. {
  8475. SubId = dac.Id,
  8476. DiId = dac.DiId,
  8477. Type = dac.Type,
  8478. Days = dac.Days,
  8479. NationalTravelFeeId = dac.NationalTravelFeeId,
  8480. Arae = $"{ntf.Country}-{ntf.City}",
  8481. Cost = dac.Cost,
  8482. Currency = dac.Currency,
  8483. CurrencyName = sd.Name,
  8484. SubTotal = dac.SubTotal,
  8485. })
  8486. .ToArray();
  8487. var data = new ChoiceMobileSubInfo3To6View()
  8488. {
  8489. ParentId = eecInfo.Id,
  8490. Choice = eecInfo.ChoiceFour,
  8491. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8492. Details = dayAndCostDatas
  8493. };
  8494. return Ok(JsonView(data));
  8495. }
  8496. else if (subType == 5) //5:公杂费
  8497. {
  8498. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8499. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8500. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8501. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8502. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8503. {
  8504. SubId = dac.Id,
  8505. DiId = dac.DiId,
  8506. Type = dac.Type,
  8507. Days = dac.Days,
  8508. NationalTravelFeeId = dac.NationalTravelFeeId,
  8509. Arae = $"{ntf.Country}-{ntf.City}",
  8510. Cost = dac.Cost,
  8511. Currency = dac.Currency,
  8512. CurrencyName = sd.Name,
  8513. SubTotal = dac.SubTotal,
  8514. })
  8515. .ToArray();
  8516. var data = new ChoiceMobileSubInfo3To6View()
  8517. {
  8518. ParentId = eecInfo.Id,
  8519. Choice = eecInfo.ChoiceFive,
  8520. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8521. Details = dayAndCostDatas
  8522. };
  8523. return Ok(JsonView(data));
  8524. }
  8525. else if (subType == 6) //6:培训费
  8526. {
  8527. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8528. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8529. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8530. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8531. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8532. {
  8533. SubId = dac.Id,
  8534. DiId = dac.DiId,
  8535. Type = dac.Type,
  8536. Days = dac.Days,
  8537. NationalTravelFeeId = dac.NationalTravelFeeId,
  8538. Arae = $"{ntf.Country}-{ntf.City}",
  8539. Cost = dac.Cost,
  8540. Currency = dac.Currency,
  8541. CurrencyName = sd.Name,
  8542. SubTotal = dac.SubTotal,
  8543. })
  8544. .ToArray();
  8545. var data = new ChoiceMobileSubInfo3To6View()
  8546. {
  8547. ParentId = eecInfo.Id,
  8548. Choice = eecInfo.ChoiceSix,
  8549. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8550. Details = dayAndCostDatas
  8551. };
  8552. return Ok(JsonView(data));
  8553. }
  8554. else if (subType == 7) //7:其他
  8555. {
  8556. //其他款项
  8557. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8558. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8559. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8560. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8561. .OrderBy((dop, sd1, sd2) => dop.Index)
  8562. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8563. {
  8564. SubId = dop.Id,
  8565. DiId = dop.Diid,
  8566. Index = dop.Index,
  8567. SetDataId = dop.SetDataId,
  8568. SetDataName = sd1.Name,
  8569. Cost = dop.Cost,
  8570. Currency = dop.Currency,
  8571. CurrencyName = sd2.Name,
  8572. SubTotal = dop.SubTotal,
  8573. Remark = dop.Remark,
  8574. })
  8575. .ToArray();
  8576. var data = new ChoiceSevenMobileSubInfoView()
  8577. {
  8578. ParentId = eecInfo.Id,
  8579. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8580. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8581. Details = otherData
  8582. };
  8583. return Ok(JsonView(data));
  8584. }
  8585. return Ok(JsonView(false));
  8586. }
  8587. #region op
  8588. /// <summary>
  8589. /// 移动端更新费用消息通知
  8590. /// </summary>
  8591. /// <param name="diid"></param>
  8592. /// <param name="id"></param>
  8593. /// <param name="currUserId"></param>
  8594. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8595. {
  8596. try
  8597. {
  8598. ////生成默认文件pdf并且通知人员
  8599. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8600. //{
  8601. // DiId = diid,
  8602. // ExportType = 1,
  8603. // SubTypeId = 1005
  8604. //}, "pdf");
  8605. ////发送通知
  8606. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8607. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8608. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8609. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8610. ////汇率信息记录
  8611. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8612. }
  8613. catch (Exception ex)
  8614. {
  8615. //记录日志
  8616. throw;
  8617. }
  8618. }
  8619. /// <summary>
  8620. /// 验证出入境费用数据是否存在
  8621. /// 不存在添加
  8622. /// </summary>
  8623. /// <param name="diId"></param>
  8624. /// <param name="currUserId"></param>
  8625. /// <returns></returns>
  8626. /// <exception cref="CustomException"></exception>
  8627. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8628. {
  8629. var parentId = 0;
  8630. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8631. if (info != null)
  8632. {
  8633. parentId = info.Id;
  8634. }
  8635. else
  8636. {
  8637. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8638. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8639. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8640. parentId = addId;
  8641. }
  8642. return parentId;
  8643. }
  8644. /// <summary>
  8645. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8646. /// </summary>
  8647. /// <returns></returns>
  8648. [HttpPost]
  8649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8650. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8651. {
  8652. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8653. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8654. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8655. //验证编辑权限
  8656. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8657. //if (!isEdit) return Ok(JsonView(false, msg));
  8658. var permissions = new List<Grp_EnterExitCostPermission>();
  8659. foreach (var userId in dto.UserIds)
  8660. {
  8661. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8662. }
  8663. if (permissions.Any())
  8664. {
  8665. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8666. {
  8667. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8668. }
  8669. _sqlSugar.BeginTran();
  8670. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8671. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8672. if (result < 1)
  8673. {
  8674. _sqlSugar.RollbackTran();
  8675. return Ok(JsonView(false));
  8676. }
  8677. _sqlSugar.CommitTran();
  8678. return Ok(JsonView(true));
  8679. }
  8680. return Ok(JsonView(false));
  8681. }
  8682. /// <summary>
  8683. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8684. /// </summary>
  8685. /// <returns></returns>
  8686. [HttpPost]
  8687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8688. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8689. {
  8690. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8691. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8692. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8693. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8694. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8695. int id = dto.Id;
  8696. if (id <= 0) //add
  8697. {
  8698. //int provinceId = dto.ProvinceId;
  8699. int groupId = dto.DiId;
  8700. //if (provinceId < 1) provinceId = 122;
  8701. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  8702. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  8703. if (add < 1) return Ok(JsonView(false));
  8704. id = add;
  8705. }
  8706. else //update
  8707. {
  8708. ////验证编辑权限
  8709. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8710. //if (!isEdit) return Ok(JsonView(false, msg));
  8711. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8712. if (upd < 1) return Ok(JsonView(false));
  8713. }
  8714. #region 汇率变更时更改币种相关费用
  8715. var opDayCosts = new List<Grp_DayAndCost>();
  8716. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8717. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8718. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8719. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8720. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8721. .Select((dac, sd) => new
  8722. {
  8723. dac.Id,
  8724. dac.DiId,
  8725. CurrencyCode = sd.Name,
  8726. dac.Cost
  8727. })
  8728. .ToList();
  8729. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8730. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8731. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8732. .Select((dop, sd) => new
  8733. {
  8734. dop.Id,
  8735. dop.Diid,
  8736. CurrencyCode = sd.Name,
  8737. dop.Cost
  8738. })
  8739. .ToList();
  8740. if (dayCosts.Count > 0)
  8741. {
  8742. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8743. foreach (var dc in new_dayCosts)
  8744. {
  8745. var thisCurrency = dc.Key.ToUpper();
  8746. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8747. if (thisRate == 0.00M) continue;
  8748. foreach (var dcSub in dc)
  8749. {
  8750. opDayCosts.Add(new Grp_DayAndCost()
  8751. {
  8752. Id = dcSub.Id,
  8753. DiId = dcSub.DiId,
  8754. Cost = dcSub.Cost,
  8755. SubTotal = dcSub.Cost * thisRate,
  8756. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8757. });
  8758. }
  8759. }
  8760. if (opDayCosts.Count > 0)
  8761. {
  8762. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8763. }
  8764. }
  8765. if (dayOtherCosts.Count > 0)
  8766. {
  8767. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8768. foreach (var dc in new_dayOtherCosts)
  8769. {
  8770. var thisCurrency = dc.Key.ToUpper();
  8771. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8772. if (thisRate == 0.00M) continue;
  8773. foreach (var dcSub in dc)
  8774. {
  8775. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8776. {
  8777. Id = dcSub.Id,
  8778. Diid = dcSub.Diid,
  8779. Cost = dcSub.Cost,
  8780. SubTotal = dcSub.Cost * thisRate,
  8781. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8782. });
  8783. }
  8784. }
  8785. if (opDayOtherCosts.Count > 0)
  8786. {
  8787. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8788. }
  8789. }
  8790. #endregion
  8791. //消息通知
  8792. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8793. //汇率信息记录
  8794. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8795. return Ok(JsonView(new { parentId = id }));
  8796. }
  8797. /// <summary>
  8798. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8799. /// </summary>
  8800. /// <returns></returns>
  8801. [HttpPost]
  8802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8803. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8804. {
  8805. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8806. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8807. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8808. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  8809. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8810. int id = dto.Id;
  8811. if (id <= 0) //add
  8812. {
  8813. checkboxInfo.CreateUserId = dto.CurrUserId;
  8814. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8815. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8816. if (add < 1) return Ok(JsonView(false));
  8817. }
  8818. else //update
  8819. {
  8820. ////验证编辑权限
  8821. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8822. //if (!isEdit) return Ok(JsonView(false, msg));
  8823. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8824. .UpdateColumns(x => new
  8825. {
  8826. x.ChoiceOne,
  8827. x.ChoiceTwo,
  8828. x.SumJJC,
  8829. x.SumGWC,
  8830. x.SumTDC,
  8831. x.ChoiceThree,
  8832. x.ChoiceFour,
  8833. x.ChoiceFive,
  8834. x.ChoiceSix,
  8835. x.OtherExpenses_Checked
  8836. })
  8837. .Where(x => x.Id == id)
  8838. .ExecuteCommandAsync();
  8839. if (upd < 1) return Ok(JsonView(false));
  8840. }
  8841. return Ok(JsonView(new { parentId = id }));
  8842. }
  8843. /// <summary>
  8844. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8845. /// </summary>
  8846. /// <returns></returns>
  8847. [HttpPost]
  8848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8849. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8850. {
  8851. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8852. // if (provinceId < 1) provinceId = 122;
  8853. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8854. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8855. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8856. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8857. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8858. var checkboxInfo = new Grp_EnterExitCost()
  8859. {
  8860. Id = id,
  8861. //ProvinceId = provinceId,
  8862. DiId = diId,
  8863. CreateUserId = currUserId
  8864. };
  8865. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8866. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8867. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8868. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8869. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8870. if (id <= 0) //add
  8871. {
  8872. checkboxInfo.CreateUserId = dto.CurrUserId;
  8873. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8874. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8875. if (add < 1) return Ok(JsonView(false));
  8876. }
  8877. else //update
  8878. {
  8879. ////验证编辑权限
  8880. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8881. //if (!isEdit) return Ok(JsonView(false, msg));
  8882. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8883. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8884. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8885. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8886. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8887. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8888. .Where(x => x.Id == id)
  8889. .ExecuteCommandAsync();
  8890. if (upd < 1) return Ok(JsonView(false));
  8891. }
  8892. return Ok(JsonView(new { parentId = id }));
  8893. }
  8894. /// <summary>
  8895. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8896. /// </summary>
  8897. /// <returns></returns>
  8898. [HttpPost]
  8899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8900. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8901. {
  8902. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8903. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8904. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8905. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  8906. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8907. info.FirstItemRemark = dto.FirstItemRemark;
  8908. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8909. int id = dto.Id;
  8910. if (id <= 0) //add
  8911. {
  8912. info.CreateUserId = dto.CurrUserId;
  8913. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8914. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8915. if (add < 1) return Ok(JsonView(false));
  8916. id = add;
  8917. }
  8918. else //update
  8919. {
  8920. ////验证编辑权限
  8921. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8922. //if (!isEdit) return Ok(JsonView(false, msg));
  8923. var upd = await _sqlSugar.Updateable(info)
  8924. .UpdateColumns(x => new
  8925. {
  8926. x.ChoiceOne,
  8927. x.InsidePay,
  8928. x.VisaRemark,
  8929. x.Visa,
  8930. x.Service,
  8931. x.Safe,
  8932. x.Ticket,
  8933. x.HeSuan,
  8934. x.YiMiao,
  8935. x.FirstItemRemark
  8936. })
  8937. .Where(x => x.Id == id)
  8938. .ExecuteCommandAsync();
  8939. if (upd < 1) return Ok(JsonView(false));
  8940. }
  8941. //消息通知
  8942. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8943. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8944. }
  8945. /// <summary>
  8946. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8947. /// </summary>
  8948. /// <returns></returns>
  8949. [HttpPost]
  8950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8951. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8952. {
  8953. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8954. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8955. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8956. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  8957. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8958. info.DiId = dto.DiId;
  8959. //info.ProvinceId = dto.ProvinceId;
  8960. info.OutsideJJPay = dto.OutsideJJPay;
  8961. info.OutsideGWPay = dto.OutsideGWPay;
  8962. info.OutsideTDPay = dto.OutsideTDPay;
  8963. info.AirJJ = dto.AirJJ;
  8964. info.AirGW = dto.AirGW;
  8965. info.AirTD = dto.AirTD;
  8966. info.CityTranffic = dto.CityTranffic;
  8967. info.TwoItemRemark = dto.TwoItemRemark;
  8968. info.SumJJC = dto.ChoiceTwoJJ;
  8969. info.SumGWC = dto.ChoiceTwoGW;
  8970. info.SumTDC = dto.ChoiceTwoTD;
  8971. int id = dto.Id;
  8972. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8973. if (id <= 0) //add
  8974. {
  8975. info.CreateUserId = dto.CurrUserId;
  8976. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8977. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8978. if (addId <= 0) return Ok(JsonView(false));
  8979. id = addId;
  8980. }
  8981. else //update
  8982. {
  8983. ////验证编辑权限
  8984. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8985. //if (!isEdit) return Ok(JsonView(false, msg));
  8986. var upd = await _sqlSugar.Updateable(info)
  8987. .UpdateColumns(x => new
  8988. {
  8989. x.SumJJC,
  8990. x.OutsideJJPay,
  8991. x.SumGWC,
  8992. x.OutsideGWPay,
  8993. x.SumTDC,
  8994. x.OutsideTDPay,
  8995. x.AirJJ,
  8996. x.AirGW,
  8997. x.AirTD,
  8998. x.CityTranffic,
  8999. x.TwoItemRemark
  9000. })
  9001. .Where(x => x.Id == id)
  9002. .ExecuteCommandAsync();
  9003. if (upd < 1) return Ok(JsonView(false));
  9004. }
  9005. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9006. gwcItemTotal = info.AirGW + info.CityTranffic;
  9007. tdcItemTotal = info.AirTD + info.CityTranffic;
  9008. //消息通知
  9009. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9010. return Ok(JsonView(new
  9011. {
  9012. parentId = id,
  9013. choiceTwoJJ = dto.ChoiceTwoJJ,
  9014. jjcItemTotal = jjcItemTotal,
  9015. choiceTwoGW = dto.ChoiceTwoGW,
  9016. gwcItemTotal = gwcItemTotal,
  9017. choiceTwoTD = dto.ChoiceTwoTD,
  9018. tdcItemTotal = tdcItemTotal
  9019. }));
  9020. }
  9021. /// <summary>
  9022. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9023. /// </summary>
  9024. /// <returns></returns>
  9025. [HttpPost]
  9026. [ApiExplorerSettings(IgnoreApi = true)]
  9027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9028. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9029. {
  9030. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9031. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9032. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9033. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9034. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9035. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9036. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9037. var infos = infos1.Select(x => new Grp_DayAndCost
  9038. {
  9039. Id = x.Id,
  9040. DiId = dto.DiId,
  9041. Type = dto.FeeType,
  9042. Days = x.Days,
  9043. NationalTravelFeeId = x.NationalTravelFeeId,
  9044. Cost = x.Cost,
  9045. Currency = x.Currency,
  9046. SubTotal = x.SubTotal,
  9047. CreateUserId = dto.CurrUserId
  9048. })
  9049. .ToList();
  9050. var adds = infos.Where(x => x.Id <= 0).ToList();
  9051. var upds = infos.Where(x => x.Id > 0).ToList();
  9052. if (adds.Count > 0)
  9053. {
  9054. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9055. if (add < 1) return Ok(JsonView(false));
  9056. }
  9057. if (upds.Count > 0)
  9058. {
  9059. var upd = await _sqlSugar.Updateable(adds)
  9060. .UpdateColumns(x => new
  9061. {
  9062. x.Days,
  9063. x.NationalTravelFeeId,
  9064. x.Cost,
  9065. x.Currency,
  9066. x.SubTotal
  9067. })
  9068. .WhereColumns(x => new { x.Id })
  9069. .ExecuteCommandAsync();
  9070. if (upd < 1) return Ok(JsonView(false));
  9071. }
  9072. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9073. //消息通知
  9074. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9075. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9076. return Ok(JsonView(new { itemTotal = itemTotal }));
  9077. }
  9078. /// <summary>
  9079. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9080. /// </summary>
  9081. /// <returns></returns>
  9082. [HttpPost]
  9083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9084. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9085. {
  9086. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9087. int subId = dto.SubId, feeType = dto.FeeType;
  9088. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9089. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9090. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9091. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9092. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9093. subInfo.Id = subId;
  9094. subInfo.DiId = dto.DiId;
  9095. if (feeType == 3) subInfo.Type = 1;
  9096. else if (feeType == 4) subInfo.Type = 2;
  9097. else if (feeType == 5) subInfo.Type = 3;
  9098. else if (feeType == 6) subInfo.Type = 4;
  9099. subInfo.CreateUserId = dto.CurrUserId;
  9100. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9101. if (parentId < 1) return Ok(JsonView(false));
  9102. //子表op
  9103. if (subId < 1)
  9104. {
  9105. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9106. if (subAdd < 1) return Ok(JsonView(false));
  9107. }
  9108. else
  9109. {
  9110. ////验证编辑权限
  9111. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9112. //if (!isEdit) return Ok(JsonView(false, msg));
  9113. var subUpd = await _sqlSugar.Updateable(subInfo)
  9114. .UpdateColumns(x => new
  9115. {
  9116. x.Days,
  9117. x.NationalTravelFeeId,
  9118. x.Cost,
  9119. x.Currency,
  9120. x.SubTotal
  9121. })
  9122. .WhereColumns(x => new { x.Id })
  9123. .ExecuteCommandAsync();
  9124. if (subUpd < 1) return Ok(JsonView(false));
  9125. }
  9126. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  9127. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  9128. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9129. }
  9130. /// <summary>
  9131. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  9132. /// </summary>
  9133. /// <returns></returns>
  9134. [HttpPost]
  9135. [ApiExplorerSettings(IgnoreApi = true)]
  9136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9137. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  9138. {
  9139. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9140. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9141. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9142. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  9143. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  9144. {
  9145. Id = x.Id,
  9146. Diid = dto.DiId,
  9147. SetDataId = x.SetDataId,
  9148. Index = x.Index,
  9149. Cost = x.Cost,
  9150. Currency = x.Currency,
  9151. SubTotal = x.SubTotal,
  9152. CreateUserId = dto.CurrUserId,
  9153. Remark = x.Remark
  9154. }).ToList();
  9155. var adds = infos.Where(x => x.Id <= 0).ToList();
  9156. var upds = infos.Where(x => x.Id > 0).ToList();
  9157. if (adds.Count > 0)
  9158. {
  9159. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9160. if (add < 1) return Ok(JsonView(false));
  9161. }
  9162. if (upds.Count > 0)
  9163. {
  9164. var upd = await _sqlSugar.Updateable(adds)
  9165. .UpdateColumns(x => new
  9166. {
  9167. x.Index,
  9168. x.SetDataId,
  9169. x.Cost,
  9170. x.Currency,
  9171. x.SubTotal,
  9172. x.Remark
  9173. })
  9174. .WhereColumns(x => new { x.Id })
  9175. .ExecuteCommandAsync();
  9176. if (upd < 1) return Ok(JsonView(false));
  9177. }
  9178. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  9179. //消息通知
  9180. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9181. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9182. return Ok(JsonView(new { itemTotal = itemTotal }));
  9183. }
  9184. /// <summary>
  9185. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  9186. /// </summary>
  9187. /// <returns></returns>
  9188. [HttpPost]
  9189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9190. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  9191. {
  9192. int subId = dto.SubId;
  9193. int diId = dto.Diid;
  9194. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9195. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9196. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9197. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  9198. subInfo.Id = subId;
  9199. subInfo.Diid = dto.Diid;
  9200. subInfo.CreateUserId = dto.CurrUserId;
  9201. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  9202. if (parentId < 1) return Ok(JsonView(false));
  9203. #region 子表op
  9204. if (subId < 1)//add
  9205. {
  9206. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9207. if (subAdd < 1) return Ok(JsonView(false));
  9208. }
  9209. else //upd
  9210. {
  9211. ////验证编辑权限
  9212. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9213. //if (!isEdit) return Ok(JsonView(false, msg));
  9214. var subUpd = await _sqlSugar.Updateable(subInfo)
  9215. .UpdateColumns(x => new
  9216. {
  9217. x.Index,
  9218. x.SetDataId,
  9219. x.Cost,
  9220. x.Currency,
  9221. x.SubTotal,
  9222. x.Remark
  9223. })
  9224. .WhereColumns(x => new { x.Id })
  9225. .ExecuteCommandAsync();
  9226. if (subUpd < 1) return Ok(JsonView(false));
  9227. }
  9228. #endregion
  9229. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9230. //消息通知
  9231. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9232. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9233. }
  9234. /// <summary>
  9235. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9236. /// </summary>
  9237. /// <returns></returns>
  9238. [HttpPost]
  9239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9240. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9241. {
  9242. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9243. if (data.Code != 0)
  9244. {
  9245. return Ok(JsonView(false, data.Msg));
  9246. }
  9247. return Ok(JsonView(true, "操作成功!", data.Data));
  9248. }
  9249. /// <summary>
  9250. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9251. /// </summary>
  9252. /// <param name="dto"></param>
  9253. /// <returns></returns>
  9254. [HttpPost]
  9255. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9256. {
  9257. var data = new Grp_DayOtherPrice()
  9258. {
  9259. Id = dto.Id,
  9260. IsDel = 1,
  9261. DeleteUserId = dto.DeleteUserId,
  9262. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9263. };
  9264. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9265. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9266. return Ok(JsonView(false, "删除失败!"));
  9267. }
  9268. #endregion
  9269. #endregion
  9270. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9271. /// <summary>
  9272. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9273. /// </summary>
  9274. /// <returns></returns>
  9275. [HttpGet]
  9276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9277. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  9278. {
  9279. var provData = await _groupRepository.ProvinceBasicSource();
  9280. return Ok(JsonView(true, "查询成功!", provData));
  9281. }
  9282. /// <summary>
  9283. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9284. /// </summary>
  9285. /// <returns></returns>
  9286. [HttpPost]
  9287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9288. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9289. {
  9290. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9291. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9292. RefAsync<int> total = 0;
  9293. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9294. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9295. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9296. .Select(x => new
  9297. {
  9298. Id = x.Id,
  9299. DraftName = x.DraftName,
  9300. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9301. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9302. .Any()
  9303. })
  9304. .OrderByDescending(x => x.Id)
  9305. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9306. return Ok(JsonView(true, "查询成功!", data, total));
  9307. }
  9308. /// <summary>
  9309. /// 出入境费用-草稿 移动端
  9310. /// 获取币种基础数据(含逻辑处理)
  9311. /// </summary>
  9312. /// <returns></returns>
  9313. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9314. {
  9315. return await GeneralMethod.EnterExitCostInitRate();
  9316. }
  9317. /// <summary>
  9318. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9319. /// </summary>
  9320. /// <returns></returns>
  9321. [HttpPost]
  9322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9323. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  9324. {
  9325. //验证城市归属并给默认值
  9326. int provinceId = dto.ProvinceId;
  9327. if (provinceId < 1) provinceId = 122;
  9328. var dataSource = await _sqlSugar
  9329. .Queryable<Sys_SetData>()
  9330. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9331. .ToListAsync();
  9332. //三公费用-Word明细类型
  9333. var wordTypeData = dataSource.Where(it => it.STid == 72)
  9334. .Select(x => new SetDataInfoView
  9335. {
  9336. Id = x.Id,
  9337. Name = x.Name,
  9338. Remark = x.Remark
  9339. })
  9340. .ToList();
  9341. //三公费用-Excel明细类型
  9342. var excelTypeData = dataSource.Where(it => it.STid == 73)
  9343. .Select(x => new SetDataInfoView
  9344. {
  9345. Id = x.Id,
  9346. Name = x.Name,
  9347. Remark = x.Remark
  9348. })
  9349. .ToList();
  9350. //默认币种显示
  9351. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9352. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9353. return Ok(JsonView(true, "查询成功!", new
  9354. {
  9355. WordTypeData = wordTypeData,
  9356. ExcelTypeData = excelTypeData,
  9357. CurrencyInit = _currencyInfos,
  9358. viewPermissionData = viewPermissionData
  9359. }));
  9360. }
  9361. /// <summary>
  9362. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9363. /// </summary>
  9364. /// <returns></returns>
  9365. [HttpPost]
  9366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9367. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9368. {
  9369. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9370. RefAsync<int> total = 0;
  9371. int diId = 0;
  9372. var status = int.TryParse(dto.GroupName, out diId);
  9373. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9374. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9375. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9376. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9377. .OrderByDescending(x => x.VisitStartDate)
  9378. .Select(x => new
  9379. {
  9380. Id = x.Id,
  9381. GroupName = x.TeamName
  9382. })
  9383. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9384. return Ok(JsonView(true, "查询成功!", data, total));
  9385. }
  9386. /// <summary>
  9387. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9388. /// </summary>
  9389. /// <returns></returns>
  9390. [HttpPost]
  9391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9392. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9393. {
  9394. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9395. RefAsync<int> total = 0;
  9396. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9397. .Where(x => x.IsDel == 0 && x.STid == 66)
  9398. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9399. .Select(x => new
  9400. {
  9401. id = x.Id,
  9402. name = x.Name,
  9403. remark = x.Remark,
  9404. })
  9405. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9406. return Ok(JsonView(true, "查询成功!", data, total));
  9407. }
  9408. /// <summary>
  9409. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9410. /// </summary>
  9411. /// <returns></returns>
  9412. [HttpPost]
  9413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9414. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9415. {
  9416. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9417. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9418. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  9419. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9420. var groupOtherRateData = groupRateData.TeamRates;
  9421. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9422. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9423. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9424. groupOtherRateData = groupOtherRateData
  9425. .Select(x => new TeamRateDescAddCurrencyIdView
  9426. {
  9427. CurrencyId = x.CurrencyId,
  9428. CurrencyName = x.CurrencyName,
  9429. CurrencyCode = x.CurrencyCode,
  9430. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9431. }).ToList();
  9432. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9433. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9434. }
  9435. /// <summary>
  9436. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9437. /// </summary>
  9438. /// <returns></returns>
  9439. [HttpPost]
  9440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9441. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9442. {
  9443. int portType = dto.PortType;
  9444. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9445. var tipsData = new List<int>() { 1, 2, 3 };
  9446. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9447. if (dto.TipsType == 1)
  9448. {
  9449. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9450. }
  9451. else if (dto.TipsType == 2)
  9452. {
  9453. if (portType == 2)
  9454. {
  9455. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9456. }
  9457. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9458. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9459. .Select(x => x.NationalTravelFeeId)
  9460. .Distinct()
  9461. .ToListAsync();
  9462. if (portType == 2)
  9463. {
  9464. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9465. }
  9466. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9467. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9468. .Select(x => x.Country)
  9469. .Distinct()
  9470. .ToArrayAsync();
  9471. if (portType == 2)
  9472. {
  9473. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9474. }
  9475. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9476. return Ok(JsonView(true, "查询成功!", new
  9477. {
  9478. totalAmt = totalAmt,
  9479. remark = remark
  9480. }));
  9481. }
  9482. else if (dto.TipsType == 3)
  9483. {
  9484. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9485. }
  9486. return Ok(JsonView(false));
  9487. }
  9488. /// <summary>
  9489. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9490. /// </summary>
  9491. /// <returns></returns>
  9492. [HttpPost]
  9493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9494. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9495. {
  9496. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9497. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9498. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9499. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9500. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9501. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9502. var info = new Grp_EnterExitCostDraft()
  9503. {
  9504. ProvinceId = dto.ProvinceId,
  9505. DraftName = dto.DraftName,
  9506. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9507. CreateUserId = dto.CurrUserId
  9508. };
  9509. _sqlSugar.BeginTran();
  9510. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9511. if (draftId < 1)
  9512. {
  9513. _sqlSugar.RollbackTran();
  9514. return Ok(JsonView(false, "草稿创建失败!"));
  9515. }
  9516. //添加默认权限
  9517. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  9518. _sqlSugar.CommitTran();
  9519. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9520. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9521. mobileInfo.Id = draftId;
  9522. mobileInfo.DraftName = dto.DraftName;
  9523. mobileInfo.Currencys = rateInfos;
  9524. mobileInfo.IsAssignPerm = assignPerm;
  9525. return Ok(JsonView(mobileInfo));
  9526. }
  9527. /// <summary>
  9528. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9529. /// </summary>
  9530. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9531. /// <summary>
  9532. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9533. /// </summary>
  9534. /// <returns></returns>
  9535. [HttpPost]
  9536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9537. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9538. {
  9539. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9540. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9541. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9542. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9543. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9544. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9545. //验证查看编辑权限
  9546. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9547. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9548. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9549. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  9550. mobileInfo.IsAssignPerm = assignPerm;
  9551. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9552. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9553. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9554. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9555. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9556. {
  9557. ParentId = dac.ParentId,
  9558. SubId = dac.Id,
  9559. Type = dac.Type,
  9560. Days = dac.Days,
  9561. NationalTravelFeeId = dac.NationalTravelFeeId,
  9562. Arae = $"{ntf.Country}-{ntf.City}",
  9563. Cost = dac.Cost,
  9564. Currency = dac.Currency,
  9565. CurrencyName = sd.Name,
  9566. SubTotal = dac.SubTotal,
  9567. })
  9568. .ToList();
  9569. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9570. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9571. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9572. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9573. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9574. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9575. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9576. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9577. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9578. //其他款项
  9579. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9580. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9581. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9582. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9583. .OrderBy((dop, sd1, sd2) => dop.Index)
  9584. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9585. {
  9586. ParentId = dop.ParentId,
  9587. SubId = dop.Id,
  9588. Index = dop.Index,
  9589. SetDataId = dop.SetDataId,
  9590. SetDataName = sd1.Name,
  9591. Cost = dop.Cost,
  9592. Currency = dop.Currency,
  9593. CurrencyName = sd2.Remark,
  9594. SubTotal = dop.SubTotal,
  9595. Remark = dop.Remark,
  9596. })
  9597. .ToArray();
  9598. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9599. return Ok(mobileInfo);
  9600. }
  9601. /// <summary>
  9602. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9603. /// </summary>
  9604. /// <returns></returns>
  9605. [HttpPost]
  9606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9607. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9608. {
  9609. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9610. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9611. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9612. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9613. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9614. //验证查看编辑权限
  9615. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9616. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9617. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9618. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9619. var subType = dto.SubType;
  9620. if (subType == 1) //1:境内费用
  9621. {
  9622. var oneData = new ChoiceOneMobileSubInfoView()
  9623. {
  9624. Id = eecInfo.Id,
  9625. ChoiceOne = eecInfo.ChoiceOne,
  9626. ChoiceOneTotalCost = eecInfo.InsidePay,
  9627. Visa = eecInfo.Visa,
  9628. VisaRemark = eecInfo.VisaRemark,
  9629. YiMiao = eecInfo.YiMiao,
  9630. HeSuan = eecInfo.HeSuan,
  9631. Service = eecInfo.Service,
  9632. Ticket = eecInfo.Ticket,
  9633. Safe = eecInfo.Safe,
  9634. FirstItemRemark = eecInfo.FirstItemRemark
  9635. };
  9636. return Ok(JsonView(oneData));
  9637. }
  9638. else if (subType == 2) //2:国际旅费
  9639. {
  9640. var twoData = new ChoiceTwoMobileSubInfoView()
  9641. {
  9642. Id = eecInfo.Id,
  9643. ChoiceTwoJJ = eecInfo.SumJJC,
  9644. OutsideJJPay = eecInfo.OutsideJJPay,
  9645. ChoiceTwoGW = eecInfo.SumGWC,
  9646. OutsideGWPay = eecInfo.OutsideGWPay,
  9647. ChoiceTwoTD = eecInfo.SumTDC,
  9648. OutsideTDPay = eecInfo.OutsideTDPay,
  9649. AirJJ = eecInfo.AirJJ,
  9650. AirGW = eecInfo.AirGW,
  9651. AirTD = eecInfo.AirTD,
  9652. CityTranffic = eecInfo.CityTranffic,
  9653. TwoItemRemark = eecInfo.TwoItemRemark
  9654. };
  9655. return Ok(JsonView(twoData));
  9656. }
  9657. else if (subType == 3) //3:住宿费
  9658. {
  9659. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9660. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9661. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9662. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9663. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9664. {
  9665. ParentId = dac.ParentId,
  9666. SubId = dac.Id,
  9667. Type = dac.Type,
  9668. Days = dac.Days,
  9669. NationalTravelFeeId = dac.NationalTravelFeeId,
  9670. Arae = $"{ntf.Country}-{ntf.City}",
  9671. Cost = dac.Cost,
  9672. Currency = dac.Currency,
  9673. CurrencyName = sd.Name,
  9674. SubTotal = dac.SubTotal,
  9675. })
  9676. .ToArray();
  9677. var data = new ChoiceDraftMobileSubInfo3To6View()
  9678. {
  9679. ParentId = eecInfo.Id,
  9680. Choice = eecInfo.ChoiceThree,
  9681. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9682. Details = dayAndCostDatas
  9683. };
  9684. return Ok(JsonView(data));
  9685. }
  9686. else if (subType == 4) //4:伙食费
  9687. {
  9688. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9689. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9690. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9691. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9692. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9693. {
  9694. ParentId = dac.ParentId,
  9695. SubId = dac.Id,
  9696. Type = dac.Type,
  9697. Days = dac.Days,
  9698. NationalTravelFeeId = dac.NationalTravelFeeId,
  9699. Arae = $"{ntf.Country}-{ntf.City}",
  9700. Cost = dac.Cost,
  9701. Currency = dac.Currency,
  9702. CurrencyName = sd.Name,
  9703. SubTotal = dac.SubTotal,
  9704. })
  9705. .ToArray();
  9706. var data = new ChoiceDraftMobileSubInfo3To6View()
  9707. {
  9708. ParentId = eecInfo.Id,
  9709. Choice = eecInfo.ChoiceFour,
  9710. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9711. Details = dayAndCostDatas
  9712. };
  9713. return Ok(JsonView(data));
  9714. }
  9715. else if (subType == 5) //5:公杂费
  9716. {
  9717. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9718. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9719. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9720. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9721. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9722. {
  9723. ParentId = dac.ParentId,
  9724. SubId = dac.Id,
  9725. Type = dac.Type,
  9726. Days = dac.Days,
  9727. NationalTravelFeeId = dac.NationalTravelFeeId,
  9728. Arae = $"{ntf.Country}-{ntf.City}",
  9729. Cost = dac.Cost,
  9730. Currency = dac.Currency,
  9731. CurrencyName = sd.Name,
  9732. SubTotal = dac.SubTotal,
  9733. })
  9734. .ToArray();
  9735. var data = new ChoiceDraftMobileSubInfo3To6View()
  9736. {
  9737. ParentId = eecInfo.Id,
  9738. Choice = eecInfo.ChoiceFive,
  9739. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9740. Details = dayAndCostDatas
  9741. };
  9742. return Ok(JsonView(data));
  9743. }
  9744. else if (subType == 6) //6:培训费
  9745. {
  9746. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9747. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9748. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9749. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9750. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9751. {
  9752. ParentId = dac.ParentId,
  9753. SubId = dac.Id,
  9754. Type = dac.Type,
  9755. Days = dac.Days,
  9756. NationalTravelFeeId = dac.NationalTravelFeeId,
  9757. Arae = $"{ntf.Country}-{ntf.City}",
  9758. Cost = dac.Cost,
  9759. Currency = dac.Currency,
  9760. CurrencyName = sd.Name,
  9761. SubTotal = dac.SubTotal,
  9762. })
  9763. .ToArray();
  9764. var data = new ChoiceDraftMobileSubInfo3To6View()
  9765. {
  9766. ParentId = eecInfo.Id,
  9767. Choice = eecInfo.ChoiceSix,
  9768. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9769. Details = dayAndCostDatas
  9770. };
  9771. return Ok(JsonView(data));
  9772. }
  9773. else if (subType == 7) //7:其他
  9774. {
  9775. //其他款项
  9776. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9777. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9778. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9779. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9780. .OrderBy((dop, sd1, sd2) => dop.Index)
  9781. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9782. {
  9783. ParentId = dop.ParentId,
  9784. SubId = dop.Id,
  9785. Index = dop.Index,
  9786. SetDataId = dop.SetDataId,
  9787. SetDataName = sd1.Name,
  9788. Cost = dop.Cost,
  9789. Currency = dop.Currency,
  9790. CurrencyName = sd2.Name,
  9791. SubTotal = dop.SubTotal,
  9792. Remark = dop.Remark,
  9793. })
  9794. .ToArray();
  9795. var data = new ChoiceSevenDraftMobileSubInfoView()
  9796. {
  9797. ParentId = eecInfo.Id,
  9798. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9799. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9800. Details = otherData
  9801. };
  9802. return Ok(JsonView(data));
  9803. }
  9804. return Ok(JsonView(false));
  9805. }
  9806. #region op
  9807. /// <summary>
  9808. /// 移动端更新费用消息通知
  9809. /// </summary>
  9810. /// <param name="draftId"></param>
  9811. /// <param name="id"></param>
  9812. /// <param name="currUserId"></param>
  9813. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9814. {
  9815. try
  9816. {
  9817. ////生成默认文件pdf并且通知人员
  9818. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9819. //{
  9820. // DiId = draftId,
  9821. // ExportType = 1,
  9822. // SubTypeId = 1005
  9823. //}, "pdf");
  9824. ////发送通知
  9825. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9826. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9827. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9828. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9829. ////汇率信息记录
  9830. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9831. }
  9832. catch (Exception ex)
  9833. {
  9834. //记录日志
  9835. throw;
  9836. }
  9837. }
  9838. /// <summary>
  9839. /// 验证出入境费用数据是否存在
  9840. /// 不存在添加
  9841. /// </summary>
  9842. /// <param name="draftId"></param>
  9843. /// <param name="currUserId"></param>
  9844. /// <returns></returns>
  9845. /// <exception cref="CustomException"></exception>
  9846. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9847. {
  9848. var parentId = 0;
  9849. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9850. if (info != null) parentId = info.Id;
  9851. else
  9852. {
  9853. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9854. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9855. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9856. parentId = addId;
  9857. }
  9858. return parentId;
  9859. }
  9860. /// <summary>
  9861. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  9862. /// </summary>
  9863. /// <returns></returns>
  9864. [HttpPost]
  9865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9866. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  9867. {
  9868. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9869. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9870. //验证查看权限
  9871. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9872. if (!isView) return Ok(JsonView(false, _viewPermStr));
  9873. var userIds = await _sqlSugar
  9874. .Queryable<Grp_EnterExitCostDraftPermission>()
  9875. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  9876. .Select(x => x.UserId)
  9877. .ToArrayAsync();
  9878. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9879. var perUsersView = new List<dynamic>();
  9880. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  9881. var viewPermissionData = new List<PermissionViewUserview>();
  9882. if (feeBasePerm.Any())
  9883. {
  9884. foreach (var item in feeBasePerm)
  9885. {
  9886. if (item.Users.Any())
  9887. {
  9888. viewPermissionData.AddRange(item.Users);
  9889. }
  9890. }
  9891. }
  9892. foreach (var item in perUsers)
  9893. {
  9894. bool isView1 = false;
  9895. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9896. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  9897. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9898. }
  9899. return Ok(JsonView(perUsersView));
  9900. }
  9901. /// <summary>
  9902. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9903. /// </summary>
  9904. /// <returns></returns>
  9905. [HttpPost]
  9906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9907. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9908. {
  9909. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9910. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9911. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9912. //验证查看编辑权限
  9913. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9914. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9915. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  9916. foreach (var userId in dto.UserIds)
  9917. {
  9918. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9919. }
  9920. if (permissions.Any())
  9921. {
  9922. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9923. {
  9924. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9925. }
  9926. _sqlSugar.BeginTran();
  9927. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9928. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9929. if (result < 1)
  9930. {
  9931. _sqlSugar.RollbackTran();
  9932. return Ok(JsonView(false));
  9933. }
  9934. _sqlSugar.CommitTran();
  9935. return Ok(JsonView(true));
  9936. }
  9937. return Ok(JsonView(false));
  9938. }
  9939. /// <summary>
  9940. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  9941. /// </summary>
  9942. /// <returns></returns>
  9943. [HttpPost]
  9944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9945. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  9946. {
  9947. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9948. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9949. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9950. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  9951. int id = dto.DraftId;
  9952. if (id <= 0) //add
  9953. {
  9954. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9955. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9956. if (add < 1) return Ok(JsonView(false));
  9957. id = add;
  9958. }
  9959. else //update
  9960. {
  9961. //验证查看编辑权限
  9962. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9963. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9964. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9965. if (upd < 1) return Ok(JsonView(false));
  9966. }
  9967. return Ok(JsonView(new { parentId = id }));
  9968. }
  9969. /// <summary>
  9970. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9971. /// </summary>
  9972. /// <returns></returns>
  9973. [HttpPost]
  9974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9975. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9976. {
  9977. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9978. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9979. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9980. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9981. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9982. int id = dto.DraftId;
  9983. if (id <= 0) //add
  9984. {
  9985. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9986. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9987. if (add < 1) return Ok(JsonView(false));
  9988. id = add;
  9989. }
  9990. else //update
  9991. {
  9992. //验证查看编辑权限
  9993. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9994. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9995. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9996. if (upd < 1) return Ok(JsonView(false));
  9997. }
  9998. #region 汇率变更时更改币种相关费用
  9999. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10000. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10001. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10002. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10003. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10004. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10005. .Select((dac, sd) => new
  10006. {
  10007. dac.Id,
  10008. dac.ParentId,
  10009. CurrencyCode = sd.Name,
  10010. dac.Cost
  10011. })
  10012. .ToList();
  10013. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10014. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10015. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10016. .Select((dop, sd) => new
  10017. {
  10018. dop.Id,
  10019. dop.ParentId,
  10020. CurrencyCode = sd.Name,
  10021. dop.Cost
  10022. })
  10023. .ToList();
  10024. if (dayCosts.Count > 0)
  10025. {
  10026. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10027. foreach (var dc in new_dayCosts)
  10028. {
  10029. var thisCurrency = dc.Key.ToUpper();
  10030. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10031. if (thisRate == 0.00M) continue;
  10032. foreach (var dcSub in dc)
  10033. {
  10034. opDayCosts.Add(new Grp_DayAndCostDraft()
  10035. {
  10036. Id = dcSub.Id,
  10037. ParentId = dcSub.ParentId,
  10038. Cost = dcSub.Cost,
  10039. SubTotal = dcSub.Cost * thisRate,
  10040. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10041. });
  10042. }
  10043. }
  10044. if (opDayCosts.Count > 0)
  10045. {
  10046. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10047. }
  10048. }
  10049. if (dayOtherCosts.Count > 0)
  10050. {
  10051. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10052. foreach (var dc in new_dayOtherCosts)
  10053. {
  10054. var thisCurrency = dc.Key.ToUpper();
  10055. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10056. if (thisRate == 0.00M) continue;
  10057. foreach (var dcSub in dc)
  10058. {
  10059. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10060. {
  10061. Id = dcSub.Id,
  10062. ParentId = dcSub.ParentId,
  10063. Cost = dcSub.Cost,
  10064. SubTotal = dcSub.Cost * thisRate,
  10065. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10066. });
  10067. }
  10068. }
  10069. if (opDayOtherCosts.Count > 0)
  10070. {
  10071. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10072. }
  10073. }
  10074. #endregion
  10075. ////消息通知
  10076. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10077. ////汇率信息记录
  10078. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10079. return Ok(JsonView(new { parentId = id }));
  10080. }
  10081. /// <summary>
  10082. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  10083. /// </summary>
  10084. /// <returns></returns>
  10085. [HttpPost]
  10086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10087. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  10088. {
  10089. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10090. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10091. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10092. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10093. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10094. int id = dto.DraftId;
  10095. if (id <= 0) //add
  10096. {
  10097. checkboxInfo.ProvinceId = dto.ProvinceId;
  10098. checkboxInfo.CreateUserId = dto.CurrUserId;
  10099. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  10100. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10101. if (add < 1) return Ok(JsonView(false));
  10102. }
  10103. else //update
  10104. {
  10105. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10106. .UpdateColumns(x => new
  10107. {
  10108. x.ChoiceOne,
  10109. x.ChoiceTwo,
  10110. x.SumJJC,
  10111. x.SumGWC,
  10112. x.SumTDC,
  10113. x.ChoiceThree,
  10114. x.ChoiceFour,
  10115. x.ChoiceFive,
  10116. x.ChoiceSix,
  10117. x.OtherExpenses_Checked
  10118. })
  10119. .Where(x => x.Id == id)
  10120. .ExecuteCommandAsync();
  10121. if (upd < 1) return Ok(JsonView(false));
  10122. }
  10123. return Ok(JsonView(new { parentId = id }));
  10124. }
  10125. /// <summary>
  10126. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  10127. /// </summary>
  10128. /// <returns></returns>
  10129. [HttpPost]
  10130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10131. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  10132. {
  10133. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  10134. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10135. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10136. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10137. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10138. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10139. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10140. var checkboxInfo = new Grp_EnterExitCostDraft()
  10141. {
  10142. Id = draftId,
  10143. ProvinceId = dto.ProvinceId,
  10144. CreateUserId = currUserId
  10145. };
  10146. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10147. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10148. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10149. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10150. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10151. if (draftId <= 0) //add
  10152. {
  10153. checkboxInfo.CreateUserId = dto.CurrUserId;
  10154. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10155. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10156. if (add < 1) return Ok(JsonView(false));
  10157. }
  10158. else //update
  10159. {
  10160. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  10161. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10162. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10163. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10164. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10165. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10166. .Where(x => x.Id == draftId)
  10167. .ExecuteCommandAsync();
  10168. if (upd < 1) return Ok(JsonView(false));
  10169. }
  10170. return Ok(JsonView(new { parentId = draftId }));
  10171. }
  10172. /// <summary>
  10173. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  10174. /// </summary>
  10175. /// <returns></returns>
  10176. [HttpPost]
  10177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10178. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  10179. {
  10180. int id = dto.DraftId, currUserId = dto.CurrUserId;
  10181. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10182. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  10183. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10184. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10185. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10186. info.ProvinceId = dto.ProvinceId;
  10187. info.FirstItemRemark = dto.FirstItemRemark;
  10188. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10189. if (id <= 0) //add
  10190. {
  10191. info.CreateUserId = dto.CurrUserId;
  10192. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10193. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10194. if (add < 1) return Ok(JsonView(false));
  10195. id = add;
  10196. }
  10197. else //update
  10198. {
  10199. var upd = await _sqlSugar.Updateable(info)
  10200. .UpdateColumns(x => new
  10201. {
  10202. x.ChoiceOne,
  10203. x.InsidePay,
  10204. x.VisaRemark,
  10205. x.Visa,
  10206. x.Service,
  10207. x.Safe,
  10208. x.Ticket,
  10209. x.HeSuan,
  10210. x.YiMiao,
  10211. x.FirstItemRemark
  10212. })
  10213. .Where(x => x.Id == id)
  10214. .ExecuteCommandAsync();
  10215. if (upd < 1) return Ok(JsonView(false));
  10216. }
  10217. ////消息通知
  10218. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10219. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10220. }
  10221. /// <summary>
  10222. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  10223. /// </summary>
  10224. /// <returns></returns>
  10225. [HttpPost]
  10226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10227. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  10228. {
  10229. int id = dto.DraftId;
  10230. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10231. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  10232. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10233. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10234. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10235. info.ProvinceId = dto.ProvinceId;
  10236. info.OutsideJJPay = dto.OutsideJJPay;
  10237. info.OutsideGWPay = dto.OutsideGWPay;
  10238. info.OutsideTDPay = dto.OutsideTDPay;
  10239. info.AirJJ = dto.AirJJ;
  10240. info.AirGW = dto.AirGW;
  10241. info.AirTD = dto.AirTD;
  10242. info.CityTranffic = dto.CityTranffic;
  10243. info.TwoItemRemark = dto.TwoItemRemark;
  10244. info.SumJJC = dto.ChoiceTwoJJ;
  10245. info.SumGWC = dto.ChoiceTwoGW;
  10246. info.SumTDC = dto.ChoiceTwoTD;
  10247. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10248. if (id <= 0) //add
  10249. {
  10250. info.CreateUserId = dto.CurrUserId;
  10251. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10252. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10253. if (addId <= 0) return Ok(JsonView(false));
  10254. id = addId;
  10255. }
  10256. else //update
  10257. {
  10258. var upd = await _sqlSugar.Updateable(info)
  10259. .UpdateColumns(x => new
  10260. {
  10261. x.SumJJC,
  10262. x.OutsideJJPay,
  10263. x.SumGWC,
  10264. x.OutsideGWPay,
  10265. x.SumTDC,
  10266. x.OutsideTDPay,
  10267. x.AirJJ,
  10268. x.AirGW,
  10269. x.AirTD,
  10270. x.CityTranffic,
  10271. x.TwoItemRemark
  10272. })
  10273. .Where(x => x.Id == id)
  10274. .ExecuteCommandAsync();
  10275. if (upd < 1) return Ok(JsonView(false));
  10276. }
  10277. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10278. gwcItemTotal = info.AirGW + info.CityTranffic;
  10279. tdcItemTotal = info.AirTD + info.CityTranffic;
  10280. ////消息通知
  10281. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10282. return Ok(JsonView(new
  10283. {
  10284. parentId = id,
  10285. choiceTwoJJ = dto.ChoiceTwoJJ,
  10286. jjcItemTotal = jjcItemTotal,
  10287. choiceTwoGW = dto.ChoiceTwoGW,
  10288. gwcItemTotal = gwcItemTotal,
  10289. choiceTwoTD = dto.ChoiceTwoTD,
  10290. tdcItemTotal = tdcItemTotal
  10291. }));
  10292. }
  10293. /// <summary>
  10294. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10295. /// </summary>
  10296. /// <returns></returns>
  10297. [HttpPost]
  10298. [ApiExplorerSettings(IgnoreApi = true)]
  10299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10300. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10301. {
  10302. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10303. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10304. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10305. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10306. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10307. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10308. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10309. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10310. {
  10311. Id = x.Id,
  10312. ParentId = dto.DraftId,
  10313. Type = dto.FeeType,
  10314. Days = x.Days,
  10315. NationalTravelFeeId = x.NationalTravelFeeId,
  10316. Cost = x.Cost,
  10317. Currency = x.Currency,
  10318. SubTotal = x.SubTotal,
  10319. CreateUserId = dto.CurrUserId
  10320. })
  10321. .ToList();
  10322. var adds = infos.Where(x => x.Id <= 0).ToList();
  10323. var upds = infos.Where(x => x.Id > 0).ToList();
  10324. if (adds.Count > 0)
  10325. {
  10326. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10327. if (add < 1) return Ok(JsonView(false));
  10328. }
  10329. if (upds.Count > 0)
  10330. {
  10331. var upd = await _sqlSugar.Updateable(adds)
  10332. .UpdateColumns(x => new
  10333. {
  10334. x.Days,
  10335. x.NationalTravelFeeId,
  10336. x.Cost,
  10337. x.Currency,
  10338. x.SubTotal
  10339. })
  10340. .WhereColumns(x => new { x.Id })
  10341. .ExecuteCommandAsync();
  10342. if (upd < 1) return Ok(JsonView(false));
  10343. }
  10344. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10345. ////消息通知
  10346. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10347. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10348. return Ok(JsonView(new { itemTotal = itemTotal }));
  10349. }
  10350. /// <summary>
  10351. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10352. /// </summary>
  10353. /// <returns></returns>
  10354. [HttpPost]
  10355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10356. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10357. {
  10358. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10359. int subId = dto.SubId, feeType = dto.FeeType;
  10360. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10361. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10362. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10363. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10364. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10365. subInfo.Id = subId;
  10366. subInfo.ParentId = dto.DraftId;
  10367. if (feeType == 3) subInfo.Type = 1;
  10368. else if (feeType == 4) subInfo.Type = 2;
  10369. else if (feeType == 5) subInfo.Type = 3;
  10370. else if (feeType == 6) subInfo.Type = 4;
  10371. subInfo.CreateUserId = dto.CurrUserId;
  10372. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10373. if (parentId < 1) return Ok(JsonView(false));
  10374. //子表op
  10375. if (subId < 1)
  10376. {
  10377. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10378. if (subAdd < 1) return Ok(JsonView(false));
  10379. }
  10380. else
  10381. {
  10382. var subUpd = await _sqlSugar.Updateable(subInfo)
  10383. .UpdateColumns(x => new
  10384. {
  10385. x.Days,
  10386. x.NationalTravelFeeId,
  10387. x.Cost,
  10388. x.Currency,
  10389. x.SubTotal
  10390. })
  10391. .WhereColumns(x => new { x.Id })
  10392. .ExecuteCommandAsync();
  10393. if (subUpd < 1) return Ok(JsonView(false));
  10394. }
  10395. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10396. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10397. }
  10398. /// <summary>
  10399. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10400. /// </summary>
  10401. /// <returns></returns>
  10402. [HttpPost]
  10403. [ApiExplorerSettings(IgnoreApi = true)]
  10404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10405. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10406. {
  10407. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10408. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10409. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10410. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10411. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10412. {
  10413. Id = x.Id,
  10414. ParentId = dto.DraftId,
  10415. SetDataId = x.SetDataId,
  10416. Index = x.Index,
  10417. Cost = x.Cost,
  10418. Currency = x.Currency,
  10419. SubTotal = x.SubTotal,
  10420. CreateUserId = dto.CurrUserId,
  10421. Remark = x.Remark
  10422. }).ToList();
  10423. var adds = infos.Where(x => x.Id <= 0).ToList();
  10424. var upds = infos.Where(x => x.Id > 0).ToList();
  10425. if (adds.Count > 0)
  10426. {
  10427. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10428. if (add < 1) return Ok(JsonView(false));
  10429. }
  10430. if (upds.Count > 0)
  10431. {
  10432. var upd = await _sqlSugar.Updateable(adds)
  10433. .UpdateColumns(x => new
  10434. {
  10435. x.Index,
  10436. x.SetDataId,
  10437. x.Cost,
  10438. x.Currency,
  10439. x.SubTotal,
  10440. x.Remark
  10441. })
  10442. .WhereColumns(x => new { x.Id })
  10443. .ExecuteCommandAsync();
  10444. if (upd < 1) return Ok(JsonView(false));
  10445. }
  10446. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10447. //消息通知
  10448. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10449. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10450. return Ok(JsonView(new { itemTotal = itemTotal }));
  10451. }
  10452. /// <summary>
  10453. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10454. /// </summary>
  10455. /// <returns></returns>
  10456. [HttpPost]
  10457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10458. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10459. {
  10460. int subId = dto.SubId, id = dto.DraftId;
  10461. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10462. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10463. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10464. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10465. subInfo.Id = subId;
  10466. subInfo.ParentId = id;
  10467. subInfo.CreateUserId = dto.CurrUserId;
  10468. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10469. if (parentId < 1) return Ok(JsonView(false));
  10470. #region 子表op
  10471. if (subId < 1)//add
  10472. {
  10473. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10474. if (subAdd < 1) return Ok(JsonView(false));
  10475. }
  10476. else //upd
  10477. {
  10478. var subUpd = await _sqlSugar.Updateable(subInfo)
  10479. .UpdateColumns(x => new
  10480. {
  10481. x.Index,
  10482. x.SetDataId,
  10483. x.Cost,
  10484. x.Currency,
  10485. x.SubTotal,
  10486. x.Remark
  10487. })
  10488. .WhereColumns(x => new { x.Id })
  10489. .ExecuteCommandAsync();
  10490. if (subUpd < 1) return Ok(JsonView(false));
  10491. }
  10492. #endregion
  10493. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10494. ////消息通知
  10495. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10496. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10497. }
  10498. /// <summary>
  10499. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10500. /// </summary>
  10501. /// <returns></returns>
  10502. [HttpPost]
  10503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10504. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10505. {
  10506. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10507. if (data.Code != 0)
  10508. {
  10509. return Ok(JsonView(false, data.Msg));
  10510. }
  10511. return Ok(JsonView(true, "操作成功!", data.Data));
  10512. }
  10513. /// <summary>
  10514. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10515. /// </summary>
  10516. /// <param name="dto"></param>
  10517. /// <returns></returns>
  10518. [HttpPost]
  10519. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10520. {
  10521. var data = new Grp_DayOtherPriceDraft()
  10522. {
  10523. Id = dto.Id,
  10524. IsDel = 1,
  10525. DeleteUserId = dto.DeleteUserId,
  10526. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10527. };
  10528. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10529. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10530. return Ok(JsonView(false, "删除失败!"));
  10531. }
  10532. #endregion
  10533. #endregion
  10534. #region 团组经理模块 出入境费用报价表
  10535. /// <summary>
  10536. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10537. /// </summary>
  10538. /// <returns></returns>
  10539. [HttpPost]
  10540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10541. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10542. {
  10543. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10544. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10545. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10546. initRates.Insert(0, cnyInfo);
  10547. liveRates.Insert(0, cnyInfo);
  10548. return Ok(JsonView(true, "查询成功!", new
  10549. {
  10550. InitRates = initRates,
  10551. LiveRates = liveRates
  10552. }));
  10553. }
  10554. /// <summary>
  10555. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10556. /// </summary>
  10557. /// <returns></returns>
  10558. [HttpPost]
  10559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10560. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10561. {
  10562. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10563. }
  10564. /// <summary>
  10565. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10566. /// </summary>
  10567. /// <returns></returns>
  10568. [HttpPost]
  10569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10570. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10571. {
  10572. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10573. }
  10574. /// <summary>
  10575. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10576. /// </summary>
  10577. /// <returns></returns>
  10578. [HttpPost]
  10579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10580. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10581. {
  10582. int groupId = dto.DiId,
  10583. currUserId = dto.CurrUserId;
  10584. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  10585. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10586. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10587. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10588. var infoView = info.Data as EnterExitCostInfoView;
  10589. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10590. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10591. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10592. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10593. var eecRates = infoView.Currencys;
  10594. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10595. int pplNum = 1;
  10596. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10597. var views = new List<QuoteSubItemInfo>();
  10598. #region 数据填充
  10599. var intTravelCosts = new List<QuoteSubItemInfo>();
  10600. #region 机票费用 1354
  10601. int intTravelIndex = 1;
  10602. if (infoView.SumJJC == 1)
  10603. {
  10604. intTravelCosts.Add(new QuoteSubItemInfo
  10605. {
  10606. ItemId = 1354,
  10607. Index = intTravelIndex,
  10608. FeeName = "经济舱",
  10609. UnitPrice = infoView.AirJJ,
  10610. Currency = "CNY",
  10611. Quantity = 1,
  10612. PplNum = 1,
  10613. TotalAmt = infoView.AirJJ,
  10614. Remark = "",
  10615. });
  10616. intTravelIndex++;
  10617. }
  10618. if (infoView.SumGWC == 1)
  10619. {
  10620. intTravelCosts.Add(new QuoteSubItemInfo
  10621. {
  10622. ItemId = 1354,
  10623. Index = intTravelIndex,
  10624. FeeName = "公务舱",
  10625. UnitPrice = infoView.AirGW,
  10626. Currency = "CNY",
  10627. Quantity = 1,
  10628. PplNum = 1,
  10629. TotalAmt = infoView.AirGW,
  10630. Remark = "",
  10631. });
  10632. intTravelIndex++;
  10633. }
  10634. if (infoView.SumTDC == 1)
  10635. {
  10636. intTravelCosts.Add(new QuoteSubItemInfo
  10637. {
  10638. ItemId = 1354,
  10639. Index = intTravelIndex,
  10640. FeeName = "头等舱",
  10641. UnitPrice = infoView.AirTD,
  10642. Currency = "CNY",
  10643. Quantity = 1,
  10644. PplNum = 1,
  10645. TotalAmt = infoView.AirTD,
  10646. Remark = "",
  10647. });
  10648. intTravelIndex++;
  10649. }
  10650. intTravelCosts.Add(new QuoteSubItemInfo
  10651. {
  10652. ItemId = 1354,
  10653. Index = intTravelIndex,
  10654. FeeName = "城市间交通费用",
  10655. UnitPrice = infoView.CityTranffic,
  10656. Currency = "CNY",
  10657. Quantity = 1,
  10658. PplNum = pplNum,
  10659. TotalAmt = infoView.CityTranffic * pplNum,
  10660. Remark = "",
  10661. });
  10662. views.AddRange(intTravelCosts);
  10663. #endregion
  10664. var accomCosts = new List<QuoteSubItemInfo>();
  10665. #region 住宿费 1355
  10666. if (infoView.QuarterageData.Any())
  10667. {
  10668. int accomIndex = 1;
  10669. int accomItemTypeId = 1355;
  10670. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10671. foreach (var item in groupData)
  10672. {
  10673. string feeName = string.Empty;
  10674. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10675. if (countryInfo != null)
  10676. {
  10677. feeName = countryInfo.Country;
  10678. var city = countryInfo.City;
  10679. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10680. {
  10681. feeName += $"-{city}";
  10682. }
  10683. }
  10684. var hotelInfo = item.FirstOrDefault();
  10685. if (hotelInfo == null) continue;
  10686. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10687. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10688. int quantity = item.ToList().Count;
  10689. accomCosts.Add(new QuoteSubItemInfo
  10690. {
  10691. ItemId = accomItemTypeId,
  10692. Index = accomIndex,
  10693. FeeName = feeName,
  10694. UnitPrice = hotelInfo.Cost,
  10695. Currency = thisCurrency,
  10696. Quantity = quantity,
  10697. PplNum = pplNum,
  10698. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10699. Remark = "",
  10700. });
  10701. accomIndex++;
  10702. }
  10703. views.AddRange(accomCosts);
  10704. }
  10705. #endregion
  10706. var mealCosts = new List<QuoteSubItemInfo>();
  10707. #region 餐饮费 1356
  10708. if (infoView.BoardWagesData.Any())
  10709. {
  10710. var mealIndex = 1;
  10711. int mealItemTypeId = 1356;
  10712. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10713. foreach (var item in groupData)
  10714. {
  10715. string feeName = string.Empty;
  10716. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10717. if (countryInfo != null)
  10718. {
  10719. feeName = countryInfo.Country;
  10720. var city = countryInfo.City;
  10721. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10722. {
  10723. feeName += $"-{city}";
  10724. }
  10725. }
  10726. var mealInfo = item.FirstOrDefault();
  10727. if (mealInfo == null) continue;
  10728. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10729. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10730. int quantity = item.ToList().Count;
  10731. mealCosts.Add(new QuoteSubItemInfo
  10732. {
  10733. ItemId = mealItemTypeId,
  10734. Index = mealIndex,
  10735. FeeName = feeName,
  10736. UnitPrice = mealInfo.Cost,
  10737. Currency = thisCurrency,
  10738. Quantity = quantity,
  10739. PplNum = pplNum,
  10740. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10741. Remark = "",
  10742. });
  10743. mealIndex++;
  10744. }
  10745. views.AddRange(mealCosts);
  10746. }
  10747. #endregion
  10748. var miscCosts = new List<QuoteSubItemInfo>();
  10749. #region 公杂费 1364
  10750. if (infoView.MiscellaneousFeeData.Any())
  10751. {
  10752. var miscIndex = 1;
  10753. int miscItemTypeId = 1364;
  10754. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10755. foreach (var item in groupData)
  10756. {
  10757. string feeName = string.Empty;
  10758. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10759. if (countryInfo != null)
  10760. {
  10761. feeName = countryInfo.Country;
  10762. var city = countryInfo.City;
  10763. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10764. {
  10765. feeName += $"-{city}";
  10766. }
  10767. }
  10768. var miscInfo = item.FirstOrDefault();
  10769. if (miscInfo == null) continue;
  10770. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10771. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10772. int quantity = item.ToList().Count;
  10773. mealCosts.Add(new QuoteSubItemInfo
  10774. {
  10775. ItemId = miscItemTypeId,
  10776. Index = miscIndex,
  10777. FeeName = feeName,
  10778. UnitPrice = miscInfo.Cost,
  10779. Currency = thisCurrency,
  10780. Quantity = quantity,
  10781. PplNum = pplNum,
  10782. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10783. Remark = "",
  10784. });
  10785. miscIndex++;
  10786. }
  10787. views.AddRange(mealCosts);
  10788. }
  10789. #endregion
  10790. #region 签证+保险 1362
  10791. int visaInsIndex = 1;
  10792. int visaInsItemTypeId = 1362;
  10793. if (infoView.Visa > 0)
  10794. {
  10795. views.Add(new QuoteSubItemInfo()
  10796. {
  10797. ItemId = visaInsItemTypeId,
  10798. Index = visaInsIndex,
  10799. FeeName = $"签证",
  10800. UnitPrice = infoView.Visa,
  10801. Currency = $"CNY",
  10802. Quantity = 1,
  10803. PplNum = pplNum,
  10804. TotalAmt = infoView.Visa * pplNum,
  10805. Remark = "",
  10806. });
  10807. visaInsIndex++;
  10808. }
  10809. if (infoView.Safe > 0)
  10810. {
  10811. views.Add(new QuoteSubItemInfo()
  10812. {
  10813. ItemId = visaInsItemTypeId,
  10814. Index = visaInsIndex,
  10815. FeeName = $"保险",
  10816. UnitPrice = infoView.Safe,
  10817. Currency = $"CNY",
  10818. Quantity = 1,
  10819. PplNum = pplNum,
  10820. TotalAmt = infoView.Safe * pplNum,
  10821. Remark = "",
  10822. });
  10823. }
  10824. #endregion
  10825. #region 服务费 1363
  10826. int serviceFeeIndex = 1;
  10827. int serviceFeeItemTypeId = 1363;
  10828. if (infoView.Service > 0)
  10829. {
  10830. views.Add(new QuoteSubItemInfo()
  10831. {
  10832. ItemId = serviceFeeItemTypeId,
  10833. Index = serviceFeeIndex,
  10834. FeeName = $"服务费",
  10835. UnitPrice = infoView.Service,
  10836. Currency = $"CNY",
  10837. Quantity = 1,
  10838. PplNum = pplNum,
  10839. TotalAmt = infoView.Service * pplNum,
  10840. Remark = "",
  10841. });
  10842. }
  10843. #endregion
  10844. #endregion
  10845. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10846. result.Rates = eecRates.ToArray();
  10847. if (result.FeeItems.Any())
  10848. {
  10849. result.FeeItems.Select(x =>
  10850. {
  10851. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10852. if (feeInfos.Any()) x.Infos = feeInfos;
  10853. return x;
  10854. }
  10855. )
  10856. .OrderBy(x => x.Index)
  10857. .ToList();
  10858. }
  10859. return Ok(JsonView(result));
  10860. }
  10861. /// <summary>
  10862. /// 团组模块 - 出入境费用报价表 - Info
  10863. /// </summary>
  10864. /// <returns></returns>
  10865. [HttpPost]
  10866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10867. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10868. {
  10869. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10870. if (!info.Rates.Any())
  10871. {
  10872. var rates = await GeneralMethod.EnterExitCostInitRate();
  10873. info.Rates = rates.ToArray();
  10874. }
  10875. return Ok(JsonView(info));
  10876. }
  10877. /// <summary>
  10878. /// 团组模块 - 出入境费用报价表 - OP
  10879. /// </summary>
  10880. /// <returns></returns>
  10881. [HttpPost]
  10882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10883. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10884. {
  10885. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10886. }
  10887. /// <summary>
  10888. /// 团组模块 - 出入境费用报价表 - 删除 项
  10889. /// </summary>
  10890. /// <returns></returns>
  10891. [HttpPost]
  10892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10893. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10894. {
  10895. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10896. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10897. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10898. }
  10899. /// <summary>
  10900. /// 团组模块 - 出入境费用报价表 - 导出
  10901. /// </summary>
  10902. /// <returns></returns>
  10903. [HttpPost]
  10904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10905. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10906. {
  10907. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10908. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10909. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  10910. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10911. var rates = info.Rates;
  10912. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10913. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10914. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10915. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10916. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10917. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10918. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10919. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10920. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10921. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10922. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10923. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10924. //获取模板
  10925. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  10926. var designer = new WorkbookDesigner();
  10927. designer.Workbook = new Workbook(tempPath);
  10928. designer.SetDataSource("QuoteName", info.Name);
  10929. designer.SetDataSource("CompanyTitle", "公司名称");
  10930. designer.SetDataSource("CompanyLabel", "");
  10931. #region 国际旅费
  10932. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10933. if (intTravelCosts.Infos.Any())
  10934. {
  10935. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  10936. StringBuilder label = new StringBuilder();
  10937. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10938. if (infos.Any())
  10939. {
  10940. label.Append(infos.Sum(x => x.PplNum));
  10941. label.Append("人全程机票:");
  10942. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  10943. label.AppendLine("元");
  10944. }
  10945. foreach (var item in intTravelCosts.Infos)
  10946. {
  10947. label.Append(item.FeeName);
  10948. label.Append(":");
  10949. label.Append(item.UnitPrice.TruncDecimals(2));
  10950. label.Append("元/人*");
  10951. label.Append(item.PplNum);
  10952. label.AppendLine("人");
  10953. }
  10954. if (label.HasValue())
  10955. {
  10956. label.Append("\r\n以上小计:");
  10957. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  10958. label.Append("元");
  10959. }
  10960. designer.SetDataSource("IntTravelLabel", label.ToString());
  10961. }
  10962. #endregion
  10963. #region 住宿费
  10964. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10965. if (accomCosts.Infos.Any())
  10966. {
  10967. string currencyName = string.Empty;
  10968. decimal rate = 1.0000M;
  10969. StringBuilder label = new StringBuilder();
  10970. label.AppendLine("全程五星酒店,每人1间房");
  10971. foreach (var item in accomCosts.Infos)
  10972. {
  10973. string hotelName = string.Empty;
  10974. if (item.FeeName.Contains("-"))
  10975. {
  10976. var feeName = item.FeeName.Split('-');
  10977. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10978. }
  10979. else hotelName = $"\r\n{item.FeeName}:";
  10980. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10981. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10982. rate = rateInfo?.Rate ?? 1.0000M;
  10983. label.Append(hotelName);
  10984. label.Append(item.UnitPrice.TruncDecimals(2));
  10985. label.Append(currencyName);
  10986. label.Append("/间/晚*");
  10987. label.Append(item.Quantity.ToString("#0"));
  10988. label.AppendLine("人");
  10989. }
  10990. if (label.HasValue())
  10991. {
  10992. label.Append("\r\n以上小计:");
  10993. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  10994. label.Append("元(");
  10995. label.Append(currencyName);
  10996. label.Append("汇率:");
  10997. label.Append(rate.TruncDecimals(4));
  10998. label.Append(")");
  10999. }
  11000. designer.SetDataSource("AccomLabel", label.ToString());
  11001. }
  11002. #endregion
  11003. #region 餐饮费
  11004. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  11005. if (mealCosts.Infos.Any())
  11006. {
  11007. string currencyName = string.Empty;
  11008. decimal rate = 1.0000M;
  11009. StringBuilder label = new StringBuilder();
  11010. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  11011. foreach (var item in mealCosts.Infos)
  11012. {
  11013. string name = string.Empty;
  11014. if (item.FeeName.Contains("-"))
  11015. {
  11016. var feeName = item.FeeName.Split('-');
  11017. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11018. }
  11019. else name = $"\r\n{item.FeeName}:";
  11020. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11021. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11022. rate = rateInfo?.Rate ?? 1.0000M;
  11023. label.Append(name);
  11024. label.Append(item.UnitPrice.TruncDecimals(2));
  11025. label.Append(currencyName);
  11026. label.Append("/天*");
  11027. label.Append(item.Quantity.ToString("#0"));
  11028. label.Append("*");
  11029. label.Append(item.PplNum);
  11030. label.Append("人\r\n");
  11031. }
  11032. if (label.HasValue())
  11033. {
  11034. label.Append("\r\n以上小计:");
  11035. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11036. label.Append("元\r\n(");
  11037. label.Append("汇率:");
  11038. label.Append(rate.TruncDecimals(4));
  11039. label.Append(")");
  11040. }
  11041. designer.SetDataSource("MealLabel", label.ToString());
  11042. }
  11043. #endregion
  11044. #region 车辆安排
  11045. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  11046. if (vehArranges.Infos.Any())
  11047. {
  11048. string currencyName = string.Empty;
  11049. //decimal rate = 1.0000M;
  11050. StringBuilder label = new StringBuilder();
  11051. foreach (var item in vehArranges.Infos)
  11052. {
  11053. label.Append(item.Remark);
  11054. label.AppendLine();
  11055. label.AppendLine();
  11056. label.Append(item.FeeName);
  11057. label.Append("\r\n\r\n费用:");
  11058. label.Append(item.FeeName);
  11059. label.Append(item.TotalAmt.TruncDecimals(2));
  11060. }
  11061. designer.SetDataSource("VehArrangeLabel", label.ToString());
  11062. }
  11063. #endregion
  11064. #region 邀请函发放对象
  11065. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  11066. #endregion
  11067. designer.Process();
  11068. //文件名
  11069. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11070. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  11071. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  11072. return Ok(JsonView(true, "成功", url));
  11073. }
  11074. #endregion
  11075. #region 签证费用录入
  11076. /// <summary>
  11077. /// 根据diid查询签证费用列表
  11078. /// </summary>
  11079. /// <param name="dto"></param>
  11080. /// <returns></returns>
  11081. [HttpPost]
  11082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11083. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  11084. {
  11085. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  11086. if (groupData.Code != 0)
  11087. {
  11088. return Ok(JsonView(false, groupData.Msg));
  11089. }
  11090. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11091. }
  11092. /// <summary>
  11093. /// 根据签证费用Id查询单条数据及c表数据
  11094. /// </summary>
  11095. /// <param name="dto"></param>
  11096. /// <returns></returns>
  11097. [HttpPost]
  11098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11099. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  11100. {
  11101. Result groupData = await _visaPriceRep.PostVisaById(dto);
  11102. if (groupData.Code != 0)
  11103. {
  11104. return Ok(JsonView(false, groupData.Msg));
  11105. }
  11106. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11107. }
  11108. /// <summary>
  11109. /// 签证费用删除
  11110. /// </summary>
  11111. /// <param name="dto"></param>
  11112. /// <returns></returns>
  11113. [HttpPost]
  11114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11115. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  11116. {
  11117. _sqlSugar.BeginTran();
  11118. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  11119. if (!res)
  11120. {
  11121. _sqlSugar.RollbackTran();
  11122. return Ok(JsonView(false, "删除失败"));
  11123. }
  11124. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  11125. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  11126. .SetColumns(a => new Grp_CreditCardPayment()
  11127. {
  11128. IsDel = 1,
  11129. DeleteUserId = dto.DeleteUserId,
  11130. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11131. })
  11132. .ExecuteCommand();
  11133. if (resSub < 1)
  11134. {
  11135. _sqlSugar.RollbackTran();
  11136. return Ok(JsonView(false, "删除失败"));
  11137. }
  11138. _sqlSugar.CommitTran();
  11139. return Ok(JsonView(true, "删除成功!"));
  11140. }
  11141. /// <summary>
  11142. /// 签证费用录入下拉框初始化
  11143. /// </summary>
  11144. /// <returns></returns>
  11145. [HttpPost]
  11146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11147. public async Task<IActionResult> VisaPriceAddSelect()
  11148. {
  11149. //支付方式
  11150. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  11151. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  11152. //币种
  11153. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  11154. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  11155. //乘客类型
  11156. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  11157. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  11158. //卡类型
  11159. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  11160. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  11161. //代办费类型
  11162. var agencyFeeTypeData = new List<dynamic>() {
  11163. new { id = 0 , Text = "未选择" },
  11164. new { id = 1 , Text = "小公务" },
  11165. new { id = 2 , Text = "大公务" },
  11166. };
  11167. //签证费用标准国家Data
  11168. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  11169. var data = new
  11170. {
  11171. Payment = _Payment,
  11172. CurrencyList = _CurrencyList,
  11173. PassengerType = _PassengerType,
  11174. BankCard = _BankCard,
  11175. AgencyFeeType = agencyFeeTypeData,
  11176. CountryFeeData = visaCountryFeeData
  11177. };
  11178. return Ok(JsonView(true, "查询成功!", data));
  11179. }
  11180. /// <summary>
  11181. /// 签证费用录入操作(Status:1.新增,2.修改)
  11182. /// </summary>
  11183. /// <param name="dto"></param>
  11184. /// <returns></returns>
  11185. [HttpPost]
  11186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11187. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  11188. {
  11189. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  11190. if (groupData.Code != 0)
  11191. {
  11192. return Ok(JsonView(false, groupData.Msg));
  11193. }
  11194. #region 应用推送
  11195. try
  11196. {
  11197. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11198. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11199. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11200. //2024-10-21 新增LZ UID
  11201. var userIds = new List<int>() { 21 };
  11202. string title = $"系统通知";
  11203. string content = "";
  11204. var diId = dto.DiId;
  11205. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11206. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11207. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  11208. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  11209. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11210. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11211. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11212. }
  11213. catch (Exception ex)
  11214. {
  11215. }
  11216. #endregion
  11217. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11218. }
  11219. #endregion
  11220. #region 签证提成录入
  11221. /// <summary>
  11222. /// 签证提成录入
  11223. /// 基础数据
  11224. /// </summary>
  11225. /// <returns></returns>
  11226. [HttpGet]
  11227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11228. public async Task<IActionResult> VisaCommissionInit()
  11229. {
  11230. return Ok(await _visaCommissionRep.Init());
  11231. }
  11232. /// <summary>
  11233. /// 签证提成录入
  11234. /// Item
  11235. /// </summary>
  11236. /// <param name="_dto"></param>
  11237. /// <returns></returns>
  11238. [HttpPost]
  11239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11240. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  11241. {
  11242. var validator = new VisaCommissionItemDtoValidator();
  11243. var validatorRes = await validator.ValidateAsync(_dto);
  11244. if (!validatorRes.IsValid)
  11245. {
  11246. StringBuilder sb = new StringBuilder();
  11247. foreach (var item in validatorRes.Errors)
  11248. {
  11249. sb.AppendLine(item.ErrorMessage);
  11250. }
  11251. return Ok(JsonView(false, sb.ToString()));
  11252. }
  11253. return Ok(await _visaCommissionRep.Item(_dto));
  11254. }
  11255. /// <summary>
  11256. /// 签证提成录入
  11257. /// Save
  11258. /// </summary>
  11259. /// <param name="_dto"></param>
  11260. /// <returns></returns>
  11261. [HttpPost]
  11262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11263. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  11264. {
  11265. //参数验证
  11266. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  11267. foreach (var item in _dto.Items)
  11268. {
  11269. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  11270. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  11271. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  11272. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  11273. }
  11274. return Ok(await _visaCommissionRep.Save(_dto));
  11275. }
  11276. /// <summary>
  11277. /// 签证提成录入
  11278. /// Create
  11279. /// </summary>
  11280. /// <param name="_dto"></param>
  11281. /// <returns></returns>
  11282. [HttpPost]
  11283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11284. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  11285. {
  11286. var validator = new VisaCommissionCreateDtoValidator();
  11287. var validatorRes = await validator.ValidateAsync(_dto);
  11288. if (!validatorRes.IsValid)
  11289. {
  11290. StringBuilder sb = new StringBuilder();
  11291. foreach (var item in validatorRes.Errors)
  11292. {
  11293. sb.AppendLine(item.ErrorMessage);
  11294. }
  11295. return Ok(JsonView(false, sb.ToString()));
  11296. }
  11297. return Ok(await _visaCommissionRep.Create(_dto));
  11298. }
  11299. /// <summary>
  11300. /// 签证提成录入
  11301. /// Put(编辑)
  11302. /// </summary>
  11303. /// <param name="id"></param>
  11304. /// <param name="_dto"></param>
  11305. /// <returns></returns>
  11306. [HttpPut]
  11307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11308. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  11309. {
  11310. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11311. var validator = new VisaCommissionCreateDtoValidator();
  11312. var validatorRes = await validator.ValidateAsync(_dto);
  11313. if (!validatorRes.IsValid)
  11314. {
  11315. StringBuilder sb = new StringBuilder();
  11316. foreach (var item in validatorRes.Errors)
  11317. {
  11318. sb.AppendLine(item.ErrorMessage);
  11319. }
  11320. return Ok(JsonView(false, sb.ToString()));
  11321. }
  11322. return Ok(await _visaCommissionRep.Edit(id, _dto));
  11323. }
  11324. /// <summary>
  11325. /// 签证提成录入
  11326. /// Del
  11327. /// </summary>
  11328. /// <param name="id"></param>
  11329. /// <param name="currUserId"></param>
  11330. /// <returns></returns>
  11331. [HttpPost]
  11332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11333. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  11334. {
  11335. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11336. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  11337. return Ok(await _visaCommissionRep.Del(id, currUserId));
  11338. }
  11339. #endregion
  11340. #region op费用录入
  11341. /// <summary>
  11342. /// 根据diid查询op费用列表
  11343. /// </summary>
  11344. /// <param name="dto"></param>
  11345. /// <returns></returns>
  11346. [HttpPost]
  11347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11348. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  11349. {
  11350. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  11351. if (groupData.Code != 0)
  11352. {
  11353. return Ok(JsonView(false, groupData.Msg));
  11354. }
  11355. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11356. }
  11357. /// <summary>
  11358. /// 根据op费用Id查询单条数据及c表数据
  11359. /// </summary>
  11360. /// <param name="dto"></param>
  11361. /// <returns></returns>
  11362. [HttpPost]
  11363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11364. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11365. {
  11366. try
  11367. {
  11368. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11369. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11370. var data = new
  11371. {
  11372. CarTouristGuideGround = _groupData,
  11373. CreditCardPayment = _creditCardPayment
  11374. };
  11375. return Ok(JsonView(true, "查询成功!", data));
  11376. }
  11377. catch (Exception ex)
  11378. {
  11379. return Ok(JsonView(false, "程序错误!"));
  11380. }
  11381. }
  11382. /// <summary>
  11383. /// op费用删除
  11384. /// </summary>
  11385. /// <param name="dto"></param>
  11386. /// <returns></returns>
  11387. [HttpPost]
  11388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11389. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11390. {
  11391. try
  11392. {
  11393. _sqlSugar.BeginTran();
  11394. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11395. if (!res)
  11396. {
  11397. return Ok(JsonView(false, "删除失败"));
  11398. }
  11399. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11400. {
  11401. IsDel = 1,
  11402. DeleteUserId = dto.DeleteUserId,
  11403. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11404. }).ExecuteCommandAsync();
  11405. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11406. {
  11407. IsDel = 1,
  11408. DeleteUserId = dto.DeleteUserId,
  11409. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11410. }).ExecuteCommandAsync();
  11411. #region 删除超支相关数据
  11412. //删除导入的超支数据
  11413. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11414. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11415. {
  11416. IsDel = 1,
  11417. DeleteUserId = dto.DeleteUserId,
  11418. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11419. }).ExecuteCommand();
  11420. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11421. {
  11422. IsDel = 1,
  11423. DeleteUserId = dto.DeleteUserId,
  11424. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11425. }).ExecuteCommand();
  11426. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11427. {
  11428. IsDel = 1,
  11429. DeleteUserId = dto.DeleteUserId,
  11430. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11431. }).ExecuteCommand();
  11432. #endregion
  11433. _sqlSugar.CommitTran();
  11434. return Ok(JsonView(true, "删除成功!"));
  11435. }
  11436. catch (Exception ex)
  11437. {
  11438. _sqlSugar.RollbackTran();
  11439. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11440. }
  11441. }
  11442. /// <summary>
  11443. /// op费用录入操作(Status:1.新增,2.修改)
  11444. /// </summary>
  11445. /// <param name="dto"></param>
  11446. /// <returns></returns>
  11447. [HttpPost]
  11448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11449. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11450. {
  11451. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11452. if (groupData.Code != 0)
  11453. {
  11454. return Ok(JsonView(false, groupData.Msg));
  11455. }
  11456. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11457. }
  11458. /// <summary>
  11459. /// 填写费用详细页面初始化绑定
  11460. /// </summary>
  11461. /// <param name="dto"></param>
  11462. /// <returns></returns>
  11463. [HttpPost]
  11464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11465. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11466. {
  11467. try
  11468. {
  11469. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11470. if (groupData.Code != 0)
  11471. {
  11472. return Ok(JsonView(false, groupData.Msg));
  11473. }
  11474. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11475. }
  11476. catch (Exception ex)
  11477. {
  11478. return Ok(JsonView(false, ex.Message));
  11479. }
  11480. }
  11481. /// <summary>
  11482. /// 根据op费用Id查询详细数据
  11483. /// </summary>
  11484. /// <param name="dto"></param>
  11485. /// <returns></returns>
  11486. [HttpPost]
  11487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11488. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11489. {
  11490. try
  11491. {
  11492. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11493. if (groupData.Code != 0)
  11494. {
  11495. return Ok(JsonView(false, groupData.Msg));
  11496. }
  11497. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11498. }
  11499. catch (Exception ex)
  11500. {
  11501. return Ok(JsonView(false, ex.Message));
  11502. }
  11503. }
  11504. /// <summary>
  11505. /// OP费用录入填写详情
  11506. /// </summary>
  11507. /// <param name="dto"></param>
  11508. /// <returns></returns>
  11509. [HttpPost]
  11510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11511. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11512. {
  11513. try
  11514. {
  11515. #region 参数校验
  11516. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11517. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11518. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11519. #endregion
  11520. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11521. if (groupData.Code != 0)
  11522. {
  11523. return Ok(JsonView(false, groupData.Msg));
  11524. }
  11525. //自动审核
  11526. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11527. #region 应用推送
  11528. try
  11529. {
  11530. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11531. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11532. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11533. //2024-10-21 新增LZ UID
  11534. var userIds = new List<int>() { 21 };
  11535. string title = $"系统通知";
  11536. var diId = dto.DiId;
  11537. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11538. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11539. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11540. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11541. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11542. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11543. }
  11544. catch (Exception ex)
  11545. {
  11546. }
  11547. #endregion
  11548. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11549. }
  11550. catch (Exception ex)
  11551. {
  11552. return Ok(JsonView(false, ex.Message));
  11553. }
  11554. }
  11555. /// <summary>
  11556. /// 获取三公详细所有城市
  11557. /// </summary>
  11558. /// <returns></returns>
  11559. [HttpGet]
  11560. public IActionResult OpCarCityResult()
  11561. {
  11562. var jw = JsonView(false);
  11563. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11564. {
  11565. x.Id,
  11566. x.Country,
  11567. x.City,
  11568. }).ToList();
  11569. if (data.Count > 0)
  11570. {
  11571. jw = JsonView(true, "获取成功!", data);
  11572. }
  11573. else
  11574. {
  11575. jw.Msg = "城市数据为空!";
  11576. jw.Data = new string[0];
  11577. }
  11578. return Ok(jw);
  11579. }
  11580. /// <summary>
  11581. /// 导出地接费用明细
  11582. /// </summary>
  11583. /// <param name="dto"></param>
  11584. /// <returns></returns>
  11585. [HttpPost]
  11586. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11587. {
  11588. var jw = JsonView(false);
  11589. if (dto.Diid < 1)
  11590. {
  11591. jw.Msg = "请输入正确的diid!";
  11592. return Ok(jw);
  11593. }
  11594. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11595. if (group == null)
  11596. {
  11597. jw.Msg = "未找到团组信息!";
  11598. return Ok(jw);
  11599. }
  11600. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11601. if (localGuideArr.Count == 0)
  11602. {
  11603. jw.Msg = "该团组暂无地接信息!";
  11604. return Ok(jw);
  11605. }
  11606. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11607. var overspendSoure = new Dictionary<int, int>
  11608. {
  11609. { 91, 982 }, //车
  11610. { 92 , 1059} ,//导游
  11611. { 994 , 1073}, //翻译
  11612. { 988 , 1074 }, //早餐
  11613. { 93 , 1075 }, //午餐
  11614. { 989 , 1076 }, //晚餐
  11615. };
  11616. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11617. foreach (var groupArr in localGroup)
  11618. {
  11619. var keyValue = groupArr.Key;
  11620. if (int.TryParse(keyValue, out int cityid))
  11621. {
  11622. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11623. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11624. }
  11625. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11626. foreach (var item in groupArr)
  11627. {
  11628. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11629. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11630. new Grp_CarTouristGuideGroundReservationsContentExtend
  11631. {
  11632. Count = a.Count,
  11633. CreateTime = a.CreateTime,
  11634. CreateUserId = a.CreateUserId,
  11635. CTGGRId = a.CTGGRId,
  11636. Currency = a.Currency,
  11637. DatePrice = a.DatePrice,
  11638. DeleteTime = a.DeleteTime,
  11639. DeleteUserId = a.DeleteUserId,
  11640. DiId = a.DiId,
  11641. Id = a.Id,
  11642. IsDel = a.IsDel,
  11643. Price = a.Price,
  11644. PriceContent = a.PriceContent,
  11645. Remark = a.Remark,
  11646. SId = a.SId,
  11647. SidName = b.Name,
  11648. Units = a.Units,
  11649. }
  11650. ).ToList();
  11651. if (content.Count > 0)
  11652. {
  11653. contentArr.Add(content);
  11654. }
  11655. }
  11656. //open excel
  11657. //set excel
  11658. //save excel
  11659. try
  11660. {
  11661. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11662. IWorkbook workbook;
  11663. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11664. {
  11665. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11666. }
  11667. else
  11668. {
  11669. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11670. }
  11671. ISheet sheet = workbook.GetSheetAt(0);
  11672. var rowStartIndex = 2;
  11673. var clounmCount = 10;
  11674. var initStyleRow = sheet.GetRow(2);
  11675. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11676. //var overspendArrDetail =
  11677. var existsId = new List<CarCompare>();
  11678. var lastElem = arr.Last();
  11679. var thisSid = -1;
  11680. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11681. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11682. {
  11683. Name = "未知币种!",
  11684. Remark = "未知币种!",
  11685. };
  11686. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11687. Action cloneRowFn = () =>
  11688. {
  11689. rowStartIndex++;
  11690. var cloneRow = sheet.CreateRow(rowStartIndex);
  11691. // 复制样式
  11692. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11693. {
  11694. ICell sourceCell = initStyleRow.GetCell(i);
  11695. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11696. // 确保单元格存在样式
  11697. if (sourceCell.CellStyle != null)
  11698. {
  11699. targetCell.CellStyle = sourceCell.CellStyle;
  11700. }
  11701. }
  11702. };
  11703. var mergeRow = () =>
  11704. {
  11705. for (int i = 2; i < sheet.LastRowNum; i++)
  11706. {
  11707. var row = sheet.GetRow(i);
  11708. var cellFirst = row.GetCell(0);
  11709. var thisIndex = i + 1;
  11710. while (thisIndex < sheet.LastRowNum)
  11711. {
  11712. var nextRow = sheet.GetRow(thisIndex);
  11713. var nextCellFirst = nextRow.GetCell(0);
  11714. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11715. {
  11716. thisIndex++;
  11717. }
  11718. else
  11719. {
  11720. break;
  11721. }
  11722. }
  11723. thisIndex--;
  11724. if (thisIndex != i)
  11725. {
  11726. //合并row
  11727. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11728. i, // 起始行索引(0-based)
  11729. thisIndex, // 结束行索引(0-based)
  11730. 0, // 起始列索引(0-based)
  11731. 0 // 结束列索引(0-based)
  11732. );
  11733. sheet.AddMergedRegion(cellRangeAddress);
  11734. i = thisIndex;
  11735. }
  11736. }
  11737. };
  11738. var chaoshiNumber = 0;
  11739. var totalNumber = 0.00M;
  11740. string lastStr = "";
  11741. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11742. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11743. {
  11744. b.IsAuditGM,
  11745. x.Id,
  11746. x.Area,
  11747. b.PayPercentage,
  11748. b.PayMoney,
  11749. }).ToList();
  11750. string yesPayment = "", noPayment = "";
  11751. foreach (var item in queryCarArrByCityAndDiid)
  11752. {
  11753. if (item.IsAuditGM == 1)
  11754. {
  11755. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11756. }
  11757. else
  11758. {
  11759. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11760. }
  11761. }
  11762. lastStr = yesPayment + noPayment;
  11763. foreach (var item in arr)
  11764. {
  11765. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11766. {
  11767. if (thisSid != item.SId)
  11768. {
  11769. if (thisSid == -1)
  11770. {
  11771. thisSid = item.SId;
  11772. }
  11773. else
  11774. {
  11775. //合并小计行
  11776. //创建合并区域的实例
  11777. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11778. rowStartIndex, // 起始行索引(0-based)
  11779. rowStartIndex, // 结束行索引(0-based)
  11780. 0, // 起始列索引(0-based)
  11781. 3 // 结束列索引(0-based)
  11782. );
  11783. sheet.AddMergedRegion(cellRangeAddress);
  11784. var CellStyle = workbook.CreateCellStyle();
  11785. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11786. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11787. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  11788. for (int i = 0; i <= clounmCount; i++)
  11789. {
  11790. if (i > 6)
  11791. {
  11792. var CellStyle1 = workbook.CreateCellStyle();
  11793. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11794. IFont Font = workbook.CreateFont(); // 创建字体
  11795. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11796. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11797. CellStyle1.SetFont(Font);
  11798. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11799. }
  11800. else
  11801. {
  11802. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11803. }
  11804. }
  11805. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11806. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11807. //超时合计
  11808. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11809. //超时数
  11810. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11811. //超时合计费用
  11812. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11813. thisSid = item.SId;
  11814. cloneRowFn();
  11815. chaoshiNumber = 0;
  11816. totalNumber = 0;
  11817. }
  11818. }
  11819. IRow row = sheet.GetRow(rowStartIndex);
  11820. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11821. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11822. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11823. if (isOpenOverspendSoure)
  11824. {
  11825. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11826. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11827. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11828. }
  11829. for (int i = 0; i <= clounmCount; i++)
  11830. {
  11831. var cell = row.GetCell(i);
  11832. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11833. if (cell == null)
  11834. {
  11835. cell = row.CreateCell(i);
  11836. }
  11837. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11838. fontRed.CloneStyleFrom(cell.CellStyle);
  11839. IFont Font = workbook.CreateFont(); // 创建字体
  11840. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11841. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11842. fontRed.SetFont(Font);
  11843. byte[] rgb = new byte[3] { 255, 242, 204 };
  11844. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11845. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11846. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11847. if (workbook is XSSFWorkbook)
  11848. {
  11849. BackgroundColor255_242_204.FillForegroundColor = 0;
  11850. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11851. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  11852. }
  11853. else
  11854. {
  11855. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11856. }
  11857. if (i == 1 || i > 6)
  11858. {
  11859. if (i > 6)
  11860. {
  11861. fontRed.FillForegroundColor = 0;
  11862. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11863. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  11864. }
  11865. cell.CellStyle = fontRed;
  11866. }
  11867. if (i > 2 && i < 7)
  11868. {
  11869. cell.CellStyle = BackgroundColor255_242_204;
  11870. }
  11871. cell.SetCellValue(setCellValue); //写入单元格
  11872. }
  11873. if (overspendSoure.ContainsKey(thisSid))
  11874. {
  11875. var overspendId = overspendSoure[thisSid];
  11876. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11877. }
  11878. cloneRowFn();
  11879. existsId.Add(new CarCompare
  11880. {
  11881. DataPrice = item.DatePrice.ObjToDate(),
  11882. Sid = item.SId
  11883. });
  11884. }
  11885. if (item.Equals(lastElem))
  11886. {
  11887. //合并小计行
  11888. //创建合并区域的实例
  11889. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11890. rowStartIndex, // 起始行索引(0-based)
  11891. rowStartIndex, // 结束行索引(0-based)
  11892. 0, // 起始列索引(0-based)
  11893. 3 // 结束列索引(0-based)
  11894. );
  11895. sheet.AddMergedRegion(cellRangeAddress);
  11896. var CellStyle = workbook.CreateCellStyle();
  11897. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11898. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11899. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  11900. for (int i = 0; i <= clounmCount; i++)
  11901. {
  11902. if (i > 6)
  11903. {
  11904. var CellStyle1 = workbook.CreateCellStyle();
  11905. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11906. IFont Font = workbook.CreateFont(); // 创建字体
  11907. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11908. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11909. CellStyle1.SetFont(Font);
  11910. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11911. }
  11912. else
  11913. {
  11914. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11915. }
  11916. }
  11917. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11918. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11919. //超时合计
  11920. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11921. //超时数
  11922. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11923. //超时合计费用
  11924. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11925. cloneRowFn();
  11926. // 创建合并区域的实例
  11927. cellRangeAddress = new CellRangeAddress(
  11928. rowStartIndex, // 起始行索引(0-based)
  11929. rowStartIndex, // 结束行索引(0-based)
  11930. 0, // 起始列索引(0-based)
  11931. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11932. );
  11933. // 添加合并区域
  11934. sheet.AddMergedRegion(cellRangeAddress);
  11935. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11936. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11937. }
  11938. }
  11939. mergeRow();
  11940. // 保存修改后的Excel文件到新文件
  11941. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11942. // new FileStream(newFilePath, FileMode.CreateNew)
  11943. using (var stream = new MemoryStream())
  11944. {
  11945. workbook.Write(stream, true);
  11946. stream.Flush();
  11947. stream.Seek(0, SeekOrigin.Begin);
  11948. MemoryStream memoryStream = new MemoryStream();
  11949. stream.CopyTo(memoryStream);
  11950. memoryStream.Seek(0, SeekOrigin.Begin);
  11951. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11952. }
  11953. workbook.Close();
  11954. workbook.Dispose();
  11955. }
  11956. catch (Exception ex)
  11957. {
  11958. jw.Msg = "出现异常!" + ex.Message;
  11959. return Ok(jw);
  11960. }
  11961. }
  11962. if (Zips.Count > 0)
  11963. {
  11964. IOOperatorHelper io = new IOOperatorHelper();
  11965. var byts = io.ConvertZipStream(Zips);
  11966. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11967. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11968. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11969. }
  11970. else
  11971. {
  11972. jw.Msg = "暂无生成文件!";
  11973. }
  11974. return Ok(jw);
  11975. }
  11976. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11977. {
  11978. string outStr = string.Empty;
  11979. switch (i)
  11980. {
  11981. case 0:
  11982. outStr = arr[0].SidName;
  11983. break;
  11984. case 1:
  11985. outStr = arr[0].DataPriceStr;
  11986. break;
  11987. case 2:
  11988. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11989. break;
  11990. case 4:
  11991. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11992. break;
  11993. case 7:
  11994. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11995. {
  11996. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11997. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11998. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11999. }
  12000. break;
  12001. case 8:
  12002. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12003. {
  12004. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  12005. }
  12006. break;
  12007. case 9:
  12008. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12009. {
  12010. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  12011. }
  12012. break;
  12013. case 10:
  12014. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12015. {
  12016. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  12017. }
  12018. break;
  12019. }
  12020. return outStr;
  12021. }
  12022. #region OP行程单
  12023. /// <summary>
  12024. /// OP行程单初始化
  12025. /// </summary>
  12026. /// <param name="dto"></param>
  12027. /// <returns></returns>
  12028. [HttpPost]
  12029. public IActionResult InitOpTravel(InitOpTravelDto dto)
  12030. {
  12031. var jw = JsonView(false);
  12032. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  12033. var group = groupList.First();
  12034. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12035. if (group == null)
  12036. {
  12037. jw.Msg = "暂无团组!";
  12038. return Ok(jw);
  12039. }
  12040. group = groupList.Find(x => x.Id == diid);
  12041. if (group == null)
  12042. {
  12043. jw.Msg = "请输入正确的团组ID!";
  12044. return Ok(jw);
  12045. }
  12046. string city = string.Empty;
  12047. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  12048. if (blackCode.Count > 0)
  12049. {
  12050. var black = blackCode.First();
  12051. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  12052. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  12053. if (blackSp.Length > 0)
  12054. {
  12055. try
  12056. {
  12057. var cityArrCode = new List<string>(20);
  12058. foreach (var item in blackSp)
  12059. {
  12060. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  12061. var IndexSelect = itemSp[2];
  12062. var cityArrCodeLength = cityArrCode.Count - 1;
  12063. var startCity = IndexSelect.Substring(0, 3);
  12064. if (cityArrCodeLength > 0)
  12065. {
  12066. var arrEndCity = cityArrCode[cityArrCodeLength];
  12067. if (arrEndCity != startCity)
  12068. {
  12069. cityArrCode.Add(startCity.ToUpper());
  12070. }
  12071. }
  12072. else
  12073. {
  12074. cityArrCode.Add(startCity.ToUpper());
  12075. }
  12076. var endCity = IndexSelect.Substring(3, 3);
  12077. cityArrCode.Add(endCity.ToUpper());
  12078. }
  12079. var cityThree = string.Empty;
  12080. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  12081. cityThree = cityThree.TrimEnd(',');
  12082. if (string.IsNullOrWhiteSpace(cityThree))
  12083. {
  12084. throw new
  12085. Exception("error");
  12086. }
  12087. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  12088. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  12089. foreach (var item in cityArrCode)
  12090. {
  12091. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  12092. if (find != null)
  12093. {
  12094. city += find.City + "/";
  12095. }
  12096. else
  12097. {
  12098. city += item + "三字码未收入/";
  12099. }
  12100. }
  12101. city = city.TrimEnd('/');
  12102. }
  12103. catch (Exception e)
  12104. {
  12105. city = "黑屏代码格式不正确!";
  12106. }
  12107. }
  12108. }
  12109. else
  12110. {
  12111. city = "未录入黑屏代码";
  12112. }
  12113. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  12114. {
  12115. Date = x.Date,
  12116. Days = x.Days,
  12117. Diffgroup = x.Diffgroup,
  12118. Diid = x.Diid,
  12119. Traffic_First = x.Traffic_First,
  12120. Traffic_Second = x.Traffic_Second,
  12121. Trip = x.Trip,
  12122. WeekDay = x.WeekDay,
  12123. Id = x.Id
  12124. }).ToList();
  12125. jw.Data = new
  12126. {
  12127. groupList = groupList.Select(x => new
  12128. {
  12129. x.Id,
  12130. x.TeamName,
  12131. x.TourCode
  12132. }).ToList(),
  12133. groupInfo = new
  12134. {
  12135. group.VisitDays,
  12136. group.TourCode,
  12137. group.VisitPNumber,
  12138. group.TeamName,
  12139. city
  12140. },
  12141. OpTravelList
  12142. };
  12143. jw.Code = 200;
  12144. jw.Msg = "操作成功!";
  12145. return Ok(jw);
  12146. }
  12147. /// <summary>
  12148. /// 删除团组行程单
  12149. /// </summary>
  12150. /// <returns></returns>
  12151. [HttpPost]
  12152. public IActionResult DelTravel(DelOpTravelDto dto)
  12153. {
  12154. var jw = JsonView(false);
  12155. if (dto.UserId <= 0 || dto.Diid <= 0)
  12156. {
  12157. jw.Msg = "请输入正确的参数!";
  12158. return Ok(jw);
  12159. }
  12160. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  12161. .SetColumns(x => new Grp_TravelList
  12162. {
  12163. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  12164. DeleteUserId = dto.UserId,
  12165. IsDel = 1,
  12166. }).ExecuteCommand();
  12167. jw = JsonView(true);
  12168. return Ok(jw);
  12169. }
  12170. /// <summary>
  12171. /// 行程单保存
  12172. /// </summary>
  12173. /// <returns></returns>
  12174. [HttpPost]
  12175. public IActionResult TravelSave(TravelSaveDto dto)
  12176. {
  12177. var jw = JsonView(false);
  12178. if (dto.Arr.Count > 0)
  12179. {
  12180. try
  12181. {
  12182. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  12183. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  12184. .ToList();
  12185. _sqlSugar.BeginTran();
  12186. foreach (var item in dto.Arr)
  12187. {
  12188. if (item.Id == 0)
  12189. {
  12190. throw new Exception("请传入正确的Id");
  12191. }
  12192. //比较上一次的差异
  12193. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  12194. if (findTravel != null)
  12195. {
  12196. item.Trip = item.Trip.Replace("[++]", string.Empty);
  12197. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  12198. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  12199. }
  12200. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  12201. .SetColumns(x => new Grp_TravelList
  12202. {
  12203. Trip = item.Trip
  12204. }).ExecuteCommand();
  12205. }
  12206. _sqlSugar.CommitTran();
  12207. jw = JsonView(true);
  12208. }
  12209. catch (Exception ex)
  12210. {
  12211. _sqlSugar.RollbackTran();
  12212. jw.Msg = "程序异常!" + ex.Message;
  12213. }
  12214. }
  12215. else
  12216. {
  12217. jw.Msg = "请传入正确的参数!";
  12218. }
  12219. return Ok(jw);
  12220. }
  12221. private string CheckStr(string original, string changed)
  12222. {
  12223. // 创建diff_match_patch对象
  12224. var dmp = new diff_match_patch();
  12225. // 计算差异
  12226. List<Diff> diffs = dmp.diff_main(original, changed);
  12227. // 清理和合并差异
  12228. dmp.diff_cleanupSemantic(diffs);
  12229. // 使用StringBuilder构建最终的字符串
  12230. StringBuilder finalString = new StringBuilder();
  12231. // 输出差异结果,并构建变动后的字符串
  12232. foreach (Diff diff in diffs)
  12233. {
  12234. switch (diff.operation)
  12235. {
  12236. case Operation.EQUAL:
  12237. // 相等的部分,直接添加到最终字符串
  12238. finalString.Append(diff.text);
  12239. break;
  12240. case Operation.INSERT:
  12241. // 插入的部分,添加标记并添加到最终字符串
  12242. finalString.Append("[++]" + diff.text + "[++]");
  12243. break;
  12244. case Operation.DELETE:
  12245. // 删除的部分,不添加到最终字符串
  12246. //finalString.Append("[++]" + diff.text + "[++]");
  12247. break;
  12248. }
  12249. }
  12250. // 输出变动后的字符串
  12251. return finalString.ToString();
  12252. }
  12253. private class tagContent
  12254. {
  12255. public DateTime Date { get; set; }
  12256. public string StartTag { get; set; }
  12257. public string EndTag { get; set; }
  12258. public string Content { get; set; }
  12259. public static int tagLength { get { return 3; } }
  12260. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  12261. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  12262. public bool IsFinally { get; set; }
  12263. }
  12264. private List<string> ExtractContentBetweenTags(string input, string tag)
  12265. {
  12266. List<string> results = new List<string>();
  12267. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  12268. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  12269. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  12270. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  12271. string[] strValueArr = new string[1];
  12272. foreach (System.Text.RegularExpressions.Match match in matches)
  12273. {
  12274. var strValue = match.Groups[1].Value;
  12275. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  12276. }
  12277. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  12278. return results;
  12279. }
  12280. /// <summary>
  12281. /// 导出行程单
  12282. /// </summary>
  12283. /// <param name="dto"></param>
  12284. /// <returns></returns>
  12285. [HttpPost]
  12286. public IActionResult ExportTravel(ExportTravelDto dto)
  12287. {
  12288. var jw = JsonView(false);
  12289. jw.Data = "";
  12290. int diid = 0;
  12291. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  12292. if (Find == null)
  12293. {
  12294. jw.Msg = "请选择正确的团组!";
  12295. return Ok(jw);
  12296. }
  12297. else
  12298. {
  12299. diid = Find.Id;
  12300. }
  12301. //数据源
  12302. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  12303. DataTable dtBlack = null;
  12304. try
  12305. {
  12306. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  12307. }
  12308. catch (Exception)
  12309. {
  12310. jw.Msg = "机票黑屏代码有误!";
  12311. return Ok(jw);
  12312. }
  12313. string CityStr = string.Empty;
  12314. if (dtBlack.Rows.Count == 0)
  12315. {
  12316. jw.Msg = "机票黑屏代码有误!";
  12317. return Ok(jw);
  12318. }
  12319. else
  12320. {
  12321. foreach (DataRow row in dtBlack.Rows)
  12322. {
  12323. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12324. {
  12325. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  12326. return Ok(jw);
  12327. }
  12328. }
  12329. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  12330. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  12331. }
  12332. // 指定的文字
  12333. var targetTextDic = new Dictionary<string, List<string>>();
  12334. //创建数据源Table
  12335. DataTable dtSource = new DataTable();
  12336. dtSource.Columns.Add("Days", typeof(string));
  12337. dtSource.Columns.Add("Date", typeof(string));
  12338. dtSource.Columns.Add("Week", typeof(string));
  12339. dtSource.Columns.Add("Traffic", typeof(string));
  12340. dtSource.Columns.Add("Trip", typeof(string));
  12341. //获取数据,放到datatable
  12342. foreach (var item in _travelList)
  12343. {
  12344. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  12345. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  12346. .Replace(tagContent.TagFormat.Item2, string.Empty)
  12347. .Replace("[++]", string.Empty);
  12348. DataRow dr = dtSource.NewRow();
  12349. dr["Days"] = item.Days;
  12350. dr["Date"] = item.Date;
  12351. dr["Week"] = item.WeekDay;
  12352. dr["Traffic"] = item.Traffic_First
  12353. + "\r\n"
  12354. + item.Traffic_Second;
  12355. dr["Trip"] = item.Trip;
  12356. dtSource.Rows.Add(dr);
  12357. }
  12358. Dictionary<string, string> dic = new Dictionary<string, string>();
  12359. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12360. dic.Add("City", CityStr);
  12361. dic.Add("Days", Find.VisitDays.ToString());
  12362. dic.Add("DeleCode", Find.TourCode);
  12363. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12364. //模板路径
  12365. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12366. //载入模板
  12367. Document doc = null;
  12368. DocumentBuilder builder = null;
  12369. try
  12370. {
  12371. //载入模板
  12372. doc = new Document(tempPath);
  12373. builder = new DocumentBuilder(doc);
  12374. }
  12375. catch (Exception)
  12376. {
  12377. jw.Msg = "模板位置不存在!";
  12378. return Ok(jw);
  12379. }
  12380. foreach (var key in dic.Keys)
  12381. {
  12382. Bookmark bookmark = doc.Range.Bookmarks[key];
  12383. if (bookmark != null)
  12384. {
  12385. builder.MoveToBookmark(key);
  12386. builder.Write(dic[key]);
  12387. }
  12388. }
  12389. //获取word里所有表格
  12390. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12391. //获取所填表格的序数
  12392. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12393. try
  12394. {
  12395. //循环赋值
  12396. for (int i = 0; i < dtSource.Rows.Count; i++)
  12397. {
  12398. builder.MoveToCell(0, i + 1, 0, 0);
  12399. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12400. builder.MoveToCell(0, i + 1, 1, 0);
  12401. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12402. builder.MoveToCell(0, i + 1, 2, 0);
  12403. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12404. var trip = dtSource.Rows[i]["Trip"].ToString();
  12405. builder.MoveToCell(0, i + 1, 3, 0);
  12406. builder.Write(trip);
  12407. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12408. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12409. // 获取特定索引的段落
  12410. Paragraph paragraph = (Paragraph)paragraphs[0];
  12411. Run run = paragraph.Runs[0];
  12412. Aspose.Words.Font font = run.Font;
  12413. font.Name = "黑体";
  12414. //设置双休红色
  12415. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12416. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12417. paragraph = (Paragraph)paragraphs[1];
  12418. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12419. {
  12420. run = paragraph.Runs[0];
  12421. font = run.Font;
  12422. font.Color = Color.Red;
  12423. }
  12424. }
  12425. }
  12426. catch (Exception ex)
  12427. {
  12428. }
  12429. //删除多余行
  12430. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12431. {
  12432. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12433. }
  12434. var targetTextList = new List<string>();
  12435. // 遍历文档中的表格
  12436. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12437. {
  12438. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12439. {
  12440. var cellIndex = 0;
  12441. foreach (Cell cell in row.Cells)
  12442. {
  12443. if (cellIndex == 1 && row.Cells.Count == 4)
  12444. {
  12445. foreach (var target in targetTextDic.Keys)
  12446. {
  12447. if (cell.GetText().Contains(target))
  12448. {
  12449. targetTextList = targetTextDic[target];
  12450. break;
  12451. }
  12452. }
  12453. }
  12454. // 遍历单元格中的所有段落
  12455. foreach (Paragraph paragraph in cell.Paragraphs)
  12456. {
  12457. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12458. List<Run> runs = new List<Run>();
  12459. foreach (Run run in paragraph.Runs)
  12460. {
  12461. runs.Add(run);
  12462. }
  12463. foreach (Run run in runs)
  12464. {
  12465. foreach (var targetText in targetTextList)
  12466. {
  12467. // 检查文字是否包含指定文字
  12468. if (run.Text.Contains(targetText))
  12469. {
  12470. // 将包含的部分设置为红色
  12471. HighlightText(run, targetText, Color.Red);
  12472. }
  12473. }
  12474. }
  12475. }
  12476. cellIndex++;
  12477. }
  12478. }
  12479. }
  12480. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12481. if (!Directory.Exists(savePath))
  12482. {
  12483. try
  12484. {
  12485. Directory.CreateDirectory(savePath);
  12486. }
  12487. catch
  12488. {
  12489. }
  12490. }
  12491. string path = savePath + Find.TeamName + "出访日程";
  12492. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12493. try
  12494. {
  12495. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12496. string postfix = ".docx";
  12497. if (dto.IsPDF == 1)
  12498. {
  12499. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12500. postfix = ".pdf";
  12501. }
  12502. doc.Save(path + postfix, saveFormat);
  12503. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12504. }
  12505. catch (Exception)
  12506. {
  12507. jw = JsonView(false);
  12508. }
  12509. return Ok(jw);
  12510. }
  12511. /// <summary>
  12512. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12513. /// </summary>
  12514. /// <param name="num"></param>
  12515. /// <returns></returns>
  12516. string GetNum(string num)
  12517. {
  12518. string str = "";
  12519. switch (num)
  12520. {
  12521. case "1":
  12522. str = "一";
  12523. break;
  12524. case "2":
  12525. str = "二";
  12526. break;
  12527. case "3":
  12528. str = "三";
  12529. break;
  12530. case "4":
  12531. str = "四";
  12532. break;
  12533. case "5":
  12534. str = "五";
  12535. break;
  12536. case "6":
  12537. str = "六";
  12538. break;
  12539. case "7":
  12540. str = "七";
  12541. break;
  12542. case "8":
  12543. str = "八";
  12544. break;
  12545. case "9":
  12546. str = "九";
  12547. break;
  12548. case "10":
  12549. str = "十";
  12550. break;
  12551. case "11":
  12552. str = "十一";
  12553. break;
  12554. case "12":
  12555. str = "十二";
  12556. break;
  12557. case "一":
  12558. str = "1";
  12559. break;
  12560. case "二":
  12561. str = "2";
  12562. break;
  12563. case "三":
  12564. str = "3";
  12565. break;
  12566. case "四":
  12567. str = "4";
  12568. break;
  12569. case "五":
  12570. str = "5";
  12571. break;
  12572. case "六":
  12573. str = "6";
  12574. break;
  12575. case "七":
  12576. str = "7";
  12577. break;
  12578. case "八":
  12579. str = "8";
  12580. break;
  12581. case "九":
  12582. str = "9";
  12583. break;
  12584. case "十":
  12585. str = "10";
  12586. break;
  12587. case "十一":
  12588. str = "11";
  12589. break;
  12590. case "十二":
  12591. str = "12";
  12592. break;
  12593. }
  12594. return str;
  12595. }
  12596. // 高亮包含指定文字的部分
  12597. void HighlightText(Run run, string targetText, Color color)
  12598. {
  12599. string text = run.Text;
  12600. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12601. if (startIndex >= 0)
  12602. {
  12603. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12604. // 前部分
  12605. if (startIndex > 0)
  12606. {
  12607. Run beforeRun = (Run)run.Clone(true);
  12608. beforeRun.Text = text.Substring(0, startIndex);
  12609. parentParagraph.InsertBefore(beforeRun, run);
  12610. }
  12611. // 匹配部分
  12612. Run matchRun = (Run)run.Clone(true);
  12613. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12614. matchRun.Font.Color = color;
  12615. parentParagraph.InsertBefore(matchRun, run);
  12616. // 后部分
  12617. if (startIndex + targetText.Length < text.Length)
  12618. {
  12619. Run afterRun = (Run)run.Clone(true);
  12620. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12621. parentParagraph.InsertBefore(afterRun, run);
  12622. }
  12623. // 删除原始Run
  12624. run.Remove();
  12625. }
  12626. }
  12627. #endregion
  12628. #endregion
  12629. #region 团组成本
  12630. /// <summary>
  12631. /// 团组成本数据初始化
  12632. /// </summary>
  12633. /// <param name="dto"></param>
  12634. /// <returns></returns>
  12635. [HttpPost]
  12636. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12637. {
  12638. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12639. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12640. WHEN COUNT(*) >= 0 THEN 'True'
  12641. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12642. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12643. ").ToList(); //团组列表
  12644. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12645. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12646. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12647. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12648. if (groupinfoValue != null)
  12649. {
  12650. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12651. var spArr = new string[1] { countryArr };
  12652. if (countryArr.Contains("|"))
  12653. {
  12654. spArr = countryArr.Split("|");
  12655. }
  12656. else if (countryArr.Contains("、"))
  12657. {
  12658. spArr = countryArr.Split("、");
  12659. }
  12660. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12661. {
  12662. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12663. if (dbQueryCountry != null)
  12664. {
  12665. visaCountryInfoArr.Add(dbQueryCountry);
  12666. }
  12667. }
  12668. }
  12669. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12670. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12671. var create = _GroupCostRepository.
  12672. CreateGroupCostByBlackCode(dto.Diid);
  12673. if (groupCost.Count == 0 && create.Code == 0)
  12674. {
  12675. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12676. }
  12677. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12678. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12679. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12680. groupCostMap = groupCostMap.Select(x =>
  12681. {
  12682. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12683. {
  12684. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12685. }
  12686. return x;
  12687. }).ToList();
  12688. //GroupCostParameter.Add(new
  12689. // Grp_GroupCostParameter());
  12690. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12691. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12692. return Ok(JsonView(new
  12693. {
  12694. groupList,
  12695. groupInfo,
  12696. groupChecks,
  12697. groupCost = groupCostMap,
  12698. hotelNumber,
  12699. GroupCostParameter = GroupCostParameterMap,
  12700. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12701. {
  12702. x.VisaCountry,
  12703. x.VisaPrice,
  12704. x.Id,
  12705. }).ToList(),
  12706. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12707. blackCodeIsTrue = create.Code == 0 ? true : false,
  12708. hotelIsTrue = hotelIsTrue,
  12709. }));
  12710. }
  12711. /// <summary>
  12712. /// 团组成本信息保存
  12713. /// </summary>
  12714. /// <param name="dto"></param>
  12715. /// <returns></returns>
  12716. [HttpPost]
  12717. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12718. {
  12719. if (dto.Diid <= 0 || dto.Userid <= 0)
  12720. {
  12721. return Ok(JsonView(false));
  12722. }
  12723. JsonView jw = null;
  12724. bool isTrue = false;
  12725. #region 复制团组成本
  12726. //if (dto.Diid == 2581)
  12727. //{
  12728. // dto.Diid = 2599;
  12729. // dto.CheckBoxs.ForEach(x =>
  12730. // {
  12731. // x.Diid = 2599;
  12732. // });
  12733. // dto.GroupCosts.ForEach(x =>
  12734. // {
  12735. // x.Diid = 2599;
  12736. // });
  12737. // dto.CostTypeHotelNumbers.ForEach(x =>
  12738. // {
  12739. // x.Diid = 2599;
  12740. // });
  12741. // dto.GroupCostParameters.ForEach(x =>
  12742. // {
  12743. // x.DiId = 2599;
  12744. // });
  12745. //}
  12746. #endregion
  12747. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12748. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12749. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12750. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12751. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12752. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12753. try
  12754. {
  12755. _sqlSugar.BeginTran();
  12756. isTrue = await _GroupCostRepository.
  12757. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12758. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12759. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12760. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12761. _sqlSugar.CommitTran();
  12762. jw = JsonView(true, "保存成功!", isTrue);
  12763. }
  12764. catch (Exception)
  12765. {
  12766. _sqlSugar.RollbackTran();
  12767. jw = JsonView(false);
  12768. }
  12769. return Ok(jw);
  12770. }
  12771. /// <summary>
  12772. /// 司兼导数据
  12773. /// </summary>
  12774. /// <param name="dto"></param>
  12775. /// <returns></returns>
  12776. [HttpPost]
  12777. public IActionResult GetCarGuides(CarGuidesDto dto)
  12778. {
  12779. JsonView jw = null;
  12780. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12781. jw = JsonView(true, "获取成功!", Data);
  12782. return Ok(jw);
  12783. }
  12784. /// <summary>
  12785. /// 导游数据
  12786. /// </summary>
  12787. /// <param name="dto"></param>
  12788. /// <returns></returns>
  12789. [HttpPost]
  12790. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12791. {
  12792. JsonView jw = null;
  12793. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12794. // 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
  12795. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12796. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12797. jw = JsonView(true, "获取成功!", Data);
  12798. return Ok(jw);
  12799. }
  12800. /// <summary>
  12801. /// 成本车数据
  12802. /// </summary>
  12803. /// <param name="dto"></param>
  12804. /// <returns></returns>
  12805. [HttpPost]
  12806. public IActionResult GetCarInfo(CarGuidesDto dto)
  12807. {
  12808. JsonView jw = null;
  12809. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12810. jw = JsonView(true, "获取成功!", Data);
  12811. return Ok(jw);
  12812. }
  12813. /// <summary>
  12814. /// 景点数据
  12815. /// </summary>
  12816. /// <param name="dto"></param>
  12817. /// <returns></returns>
  12818. [HttpPost]
  12819. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12820. {
  12821. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12822. return Ok(JsonView(true, "获取成功!", Data));
  12823. }
  12824. /// <summary>
  12825. /// 成本通知
  12826. /// </summary>
  12827. /// <param name="dto"></param>
  12828. /// <returns></returns>
  12829. [HttpPost]
  12830. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12831. {
  12832. if (dto.Diid < 0)
  12833. {
  12834. return Ok(JsonView(false));
  12835. }
  12836. JsonView jw = null;
  12837. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12838. if (GroupCostParameter != null)
  12839. {
  12840. int IsShare = 0;
  12841. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12842. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12843. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12844. string msg = string.Empty;
  12845. if (isTrue)
  12846. {
  12847. if (IsShare == 0)
  12848. {
  12849. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12850. }
  12851. else
  12852. {
  12853. #region 企微通知对应岗位用户
  12854. try
  12855. {
  12856. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12857. }
  12858. catch (Exception ex)
  12859. {
  12860. }
  12861. #endregion
  12862. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12863. }
  12864. jw = JsonView(isTrue, msg, new { IsShare });
  12865. }
  12866. else
  12867. {
  12868. msg = "修改失败!";
  12869. jw = JsonView(isTrue, msg);
  12870. }
  12871. }
  12872. else
  12873. {
  12874. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12875. }
  12876. return Ok(jw);
  12877. }
  12878. /// <summary>
  12879. /// 导出报价单
  12880. /// </summary>
  12881. /// <param name="dto"></param>
  12882. /// <returns></returns>
  12883. [HttpPost]
  12884. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12885. {
  12886. if (dto.Diid == 0)
  12887. {
  12888. return Ok(JsonView(false, "请传递团组id"));
  12889. }
  12890. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12891. if (deleInfo.Code != 0)
  12892. {
  12893. return Ok(JsonView(false, "团组信息查询失败!"));
  12894. }
  12895. var di = deleInfo.Data as DelegationInfoWebView;
  12896. if (di != null)
  12897. {
  12898. di.TeamName = di.TeamName.Replace("|", "、");
  12899. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12900. //文件名
  12901. string strFileName = di.TeamName + "-收款账单.doc";
  12902. //获取模板
  12903. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12904. //载入模板
  12905. Document doc = new Document(tmppath);
  12906. decimal TotalPrice = 0.00M;
  12907. string itemStr = string.Empty;
  12908. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12909. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12910. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12911. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12912. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12913. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12914. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12915. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12916. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12917. foreach (var cost in groupCostType)
  12918. {
  12919. var List = cost.ToList();
  12920. if (cost.Key == "A")
  12921. {
  12922. foreach (var ListItem in List)
  12923. {
  12924. if (ListItem.number > 0)
  12925. {
  12926. if (ListItem.code.Contains("TBR"))
  12927. {
  12928. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12929. }
  12930. else
  12931. {
  12932. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12933. }
  12934. TotalPrice += (ListItem.number * ListItem.price);
  12935. }
  12936. }
  12937. }
  12938. else
  12939. {
  12940. itemStr = itemStr.Insert(0, "A段\r\n");
  12941. itemStr += "B段\r\n";
  12942. foreach (var ListItem in List)
  12943. {
  12944. if (ListItem.number > 0)
  12945. {
  12946. if (ListItem.code.Contains("TBR"))
  12947. {
  12948. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12949. }
  12950. else
  12951. {
  12952. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12953. }
  12954. TotalPrice += (ListItem.number * ListItem.price);
  12955. }
  12956. }
  12957. }
  12958. }
  12959. #region 替换Word模板书签内容
  12960. Dictionary<string, string> marks = new Dictionary<string, string>();
  12961. marks.Add("To", di.ClientUnit);//付款方
  12962. marks.Add("ToTel", di.TellPhone);//付款方电话
  12963. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12964. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12965. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12966. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12967. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12968. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12969. marks.Add("PayItemContent", itemStr);//详细信息
  12970. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12971. #endregion
  12972. ////注
  12973. //if (doc.Range.Bookmarks["Attention"] != null)
  12974. //{
  12975. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12976. // mark.Text = frList[0].Attention;
  12977. //}
  12978. foreach (var item in marks.Keys)
  12979. {
  12980. if (doc.Range.Bookmarks[item] != null)
  12981. {
  12982. Bookmark mark = doc.Range.Bookmarks[item];
  12983. mark.Text = marks[item];
  12984. }
  12985. }
  12986. byte[] bytes = null;
  12987. using (MemoryStream stream = new MemoryStream())
  12988. {
  12989. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12990. bytes = stream.ToArray();
  12991. }
  12992. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12993. return Ok(JsonView(true, "", new
  12994. {
  12995. Data = bytes,
  12996. strFileName,
  12997. }));
  12998. }
  12999. else
  13000. {
  13001. return Ok(JsonView(false, "团组信息不存在!"));
  13002. }
  13003. }
  13004. /// <summary>
  13005. /// 导出团组成本
  13006. /// </summary>
  13007. /// <param name="dto"></param>
  13008. /// <returns></returns>
  13009. [HttpPost]
  13010. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  13011. {
  13012. var jw = JsonView(false);
  13013. if (dto.Diid == 0)
  13014. {
  13015. return Ok(JsonView(false, "请传递团组id"));
  13016. }
  13017. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13018. if (deleInfo.Code != 0)
  13019. {
  13020. return Ok(JsonView(false, "团组信息查询失败!"));
  13021. }
  13022. var di = deleInfo.Data as DelegationInfoWebView;
  13023. if (di == null)
  13024. {
  13025. return Ok(JsonView(false, "团组信息查询失败!"));
  13026. }
  13027. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  13028. WorkbookDesigner designer = new WorkbookDesigner();
  13029. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  13030. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  13031. for (int i = 0; i < List_GC.Count; i++)
  13032. {
  13033. GroupCost_Excel gc = new GroupCost_Excel();
  13034. gc.Id = List_GC[i].Id;
  13035. gc.Diid = List_GC[i].Diid.ToString();
  13036. gc.DAY = List_GC[i].DAY;
  13037. string week = "";
  13038. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  13039. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  13040. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  13041. gc.ITIN = List_GC[i].ITIN;
  13042. gc.CarType = List_GC[i].CarType;
  13043. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  13044. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  13045. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  13046. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  13047. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  13048. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  13049. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  13050. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  13051. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  13052. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  13053. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  13054. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  13055. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13056. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13057. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  13058. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  13059. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  13060. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  13061. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  13062. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  13063. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  13064. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  13065. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  13066. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  13067. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  13068. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  13069. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  13070. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  13071. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  13072. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  13073. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  13074. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  13075. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  13076. List_GC1.Add(gc);
  13077. }
  13078. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  13079. dt.TableName = "TB";
  13080. //报表标题等不用dt的值
  13081. designer.SetDataSource("TeamName", dto.title.TeamName);
  13082. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  13083. designer.SetDataSource("Tax", dto.title.Tax);
  13084. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  13085. designer.SetDataSource("Currency", dto.title.Currency);
  13086. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  13087. designer.SetDataSource("Rate", dto.title.Rate);
  13088. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  13089. var Aparams = hotels.Find(x => x.Type == "Default");
  13090. if (Aparams == null)
  13091. {
  13092. return Ok(jw);
  13093. }
  13094. //酒店数量
  13095. var txtSGRNumber = Aparams.SGR.ToString();
  13096. var txtTBRNumber = Aparams.TBR.ToString();
  13097. var txtJSESNumber = Aparams.JSES.ToString();
  13098. var txtSUITENumbe = Aparams.SUITE.ToString();
  13099. if (dto.costType == "B")
  13100. {
  13101. Aparams = hotels.Find(x => x.Type == "A");
  13102. var Bparams = hotels.Find(x => x.Type == "B");
  13103. if (Aparams == null || Bparams == null)
  13104. {
  13105. return Ok(jw);
  13106. }
  13107. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  13108. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  13109. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  13110. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  13111. }
  13112. designer.SetDataSource("SGRNumber", txtSGRNumber);
  13113. designer.SetDataSource("TBRNumber", txtTBRNumber);
  13114. designer.SetDataSource("JSESNumber", txtJSESNumber);
  13115. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  13116. var ws = designer.Workbook.Worksheets[0];
  13117. int Row = List_GC.Count;
  13118. int startIndex = 11;
  13119. int HideRows = 0;
  13120. List<int> hideRowsList = new List<int>();
  13121. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  13122. #region A段left数据
  13123. var left = dto.leftInfo.Find(x => x.Type == "A");
  13124. if (left == null)
  13125. {
  13126. return Ok(jw);
  13127. }
  13128. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  13129. if (leftBindData != null)
  13130. {
  13131. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  13132. designer.SetDataSource("VisaRS", leftBindData.rs);
  13133. designer.SetDataSource("VisaXS", leftBindData.xs);
  13134. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13135. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13136. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13137. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13138. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13139. }
  13140. else
  13141. {
  13142. hideRowsList.Add(Row + startIndex + HideRows);
  13143. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13144. }
  13145. HideRows += 2;
  13146. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  13147. if (leftBindData != null)
  13148. {
  13149. designer.SetDataSource("BXDRCB", leftBindData.cb);
  13150. designer.SetDataSource("BXRS", leftBindData.rs);
  13151. designer.SetDataSource("BXXS", leftBindData.xs);
  13152. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13153. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13154. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13155. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13156. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13157. }
  13158. else
  13159. {
  13160. hideRowsList.Add(Row + startIndex + HideRows);
  13161. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13162. }
  13163. HideRows += 2;
  13164. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13165. if (leftBindData != null)
  13166. {
  13167. designer.SetDataSource("HSDRCB", leftBindData.cb);
  13168. designer.SetDataSource("HSRS", leftBindData.rs);
  13169. designer.SetDataSource("HSXS", leftBindData.xs);
  13170. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13171. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13172. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13173. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13174. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13175. }
  13176. else
  13177. {
  13178. hideRowsList.Add(Row + startIndex + HideRows);
  13179. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13180. }
  13181. HideRows += 2;
  13182. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13183. if (leftBindData != null)
  13184. {
  13185. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  13186. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  13187. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  13188. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13189. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13190. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13191. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13192. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13193. }
  13194. else
  13195. {
  13196. hideRowsList.Add(Row + startIndex + HideRows);
  13197. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13198. }
  13199. HideRows += 2;
  13200. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13201. if (leftBindData != null)
  13202. {
  13203. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  13204. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  13205. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  13206. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13207. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13208. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13209. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13210. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13211. }
  13212. else
  13213. {
  13214. hideRowsList.Add(Row + startIndex + HideRows);
  13215. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13216. }
  13217. HideRows += 2;
  13218. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13219. if (leftBindData != null)
  13220. {
  13221. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  13222. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  13223. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  13224. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13225. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13226. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13227. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13228. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13229. }
  13230. else
  13231. {
  13232. hideRowsList.Add(Row + startIndex + HideRows);
  13233. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13234. }
  13235. HideRows += 2;
  13236. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13237. if (leftBindData != null)
  13238. {
  13239. ////TBR
  13240. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  13241. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  13242. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  13243. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13244. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13245. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13246. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13247. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13248. }
  13249. else
  13250. {
  13251. hideRowsList.Add(Row + startIndex + HideRows);
  13252. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13253. }
  13254. HideRows += 2;
  13255. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13256. if (leftBindData != null)
  13257. {
  13258. ////SGR
  13259. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  13260. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  13261. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  13262. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13263. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13264. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13265. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13266. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13267. }
  13268. else
  13269. {
  13270. hideRowsList.Add(Row + startIndex + HideRows);
  13271. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13272. }
  13273. HideRows += 2;
  13274. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13275. if (leftBindData != null)
  13276. {
  13277. ////JS/ES
  13278. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  13279. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  13280. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  13281. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13282. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13283. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13284. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13285. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13286. }
  13287. else
  13288. {
  13289. hideRowsList.Add(Row + startIndex + HideRows);
  13290. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13291. }
  13292. HideRows += 2;
  13293. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13294. if (leftBindData != null)
  13295. {
  13296. ////SUITE
  13297. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  13298. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  13299. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  13300. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13301. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13302. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13303. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13304. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13305. }
  13306. else
  13307. {
  13308. hideRowsList.Add(Row + startIndex + HideRows);
  13309. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13310. }
  13311. HideRows += 2;
  13312. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13313. if (leftBindData != null)
  13314. {
  13315. designer.SetDataSource("DJDRCB", leftBindData.cb);
  13316. designer.SetDataSource("DJRS", leftBindData.rs);
  13317. designer.SetDataSource("DJXS", leftBindData.xs);
  13318. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13319. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13320. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13321. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13322. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13323. }
  13324. else
  13325. {
  13326. hideRowsList.Add(Row + startIndex + HideRows);
  13327. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13328. }
  13329. HideRows += 2;
  13330. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13331. if (leftBindData != null)
  13332. {
  13333. designer.SetDataSource("HCPCB", leftBindData.cb);
  13334. designer.SetDataSource("HCPRS", leftBindData.rs);
  13335. designer.SetDataSource("HCPXS", leftBindData.xs);
  13336. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13337. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13338. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13339. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13340. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13341. }
  13342. else
  13343. {
  13344. hideRowsList.Add(Row + startIndex + HideRows);
  13345. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13346. }
  13347. HideRows += 2;
  13348. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13349. if (leftBindData != null)
  13350. {
  13351. designer.SetDataSource("CPCB", leftBindData.cb);
  13352. designer.SetDataSource("CPRS", leftBindData.rs);
  13353. designer.SetDataSource("CPXS", leftBindData.xs);
  13354. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13355. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13356. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13357. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13358. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13359. }
  13360. else
  13361. {
  13362. hideRowsList.Add(Row + startIndex + HideRows);
  13363. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13364. }
  13365. HideRows += 2;
  13366. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13367. if (leftBindData != null)
  13368. {
  13369. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13370. designer.SetDataSource("GWRS", leftBindData.rs);
  13371. designer.SetDataSource("GWXS", leftBindData.xs);
  13372. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13373. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13374. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13375. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13376. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13377. }
  13378. else
  13379. {
  13380. hideRowsList.Add(Row + startIndex + HideRows);
  13381. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13382. }
  13383. HideRows += 2;
  13384. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13385. if (leftBindData != null)
  13386. {
  13387. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13388. designer.SetDataSource("LYJRS", leftBindData.rs);
  13389. designer.SetDataSource("LYJXS", leftBindData.xs);
  13390. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13391. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13392. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13393. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13394. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13395. }
  13396. else
  13397. {
  13398. hideRowsList.Add(Row + startIndex + HideRows);
  13399. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13400. }
  13401. #endregion
  13402. #region A段Right信息
  13403. var right = dto.rightInfo.Find(x => x.Type == "A");
  13404. if (right == null)
  13405. {
  13406. return Ok(jw);
  13407. }
  13408. HideRows += 4;
  13409. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13410. if (rightBindData != null)
  13411. {
  13412. //经济舱 + 双人间 TBR
  13413. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13414. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13415. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13416. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13417. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13418. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13419. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13420. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13421. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13422. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13423. }
  13424. else
  13425. {
  13426. hideRowsList.Add(Row + startIndex + HideRows);
  13427. }
  13428. HideRows += 2;
  13429. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13430. if (rightBindData != null)
  13431. {
  13432. //经济舱 + 单人间 SGR
  13433. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13434. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13435. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13436. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13437. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13438. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13439. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13440. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13441. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13442. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13443. }
  13444. else
  13445. {
  13446. hideRowsList.Add(Row + startIndex + HideRows);
  13447. }
  13448. HideRows += 2;
  13449. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13450. if (rightBindData != null)
  13451. {
  13452. //公务舱 + 单人间 SGR
  13453. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13454. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13455. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13456. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13457. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13458. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13459. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13460. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13461. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13462. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13463. }
  13464. else
  13465. {
  13466. hideRowsList.Add(Row + startIndex + HideRows);
  13467. }
  13468. HideRows += 2;
  13469. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13470. if (rightBindData != null)
  13471. {
  13472. //公务舱 + 小套房 JSES
  13473. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13474. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13475. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13476. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13477. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13478. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13479. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13480. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13481. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13482. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13483. }
  13484. else
  13485. {
  13486. hideRowsList.Add(Row + startIndex + HideRows);
  13487. }
  13488. HideRows += 2;
  13489. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13490. if (rightBindData != null)
  13491. {
  13492. //公务舱 + 小套房 JSES
  13493. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13494. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13495. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13496. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13497. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13498. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13499. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13500. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13501. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13502. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13503. }
  13504. else
  13505. {
  13506. hideRowsList.Add(Row + startIndex + HideRows);
  13507. }
  13508. HideRows += 2;
  13509. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13510. if (rightBindData != null)
  13511. {
  13512. //经济舱 + 大套房
  13513. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13514. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13515. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13516. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13517. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13518. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13519. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13520. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13521. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13522. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13523. }
  13524. else
  13525. {
  13526. hideRowsList.Add(Row + startIndex + HideRows);
  13527. }
  13528. HideRows += 2;
  13529. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13530. if (rightBindData != null)
  13531. {
  13532. //头等舱 + 小套房 JSES
  13533. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13534. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13535. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13536. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13537. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13538. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13539. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13540. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13541. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13542. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13543. }
  13544. else
  13545. {
  13546. hideRowsList.Add(Row + startIndex + HideRows);
  13547. }
  13548. HideRows += 2;
  13549. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13550. if (rightBindData != null)
  13551. {
  13552. //头等舱 + 大套房
  13553. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13554. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13555. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13556. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13557. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13558. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13559. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13560. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13561. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13562. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13563. }
  13564. else
  13565. {
  13566. hideRowsList.Add(Row + startIndex + HideRows);
  13567. }
  13568. #endregion
  13569. #region B段标题清空
  13570. designer.SetDataSource("CostBDRCB", "");
  13571. designer.SetDataSource("CostBRS", "");
  13572. designer.SetDataSource("CostBXS", "");
  13573. designer.SetDataSource("CostBZCB", "");
  13574. designer.SetDataSource("CostBDRBJ", "");
  13575. designer.SetDataSource("CostBZBJ", "");
  13576. designer.SetDataSource("CostBDRLR", "");
  13577. designer.SetDataSource("CostBZLR", "");
  13578. designer.SetDataSource("CostBDRCBOM", "");
  13579. designer.SetDataSource("CostBRSOM", "");
  13580. designer.SetDataSource("CostBZCBOM", "");
  13581. designer.SetDataSource("CostBDRBJOM", "");
  13582. designer.SetDataSource("CostBZBJOM", "");
  13583. designer.SetDataSource("CostBDRLROM", "");
  13584. designer.SetDataSource("CostBZLROM", "");
  13585. #endregion
  13586. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13587. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13588. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13589. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13590. designer.SetDataSource("DJName", "地接(CNY)");
  13591. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13592. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13593. designer.SetDataSource("GWName", "公务(CNY)");
  13594. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13595. designer.SetDataSource("LYJName", "零用金(CNY)");
  13596. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13597. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13598. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13599. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13600. designer.SetDataSource("BXName", "保险(CNY)");
  13601. designer.SetDataSource("VisaName", "签证(CNY)");
  13602. #region B段基本数据
  13603. if (dto.costType == "B")
  13604. {
  13605. left = dto.leftInfo.Find(x => x.Type == "B");
  13606. if (left == null)
  13607. {
  13608. return Ok(jw);
  13609. }
  13610. #region B段left数据
  13611. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13612. if (leftBindData != null)
  13613. {
  13614. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13615. designer.SetDataSource("BHSRS", leftBindData.rs);
  13616. designer.SetDataSource("BHSXS", leftBindData.xs);
  13617. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13618. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13619. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13620. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13621. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13622. }
  13623. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13624. if (leftBindData != null)
  13625. {
  13626. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13627. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13628. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13629. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13630. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13631. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13632. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13633. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13634. }
  13635. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13636. if (leftBindData != null)
  13637. {
  13638. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13639. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13640. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13641. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13642. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13643. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13644. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13645. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13646. }
  13647. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13648. if (leftBindData != null)
  13649. {
  13650. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13651. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13652. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13653. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13654. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13655. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13656. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13657. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13658. }
  13659. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13660. if (leftBindData != null)
  13661. {
  13662. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13663. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13664. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13665. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13666. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13667. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13668. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13669. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13670. }
  13671. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13672. if (leftBindData != null)
  13673. {
  13674. designer.SetDataSource("BCPCB", leftBindData.cb);
  13675. designer.SetDataSource("BCPRS", leftBindData.rs);
  13676. designer.SetDataSource("BCPXS", leftBindData.xs);
  13677. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13678. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13679. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13680. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13681. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13682. }
  13683. //TBR
  13684. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13685. if (leftBindData != null)
  13686. {
  13687. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13688. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13689. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13690. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13691. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13692. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13693. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13694. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13695. }
  13696. //SGR
  13697. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13698. if (leftBindData != null)
  13699. {
  13700. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13701. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13702. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13703. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13704. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13705. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13706. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13707. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13708. }
  13709. //JS/ES
  13710. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13711. if (leftBindData != null)
  13712. {
  13713. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13714. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13715. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13716. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13717. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13718. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13719. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13720. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13721. }
  13722. //SUITE
  13723. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13724. if (leftBindData != null)
  13725. {
  13726. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13727. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13728. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13729. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13730. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13731. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13732. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13733. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13734. }
  13735. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13736. if (leftBindData != null)
  13737. {
  13738. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13739. designer.SetDataSource("BDJRS", leftBindData.rs);
  13740. designer.SetDataSource("BDJXS", leftBindData.xs);
  13741. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13742. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13743. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13744. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13745. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13746. }
  13747. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13748. if (leftBindData != null)
  13749. {
  13750. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13751. designer.SetDataSource("BGWRS", leftBindData.rs);
  13752. designer.SetDataSource("BGWXS", leftBindData.xs);
  13753. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13754. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13755. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13756. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13757. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13758. }
  13759. #region 优化方案
  13760. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13761. //excelBind.Add("零用金", new {
  13762. //cb="",
  13763. //rs="",
  13764. //xs ="",
  13765. //zcb = "",
  13766. //});
  13767. #endregion
  13768. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13769. if (leftBindData != null)
  13770. {
  13771. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13772. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13773. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13774. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13775. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13776. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13777. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13778. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13779. }
  13780. #endregion
  13781. #region B段Right信息
  13782. right = dto.rightInfo.Find(x => x.Type == "B");
  13783. if (right == null)
  13784. {
  13785. return Ok(jw);
  13786. }
  13787. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13788. if (rightBindData != null)
  13789. {
  13790. //经济舱 + 双人间 TBR
  13791. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13792. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13793. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13794. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13795. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13796. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13797. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13798. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13799. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13800. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13801. }
  13802. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13803. if (rightBindData != null)
  13804. {
  13805. //经济舱 + 单人间 SGR
  13806. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13807. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13808. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13809. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13810. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13811. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13812. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13813. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13814. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13815. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13816. }
  13817. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13818. if (rightBindData != null)
  13819. {
  13820. //公务舱 + 单人间 SGR
  13821. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13822. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13823. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13824. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13825. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13826. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13827. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13828. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13829. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13830. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13831. }
  13832. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13833. if (rightBindData != null)
  13834. {
  13835. //公务舱 + 小套房 JSES
  13836. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13837. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13838. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13839. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13840. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13841. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13842. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13843. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13844. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13845. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13846. }
  13847. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13848. if (rightBindData != null)
  13849. {
  13850. //公务舱 + 小套房 JSES
  13851. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13852. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13853. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13854. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13855. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13856. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13857. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13858. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13859. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13860. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13861. }
  13862. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13863. if (rightBindData != null)
  13864. {
  13865. //经济舱 + 大套房
  13866. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13867. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13868. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13869. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13870. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13871. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13872. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13873. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13874. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13875. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13876. }
  13877. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13878. if (rightBindData != null)
  13879. {
  13880. //头等舱 + 小套房 JSES
  13881. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13882. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13883. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13884. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13885. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13886. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13887. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13888. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13889. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13890. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13891. }
  13892. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13893. if (rightBindData != null)
  13894. {
  13895. //头等舱 + 大套房
  13896. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13897. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13898. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13899. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13900. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13901. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13902. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13903. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13904. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13905. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13906. }
  13907. #endregion
  13908. #region 标题
  13909. designer.SetDataSource("CostBDRCB", "单人成本");
  13910. designer.SetDataSource("CostBRS", "人数");
  13911. designer.SetDataSource("CostBXS", "系数");
  13912. designer.SetDataSource("CostBZCB", "总成本");
  13913. designer.SetDataSource("CostBDRBJ", "单人报价");
  13914. designer.SetDataSource("CostBZBJ", "总报价");
  13915. designer.SetDataSource("CostBDRLR", "单人利润");
  13916. designer.SetDataSource("CostBZLR", "总利润");
  13917. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13918. designer.SetDataSource("CostBRSOM", "人数");
  13919. designer.SetDataSource("CostBZCBOM", "总成本");
  13920. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13921. designer.SetDataSource("CostBZBJOM", "总报价");
  13922. designer.SetDataSource("CostBDRLROM", "单人利润");
  13923. designer.SetDataSource("CostBZLROM", "总利润");
  13924. #endregion
  13925. }
  13926. #endregion
  13927. designer.SetDataSource("TzZCB2", TzZCB2);
  13928. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13929. designer.SetDataSource("TzZLR2", TzZLR2);
  13930. string[] dataSourceKeys = new string[]
  13931. {
  13932. "VF",
  13933. "TGS",
  13934. "TGOF",
  13935. "TGM",
  13936. "TGA",
  13937. "TGTF",
  13938. "TGEF",
  13939. "CFM",
  13940. "CFOF",
  13941. "B",
  13942. "L",
  13943. "D",
  13944. "TBR",
  13945. "SGR",
  13946. "JSES",
  13947. "Suite",
  13948. "TV",
  13949. "1L",
  13950. "IF",
  13951. "EF",
  13952. "BRF",
  13953. "TE",
  13954. "TGT",
  13955. "DRVT",
  13956. "PC",
  13957. "TLF",
  13958. "ECT"
  13959. };
  13960. foreach (var item in dataSourceKeys)
  13961. {
  13962. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13963. if (find != null)
  13964. {
  13965. designer.SetDataSource(item, find.text);
  13966. }
  13967. else
  13968. {
  13969. designer.SetDataSource(item, 0);
  13970. }
  13971. }
  13972. designer.SetDataSource(dt);
  13973. //根据数据源处理生成报表内容
  13974. designer.Process();
  13975. designer.Workbook.Worksheets[0].Name = "清单";
  13976. Worksheet sheet = designer.Workbook.Worksheets[0];
  13977. foreach (var Rowindex in hideRowsList)
  13978. {
  13979. ws.Cells.HideRows(Rowindex, 2);
  13980. }
  13981. byte[] bytes = null;
  13982. string strFileName = di.TeamName + "-团组-成本.xls";
  13983. using (MemoryStream stream = new MemoryStream())
  13984. {
  13985. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13986. bytes = stream.ToArray();
  13987. }
  13988. return Ok(JsonView(true, "", new
  13989. {
  13990. Data = bytes,
  13991. strFileName,
  13992. }));
  13993. }
  13994. /// <summary>
  13995. /// 导出客户报表
  13996. /// </summary>
  13997. /// <returns></returns>
  13998. [HttpPost]
  13999. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  14000. {
  14001. var jw = JsonView(false);
  14002. if (dto.Diid == 0)
  14003. {
  14004. return Ok(JsonView(false, "请传递团组id"));
  14005. }
  14006. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14007. if (deleInfo.Code != 0)
  14008. {
  14009. return Ok(JsonView(false, "团组信息查询失败!"));
  14010. }
  14011. var di = deleInfo.Data as DelegationInfoWebView;
  14012. if (di == null)
  14013. {
  14014. return Ok(JsonView(false, "团组信息查询失败!"));
  14015. }
  14016. //文件名
  14017. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  14018. //获取模板
  14019. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  14020. //载入模板
  14021. Document doc = new Document(tmppath);
  14022. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  14023. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  14024. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  14025. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  14026. var AParameter = ParameterList.Find(x => x.CostType == "A");
  14027. var BParameter = ParameterList.Find(x => x.CostType == "B");
  14028. if (AParameter == null)
  14029. {
  14030. return Ok(JsonView(false, "系数不存在!"));
  14031. }
  14032. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  14033. , TzAirDesc, TzZCost;
  14034. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  14035. = TzAirDesc = TzZCost = string.Empty;
  14036. TzNumber = AParameter.CostTypenumber.ToString();
  14037. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  14038. CarGuides1 = dto.CarGuides1;
  14039. Meal = dto.Meal;
  14040. SubsidizedMeals = dto.SubsidizedMeals;
  14041. NightRepair = dto.NightRepair;
  14042. AttractionsTickets = dto.AttractionsTickets;
  14043. MiscellaneousFees = dto.MiscellaneousFees;
  14044. ATip = dto.ATip;
  14045. TzHotelDesc = "";
  14046. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  14047. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  14048. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  14049. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  14050. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  14051. TzAirDesc = "";
  14052. TzZCost = dto.TzZCost;
  14053. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  14054. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  14055. var index = 1;
  14056. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  14057. foreach (var item in TzHotelDescArr)
  14058. {
  14059. if (AinfoArr != null)
  14060. {
  14061. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14062. if (Ainfo != null)
  14063. {
  14064. if (int.Parse(Ainfo.rs) <= 0)
  14065. {
  14066. continue;
  14067. }
  14068. var hotelText = string.Empty;
  14069. switch (item)
  14070. {
  14071. case "SGR":
  14072. hotelText = "单人间";
  14073. break;
  14074. case "JSES":
  14075. hotelText = "小套房";
  14076. break;
  14077. case "SUITE":
  14078. hotelText = "套房";
  14079. break;
  14080. case "TBR":
  14081. hotelText = "双人间";
  14082. break;
  14083. }
  14084. if (item != "TBR")
  14085. {
  14086. 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";
  14087. }
  14088. else
  14089. {
  14090. 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";
  14091. }
  14092. index++;
  14093. }
  14094. }
  14095. }
  14096. index = 1;
  14097. foreach (var item in TzAirDescArr)
  14098. {
  14099. if (AinfoArr != null)
  14100. {
  14101. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14102. if (Ainfo != null)
  14103. {
  14104. if (int.Parse(Ainfo.rs) <= 0)
  14105. {
  14106. continue;
  14107. }
  14108. 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";
  14109. index++;
  14110. }
  14111. }
  14112. }
  14113. if (dto.costType == "B")
  14114. {
  14115. if (BParameter == null)
  14116. {
  14117. return Ok(JsonView(false, "B段系数不存在!"));
  14118. }
  14119. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  14120. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  14121. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  14122. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  14123. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  14124. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  14125. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  14126. foreach (var item in TzHotelDescArr)
  14127. {
  14128. if (AinfoArr != null)
  14129. {
  14130. TzHotelDesc += "B段信息 \r\n";
  14131. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14132. if (Ainfo != null)
  14133. {
  14134. if (int.Parse(Ainfo.rs) <= 0)
  14135. {
  14136. continue;
  14137. }
  14138. var hotelText = string.Empty;
  14139. switch (item)
  14140. {
  14141. case "SGR":
  14142. hotelText = "单人间";
  14143. break;
  14144. case "JSES":
  14145. hotelText = "小套房";
  14146. break;
  14147. case "SUITE":
  14148. hotelText = "套房";
  14149. break;
  14150. case "TBR":
  14151. hotelText = "双人间";
  14152. break;
  14153. }
  14154. if (item != "TBR")
  14155. {
  14156. 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";
  14157. }
  14158. else
  14159. {
  14160. 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";
  14161. }
  14162. index++;
  14163. }
  14164. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  14165. }
  14166. }
  14167. index = 1;
  14168. foreach (var item in TzAirDescArr)
  14169. {
  14170. if (AinfoArr != null)
  14171. {
  14172. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14173. if (Ainfo != null)
  14174. {
  14175. if (int.Parse(Ainfo.rs) <= 0)
  14176. {
  14177. continue;
  14178. }
  14179. 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";
  14180. index++;
  14181. }
  14182. }
  14183. }
  14184. }
  14185. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  14186. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  14187. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  14188. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  14189. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  14190. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  14191. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  14192. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  14193. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  14194. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  14195. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  14196. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  14197. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  14198. DickeyValue.Add("Visa", Visa); // 签证单人报价
  14199. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  14200. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  14201. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  14202. DickeyValue.Add("TzZCost", TzZCost);
  14203. foreach (var key in DickeyValue.Keys)
  14204. {
  14205. if (doc.Range.Bookmarks[key] != null)
  14206. {
  14207. Bookmark mark = doc.Range.Bookmarks[key];
  14208. mark.Text = DickeyValue[key];
  14209. }
  14210. }
  14211. byte[] bytes = null;
  14212. string strFileName = di.TeamName + "-客户报价.doc";
  14213. using (MemoryStream stream = new MemoryStream())
  14214. {
  14215. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14216. bytes = stream.ToArray();
  14217. }
  14218. return Ok(JsonView(true, "", new
  14219. {
  14220. Data = bytes,
  14221. strFileName,
  14222. }));
  14223. }
  14224. /// <summary>
  14225. /// 团组成本 各模块(酒店,地接,机票)成本提示
  14226. /// </summary>
  14227. /// <param name="dto"></param>
  14228. /// <returns></returns>
  14229. [HttpPost]
  14230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14231. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  14232. {
  14233. try
  14234. {
  14235. #region 参数验证
  14236. if (dto.DiId < 0)
  14237. {
  14238. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  14239. }
  14240. List<int> cTableIds = new List<int>() {
  14241. 76 ,//酒店预订
  14242. 77 ,//行程
  14243. 79 ,//车/导游地接
  14244. 80 ,//签证
  14245. 81 ,//邀请/公务活
  14246. 82 ,//团组客户保险
  14247. 85 ,//机票预订
  14248. 98 ,//其他款项
  14249. 285 ,//收款退还
  14250. 751 ,//酒店早餐
  14251. 1015 // 超支费用
  14252. };
  14253. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  14254. {
  14255. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  14256. }
  14257. #endregion
  14258. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  14259. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  14260. if (_GroupCostParameters.Count <= 0)
  14261. {
  14262. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  14263. }
  14264. if (_GroupCostParameters[0].IsShare == 0)
  14265. {
  14266. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  14267. }
  14268. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14269. //处理date为空问题
  14270. if (_GroupCosts.Count > 0)
  14271. {
  14272. for (int i = 0; i < _GroupCosts.Count; i++)
  14273. {
  14274. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  14275. {
  14276. if (i > 0)
  14277. {
  14278. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  14279. }
  14280. }
  14281. }
  14282. }
  14283. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  14284. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  14285. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  14286. string currCode = "";
  14287. #region currCode 验证
  14288. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  14289. if (isInt)
  14290. {
  14291. var currData = currDatas.Find(it => it.Id == intCurrency);
  14292. if (currData != null)
  14293. {
  14294. currCode = currData.Name;
  14295. }
  14296. }
  14297. else
  14298. {
  14299. currCode = _GroupCostParameters[0].Currency.Trim();
  14300. }
  14301. #endregion
  14302. //op,酒店单段模式存储
  14303. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  14304. {
  14305. CurrencyCode = currCode,
  14306. Rate = _GroupCostParameters[0].Rate,
  14307. CostType = _GroupCostParameters[0].CostType,
  14308. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  14309. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  14310. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  14311. };
  14312. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  14313. if (_GroupCostParameters.Count == 2)
  14314. {
  14315. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  14316. }
  14317. foreach (var item in _GroupCostParameters)
  14318. {
  14319. decimal _rate = 1;
  14320. decimal _rate1 = item.Rate;
  14321. decimal _scale = 1;
  14322. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  14323. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  14324. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  14325. //if (userInfo != null)
  14326. //{
  14327. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  14328. // {
  14329. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  14330. // {
  14331. // _scale = 1.00M;
  14332. // }
  14333. // }
  14334. //}
  14335. #endregion
  14336. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  14337. {
  14338. CurrencyCode = currCode,
  14339. Rate = _rate1,
  14340. CostType = item.CostType,
  14341. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  14342. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  14343. CostTypeNumber = item.CostTypenumber
  14344. };
  14345. if (_GroupCostParameters.Count > 1)
  14346. {
  14347. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  14348. }
  14349. else
  14350. {
  14351. modulePromptInfo.CostTypeNumber = item.LYJRS;
  14352. }
  14353. if (dto.CTable == 79)//
  14354. {
  14355. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14356. modulePromptInfo.TotalCost = item.DJCB;
  14357. }
  14358. List<string> costTypes = new List<string>() { "A", "B" };
  14359. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14360. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14361. if (_GroupCostsDuplicates.Count() == 1)
  14362. {
  14363. _GroupCostsTypeData = _GroupCosts;
  14364. }
  14365. else
  14366. {
  14367. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14368. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14369. }
  14370. /*
  14371. * 76 酒店预订
  14372. * 77 行程
  14373. * 79 车/导游地接
  14374. * 80 签证
  14375. * 81 邀请/公务活动
  14376. * 82 团组客户保险
  14377. * 85 机票预订
  14378. * 98 其他款项
  14379. * 285 收款退还
  14380. * 751 酒店早餐
  14381. * 1015 超支费用
  14382. */
  14383. switch (dto.CTable)
  14384. {
  14385. case 76: // 酒店预订
  14386. _ModuleSubPromptInfo.AddRange(
  14387. _GroupCostsTypeData.Select(it => new
  14388. {
  14389. it.DAY,
  14390. it.Date,
  14391. it.ACCON,
  14392. it.ITIN,
  14393. it.SGR,
  14394. it.TBR,
  14395. it.JS_ES,
  14396. it.Suite
  14397. })
  14398. );
  14399. break;
  14400. case 79: // 车/导游地接
  14401. _ModuleSubPromptInfo.AddRange(
  14402. _GroupCostsTypeData.Select(it => new
  14403. {
  14404. Date = it.Date, //日期
  14405. CarFee = it.CarCost * _rate * _scale, //车费用
  14406. CarType = it.CarType, //车型
  14407. DriverFee = it.CFS * _rate * _scale, //司机工资
  14408. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14409. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14410. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14411. GuideFee = it.TGS * _rate * _scale, //导游费用
  14412. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14413. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14414. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14415. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14416. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14417. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14418. Breakfast = it.B * _rate * _scale, //早餐费
  14419. Lunch = it.L * _rate * _scale, //午餐费
  14420. Dinner = it.D * _rate * _scale, //晚餐费
  14421. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14422. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14423. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14424. TicketFee = it.EF * _rate * _scale, //门票费
  14425. TicketRemark = it.EFR, //门票费描述
  14426. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14427. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14428. SpentCash = it.PC * _rate * _scale, //零用金
  14429. LeadersFee = it.TLF * _rate * _scale, //领队费
  14430. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14431. })
  14432. );
  14433. break;
  14434. case 85: // 机票
  14435. List<dynamic> datas = new List<dynamic>();
  14436. datas.Add(
  14437. new
  14438. {
  14439. AirType = "经济舱",
  14440. AirNum = item.JJCRS,
  14441. AirDRCB = item.JJCCB,
  14442. AirZCB = (item.JJCRS * item.JJCCB)
  14443. }
  14444. );
  14445. datas.Add(
  14446. new
  14447. {
  14448. AirType = "公务舱",
  14449. AirNum = item.GWCRS,
  14450. AirDRCB = item.GWCCB,
  14451. AirZCB = (item.GWCRS * item.GWCCB)
  14452. }
  14453. );
  14454. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14455. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14456. modulePromptInfo.Data = new
  14457. {
  14458. airFeeData = datas,
  14459. airInitData = initDatas
  14460. };
  14461. _ModulePromptInfos.Add(modulePromptInfo);
  14462. break;
  14463. default:
  14464. break;
  14465. }
  14466. }
  14467. if (dto.CTable != 85)
  14468. {
  14469. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14470. _ModulePromptInfos.Add(_ModulePromptInfo);
  14471. }
  14472. _view.ModulePromptInfos = _ModulePromptInfos;
  14473. return Ok(JsonView(true, "操作成功!", _view));
  14474. }
  14475. catch (Exception ex)
  14476. {
  14477. return Ok(JsonView(false, ex.Message));
  14478. }
  14479. }
  14480. /// <summary>
  14481. /// 根据黑屏代码重新生成行程
  14482. /// </summary>
  14483. /// <param name="dto"></param>
  14484. /// <returns></returns>
  14485. [HttpPost]
  14486. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14487. {
  14488. var jw = JsonView(false);
  14489. var Create = _GroupCostRepository.
  14490. CreateGroupCostByBlackCode(dto.Diid);
  14491. jw.Msg = Create.Msg;
  14492. if (Create.Code == 0)
  14493. {
  14494. jw.Code = 200;
  14495. jw.Data = new
  14496. {
  14497. groupCost = Create.Data,
  14498. blackCodeIsTrue = true
  14499. };
  14500. }
  14501. else
  14502. {
  14503. jw.Code = 400;
  14504. jw.Data = new
  14505. {
  14506. groupCost = Create.Data,
  14507. blackCodeIsTrue = false,
  14508. };
  14509. }
  14510. return Ok(jw);
  14511. }
  14512. /// <summary>
  14513. /// 成本获取OP历史车费用
  14514. /// </summary>
  14515. /// <param name="dto"></param>
  14516. /// <returns></returns>
  14517. [HttpPost]
  14518. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14519. {
  14520. var jw = JsonView(false);
  14521. try
  14522. {
  14523. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14524. //获取现有所有车的数据
  14525. if (!dto.Param.IsNullOrWhiteSpace())
  14526. {
  14527. string sql = $@"
  14528. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14529. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14530. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14531. 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
  14532. AND gctggr.ServiceEndTime is not NULL
  14533. ORDER by gctggrc.id DESC
  14534. ";
  14535. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14536. var numeberResult = await Task.Run(() =>
  14537. {
  14538. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14539. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14540. return numberArr;
  14541. });
  14542. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14543. foreach (var item in numeberResult)
  14544. {
  14545. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14546. {
  14547. Country = "数据异常!",
  14548. City = string.Empty,
  14549. };
  14550. item.Area = find.Country + " " + find.City;
  14551. }
  14552. dbResult.AddRange(numeberResult);
  14553. if (dto.Param.Contains("、"))
  14554. {
  14555. var sp = dto.Param.Split("、");
  14556. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14557. .Where(x =>
  14558. {
  14559. return System.Array.Exists(sp, e =>
  14560. {
  14561. bool where = false;
  14562. if (x.Area != null)
  14563. {
  14564. where = x.Area.Contains(e);
  14565. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14566. {
  14567. return false;
  14568. }
  14569. }
  14570. if (x.PriceName != null && !where)
  14571. {
  14572. where = x.PriceName.Contains(e);
  14573. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14574. {
  14575. return false;
  14576. }
  14577. }
  14578. return where;
  14579. });
  14580. }).ToList();
  14581. }
  14582. else
  14583. {
  14584. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14585. .Where(x =>
  14586. {
  14587. bool where = false;
  14588. if (x.Area != null)
  14589. {
  14590. where = x.Area.Contains(dto.Param);
  14591. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14592. {
  14593. return false;
  14594. }
  14595. }
  14596. if (x.PriceName != null && !where)
  14597. {
  14598. where = x.PriceName.Contains(dto.Param);
  14599. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14600. {
  14601. return false;
  14602. }
  14603. }
  14604. return where;
  14605. }
  14606. )
  14607. .ToList();
  14608. }
  14609. }
  14610. var view = dbResult.Select(x =>
  14611. {
  14612. decimal dp = 0.00M;
  14613. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14614. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14615. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14616. {
  14617. if (startB && endB)
  14618. {
  14619. var timesp = endD.Subtract(startD);
  14620. if ((timesp.Days + 1) != 0)
  14621. {
  14622. dp = x.Price / (timesp.Days + 1);
  14623. }
  14624. }
  14625. }
  14626. else
  14627. {
  14628. dp = x.Price;
  14629. }
  14630. return new
  14631. {
  14632. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14633. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14634. x.Area,
  14635. x.id,
  14636. price = x.Price.ToString("F2"),
  14637. x.PriceName,
  14638. x.PriceContent,
  14639. x.TeamName,
  14640. x.DatePrice,
  14641. dayPrice = dp.ToString("F2"),
  14642. };
  14643. }).OrderByDescending(x => x.id).ToList();
  14644. jw = JsonView(true, "获取成功!", view);
  14645. }
  14646. catch (Exception e)
  14647. {
  14648. jw = JsonView(false, e.Message);
  14649. }
  14650. return Ok(jw);
  14651. }
  14652. #endregion
  14653. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14654. /// <summary>
  14655. /// 酒店预订
  14656. /// 酒店费用列表 根据团组Id查询
  14657. /// </summary>
  14658. /// <param name="_dto"></param>
  14659. /// <returns></returns>
  14660. [HttpPost]
  14661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14662. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14663. {
  14664. #region 参数验证
  14665. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14666. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14667. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14668. #region 团组操作权限验证 76 酒店预定模块
  14669. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14670. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14671. #endregion
  14672. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14673. #region 页面操作权限验证
  14674. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14675. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14676. #endregion
  14677. #endregion
  14678. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14679. }
  14680. /// <summary>
  14681. /// 酒店预订
  14682. /// 基础数据
  14683. /// </summary>
  14684. /// <param name="_dto"></param>
  14685. /// <returns></returns>
  14686. [HttpPost]
  14687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14688. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14689. {
  14690. #region 参数验证
  14691. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14692. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14693. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14694. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14695. #region 页面操作权限验证
  14696. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14697. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14698. #endregion
  14699. #region 团组操作权限验证 76 酒店预定模块
  14700. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14701. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14702. #endregion
  14703. #endregion
  14704. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14705. }
  14706. /// <summary>
  14707. /// 酒店预订
  14708. /// 创建 入住卷号码
  14709. /// </summary>
  14710. /// <param name="_dto"></param>
  14711. /// <returns></returns>
  14712. [HttpPost]
  14713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14714. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14715. {
  14716. #region 参数验证
  14717. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14718. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14719. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14720. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14721. #region 页面操作权限验证
  14722. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14723. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14724. #endregion
  14725. #region 团组操作权限验证 76 酒店预定模块
  14726. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14727. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14728. #endregion
  14729. #endregion
  14730. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14731. if (data.Code != 0)
  14732. {
  14733. return Ok(JsonView(false, data.Msg));
  14734. }
  14735. return Ok(JsonView(true, data.Msg, data.Data));
  14736. }
  14737. /// <summary>
  14738. /// 酒店预订
  14739. /// 详情
  14740. /// </summary>
  14741. /// <param name="_dto"></param>
  14742. /// <returns></returns>
  14743. [HttpPost]
  14744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14745. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14746. {
  14747. #region 参数验证
  14748. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14749. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14750. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14751. #region 团组操作权限验证 76 酒店预定模块
  14752. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14753. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14754. #endregion
  14755. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14756. #region 页面操作权限验证
  14757. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14758. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14759. #endregion
  14760. #endregion
  14761. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14762. }
  14763. /// <summary>
  14764. /// 酒店预订
  14765. /// Add Or Edit
  14766. /// </summary>
  14767. /// <param name="_dto"></param>
  14768. /// <returns></returns>
  14769. [HttpPost]
  14770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14771. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14772. {
  14773. #region 参数验证
  14774. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14775. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14776. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14777. #region 团组操作权限验证 76 酒店预定模块
  14778. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14779. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14780. #endregion
  14781. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14782. #region 页面操作权限验证
  14783. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14784. if (_dto.Id == 0) // Add
  14785. {
  14786. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14787. }
  14788. else if (_dto.Id > 1) // Edit
  14789. {
  14790. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14791. }
  14792. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14793. #endregion
  14794. #endregion
  14795. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14796. if (_view.Code != 200)
  14797. {
  14798. return Ok(_view);
  14799. }
  14800. #region 成本无酒店价格数据进入超支
  14801. _sqlSugar.BeginTran();
  14802. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14803. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14804. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14805. for (int i = 0; i < groupCost.Count; i++)
  14806. {
  14807. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14808. {
  14809. groupCost[i].Date = groupCost[i - 1].Date;
  14810. }
  14811. }
  14812. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14813. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14814. List<Fin_GroupExtraCostDto_OP>();
  14815. if (start_Bool && end_Bool)
  14816. {
  14817. while (start_Time < end_Time)
  14818. {
  14819. foreach (var item in groupCost_Grp)
  14820. {
  14821. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14822. {
  14823. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14824. {
  14825. extraCostList.Add(new
  14826. Fin_GroupExtraCostDto_OP
  14827. {
  14828. Area = _dto.AreaId,
  14829. coefficient = 1.5M,
  14830. createUser = _dto.UserId,
  14831. currency = _dto.CardPriceCurrency,
  14832. diId = _dto.DiId,
  14833. ManagerConfirm = 0,
  14834. SupervisorConfirm = 0,
  14835. SYsupervisorConfirm = 0,
  14836. editType = 1,
  14837. PortType = 1,
  14838. price = _dto.CardPrice,
  14839. PriceCount = 1,
  14840. priceType = 1027,
  14841. priceDetailType = 1044,
  14842. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14843. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14844. });
  14845. }
  14846. }
  14847. }
  14848. start_Time = start_Time.AddDays(1);
  14849. }
  14850. }
  14851. if (extraCostList.Any())
  14852. {
  14853. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14854. }
  14855. _sqlSugar.CommitTran();
  14856. #endregion
  14857. #region 应用推送
  14858. try
  14859. {
  14860. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14861. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14862. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14863. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14864. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14865. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14866. var diId = _dto.DiId;
  14867. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14868. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14869. #region 操作记录
  14870. var opInfo = new Crm_TableOperationRecord()
  14871. {
  14872. TableName = "Grp_HotelReservations",
  14873. PortType = _dto.PortType,
  14874. DataId = hotelId,
  14875. CreateUserId = _dto.UserId
  14876. };
  14877. //var opStatus = OperationEnum.NoOperation;
  14878. if (_dto.Id < 1) //添加操作
  14879. {
  14880. opInfo.OperationItem = OperationEnum.Add;
  14881. }
  14882. else if (_dto.Id > 0)
  14883. {
  14884. opInfo.OperationItem = OperationEnum.Edit;
  14885. }
  14886. string opRemark = string.Empty;
  14887. if (ccpInfo != null)
  14888. {
  14889. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14890. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14891. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14892. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14893. }
  14894. opInfo.Remark = opRemark;
  14895. await _tableorRep.AddAsync(opInfo);
  14896. #endregion
  14897. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14898. //2024-10-21 新增LZ UID
  14899. var userIds = new List<int>() { 21 };
  14900. string title = $"费用审核";
  14901. string content = "";
  14902. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14903. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14904. try
  14905. {
  14906. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14907. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14908. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14909. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14910. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14911. }
  14912. catch (Exception ex)
  14913. {
  14914. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14915. }
  14916. }
  14917. catch (Exception ex)
  14918. {
  14919. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14920. }
  14921. try
  14922. {
  14923. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14924. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14925. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14926. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14927. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14928. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14929. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14930. //自动审核
  14931. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14932. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14933. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14934. //2024-10-21 新增LZ UID
  14935. var userIds = new List<int>() { 21 };
  14936. string title = $"系统通知";
  14937. var diId = _dto.DiId;
  14938. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14939. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14940. string content = "";
  14941. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14942. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14943. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14944. }
  14945. catch (Exception ex)
  14946. {
  14947. }
  14948. #endregion
  14949. return Ok(_view);
  14950. }
  14951. /// <summary>
  14952. /// 酒店自动审核测试
  14953. /// Add Or Edit
  14954. /// </summary>
  14955. /// <param name="diid"></param>
  14956. /// <param name="dataId"></param>
  14957. /// <returns></returns>
  14958. [HttpPost]
  14959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14960. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14961. {
  14962. #region 应用推送
  14963. try
  14964. {
  14965. //自动审核
  14966. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14967. }
  14968. catch (Exception ex)
  14969. {
  14970. return Ok(JsonView(false, "操作失败"));
  14971. }
  14972. #endregion
  14973. return Ok(JsonView(false, "操作成功"));
  14974. }
  14975. /// <summary>
  14976. /// 酒店预订
  14977. /// Del
  14978. /// </summary>
  14979. /// <param name="_dto"></param>
  14980. /// <returns></returns>
  14981. [HttpPost]
  14982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14983. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14984. {
  14985. #region 参数验证
  14986. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14987. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14988. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14989. #region 团组操作权限验证 76 酒店预定模块
  14990. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14991. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14992. #endregion
  14993. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14994. #region 页面操作权限验证
  14995. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14996. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14997. #endregion
  14998. #endregion
  14999. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  15000. #region 操作记录
  15001. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  15002. {
  15003. TableName = "Grp_HotelReservations",
  15004. PortType = _dto.PortType,
  15005. OperationItem = OperationEnum.Del,
  15006. DataId = _dto.Id,
  15007. CreateUserId = _dto.UserId
  15008. });
  15009. #endregion
  15010. return Ok(data);
  15011. }
  15012. /// <summary>
  15013. /// 酒店预订
  15014. /// 生成VOUCHER
  15015. /// 2024.05.06 之前版本
  15016. /// </summary>
  15017. /// <param name="_dto"></param>
  15018. /// <returns></returns>
  15019. [HttpPost]
  15020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15021. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  15022. {
  15023. try
  15024. {
  15025. #region 参数验证
  15026. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15027. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15028. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15029. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  15030. #region 团组操作权限验证 76 酒店预定模块
  15031. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15032. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15033. #endregion
  15034. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15035. #region 页面操作权限验证
  15036. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15037. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15038. #endregion
  15039. #endregion
  15040. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  15041. //判断数据是否完整
  15042. if (hr != null)
  15043. {
  15044. if (!string.IsNullOrEmpty(hr.DetermineNo))
  15045. {
  15046. string strFileName = "HotelStatement/";
  15047. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15048. if (dele != null)
  15049. strFileName += dele.TourCode;
  15050. //载入模板
  15051. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  15052. Document doc = new Document(sss);
  15053. DocumentBuilder builder = new DocumentBuilder(doc);
  15054. #region 替换Word模板书签内容
  15055. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  15056. //入住卷预定号码
  15057. if (doc.Range.Bookmarks["VNO"] != null)
  15058. {
  15059. Bookmark mark = doc.Range.Bookmarks["VNO"];
  15060. mark.Text = hr.CheckNumber;
  15061. }
  15062. //酒店时间
  15063. if (doc.Range.Bookmarks["Date"] != null)
  15064. {
  15065. Bookmark mark = doc.Range.Bookmarks["Date"];
  15066. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  15067. }
  15068. //团号
  15069. if (doc.Range.Bookmarks["TNo"] != null)
  15070. {
  15071. Bookmark mark = doc.Range.Bookmarks["TNo"];
  15072. mark.Text = dele.TourCode;
  15073. }
  15074. //预定号码
  15075. if (doc.Range.Bookmarks["BookingId"] != null)
  15076. {
  15077. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  15078. mark.Text = hr.ReservationsNo;
  15079. }
  15080. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  15081. {
  15082. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  15083. mark.Text = hr.DetermineNo;
  15084. }
  15085. //酒店城市
  15086. if (doc.Range.Bookmarks["City"] != null)
  15087. {
  15088. Bookmark mark = doc.Range.Bookmarks["City"];
  15089. mark.Text = hr.City;
  15090. }
  15091. //酒店名称
  15092. if (doc.Range.Bookmarks["HName"] != null)
  15093. {
  15094. Bookmark mark = doc.Range.Bookmarks["HName"];
  15095. mark.Text = hr.HotelName;
  15096. }
  15097. //酒店地址
  15098. if (doc.Range.Bookmarks["Address"] != null)
  15099. {
  15100. Bookmark mark = doc.Range.Bookmarks["Address"];
  15101. mark.Text = hr.HotelAddress;
  15102. }
  15103. //酒店电话
  15104. if (doc.Range.Bookmarks["Tel"] != null)
  15105. {
  15106. Bookmark mark = doc.Range.Bookmarks["Tel"];
  15107. mark.Text = hr.HotelTel;
  15108. }
  15109. //酒店传真
  15110. if (doc.Range.Bookmarks["Fax"] != null)
  15111. {
  15112. Bookmark mark = doc.Range.Bookmarks["Fax"];
  15113. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  15114. {
  15115. mark.Text = hr.HotelFax;
  15116. }
  15117. }
  15118. //入住时间
  15119. if (doc.Range.Bookmarks["CIn"] != null)
  15120. {
  15121. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  15122. Bookmark mark = doc.Range.Bookmarks["CIn"];
  15123. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  15124. }
  15125. //退房时间
  15126. if (doc.Range.Bookmarks["COut"] != null)
  15127. {
  15128. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  15129. Bookmark mark = doc.Range.Bookmarks["COut"];
  15130. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  15131. }
  15132. //客户名称
  15133. if (doc.Range.Bookmarks["GName"] != null)
  15134. {
  15135. string guestName = "";
  15136. string[] clients = new string[] { };
  15137. if (hr.GuestName.Contains(","))
  15138. {
  15139. clients = hr.GuestName.Split(",");
  15140. }
  15141. else
  15142. {
  15143. clients = new string[] { hr.GuestName };
  15144. }
  15145. List<int> clientIds_int = new List<int>();
  15146. if (clients.Length > 0)
  15147. {
  15148. foreach (var item in clients)
  15149. {
  15150. if (item.IsNumeric())
  15151. {
  15152. clientIds_int.Add(int.Parse(item));
  15153. }
  15154. }
  15155. }
  15156. if (clientIds_int.Count > 0)
  15157. {
  15158. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  15159. foreach (var client in _clientDatas)
  15160. {
  15161. //男
  15162. if (client.Sex == 0) guestName += $"Mr.";
  15163. //女
  15164. else if (client.Sex == 1) guestName += $"Ms.";
  15165. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  15166. {
  15167. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  15168. }
  15169. //guestName += $"{client.Pinyin},";
  15170. }
  15171. if (guestName.Length > 0)
  15172. {
  15173. guestName = guestName.Substring(0, guestName.Length - 1);
  15174. }
  15175. }
  15176. else
  15177. {
  15178. guestName = hr.GuestName;
  15179. }
  15180. Bookmark mark = doc.Range.Bookmarks["GName"];
  15181. mark.Text = guestName;
  15182. }
  15183. //房间介绍
  15184. if (doc.Range.Bookmarks["ROOM"] != null)
  15185. {
  15186. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  15187. mark.Text = hr.RoomExplanation;
  15188. }
  15189. //报价描述
  15190. if (doc.Range.Bookmarks["NOTE"] != null)
  15191. {
  15192. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  15193. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  15194. if (ss != null)
  15195. mark.Text = ss.Name;
  15196. }
  15197. //入住时间
  15198. if (doc.Range.Bookmarks["CheckIn"] != null)
  15199. {
  15200. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  15201. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  15202. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15203. }
  15204. //退房时间
  15205. if (doc.Range.Bookmarks["CheckOut"] != null)
  15206. {
  15207. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  15208. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  15209. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  15210. }
  15211. //日期
  15212. if (doc.Range.Bookmarks["DT"] != null)
  15213. {
  15214. Bookmark mark = doc.Range.Bookmarks["DT"];
  15215. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  15216. }
  15217. //名称
  15218. if (doc.Range.Bookmarks["VName"] != null)
  15219. {
  15220. Bookmark mark = doc.Range.Bookmarks["VName"];
  15221. mark.Text = hr.HotelName;
  15222. }
  15223. //号码
  15224. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  15225. {
  15226. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  15227. mark.Text = hr.CheckNumber;
  15228. }
  15229. #endregion
  15230. strFileName += "VOUCHER.doc";
  15231. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15232. doc.Save(fileDir);
  15233. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15234. return Ok(JsonView(true, "操作成功!", Url));
  15235. }
  15236. else
  15237. {
  15238. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  15239. }
  15240. }
  15241. else
  15242. {
  15243. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  15244. }
  15245. }
  15246. catch (Exception ex)
  15247. {
  15248. return Ok(JsonView(false, ex.Message));
  15249. }
  15250. }
  15251. /// <summary>
  15252. /// 酒店预订
  15253. /// 生成VOUCHER
  15254. /// 2024.05.06 之后版本
  15255. /// </summary>
  15256. /// <param name="_dto"></param>
  15257. /// <returns></returns>
  15258. [HttpPost]
  15259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15260. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  15261. {
  15262. #region 参数验证
  15263. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15264. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15265. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15266. #region 团组操作权限验证 76 酒店预定模块
  15267. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15268. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15269. #endregion
  15270. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15271. #region 页面操作权限验证
  15272. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15273. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15274. #endregion
  15275. #endregion
  15276. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  15277. //判断数据是否完整
  15278. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15279. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15280. string strFileName = "HotelStatement/";
  15281. string guestNames = ""; //格式Mr.xxx Ms.xxx
  15282. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  15283. #region 数据处理
  15284. List<int> guestIds = new List<int>();
  15285. //int index = 0;
  15286. foreach (var item in hrDtas)
  15287. {
  15288. if (item.GuestName.Contains(","))
  15289. {
  15290. string[] guestIdArr = item.GuestName.Split(',');
  15291. foreach (var guestIdStr in guestIdArr)
  15292. {
  15293. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  15294. if (guestBool)
  15295. {
  15296. guestIds.Add(guestId);
  15297. }
  15298. }
  15299. }
  15300. else guestNames += item.GuestName;
  15301. var voucherInfo = new HotelVoucherInfoView()
  15302. {
  15303. HotelName = item.HotelName,
  15304. CheckInDate = item.CheckInDate,
  15305. CheckOutDate = item.CheckOutDate,
  15306. ConfirmationNumber = item.DetermineNo.Trim(),
  15307. RoomType = item.RoomExplanation
  15308. };
  15309. vouchers.Add(voucherInfo);
  15310. }
  15311. if (guestIds.Count > 0)
  15312. {
  15313. guestIds = guestIds.Distinct().ToList();
  15314. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  15315. if (guestDatas.Count > 0)
  15316. {
  15317. guestNames = "";
  15318. foreach (var guest in guestDatas)
  15319. {
  15320. string guestName = "";
  15321. if (guest.Sex == 0) guestName += @"MR.";
  15322. else if (guest.Sex == 1) guestName += @"MS.";
  15323. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15324. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15325. guestNames += @$"{guestName.Trim()}、";
  15326. }
  15327. if (guestNames.Length > 0)
  15328. {
  15329. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15330. }
  15331. }
  15332. }
  15333. #endregion
  15334. //载入模板
  15335. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  15336. Document doc = new Document(sss);
  15337. DocumentBuilder builder = new DocumentBuilder(doc);
  15338. if (doc.Range.Bookmarks["GuestName"] != null)
  15339. {
  15340. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  15341. mark.Text = guestNames;
  15342. }
  15343. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15344. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  15345. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  15346. for (int i = 1; i <= vouchers.Count; i++)
  15347. {
  15348. HotelVoucherInfoView hviv = vouchers[i - 1];
  15349. builder.MoveToCell(0, i, 0, 0);
  15350. builder.Write(hviv.HotelName);
  15351. builder.MoveToCell(0, i, 1, 0);
  15352. builder.Write(hviv.CheckInDate);
  15353. builder.MoveToCell(0, i, 2, 0);
  15354. builder.Write(hviv.CheckOutDate);
  15355. builder.MoveToCell(0, i, 3, 0);
  15356. builder.Write(hviv.RoomType);
  15357. builder.MoveToCell(0, i, 4, 0);
  15358. builder.Write(hviv.ConfirmationNumber);
  15359. }
  15360. //删除多余行
  15361. int currRowIndex = vouchers.Count + 1;
  15362. int delRows = 21 - currRowIndex;
  15363. if (delRows > 0)
  15364. {
  15365. for (int i = 0; i < delRows; i++)
  15366. {
  15367. table.Rows.RemoveAt(currRowIndex);
  15368. //cultivateRowIndex++;
  15369. }
  15370. }
  15371. strFileName += "VOUCHER.docx";
  15372. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15373. doc.Save(fileDir);
  15374. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15375. return Ok(JsonView(true, "操作成功!", Url));
  15376. }
  15377. /// <summary>
  15378. /// 酒店预订
  15379. /// 生成VOUCHER 批量生成
  15380. /// New
  15381. /// </summary>
  15382. /// <param name="_dto"></param>
  15383. /// <returns></returns>
  15384. [HttpPost]
  15385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15386. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15387. {
  15388. #region 参数验证
  15389. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15390. if (_dto.PageId < 1) _dto.PageId = 28;
  15391. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15392. #region 团组操作权限验证 76 酒店预定模块
  15393. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15394. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15395. #endregion
  15396. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15397. #region 页面操作权限验证
  15398. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15399. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15400. #endregion
  15401. #endregion
  15402. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15403. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15404. .OrderBy(x => x.CheckInDate)
  15405. .ToListAsync();
  15406. //判断数据是否完整
  15407. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15408. string strFileName = "HotelStatement/";
  15409. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15410. if (dele != null)
  15411. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15412. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15413. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15414. .Where(it => it.IsDel == 0)
  15415. .ToListAsync();
  15416. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15417. for (int i = 0; i < hrDtas.Count; i++)
  15418. {
  15419. string guestNames = string.Empty;
  15420. List<int> guestIds = new List<int>();
  15421. var item = hrDtas[i];
  15422. //处理客户姓名
  15423. if (item.GuestName.Contains(","))
  15424. {
  15425. string[] guestIdArr = item.GuestName.Split(',');
  15426. foreach (var guestIdStr in guestIdArr)
  15427. if (int.TryParse(guestIdStr, out int guestId))
  15428. guestIds.Add(guestId);
  15429. }
  15430. else
  15431. {
  15432. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15433. if (guestIdBool)
  15434. {
  15435. guestIds.Add(guestId);
  15436. }
  15437. //NaN
  15438. if (item.GuestName.Contains("NaN"))
  15439. {
  15440. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15441. }
  15442. }
  15443. if (guestIds.Count > 0)
  15444. {
  15445. guestIds = guestIds.Distinct().ToList();
  15446. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15447. if (guestDatas1.Count > 0)
  15448. {
  15449. guestNames = "";
  15450. foreach (var guest in guestDatas1)
  15451. {
  15452. string guestName = "";
  15453. if (guest.Sex == 0) guestName += @"MR.";
  15454. else if (guest.Sex == 1) guestName += @"MS.";
  15455. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15456. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15457. guestNames += @$"{guestName.Trim()}、";
  15458. }
  15459. if (guestNames.Length > 0)
  15460. {
  15461. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15462. }
  15463. }
  15464. }
  15465. //if (!string.IsNullOrEmpty(guestNames))
  15466. //{
  15467. hrDtas[i].GuestName = guestNames;
  15468. //}
  15469. }
  15470. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15471. Document doc = new Document();
  15472. DocumentBuilder builder = new DocumentBuilder(doc);
  15473. try
  15474. {
  15475. builder.MoveToDocumentStart();
  15476. foreach (var item in hrDtas)
  15477. {
  15478. //标题
  15479. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15480. builder.ParagraphFormat.LineSpacing = 1;
  15481. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15482. builder.ParagraphFormat.Style.Font.Size = 9;
  15483. builder.ParagraphFormat.Style.Font.Bold = true;
  15484. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15485. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15486. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15487. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15488. builder.ParagraphFormat.LineSpacing = 1;
  15489. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15490. builder.ParagraphFormat.Style.Font.Size = 9;
  15491. builder.ParagraphFormat.Style.Font.Bold = true;
  15492. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15493. builder.StartTable();
  15494. // 设置边框颜色
  15495. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15496. //设置边框样式
  15497. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15498. //表格
  15499. #region 第一行
  15500. builder.InsertCell();
  15501. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15502. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15503. //builder.CellFormat.AllowAutoFit = false;
  15504. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15505. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15506. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15507. builder.CellFormat.WrapText = true; //自动换行
  15508. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15509. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15510. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15511. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15512. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15513. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15514. builder.Write("TOUR NO:");
  15515. builder.InsertCell();
  15516. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15517. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15518. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15519. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15520. builder.ParagraphFormat.Style.Font.Bold = false;
  15521. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15522. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15523. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15524. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15525. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15526. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15527. builder.Write($"{dele?.TourCode ?? "-"}");
  15528. builder.InsertCell();
  15529. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15530. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15531. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15532. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15533. builder.ParagraphFormat.Style.Font.Bold = false;
  15534. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15535. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15536. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15537. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15538. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15539. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15540. builder.Write($"CITY:");
  15541. builder.InsertCell();
  15542. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15543. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15544. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15545. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15546. builder.ParagraphFormat.Style.Font.Bold = false;
  15547. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15548. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15549. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15550. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15551. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15552. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15553. builder.Write($"{item.City}");
  15554. builder.EndRow();
  15555. #endregion
  15556. #region 第二行
  15557. builder.InsertCell();
  15558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15559. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15560. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15561. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15562. builder.ParagraphFormat.Style.Font.Bold = false;
  15563. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15564. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15565. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15566. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15567. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15568. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15569. builder.Write("CONFIRMATION NO:");
  15570. builder.InsertCell();
  15571. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15572. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15573. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15574. builder.ParagraphFormat.Style.Font.Bold = false;
  15575. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15576. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15577. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15578. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15579. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15580. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15581. builder.CellFormat.VerticalMerge = CellMerge.None;
  15582. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15583. builder.Write($"{item.DetermineNo}");
  15584. builder.InsertCell();
  15585. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15586. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15587. builder.InsertCell();
  15588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15589. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15590. builder.EndRow();
  15591. #endregion
  15592. #region 第三行
  15593. builder.InsertCell();
  15594. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15595. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15596. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15597. builder.ParagraphFormat.Style.Font.Bold = false;
  15598. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15599. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15600. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15601. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15602. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15603. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15604. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15605. builder.Write($"HOTEL NAME:");
  15606. builder.InsertCell();
  15607. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15608. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15609. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15610. builder.ParagraphFormat.Style.Font.Bold = false;
  15611. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15612. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15613. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15614. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15615. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15616. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15617. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15618. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15619. builder.Write($"{item.HotelName}");
  15620. builder.InsertCell();
  15621. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15622. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15623. builder.InsertCell();
  15624. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15625. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15626. builder.EndRow();
  15627. #endregion
  15628. #region 第四行
  15629. builder.InsertCell();
  15630. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15631. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15632. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15633. builder.ParagraphFormat.Style.Font.Bold = false;
  15634. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15635. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15636. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15637. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15638. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15639. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15640. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15641. builder.Write($"HOTEL ADDRESS:");
  15642. builder.InsertCell();
  15643. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15644. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15645. builder.ParagraphFormat.Style.Font.Size = 8;
  15646. builder.ParagraphFormat.Style.Font.Bold = false;
  15647. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15648. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15649. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15650. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15651. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15652. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15653. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15654. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15655. builder.Write($"{item.HotelAddress}");
  15656. builder.InsertCell();
  15657. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15658. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15659. builder.InsertCell();
  15660. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15661. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15662. builder.EndRow();
  15663. #endregion
  15664. #region 第五行
  15665. builder.InsertCell();
  15666. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15667. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15668. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15669. builder.ParagraphFormat.Style.Font.Bold = false;
  15670. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15671. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15672. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15673. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15674. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15675. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15676. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15677. builder.Write("TEL:");
  15678. builder.InsertCell();
  15679. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15680. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15681. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15682. builder.ParagraphFormat.Style.Font.Bold = false;
  15683. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15684. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15685. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15686. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15687. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15688. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15689. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15690. builder.Write($"{item.HotelTel}");
  15691. builder.InsertCell();
  15692. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15693. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15694. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15695. builder.ParagraphFormat.Style.Font.Bold = false;
  15696. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15697. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15698. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15699. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15700. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15701. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15702. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15703. builder.Write($"FAX:");
  15704. builder.InsertCell();
  15705. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15706. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15707. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15708. builder.ParagraphFormat.Style.Font.Bold = false;
  15709. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15710. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15711. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15712. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15713. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15714. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15715. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15716. builder.Write($"{item.HotelFax}");
  15717. builder.EndRow();
  15718. #endregion
  15719. #region 第六行
  15720. builder.InsertCell();
  15721. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15722. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15723. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15724. builder.ParagraphFormat.Style.Font.Bold = false;
  15725. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15726. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15727. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15728. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15729. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15730. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15731. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15732. builder.Write("CHECK IN:");
  15733. builder.InsertCell();
  15734. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15735. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15736. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15737. builder.ParagraphFormat.Style.Font.Bold = false;
  15738. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15739. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15740. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15741. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15742. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15743. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15744. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15745. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15746. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15747. builder.Write($"{checkInStr}");
  15748. builder.InsertCell();
  15749. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15750. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15751. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15752. builder.ParagraphFormat.Style.Font.Bold = false;
  15753. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15754. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15755. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15756. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15757. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15758. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15759. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15760. builder.Write($"CHECK OUT:");
  15761. builder.InsertCell();
  15762. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15763. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15764. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15765. builder.ParagraphFormat.Style.Font.Bold = false;
  15766. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15767. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15768. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15769. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15770. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15771. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15772. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15773. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15774. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15775. builder.Write($"{checkOutStr}");
  15776. builder.EndRow();
  15777. #endregion
  15778. #region 第七行
  15779. builder.InsertCell();
  15780. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15781. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15782. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15783. builder.ParagraphFormat.Style.Font.Bold = false;
  15784. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15785. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15786. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15787. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15788. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15789. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15790. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15791. builder.Write($"GUEST NAME:");
  15792. builder.InsertCell();
  15793. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15794. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15795. builder.ParagraphFormat.Style.Font.Size = 8;
  15796. builder.ParagraphFormat.Style.Font.Bold = false;
  15797. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15798. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15799. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15800. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15801. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15802. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15803. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15804. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15805. builder.Write($"{item.GuestName}");
  15806. builder.InsertCell();
  15807. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15808. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15809. builder.InsertCell();
  15810. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15811. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15812. builder.EndRow();
  15813. #endregion
  15814. #region 第八行
  15815. builder.InsertCell();
  15816. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15817. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15818. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15819. builder.ParagraphFormat.Style.Font.Bold = false;
  15820. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15821. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15822. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15823. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15824. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15825. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15826. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15827. builder.Write($"ROOM TYPE:");
  15828. builder.InsertCell();
  15829. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15830. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15831. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15832. builder.ParagraphFormat.Style.Font.Bold = false;
  15833. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15834. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15835. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15836. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15837. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15838. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15839. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15840. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15841. builder.Write($"{item.RoomExplanation}");
  15842. builder.InsertCell();
  15843. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15844. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15845. builder.InsertCell();
  15846. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15847. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15848. builder.EndRow();
  15849. #endregion
  15850. #region 第九行
  15851. builder.InsertCell();
  15852. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15853. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15854. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15855. builder.ParagraphFormat.Style.Font.Bold = false;
  15856. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15857. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15858. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15859. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15860. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15861. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15862. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15863. builder.Write($"NOTE:");
  15864. builder.InsertCell();
  15865. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15866. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15867. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15868. builder.ParagraphFormat.Style.Font.Bold = false;
  15869. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15870. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15871. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15872. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15873. 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.");
  15874. builder.InsertCell();
  15875. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15876. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15877. builder.InsertCell();
  15878. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15879. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15880. builder.EndRow();
  15881. #endregion
  15882. builder.EndTable();
  15883. //换行
  15884. builder.Writeln("");
  15885. builder.Writeln("");
  15886. }
  15887. #region 获取文档中的所有表格 设置文字自适应
  15888. // 获取文档中的所有表格。
  15889. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15890. {
  15891. // 遍历表格中的所有行。
  15892. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15893. {
  15894. foreach (Cell cell in row.Cells)
  15895. {
  15896. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15897. cellFormat.Width = 0;
  15898. }
  15899. }
  15900. }
  15901. #endregion
  15902. #region 设置页眉
  15903. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15904. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15905. if (System.IO.File.Exists(voucherHeaderPath))
  15906. {
  15907. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15908. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15909. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15910. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  15911. // 调整图片位置
  15912. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15913. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15914. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15915. shape.Left = 0; // 将图片距离页面左边缘的距离
  15916. shape.Width = 81; // 设置图片宽度
  15917. shape.Height = 36; // 设置图片高度
  15918. }
  15919. //靠右
  15920. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15921. //// 设置页脚上下边距
  15922. //builder.PageSetup.HeaderDistance = 42;
  15923. // 添加页眉线
  15924. Aspose.Words.Border borderHeader = null;
  15925. try
  15926. {
  15927. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15928. }
  15929. catch (Exception e)
  15930. {
  15931. // TODO Auto-generated catch block
  15932. //e.printStackTrace();
  15933. }
  15934. borderHeader.Shadow = true;
  15935. borderHeader.DistanceFromText = 2;
  15936. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15937. #endregion
  15938. }
  15939. catch (Exception ex)
  15940. {
  15941. }
  15942. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15943. doc.Save(fileDir);
  15944. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15945. return Ok(JsonView(true, "操作成功!", Url));
  15946. }
  15947. /// <summary>
  15948. /// 酒店预订
  15949. /// 生成 预定成本 Excel
  15950. /// </summary>
  15951. /// <param name="_dto"></param>
  15952. /// <returns></returns>
  15953. [HttpPost]
  15954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15955. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15956. {
  15957. #region 参数验证
  15958. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15959. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15960. if (!vadalitorRes.IsValid)
  15961. {
  15962. var errors = new StringBuilder();
  15963. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15964. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15965. }
  15966. #region 团组操作权限验证 76 酒店预定模块
  15967. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15968. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15969. #endregion
  15970. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15971. #region 页面操作权限验证
  15972. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15973. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15974. #endregion
  15975. #endregion
  15976. decimal _rate = 1.00M;
  15977. string _currency = string.Empty;
  15978. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15979. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15980. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15981. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15982. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15983. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15984. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15985. if (_GroupCostParameter == null)
  15986. {
  15987. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15988. bool isIntType = int.TryParse(_currency, out int currId);
  15989. if (isIntType)
  15990. {
  15991. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15992. }
  15993. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15994. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15995. if (currInfo == null)
  15996. {
  15997. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15998. }
  15999. else _rate = currInfo.Rate;
  16000. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  16001. {
  16002. _rate = _GroupCostParameter.Rate;
  16003. }
  16004. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16005. //string strFileName = "HotelStatement/";
  16006. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16007. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16008. var rateDatas = new List<dynamic>();
  16009. #region 数据处理
  16010. foreach (var item in hrDtas)
  16011. {
  16012. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16013. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16014. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16015. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16016. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16017. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  16018. {
  16019. continue;
  16020. }
  16021. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16022. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  16023. string singleRoomFeeStr = string.Empty,
  16024. doubleRoomFeeStr = string.Empty,
  16025. suiteRoomFeeStr = string.Empty,
  16026. otherRoomFeeStr = string.Empty,
  16027. payMoneyStr = string.Empty,
  16028. cardPriceStr = string.Empty;
  16029. if (roomCurr.Equals("CNY"))
  16030. {
  16031. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  16032. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16033. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16034. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16035. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16036. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  16037. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  16038. }
  16039. else
  16040. {
  16041. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16042. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16043. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16044. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16045. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16046. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16047. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16048. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16049. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16050. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16051. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  16052. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  16053. if (ccpPaymentCurrency.Equals("CNY"))
  16054. {
  16055. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  16056. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16057. }
  16058. else
  16059. {
  16060. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  16061. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  16062. }
  16063. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  16064. if (hotelcardPriceCurrency.Equals("CNY"))
  16065. {
  16066. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16067. }
  16068. else
  16069. {
  16070. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  16071. }
  16072. }
  16073. string breakfastPriceStr = string.Empty,
  16074. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  16075. governmentRentStr = string.Empty,
  16076. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  16077. cityTaxStr = string.Empty,
  16078. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16079. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  16080. if (!string.IsNullOrEmpty(breakfastCurrency1))
  16081. {
  16082. if (breakfastCurrency1.Equals("CNY"))
  16083. {
  16084. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  16085. }
  16086. else
  16087. {
  16088. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  16089. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  16090. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  16091. }
  16092. }
  16093. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  16094. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  16095. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  16096. {
  16097. if (governmentRentCurrency.Equals("CNY"))
  16098. {
  16099. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  16100. }
  16101. else
  16102. {
  16103. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  16104. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  16105. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  16106. }
  16107. }
  16108. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  16109. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  16110. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  16111. {
  16112. if (cityTaxStrCurrency1.Equals("CNY"))
  16113. {
  16114. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  16115. }
  16116. else
  16117. {
  16118. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  16119. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  16120. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  16121. }
  16122. }
  16123. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  16124. int payDId = roomInfo?.PayDId ?? 0;
  16125. pcfds.Add(new HotelReservations_PCFD_View()
  16126. {
  16127. City = item.City,
  16128. HotelName = item.HotelName,
  16129. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16130. // SingleRoomCount = item.SingleRoomCount,
  16131. SingleRoomPrice = singleRoomFeeStr,
  16132. // DoubleRoomCount = item.DoubleRoomCount,
  16133. DoubleRoomPrice = doubleRoomFeeStr,
  16134. //SuiteRoomCount = item.SuiteRoomCount,
  16135. SuiteRoomPrice = suiteRoomFeeStr,
  16136. OtherRoomPrice = otherRoomFeeStr,
  16137. //OtherRoomCount = item.OtherRoomCount,
  16138. BreakfastPrice = breakfastPriceStr,
  16139. GovernmentRent = governmentRentStr,
  16140. CityTax = cityTaxStr,
  16141. RoomExplanation = item.RoomExplanation,
  16142. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16143. PayTime = roomInfo?.ConsumptionDate,
  16144. BankNo = roomInfo?.BankNo,
  16145. PayMoney = payMoneyStr,
  16146. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16147. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16148. CardPrice = cardPriceStr,
  16149. Remark = ccpInfo.Remark
  16150. });
  16151. }
  16152. #endregion
  16153. //载入模板
  16154. WorkbookDesigner designer = new WorkbookDesigner();
  16155. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16156. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16157. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16158. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16159. var rateDatas1 = rateDatas.Distinct();
  16160. var rateStr = string.Empty;
  16161. foreach (var item in rateDatas1)
  16162. {
  16163. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  16164. }
  16165. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  16166. designer.SetDataSource("Opertor", userInfo.CnName);
  16167. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16168. dt.TableName = "ViewMyHotelReservations";
  16169. designer.SetDataSource(dt);
  16170. designer.Process();
  16171. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16172. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16173. designer.Workbook.Save(serverPath);
  16174. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16175. #region 删除指定行
  16176. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16177. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16178. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16179. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16180. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16181. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16182. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16183. cssIndex = dt.Columns["CityTax"].Ordinal,
  16184. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16185. remarkIndex = dt.Columns["Remark"].Ordinal;
  16186. //删除指定列
  16187. foreach (DataRow item in dt.Rows)
  16188. {
  16189. string singleStr = item["SingleRoomPrice"].ToString();
  16190. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16191. if (containsDigitButNotZero1) singleDel = false;
  16192. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16193. string doubleStr = item["DoubleRoomPrice"].ToString();
  16194. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16195. if (containsDigitButNotZero2) doubleDel = false;
  16196. string suiteStr = item["SuiteRoomPrice"].ToString();
  16197. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16198. if (containsDigitButNotZero3) suiteDel = false;
  16199. string otherStr = item["OtherRoomPrice"].ToString();
  16200. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16201. if (containsDigitButNotZero4) otherDel = false;
  16202. string zcStr = item["BreakfastPrice"].ToString();
  16203. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16204. if (containsDigitButNotZero5) zcDel = false;
  16205. string dsStr = item["GovernmentRent"].ToString();
  16206. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16207. if (containsDigitButNotZero6) dsDel = false;
  16208. string cssStr = item["CityTax"].ToString();
  16209. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16210. if (containsDigitButNotZero7) cssDel = false;
  16211. string cpStr = item["ConsumptionPatterns"].ToString();
  16212. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16213. string remarkStr = item["Remark"].ToString();
  16214. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16215. }
  16216. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16217. DeleteColumn(serverPath, cpIndex, cpDel);
  16218. DeleteColumn(serverPath, dsIndex, dsDel);
  16219. DeleteColumn(serverPath, cssIndex, cssDel);
  16220. DeleteColumn(serverPath, zcIndex, zcDel);
  16221. DeleteColumn(serverPath, otherIndex, otherDel);
  16222. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16223. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16224. DeleteColumn(serverPath, singleIndex, singleDel);
  16225. #endregion
  16226. //只保留第一个表格
  16227. DeleteSheet(serverPath);
  16228. return Ok(JsonView(true, "操作成功", url = rst));
  16229. }
  16230. else
  16231. {
  16232. _currency = _GroupCostParameter.Currency;
  16233. bool isIntType = int.TryParse(_currency, out int currId);
  16234. if (isIntType)
  16235. {
  16236. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16237. }
  16238. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16239. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16240. if (currInfo == null)
  16241. {
  16242. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16243. }
  16244. if (!_currency.ToUpper().Equals("CNY"))
  16245. {
  16246. _rate = _GroupCostParameter.Rate;
  16247. }
  16248. _rate = currInfo.Rate;
  16249. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16250. //string strFileName = "HotelStatement/";
  16251. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16252. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16253. #region 数据处理
  16254. foreach (var item in hrDtas)
  16255. {
  16256. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16257. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16258. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16259. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16260. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16261. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16262. string singleRoomFeeStr = string.Empty,
  16263. doubleRoomFeeStr = string.Empty,
  16264. suiteRoomFeeStr = string.Empty,
  16265. otherRoomFeeStr = string.Empty,
  16266. payMoneyStr = string.Empty,
  16267. cardPriceStr = string.Empty;
  16268. if (roomCurr.Equals(_currency))
  16269. {
  16270. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  16271. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  16272. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  16273. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  16274. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  16275. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  16276. }
  16277. else
  16278. {
  16279. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16280. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16281. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16282. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16283. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16284. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16285. }
  16286. string breakfastPriceStr = string.Empty,
  16287. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  16288. governmentRentStr = string.Empty,
  16289. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  16290. cityTaxStrStr = string.Empty,
  16291. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16292. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  16293. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  16294. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  16295. int payDId = roomInfo?.PayDId ?? 0;
  16296. pcfds.Add(new HotelReservations_PCFD_View()
  16297. {
  16298. City = item.City,
  16299. HotelName = item.HotelName,
  16300. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16301. // SingleRoomCount = item.SingleRoomCount,
  16302. SingleRoomPrice = singleRoomFeeStr,
  16303. // DoubleRoomCount = item.DoubleRoomCount,
  16304. DoubleRoomPrice = doubleRoomFeeStr,
  16305. //SuiteRoomCount = item.SuiteRoomCount,
  16306. SuiteRoomPrice = suiteRoomFeeStr,
  16307. OtherRoomPrice = otherRoomFeeStr,
  16308. //OtherRoomCount = item.OtherRoomCount,
  16309. BreakfastPrice = breakfastPriceStr,
  16310. GovernmentRent = governmentRentStr,
  16311. CityTax = cityTaxStrStr,
  16312. RoomExplanation = item.RoomExplanation,
  16313. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16314. PayTime = roomInfo?.ConsumptionDate,
  16315. BankNo = roomInfo?.BankNo,
  16316. PayMoney = payMoneyStr,
  16317. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16318. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16319. CardPrice = cardPriceStr,
  16320. Remark = ccpInfo.Remark
  16321. });
  16322. }
  16323. #endregion
  16324. //载入模板
  16325. WorkbookDesigner designer = new WorkbookDesigner();
  16326. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16327. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16328. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16329. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16330. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  16331. designer.SetDataSource("Opertor", userInfo.CnName);
  16332. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16333. dt.TableName = "ViewMyHotelReservations";
  16334. designer.SetDataSource(dt);
  16335. designer.Process();
  16336. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16337. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16338. designer.Workbook.Save(serverPath);
  16339. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16340. #region 删除指定行
  16341. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16342. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16343. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16344. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16345. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16346. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16347. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16348. cssIndex = dt.Columns["CityTax"].Ordinal,
  16349. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16350. remarkIndex = dt.Columns["Remark"].Ordinal;
  16351. //删除指定列
  16352. foreach (DataRow item in dt.Rows)
  16353. {
  16354. string singleStr = item["SingleRoomPrice"].ToString();
  16355. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16356. if (containsDigitButNotZero1) singleDel = false;
  16357. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16358. string doubleStr = item["DoubleRoomPrice"].ToString();
  16359. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16360. if (containsDigitButNotZero2) doubleDel = false;
  16361. string suiteStr = item["SuiteRoomPrice"].ToString();
  16362. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16363. if (containsDigitButNotZero3) suiteDel = false;
  16364. string otherStr = item["OtherRoomPrice"].ToString();
  16365. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16366. if (containsDigitButNotZero4) otherDel = false;
  16367. string zcStr = item["BreakfastPrice"].ToString();
  16368. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16369. if (containsDigitButNotZero5) zcDel = false;
  16370. string dsStr = item["GovernmentRent"].ToString();
  16371. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16372. if (containsDigitButNotZero6) dsDel = false;
  16373. string cssStr = item["CityTax"].ToString();
  16374. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16375. if (containsDigitButNotZero7) cssDel = false;
  16376. string cpStr = item["ConsumptionPatterns"].ToString();
  16377. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16378. string remarkStr = item["Remark"].ToString();
  16379. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16380. }
  16381. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16382. DeleteColumn(serverPath, cpIndex, cpDel);
  16383. DeleteColumn(serverPath, dsIndex, dsDel);
  16384. DeleteColumn(serverPath, cssIndex, cssDel);
  16385. DeleteColumn(serverPath, zcIndex, zcDel);
  16386. DeleteColumn(serverPath, otherIndex, otherDel);
  16387. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16388. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16389. DeleteColumn(serverPath, singleIndex, singleDel);
  16390. #endregion
  16391. //只保留第一个表格
  16392. DeleteSheet(serverPath);
  16393. return Ok(JsonView(true, "操作成功", url = rst));
  16394. }
  16395. //return Ok(JsonView(false));
  16396. }
  16397. /// <summary>
  16398. /// 删除指定列
  16399. /// </summary>
  16400. /// <param name="file"></param>
  16401. /// <param name="columnIndex"></param>
  16402. /// <param name="isDel"></param>
  16403. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16404. {
  16405. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16406. //wb.Save(file);
  16407. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16408. if (sheet1 != null)
  16409. {
  16410. if (isDel)
  16411. {
  16412. Cells cells = sheet1.Cells;
  16413. cells.DeleteColumn(columnIndex);
  16414. }
  16415. }
  16416. wb.Save(file);
  16417. }
  16418. /// <summary>
  16419. /// 删除sheet
  16420. /// </summary>
  16421. /// <param name="file"></param>
  16422. /// <param name="sheetName"></param>
  16423. private void DeleteSheet(string file, string sheetName = "")
  16424. {
  16425. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16426. //wb.Save(file);
  16427. List<string> sheets = new List<string>();
  16428. foreach (var item in wb.Worksheets)
  16429. {
  16430. sheets.Add(item.Name);
  16431. }
  16432. if (sheets.Count > 0)
  16433. {
  16434. sheets.RemoveAt(0);//不删除第一个sheet
  16435. foreach (var item in sheets)
  16436. {
  16437. wb.Worksheets.RemoveAt(item);
  16438. }
  16439. }
  16440. wb.Save(file);
  16441. }
  16442. /// <summary>
  16443. /// 酒店预订
  16444. /// 确认单
  16445. /// </summary>
  16446. /// <param name="_dto"></param>
  16447. /// <returns></returns>
  16448. [HttpPost]
  16449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16450. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16451. {
  16452. try
  16453. {
  16454. #region 参数验证
  16455. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16456. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16457. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16458. #region 团组操作权限验证 76 酒店预定模块
  16459. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16460. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16461. #endregion
  16462. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16463. #region 页面操作权限验证
  16464. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16465. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16466. #endregion
  16467. #endregion
  16468. //团组信息
  16469. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16470. //酒店数据
  16471. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16472. if (listhoteldata.Count < 0)
  16473. {
  16474. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16475. }
  16476. //利datatable存储
  16477. DataTable dt = new DataTable();
  16478. dt.Columns.Add("CheckInDate", typeof(string));
  16479. dt.Columns.Add("City", typeof(string));
  16480. dt.Columns.Add("Hotel", typeof(string));
  16481. dt.Columns.Add("Room", typeof(string));
  16482. for (int i = 0; i < listhoteldata.Count; i++)
  16483. {
  16484. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16485. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16486. while (dayStart < dayEnd)
  16487. {
  16488. string temp = "";
  16489. DataRow row = dt.NewRow();
  16490. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16491. row["City"] = listhoteldata[i].City;
  16492. row["Hotel"] = listhoteldata[i].HotelName;
  16493. if (listhoteldata[i].SingleRoomCount > 0)
  16494. {
  16495. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16496. }
  16497. if (listhoteldata[i].DoubleRoomCount > 0)
  16498. {
  16499. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16500. }
  16501. if (listhoteldata[i].SuiteRoomCount > 0)
  16502. {
  16503. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16504. }
  16505. if (listhoteldata[i].OtherRoomCount > 0)
  16506. {
  16507. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16508. }
  16509. row["Room"] = temp;
  16510. dt.Rows.Add(row);
  16511. dayStart = dayStart.AddDays(1);
  16512. }
  16513. }
  16514. Dictionary<string, string> dic = new Dictionary<string, string>();
  16515. dic.Add("Dele", di.TeamName);
  16516. dic.Add("City", di.VisitCountry);
  16517. //模板路径
  16518. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16519. //载入模板
  16520. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16521. DocumentBuilder builder = new DocumentBuilder(doc);
  16522. foreach (var key in dic.Keys)
  16523. {
  16524. builder.MoveToBookmark(key);
  16525. builder.Write(dic[key]);
  16526. }
  16527. //获取word里所有表格
  16528. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16529. //获取所填表格的序数
  16530. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16531. var rowStart = tableOne.Rows[0]; //获取第1行
  16532. //循环赋值
  16533. for (int i = 0; i < dt.Rows.Count; i++)
  16534. {
  16535. builder.MoveToCell(0, i + 1, 0, 0);
  16536. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16537. builder.MoveToCell(0, i + 1, 1, 0);
  16538. builder.Write(dt.Rows[i]["City"].ToString());
  16539. builder.MoveToCell(0, i + 1, 2, 0);
  16540. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16541. builder.MoveToCell(0, i + 1, 3, 0);
  16542. builder.Write(dt.Rows[i]["Room"].ToString());
  16543. }
  16544. //删除多余行
  16545. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16546. {
  16547. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16548. }
  16549. string strFileName = di.TeamName + "酒店确认单.doc";
  16550. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16551. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16552. return Ok(JsonView(true, "成功", url));
  16553. }
  16554. catch (Exception ex)
  16555. {
  16556. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16557. }
  16558. }
  16559. #endregion
  16560. #region 团组状态
  16561. /// <summary>
  16562. /// 团组状态列表 Page
  16563. /// </summary>
  16564. /// <param name="dto">团组列表请求dto</param>
  16565. /// <returns></returns>
  16566. [HttpPost]
  16567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16568. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16569. {
  16570. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16571. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16572. {
  16573. string sqlWhere = string.Empty;
  16574. if (dto.IsSure == 0) //未完成
  16575. {
  16576. sqlWhere += string.Format(@" And IsSure = 0");
  16577. }
  16578. else if (dto.IsSure == 1) //已完成
  16579. {
  16580. sqlWhere += string.Format(@" And IsSure = 1");
  16581. }
  16582. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16583. {
  16584. string tj = dto.SearchCriteria;
  16585. 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}%')",
  16586. tj, tj, tj, tj, tj);
  16587. }
  16588. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16589. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16590. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16591. From (
  16592. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16593. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16594. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16595. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16596. From Grp_DelegationInfo gdi
  16597. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16598. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16599. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16600. Where gdi.IsDel = 0 {0}
  16601. ) temp ", sqlWhere);
  16602. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16603. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16604. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16605. }
  16606. else
  16607. {
  16608. return Ok(JsonView(false, "查询失败"));
  16609. }
  16610. }
  16611. /// <summary>
  16612. /// 团组状态
  16613. /// 设置操作完成
  16614. /// </summary>
  16615. /// <param name="dto">团组列表请求dto</param>
  16616. /// <returns></returns>
  16617. [HttpPost]
  16618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16619. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16620. {
  16621. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16622. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16623. {
  16624. Id = dto.Id,
  16625. IsSure = 1
  16626. };
  16627. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16628. .UpdateColumns(it => new { it.IsSure })
  16629. .WhereColumns(it => new { it.Id })
  16630. .ExecuteCommandAsync();
  16631. if (result > 0)
  16632. {
  16633. return Ok(JsonView(true, "操作完成!"));
  16634. }
  16635. return Ok(JsonView(false, "操作失败!"));
  16636. }
  16637. #endregion
  16638. #region 保险费用录入
  16639. /// <summary>
  16640. /// 根据团组Id查询保险费用列表
  16641. /// </summary>
  16642. /// <param name="dto"></param>
  16643. /// <returns></returns>
  16644. [HttpPost]
  16645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16646. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16647. {
  16648. Result groupData = await _customersRep.CustomersByDiId(dto);
  16649. if (groupData.Code != 0)
  16650. {
  16651. return Ok(JsonView(false, groupData.Msg));
  16652. }
  16653. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16654. }
  16655. /// <summary>
  16656. /// 根据保险费用Id查询保险费用详细
  16657. /// </summary>
  16658. /// <param name="dto"></param>
  16659. /// <returns></returns>
  16660. [HttpPost]
  16661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16662. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16663. {
  16664. try
  16665. {
  16666. Result groupData = await _customersRep.CustomersById(dto);
  16667. if (groupData.Code != 0)
  16668. {
  16669. return Ok(JsonView(false, groupData.Msg));
  16670. }
  16671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16672. }
  16673. catch (Exception ex)
  16674. {
  16675. return Ok(JsonView(false, ex.Message));
  16676. }
  16677. }
  16678. /// <summary>
  16679. /// 保险费用录入页面初始化绑定
  16680. /// </summary>
  16681. /// <param name="dto"></param>
  16682. /// <returns></returns>
  16683. [HttpPost]
  16684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16685. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16686. {
  16687. try
  16688. {
  16689. Result groupData = await _customersRep.CustomersInitialize(dto);
  16690. if (groupData.Code != 0)
  16691. {
  16692. return Ok(JsonView(false, groupData.Msg));
  16693. }
  16694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16695. }
  16696. catch (Exception ex)
  16697. {
  16698. return Ok(JsonView(false, ex.Message));
  16699. }
  16700. }
  16701. /// <summary>
  16702. /// 保险费用操作(Status:1.新增,2.修改)
  16703. /// </summary>
  16704. /// <param name="dto"></param>
  16705. /// <returns></returns>
  16706. [HttpPost]
  16707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16708. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16709. {
  16710. Result groupData = await _customersRep.OpCustomers(dto);
  16711. if (groupData.Code != 0)
  16712. {
  16713. return Ok(JsonView(false, groupData.Msg));
  16714. }
  16715. #region 应用推送
  16716. try
  16717. {
  16718. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16719. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16720. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16721. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16722. //自动审核
  16723. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16724. //2024-10-21 新增LZ UID
  16725. var userIds = new List<int>() { 21 };
  16726. string title = $"系统通知";
  16727. var diId = dto.DiId;
  16728. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16729. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16730. string content = "";
  16731. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16732. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16733. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16734. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16735. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16736. }
  16737. catch (Exception ex)
  16738. {
  16739. }
  16740. #endregion
  16741. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16742. }
  16743. /// <summary>
  16744. /// 保险文件上传
  16745. /// </summary>
  16746. /// <param name="file"></param>
  16747. /// <returns></returns>
  16748. [HttpPost]
  16749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16750. public async Task<IActionResult> UploadCus(IFormFile file)
  16751. {
  16752. try
  16753. {
  16754. if (file != null)
  16755. {
  16756. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16757. //文件名称
  16758. string projectFileName = file.FileName;
  16759. //上传的文件的路径
  16760. string filePath = "";
  16761. if (!Directory.Exists(fileDir))
  16762. {
  16763. Directory.CreateDirectory(fileDir);
  16764. }
  16765. //上传的文件的路径
  16766. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16767. using (FileStream fs = System.IO.File.Create(filePath))
  16768. {
  16769. file.CopyTo(fs);
  16770. fs.Flush();
  16771. }
  16772. return Ok(JsonView(true, "上传成功!", projectFileName));
  16773. }
  16774. else
  16775. {
  16776. return Ok(JsonView(false, "上传失败!"));
  16777. }
  16778. }
  16779. catch (Exception ex)
  16780. {
  16781. return Ok(JsonView(false, "程序错误!"));
  16782. throw;
  16783. }
  16784. }
  16785. /// <summary>
  16786. /// 保险删除指定文件
  16787. /// </summary>
  16788. /// <param name="dto"></param>
  16789. /// <returns></returns>
  16790. [HttpPost]
  16791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16792. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16793. {
  16794. try
  16795. {
  16796. string filePath = "";
  16797. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16798. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16799. //int id = 0;
  16800. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16801. // 删除该文件
  16802. try
  16803. {
  16804. System.IO.File.Delete(filePath);
  16805. 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()
  16806. {
  16807. Attachment = "",
  16808. }).ExecuteCommandAsync();
  16809. if (result != 0)
  16810. {
  16811. return Ok(JsonView(true, "成功!"));
  16812. }
  16813. else
  16814. {
  16815. return Ok(JsonView(false, "失败!"));
  16816. }
  16817. }
  16818. catch (Exception)
  16819. {
  16820. 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()
  16821. {
  16822. Attachment = "",
  16823. }).ExecuteCommandAsync();
  16824. if (result != 0)
  16825. {
  16826. return Ok(JsonView(true, "成功!"));
  16827. }
  16828. else
  16829. {
  16830. return Ok(JsonView(false, "失败!"));
  16831. }
  16832. }
  16833. }
  16834. catch (Exception ex)
  16835. {
  16836. return Ok(JsonView(false, "程序错误!"));
  16837. throw;
  16838. }
  16839. }
  16840. /// <summary>
  16841. /// 保险费用操作(删除)
  16842. /// </summary>
  16843. /// <param name="dto"></param>
  16844. /// <returns></returns>
  16845. [HttpPost]
  16846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16847. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16848. {
  16849. try
  16850. {
  16851. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16852. if (!res)
  16853. {
  16854. return Ok(JsonView(false, "删除失败"));
  16855. }
  16856. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16857. {
  16858. IsDel = 1,
  16859. DeleteUserId = dto.DeleteUserId,
  16860. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16861. }).ExecuteCommandAsync();
  16862. return Ok(JsonView(true, "删除成功!"));
  16863. }
  16864. catch (Exception ex)
  16865. {
  16866. return Ok(JsonView(false, "程序错误!"));
  16867. throw;
  16868. }
  16869. }
  16870. #endregion
  16871. #region 接团客户名单 PageId 104
  16872. /// <summary>
  16873. /// 接团客户名单
  16874. /// 迁移数据(慎用!)
  16875. /// </summary>
  16876. /// <returns></returns>
  16877. [HttpPost]
  16878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16879. public async Task<IActionResult> PostTourClientListChange()
  16880. {
  16881. try
  16882. {
  16883. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16884. //var groupClinetData1
  16885. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16886. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16887. int updateCount = 0;
  16888. if (oldOAClientList.Count > 0)
  16889. {
  16890. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16891. _sqlSugar.BeginTran();
  16892. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16893. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16894. foreach (var item in oldOAClientList)
  16895. {
  16896. int comId = 0;
  16897. string format = "yyyy-MM-dd HH:mm:ss";
  16898. string data11 = "1990-01-01 00:00";
  16899. var data1 = IsValidDate(item.OPdate, format);
  16900. if (data1) data11 = item.OPdate;
  16901. //客户公司验证
  16902. if (!string.IsNullOrEmpty(item.Company))
  16903. {
  16904. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16905. if (clientComInfo == null) // add
  16906. {
  16907. var addInfo = new Crm_CustomerCompany()
  16908. {
  16909. CompanyAbbreviation = "",
  16910. CompanyFullName = item.Company,
  16911. Address = "",
  16912. PostCodes = "",
  16913. LastedOpUserId = item.OPer,
  16914. LastedOpDt = Convert.ToDateTime(data11),
  16915. CreateUserId = item.OPer,
  16916. CreateTime = Convert.ToDateTime(data11),
  16917. IsDel = 0
  16918. };
  16919. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16920. if (comId1 > 0) comId = comId1;
  16921. }
  16922. else comId = clientComInfo.Id;
  16923. }
  16924. //客户人员验证
  16925. int clientId = 0;
  16926. string name = item.LastName + item.Name;
  16927. if (!string.IsNullOrEmpty(name))
  16928. {
  16929. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16930. if (clientInfo == null)
  16931. {
  16932. DateTime? dateTime = null;
  16933. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16934. if (isDt) dateTime = birthDayDt;
  16935. var addInfo1 = new Crm_DeleClient()
  16936. {
  16937. CrmCompanyId = comId,
  16938. DiId = -1,
  16939. LastName = item.LastName,
  16940. FirstName = item.Name,
  16941. OldName = "",
  16942. Pinyin = item.Pinyin,
  16943. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16944. Marriage = 0,
  16945. Phone = item.Phone,
  16946. Job = item.Job,
  16947. BirthDay = dateTime
  16948. };
  16949. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16950. if (clientId1 > 0) clientId = clientId1;
  16951. }
  16952. else clientId = clientInfo.Id;
  16953. }
  16954. if (clientId < 1)
  16955. {
  16956. continue;
  16957. }
  16958. int airType = 0;
  16959. if (item.AirType == "超经舱") airType = 459;
  16960. else if (item.AirType == "公务舱") airType = 458;
  16961. else if (item.AirType == "经济舱") airType = 460;
  16962. else if (item.AirType == "其他") airType = 565;
  16963. else if (item.AirType == "头等舱") airType = 457;
  16964. var _TourClientListEntity = new Grp_TourClientList()
  16965. {
  16966. DiId = item.Diid,
  16967. ClientId = clientId,
  16968. CreateUserId = item.OPer,
  16969. CreateTime = Convert.ToDateTime(data11),
  16970. Remark = item.Remark,
  16971. IsDel = item.Isdel,
  16972. ShippingSpaceTypeId = airType,
  16973. ShippingSpaceSpecialNeeds = item.AirRemark,
  16974. HotelSpecialNeeds = item.RoomType
  16975. };
  16976. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16977. if (_TourClientList > 0)
  16978. {
  16979. updateCount++;
  16980. }
  16981. }
  16982. _sqlSugar.CommitTran();
  16983. }
  16984. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16985. }
  16986. catch (Exception ex)
  16987. {
  16988. _sqlSugar.RollbackTran();
  16989. return Ok(JsonView(false, ex.Message));
  16990. }
  16991. //return Ok(JsonView(true));
  16992. }
  16993. private bool IsValidDate(string dateString, string format)
  16994. {
  16995. DateTime dateValue;
  16996. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16997. return valid;
  16998. }
  16999. /// <summary>
  17000. /// 接团客户名单
  17001. /// 根据团组Id查询List
  17002. /// </summary>
  17003. /// <param name="_dto"></param>
  17004. /// <returns></returns>
  17005. [HttpPost]
  17006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17007. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  17008. {
  17009. #region 参数验证
  17010. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  17011. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  17012. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  17013. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17014. #region 页面操作权限验证
  17015. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17016. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17017. #endregion
  17018. #endregion
  17019. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  17020. if (viewData.Code != 0)
  17021. {
  17022. return Ok(JsonView(false, viewData.Msg));
  17023. }
  17024. return Ok(JsonView(viewData.Data));
  17025. }
  17026. /// <summary>
  17027. /// 接团客户名单
  17028. /// 基础数据 Init
  17029. /// </summary>
  17030. /// <param name="_dto"></param>
  17031. /// <returns></returns>
  17032. [HttpPost]
  17033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17034. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  17035. {
  17036. #region 参数验证
  17037. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17038. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17039. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17040. #region 页面操作权限验证
  17041. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17042. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17043. #endregion
  17044. #endregion
  17045. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  17046. }
  17047. /// <summary>
  17048. /// 接团客户名单
  17049. /// 根据 Id查询 Details
  17050. /// </summary>
  17051. /// <param name="_dto"></param>
  17052. /// <returns></returns>
  17053. [HttpPost]
  17054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17055. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  17056. {
  17057. #region 参数验证
  17058. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17059. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17060. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  17061. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17062. #region 页面操作权限验证
  17063. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17064. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17065. #endregion
  17066. #endregion
  17067. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  17068. if (viewData.Code != 0)
  17069. {
  17070. return Ok(JsonView(false, viewData.Msg));
  17071. }
  17072. return Ok(JsonView(viewData.Data));
  17073. }
  17074. /// <summary>
  17075. /// 接团客户名单
  17076. /// Add Or Edit
  17077. /// </summary>
  17078. /// <param name="_dto"></param>
  17079. /// <returns></returns>
  17080. [HttpPost]
  17081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17082. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  17083. {
  17084. #region 参数验证
  17085. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17086. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17087. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  17088. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17089. #region 页面操作权限验证
  17090. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17091. if (_dto.Id == 0) //添加
  17092. {
  17093. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17094. }
  17095. else if (_dto.Id >= 0) //修改
  17096. {
  17097. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17098. }
  17099. #endregion
  17100. #endregion
  17101. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  17102. if (viewData.Code != 0)
  17103. {
  17104. return Ok(JsonView(false, viewData.Msg));
  17105. }
  17106. return Ok(JsonView(true));
  17107. }
  17108. /// <summary>
  17109. /// 接团客户名单
  17110. /// json字符串 AddMultiple(添加多个)
  17111. /// </summary>
  17112. /// <param name="_dto"></param>
  17113. /// <returns></returns>
  17114. [HttpPost]
  17115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17116. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  17117. {
  17118. #region 参数验证
  17119. string jsonLabel = _dto.JsonLabel;
  17120. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17121. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17122. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17123. #region 页面操作权限验证
  17124. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17125. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17126. #endregion
  17127. #endregion
  17128. var request = new TourClientListAddMultipleDto();
  17129. request.DiId = _dto.DiId;
  17130. request.UserId = _dto.UserId;
  17131. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  17132. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  17133. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  17134. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  17135. var infos = new List<TourClientListInfo>();
  17136. foreach (var data in datas)
  17137. {
  17138. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  17139. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  17140. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  17141. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  17142. {
  17143. continue;
  17144. }
  17145. infos.Add(new TourClientListInfo()
  17146. {
  17147. IsAccompany = 1,
  17148. LastName = lastName,
  17149. FirstName = firstName,
  17150. Pinyin = lastNameEn + @"/" + firstNameEn,
  17151. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  17152. CompanyFullName = data.CompanyFullName,
  17153. Job = data.Job
  17154. });
  17155. }
  17156. if (infos.Any())
  17157. {
  17158. var viewData = await _tourClientListRep._AddMultiple(request);
  17159. if (viewData.Code != 0)
  17160. {
  17161. return Ok(JsonView(false, viewData.Msg));
  17162. }
  17163. return Ok(JsonView(true));
  17164. }
  17165. return Ok(JsonView(false));
  17166. }
  17167. /// <summary>
  17168. /// 接团客户名单
  17169. /// AddMultiple(添加多个)
  17170. /// </summary>
  17171. /// <param name="_dto"></param>
  17172. /// <returns></returns>
  17173. [HttpPost]
  17174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17175. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  17176. {
  17177. #region 参数验证
  17178. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17179. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17180. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17181. #region 页面操作权限验证
  17182. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17183. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17184. #endregion
  17185. #endregion
  17186. var viewData = await _tourClientListRep._AddMultiple(_dto);
  17187. if (viewData.Code != 0)
  17188. {
  17189. return Ok(JsonView(false, viewData.Msg));
  17190. }
  17191. return Ok(JsonView(true));
  17192. }
  17193. /// <summary>
  17194. /// 接团客户名单
  17195. /// Del
  17196. /// </summary>
  17197. /// <param name="_dto"></param>
  17198. /// <returns></returns>
  17199. [HttpPost]
  17200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17201. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  17202. {
  17203. #region 参数验证
  17204. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17205. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17206. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17207. #region 页面操作权限验证
  17208. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17209. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17210. #endregion
  17211. #endregion
  17212. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  17213. if (viewData.Code != 0)
  17214. {
  17215. return Ok(JsonView(false, viewData.Msg));
  17216. }
  17217. return Ok(JsonView(true));
  17218. }
  17219. /// <summary>
  17220. /// 接团客户名单
  17221. /// 文件下载 客户名单
  17222. /// </summary>
  17223. /// <param name="_dto"></param>
  17224. /// <returns></returns>
  17225. [HttpPost]
  17226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17227. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  17228. {
  17229. #region 参数验证
  17230. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17231. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17232. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  17233. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17234. #region 页面操作权限验证
  17235. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17236. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17237. #endregion
  17238. #endregion
  17239. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  17240. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  17241. From Grp_TourClientList tcl
  17242. Left Join
  17243. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  17244. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  17245. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  17246. From Crm_DeleClient dc
  17247. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  17248. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  17249. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  17250. Where dc.IsDel = 0) temp
  17251. On temp.DcId =tcl.ClientId
  17252. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  17253. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  17254. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  17255. //载入模板
  17256. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  17257. if (_dto.Language == 1)
  17258. {
  17259. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  17260. }
  17261. //载入模板
  17262. var doc = new Document(tempPath);
  17263. DocumentBuilder builder = new DocumentBuilder(doc);
  17264. //获取word里所有表格
  17265. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17266. //获取所填表格的序数
  17267. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17268. var rowStart = tableOne.Rows[0]; //获取第1行
  17269. if (_dto.Language == 0)
  17270. {
  17271. //循环赋值
  17272. for (int i = 0; i < DcList.Count; i++)
  17273. {
  17274. EncryptionProcessor.DecryptProperties(DcList[i]);
  17275. builder.MoveToCell(0, i + 1, 0, 0);
  17276. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  17277. builder.MoveToCell(0, i + 1, 1, 0);
  17278. int sex = DcList[i].Sex;
  17279. string sexStr = string.Empty;
  17280. if (sex == 0) sexStr = "男";
  17281. else if (sex == 1) sexStr = "女";
  17282. else sexStr = "未设置";
  17283. builder.Write(sexStr);
  17284. builder.MoveToCell(0, i + 1, 2, 0);
  17285. string birthDay = DcList[i].BirthDay;
  17286. string birthDayStr = string.Empty;
  17287. if (!string.IsNullOrEmpty(birthDay))
  17288. {
  17289. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  17290. }
  17291. builder.Write(birthDayStr);
  17292. builder.MoveToCell(0, i + 1, 3, 0);
  17293. string company = "";
  17294. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17295. {
  17296. company = DcList[i].CompanyFullName.ToString();
  17297. }
  17298. builder.Write(company);
  17299. builder.MoveToCell(0, i + 1, 4, 0);
  17300. builder.Write(DcList[i].Job);
  17301. }
  17302. }
  17303. else if (_dto.Language == 1)
  17304. {
  17305. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  17306. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  17307. List<string> transArrayStr = new List<string>();
  17308. string transStrRes1 = "";
  17309. for (int i = 0; i < DcList.Count; i++)
  17310. {
  17311. var dc = DcList[i];
  17312. EncryptionProcessor.DecryptProperties(dc);
  17313. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  17314. if (dc.Job.Equals("暂无")) dc.Job = "-";
  17315. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  17316. if (DcList.Count - 1 == i) transStrRes1 += str1;
  17317. else transStrRes1 += $"{str1}|";
  17318. }
  17319. //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";
  17320. string transStrRes = "";
  17321. if (transStrRes1.Length > 0)
  17322. {
  17323. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  17324. }
  17325. //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
  17326. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  17327. //List<string> transArray = new List<string> { };
  17328. List<TranslateInfo> transArray = new List<TranslateInfo>();
  17329. if (transStrRes.Contains("|"))
  17330. {
  17331. string[] transArray1 = transStrRes.Split('|');
  17332. if (transArray1.Length > 0)
  17333. {
  17334. foreach (var item in transArray1)
  17335. {
  17336. if (item.Contains("&"))
  17337. {
  17338. string[] transArray2 = item.Split('&');
  17339. int index = 0;
  17340. string companyName = "", job = "";
  17341. if (transArray2.Length > 0)
  17342. {
  17343. bool success = int.TryParse(transArray2[0].Trim(), out index);
  17344. if (1 < transArray2.Length) companyName = transArray2[1];
  17345. if (2 < transArray2.Length) job = transArray2[2];
  17346. }
  17347. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  17348. }
  17349. }
  17350. }
  17351. }
  17352. //循环赋值
  17353. for (int i = 0; i < DcList.Count; i++)
  17354. {
  17355. string PYName = "";
  17356. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17357. {
  17358. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17359. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17360. PYName = PY_First + " " + PY_Last;
  17361. }
  17362. else
  17363. {
  17364. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17365. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17366. PYName = PY_First + " " + PY_Last;
  17367. }
  17368. builder.MoveToCell(0, i + 1, 0, 0);
  17369. builder.Write(PYName);
  17370. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17371. builder.MoveToCell(0, i + 1, 1, 0);
  17372. builder.Write(sex);
  17373. DateTime birthDt;
  17374. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17375. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17376. builder.MoveToCell(0, i + 1, 2, 0);
  17377. builder.Write(birthday);
  17378. string company = string.Empty, job = string.Empty;
  17379. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17380. if (dcTransInfo != null)
  17381. {
  17382. company = dcTransInfo.CompanyName;
  17383. job = dcTransInfo.Job;
  17384. }
  17385. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17386. {
  17387. //查询对照表
  17388. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17389. if (tempCec != null)
  17390. {
  17391. company = tempCec.enName;
  17392. }
  17393. //翻译
  17394. else
  17395. {
  17396. }
  17397. }
  17398. builder.MoveToCell(0, i + 1, 3, 0);
  17399. builder.Write(company);
  17400. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17401. {
  17402. //查询对照表
  17403. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17404. if (tempPec != null)
  17405. {
  17406. job = tempPec.enName;
  17407. }
  17408. //翻译
  17409. else
  17410. {
  17411. }
  17412. }
  17413. builder.MoveToCell(0, i + 1, 4, 0);
  17414. builder.Write(job);
  17415. }
  17416. }
  17417. //删除多余行
  17418. while (tableOne.Rows.Count > DcList.Count + 1)
  17419. {
  17420. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17421. }
  17422. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17423. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17424. doc.Save(fileDir);
  17425. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17426. return Ok(JsonView(true, "操作成功!", Url));
  17427. }
  17428. private class TranslateInfo
  17429. {
  17430. public int Index { get; set; }
  17431. public string CompanyName { get; set; }
  17432. public string Job { get; set; }
  17433. }
  17434. #endregion
  17435. #region 团组倒推表
  17436. /// <summary>
  17437. /// 倒推表基础数据
  17438. /// Init
  17439. /// </summary>
  17440. /// <returns></returns>
  17441. [HttpPost]
  17442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17443. public async Task<IActionResult> PostInvertedListInit()
  17444. {
  17445. var viewData = await _invertedListRep._Init();
  17446. if (viewData.Code != 0)
  17447. {
  17448. return Ok(JsonView(false, viewData.Msg));
  17449. }
  17450. return Ok(JsonView(viewData.Data));
  17451. }
  17452. /// <summary>
  17453. /// 倒推表
  17454. /// Info
  17455. /// </summary>
  17456. /// <param name="dto"></param>
  17457. /// <returns></returns>
  17458. [HttpPost]
  17459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17460. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17461. {
  17462. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17463. if (viewData.Code != 0)
  17464. {
  17465. return Ok(JsonView(false, viewData.Msg));
  17466. }
  17467. return Ok(JsonView(viewData.Data));
  17468. }
  17469. /// <summary>
  17470. /// 倒推表
  17471. /// Create
  17472. /// </summary>
  17473. /// <param name="dto"></param>
  17474. /// <returns></returns>
  17475. [HttpPost]
  17476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17477. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17478. {
  17479. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17480. if (viewData.Code != 0)
  17481. {
  17482. return Ok(JsonView(false, viewData.Msg));
  17483. }
  17484. return Ok(JsonView(viewData.Data));
  17485. }
  17486. /// <summary>
  17487. /// 倒推表
  17488. /// Update
  17489. /// </summary>
  17490. /// <param name="dto"></param>
  17491. /// <returns></returns>
  17492. [HttpPost]
  17493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17494. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17495. {
  17496. var viewData = await _invertedListRep._Update(dto);
  17497. if (viewData.Code != 0)
  17498. {
  17499. return Ok(JsonView(false, viewData.Msg));
  17500. }
  17501. return Ok(JsonView(viewData.Data));
  17502. }
  17503. /// <summary>
  17504. /// 倒推表
  17505. /// File Download
  17506. /// </summary>
  17507. /// <param name="dto"></param>
  17508. /// <returns></returns>
  17509. [HttpPost]
  17510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17511. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17512. {
  17513. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17514. if (info2.Code != 0)
  17515. {
  17516. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17517. }
  17518. var info1 = info2.Data as InvertedListInfoView;
  17519. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17520. string teamName = "";
  17521. if (info != null) teamName = info.TeamName;
  17522. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17523. var doc = new Document();
  17524. var builder = new DocumentBuilder(doc);
  17525. #region old insert
  17526. ////载入模板
  17527. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17528. //Document doc = new Document(tempPath);
  17529. //DocumentBuilder builder = new DocumentBuilder(doc);
  17530. //利用键值对存放数据
  17531. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17532. //dic.Add("TeamName", teamName);
  17533. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17534. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17535. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17536. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17537. //dic.Add("SQRemark", info1.ApprovalRemark);
  17538. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17539. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17540. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17541. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17542. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17543. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17544. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17545. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17546. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17547. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17548. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17549. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17550. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17551. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17552. //#region 填充word模板书签内容
  17553. //foreach (var key in dic.Keys)
  17554. //{
  17555. // builder.MoveToBookmark(key);
  17556. // builder.Write(dic[key]);
  17557. //}
  17558. //#endregion
  17559. #endregion
  17560. #region New Insert
  17561. string titleFont = $"仿宋",
  17562. contentFont = $"仿宋";
  17563. var fontColor = Color.FromArgb(64, 64, 64);
  17564. //设置标题 团组名称
  17565. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17566. builder.Font.Name = titleFont;
  17567. builder.Font.Color = fontColor;
  17568. builder.Font.Size = 12;
  17569. builder.Font.Bold = true;
  17570. builder.Writeln(teamName);
  17571. //设置副标题 团组出访时间
  17572. builder.Font.Size = 12;
  17573. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17574. builder.Writeln();
  17575. var backgroundColor = Color.FromArgb(199, 199, 199);
  17576. var table = builder.StartTable();
  17577. builder.InsertCell();
  17578. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17579. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17580. builder.CellFormat.Borders.LineWidth = 1;
  17581. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17582. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17583. builder.RowFormat.Height = 40;
  17584. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17585. builder.Font.Name = contentFont;
  17586. builder.Font.Size = 12;
  17587. builder.Font.Bold = true;
  17588. builder.Font.Color = fontColor;
  17589. builder.Write("时间");
  17590. builder.InsertCell();
  17591. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17592. builder.Write("流程");
  17593. builder.InsertCell();
  17594. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17595. builder.Write("说明");
  17596. builder.EndRow();
  17597. //报批资料准备
  17598. if (info1.IsSelectedAirportd)
  17599. {
  17600. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17601. }
  17602. //报批/提供送签资料
  17603. if (info1.IsSelectedApprovalData)
  17604. {
  17605. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17606. }
  17607. //出批件护照办理
  17608. if (info1.IsSelectedIssueApproval)
  17609. {
  17610. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17611. }
  17612. //签证资料准备
  17613. if (info1.IsSelectedVisaInfo)
  17614. {
  17615. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17616. }
  17617. //送签
  17618. if (info1.IsSelectedSendVisa)
  17619. {
  17620. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17621. }
  17622. //出签
  17623. if (info1.IsSelectedIssueVisa)
  17624. {
  17625. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17626. }
  17627. //机票
  17628. if (info1.IsSelectedAirTicket)
  17629. {
  17630. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17631. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17632. }
  17633. //酒店
  17634. if (info1.IsSelectedHotel)
  17635. {
  17636. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17637. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17638. }
  17639. //开行前会
  17640. if (info1.IsSelectedPreTripMeeting)
  17641. {
  17642. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17643. }
  17644. //送机
  17645. if (info1.IsSelectedAirportdDropOff)
  17646. {
  17647. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17648. }
  17649. builder.EndTable();
  17650. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17651. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17652. for (int i = 0; i < table.Rows.Count; i++)
  17653. {
  17654. var row = table.Rows[i];
  17655. //设置宽度
  17656. row.Cells[0].CellFormat.Width = 20.00;
  17657. row.Cells[1].CellFormat.Width = 30.00;
  17658. row.Cells[2].CellFormat.Width = 50.00;
  17659. if (i != 0)
  17660. {
  17661. //边框设置
  17662. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17663. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17664. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17665. }
  17666. }
  17667. #region 页脚插入图片
  17668. // 创建页脚
  17669. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17670. doc.FirstSection.HeadersFooters.Add(footer);
  17671. Paragraph para = new Paragraph(doc);
  17672. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17673. footer.AppendChild(para);
  17674. builder.MoveTo(para);
  17675. string imagePath = "./Images/FMGJ_Log.png";
  17676. builder.InsertImage(imagePath);
  17677. #endregion
  17678. #endregion
  17679. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17680. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17681. string filePath = fileDir + $@"InvertedList/{fileName}";
  17682. doc.Save(filePath);
  17683. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17684. return Ok(JsonView(true, "操作成功!", Url));
  17685. }
  17686. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  17687. {
  17688. var fontColor = Color.FromArgb(64, 64, 64);
  17689. builder.InsertCell();
  17690. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17691. builder.RowFormat.Height = 40;
  17692. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17693. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17694. builder.Font.Name = fontName;
  17695. builder.Font.Size = 8;
  17696. builder.Font.Bold = true;
  17697. builder.Font.Color = fontColor;
  17698. builder.Write(dateTime);
  17699. builder.InsertCell();
  17700. builder.Font.Size = 9;
  17701. builder.Font.Bold = true;
  17702. builder.Font.Color = fontColor;
  17703. builder.Write(content);
  17704. builder.InsertCell();
  17705. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17706. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17707. builder.Font.Size = 9;
  17708. builder.Font.Bold = false;
  17709. builder.Font.Color = fontColor;
  17710. builder.Write(reamrk);
  17711. builder.EndRow();
  17712. }
  17713. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  17714. {
  17715. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17716. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17717. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17718. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17719. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17720. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17721. }
  17722. #endregion
  17723. #region 会务倒推表
  17724. /// <summary>
  17725. /// 会务倒推表
  17726. /// Init
  17727. /// </summary>
  17728. /// <returns></returns>
  17729. [HttpPost]
  17730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17731. public async Task<IActionResult> InforRetrogressTableInit()
  17732. {
  17733. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17734. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17735. return Ok(JsonView(false, groupData.Msg));
  17736. }
  17737. /// <summary>
  17738. /// 会务倒推表
  17739. /// ExcelDownload
  17740. /// </summary>
  17741. /// <param name="dto"></param>
  17742. /// <returns></returns>
  17743. [HttpPost]
  17744. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17746. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17747. {
  17748. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17749. var validatorRes = await validator.ValidateAsync(dto);
  17750. if (!validatorRes.IsValid)
  17751. {
  17752. StringBuilder sb = new StringBuilder();
  17753. foreach (var item in validatorRes.Errors)
  17754. {
  17755. sb.AppendLine(item.ErrorMessage);
  17756. }
  17757. return Ok(JsonView(false, sb.ToString()));
  17758. }
  17759. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17760. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17761. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17762. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17763. #region Excel
  17764. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17765. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17766. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17767. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17768. var fileNamePrefix = string.Empty;
  17769. if (days >= 30)
  17770. {
  17771. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17772. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17773. }
  17774. else if (days < 30 && days > 7)
  17775. {
  17776. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17777. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17778. }
  17779. else if (days <= 7)
  17780. {
  17781. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17782. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17783. }
  17784. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17785. fileName = CommonFun.ValidFileName(fileName);
  17786. //载入模板
  17787. WorkbookDesigner designer = new WorkbookDesigner();
  17788. designer.Workbook = new Workbook(tempPath);
  17789. designer.Process();
  17790. if (!Directory.Exists(savePath))
  17791. {
  17792. Directory.CreateDirectory(savePath);
  17793. }
  17794. string serverPath = $"{savePath}{fileName}";
  17795. designer.Workbook.Save(serverPath);
  17796. string rst = $"{servicePath}{ftpPath}{fileName}";
  17797. #endregion
  17798. return Ok(JsonView(new { url = rst }));
  17799. }
  17800. #endregion
  17801. #region 三公签证费用(签证费、代办费)
  17802. /// <summary>
  17803. /// 三公签证费用(签证费、代办费)
  17804. /// List
  17805. /// </summary>
  17806. /// <returns></returns>
  17807. [HttpPost]
  17808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17809. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17810. {
  17811. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17812. if (_view.Code != 0)
  17813. {
  17814. return Ok(JsonView(false, _view.Msg));
  17815. }
  17816. return Ok(JsonView(true, "操作成功!", _view.Data));
  17817. }
  17818. /// <summary>
  17819. /// 三公签证费用(签证费、代办费)
  17820. /// Add Or Update
  17821. /// </summary>
  17822. /// <returns></returns>
  17823. [HttpPost]
  17824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17825. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17826. {
  17827. var _view = await _visaFeeInfoRep._Update(_dto);
  17828. if (_view.Code != 0)
  17829. {
  17830. return Ok(JsonView(false, _view.Msg));
  17831. }
  17832. return Ok(JsonView(true, _view.Msg));
  17833. }
  17834. #endregion
  17835. #region 酒店询价
  17836. /// <summary>
  17837. /// 酒店询价
  17838. /// Init
  17839. /// </summary>
  17840. /// <returns></returns>
  17841. [HttpPost]
  17842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17843. public async Task<IActionResult> PostHotelInquiryInit()
  17844. {
  17845. var res = await _hotelInquiryRep._Init();
  17846. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17847. return Ok(JsonView(true, res.Msg, res.Data));
  17848. }
  17849. /// <summary>
  17850. /// 酒店询价
  17851. /// page Item
  17852. /// </summary>
  17853. /// <param name="_dto"></param>
  17854. /// <returns></returns>
  17855. [HttpPost]
  17856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17857. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17858. {
  17859. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17860. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17861. var view = res.Data as PageDataViewBase;
  17862. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17863. }
  17864. /// <summary>
  17865. /// 酒店询价
  17866. /// info
  17867. /// </summary>
  17868. /// <param name="_dto"></param>
  17869. /// <returns></returns>
  17870. [HttpPost]
  17871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17872. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17873. {
  17874. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17875. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17876. return Ok(JsonView(true, res.Msg, res.Data));
  17877. }
  17878. /// <summary>
  17879. /// 酒店询价
  17880. /// Add Or Edit
  17881. /// </summary>
  17882. /// <param name="_dto"></param>
  17883. /// <returns></returns>
  17884. [HttpPost]
  17885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17886. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17887. {
  17888. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17889. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17890. return Ok(JsonView(true, res.Msg, res.Data));
  17891. }
  17892. /// <summary>
  17893. /// 酒店询价
  17894. /// Del
  17895. /// </summary>
  17896. /// <param name="_dto"></param>
  17897. /// <returns></returns>
  17898. [HttpPost]
  17899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17900. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17901. {
  17902. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17903. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17904. return Ok(JsonView(true, res.Msg, res.Data));
  17905. }
  17906. #endregion
  17907. #region 下载匹配op行程单
  17908. /// <summary>
  17909. /// 匹配op行程单
  17910. /// Init
  17911. /// </summary>
  17912. /// <param name="dto">团组列表请求dto</param>
  17913. /// <returns></returns>
  17914. [HttpPost]
  17915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17916. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17917. {
  17918. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17919. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17920. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17921. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17922. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17923. .Where(it => it.IsDel == 0)
  17924. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17925. .OrderByDescending(it => it.VisitStartDate)
  17926. .ToList();
  17927. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17928. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17929. var diids = groupInfos.Select(it => it.Id).ToList();
  17930. List<string> countrys = new List<string>();
  17931. foreach (var item in country)
  17932. {
  17933. var data = _groupRepository.FormartTeamName(item);
  17934. var dataArray = _groupRepository.GroupSplitCountry(data);
  17935. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17936. }
  17937. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17938. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17939. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17940. foreach (var item in areaItem)
  17941. {
  17942. string areaStr = item.Value;
  17943. if (!string.IsNullOrEmpty(areaStr))
  17944. {
  17945. string[] str1 = areaStr.Split("-");
  17946. if (str1.Length > 0)
  17947. {
  17948. areaArray.AddRange(str1);
  17949. }
  17950. }
  17951. }
  17952. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17953. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17954. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17955. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17956. .ToList();
  17957. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17958. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17959. .Where(it => countriesIds.Contains(it.Id))
  17960. .Select(it => new { it.Id, Name = it.Name_CN })
  17961. .ToList();
  17962. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17963. .Select(it => it.TeamName).ToList();
  17964. stopwatch.Stop();
  17965. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17966. }
  17967. ///// <summary>
  17968. ///// 匹配op行程单
  17969. ///// Init 查询区域数据
  17970. ///// </summary>
  17971. ///// <param name="dto">团组列表请求dto</param>
  17972. ///// <returns></returns>
  17973. //[HttpPost]
  17974. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17975. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17976. //{
  17977. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17978. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17979. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17980. // if (string.IsNullOrEmpty(countriesDataStr))
  17981. // {
  17982. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17983. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17984. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17985. // }
  17986. // else
  17987. // {
  17988. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17989. // }
  17990. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17991. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17992. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17993. // List<dynamic> childList = new List<dynamic>();
  17994. // int parentId = dto.CountriesId;
  17995. // if (provinceData.Count > 1)
  17996. // {
  17997. // foreach (var item1 in provinceData)
  17998. // {
  17999. // List<dynamic> childList1 = new List<dynamic>();
  18000. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  18001. // foreach (var item2 in citiesData1)
  18002. // {
  18003. // List<dynamic> childList2 = new List<dynamic>();
  18004. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18005. // foreach (var item3 in countiesData1)
  18006. // {
  18007. // childList2.Add(new
  18008. // {
  18009. // id = item3.Id,
  18010. // parentId = item2.Id,
  18011. // level = "district",
  18012. // name = item3.Name_CN,
  18013. // });
  18014. // }
  18015. // childList1.Add(new
  18016. // {
  18017. // id = item2.Id,
  18018. // parentId = item1.Id,
  18019. // level = "city",
  18020. // name = item2.Name_CN,
  18021. // childList = childList2
  18022. // });
  18023. // }
  18024. // childList.Add(new
  18025. // {
  18026. // id = item1.Id,
  18027. // parentId = parentId,
  18028. // level = "province",
  18029. // name = item1.Name_CN,
  18030. // childList = childList1
  18031. // });
  18032. // }
  18033. // //城市
  18034. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  18035. // foreach (var item2 in citiesData2)
  18036. // {
  18037. // List<dynamic> childList22 = new List<dynamic>();
  18038. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18039. // foreach (var item3 in countiesData1)
  18040. // {
  18041. // childList22.Add(new
  18042. // {
  18043. // id = item3.Id,
  18044. // parentId = item2.Id,
  18045. // level = "district",
  18046. // name = item3.Name_CN,
  18047. // });
  18048. // }
  18049. // childList.Add(new
  18050. // {
  18051. // id = item2.Id,
  18052. // parentId = parentId,
  18053. // level = "city",
  18054. // name = item2.Name_CN,
  18055. // childList = childList22
  18056. // });
  18057. // }
  18058. // }
  18059. // else
  18060. // {
  18061. // foreach (var item2 in citiesData)
  18062. // {
  18063. // string cname = item2.Name_CN;
  18064. // List<dynamic> childList1 = new List<dynamic>();
  18065. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18066. // foreach (var item3 in countiesData1)
  18067. // {
  18068. // childList1.Add(new
  18069. // {
  18070. // Id = item3.Id,
  18071. // parentId = item2.Id,
  18072. // level = "district",
  18073. // name = item3.Name_CN
  18074. // });
  18075. // }
  18076. // childList.Add(new
  18077. // {
  18078. // id = item2.Id,
  18079. // parentId = parentId,
  18080. // level = "city",
  18081. // name = item2.Name_CN,
  18082. // childList = childList1
  18083. // });
  18084. // }
  18085. // }
  18086. // stopwatch.Stop();
  18087. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  18088. //}
  18089. /// <summary>
  18090. /// 匹配op行程单
  18091. /// 接团信息列表 Page
  18092. /// </summary>
  18093. /// <param name="dto">团组列表请求dto</param>
  18094. /// <returns></returns>
  18095. [HttpPost]
  18096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18097. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  18098. {
  18099. var swatch = new Stopwatch();
  18100. swatch.Start();
  18101. #region 参数验证
  18102. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18103. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  18104. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18105. #region 页面操作权限验证
  18106. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  18107. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  18108. #endregion
  18109. #endregion
  18110. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  18111. {
  18112. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  18113. //string sqlWhere = "";
  18114. if (!string.IsNullOrEmpty(dto.Country))
  18115. {
  18116. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  18117. }
  18118. if (!string.IsNullOrEmpty(dto.Area))
  18119. {
  18120. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  18121. }
  18122. if (!string.IsNullOrEmpty(dto.TeamName))
  18123. {
  18124. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  18125. }
  18126. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  18127. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  18128. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  18129. swatch.Stop();
  18130. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  18131. }
  18132. else
  18133. {
  18134. return Ok(JsonView(false, "查询失败"));
  18135. }
  18136. }
  18137. /// <summary>
  18138. /// 匹配op行程单
  18139. /// 行程单下载
  18140. /// </summary>
  18141. /// <param name="dto">团组列表请求dto</param>
  18142. /// <returns></returns>
  18143. [HttpPost]
  18144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18145. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  18146. {
  18147. #region 参数验证
  18148. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18149. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  18150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18151. #region 页面操作权限验证
  18152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  18153. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  18154. #endregion
  18155. #endregion
  18156. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  18157. {
  18158. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  18159. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  18160. }
  18161. else
  18162. {
  18163. return Ok(JsonView(false, "下载失败!"));
  18164. }
  18165. }
  18166. #endregion
  18167. #region 国家信息 数据 注释
  18168. //[HttpPost]
  18169. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  18170. //{
  18171. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  18172. // foreach (var item in dto)
  18173. // {
  18174. // infos.Add(new Grp_GroupsTaskAssignment()
  18175. // {
  18176. // DIId = item,
  18177. // CTId = 82,
  18178. // UId = 248,
  18179. // IsEnable = 1,
  18180. // CreateUserId = 233,
  18181. // CreateTime = DateTime.Now,
  18182. // IsDel = 0
  18183. // });
  18184. // infos.Add(new Grp_GroupsTaskAssignment()
  18185. // {
  18186. // DIId = item,
  18187. // CTId = 82,
  18188. // UId = 286,
  18189. // IsEnable = 1,
  18190. // CreateUserId = 233,
  18191. // CreateTime = DateTime.Now,
  18192. // IsDel = 0
  18193. // });
  18194. // }
  18195. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  18196. // return Ok("操作成功");
  18197. //}
  18198. //public class paramJsonDto
  18199. //{
  18200. // public List<CountriesInfo> str { get; set; }
  18201. //}
  18202. //[HttpPost]
  18203. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  18204. //{
  18205. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  18206. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  18207. // List<Sys_Cities> cities = new List<Sys_Cities>();
  18208. // List<Sys_Cities> districts = new List<Sys_Cities>();
  18209. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18210. // _sqlSugar.BeginTran();
  18211. // int countitiesIndex = 0;
  18212. // foreach (var item in dto.str)
  18213. // {
  18214. // dynamic data = item.c;
  18215. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  18216. // if (data != null)
  18217. // {
  18218. // countitiesIndex++;
  18219. // foreach (var item1 in data)
  18220. // {
  18221. // string cnname = item1.cn;
  18222. // string enname = item1.en;
  18223. // Sys_Cities provinceInfo = new Sys_Cities()
  18224. // {
  18225. // CountriesId = countriesId,
  18226. // Name_CN = cnname,
  18227. // Name_EN = enname,
  18228. // ParentId = 0,
  18229. // IsCapital = 1,
  18230. // CreateUserId = 208,
  18231. // CreateTime = DateTime.Now,
  18232. // IsDel = 0
  18233. // };
  18234. // if (item1.lv == "province") //省份
  18235. // {
  18236. // provinceInfo.Level = 1;
  18237. // int provinceId = 0;
  18238. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  18239. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  18240. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18241. // var data1 = item1.c;
  18242. // foreach (var item2 in data1)
  18243. // {
  18244. // if (item2.lv == "city")
  18245. // {
  18246. // string citycnname = item2.cn;
  18247. // string cityenname = item2.en;
  18248. // Sys_Cities cityInfo = new Sys_Cities()
  18249. // {
  18250. // CountriesId = countriesId,
  18251. // ParentId = provinceId,
  18252. // Level = 2,
  18253. // Name_CN = citycnname,
  18254. // Name_EN = cityenname,
  18255. // IsCapital = 1,
  18256. // CreateUserId = 208,
  18257. // CreateTime = DateTime.Now,
  18258. // IsDel = 0
  18259. // };
  18260. // if (item2.c != null)
  18261. // {
  18262. // int cityId = 0;
  18263. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  18264. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18265. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  18266. // foreach (var item3 in item2.c)
  18267. // {
  18268. // if (item3.lv == "district")
  18269. // {
  18270. // var districtInfo = new Sys_Cities()
  18271. // {
  18272. // CountriesId = countriesId,
  18273. // Name_CN = item3.cn,
  18274. // Name_EN = item3.en,
  18275. // Level = 3,
  18276. // ParentId = cityId,
  18277. // IsCapital = 1,
  18278. // CreateUserId = 208,
  18279. // CreateTime = DateTime.Now,
  18280. // IsDel = 0
  18281. // };
  18282. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18283. // //{
  18284. // districts.Add(districtInfo);
  18285. // //}
  18286. // }
  18287. // }
  18288. // }
  18289. // else
  18290. // {
  18291. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  18292. // //{
  18293. // cities.Add(cityInfo);
  18294. // //}
  18295. // }
  18296. // }
  18297. // }
  18298. // }
  18299. // else if (item1.lv == "city")//城市
  18300. // {
  18301. // provinceInfo.Level = 2;
  18302. // if (item1.c != null)
  18303. // {
  18304. // int cityId = 0;
  18305. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  18306. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18307. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18308. // foreach (var item3 in item1.c)
  18309. // {
  18310. // if (item3.lv == "district")
  18311. // {
  18312. // var districtInfo = new Sys_Cities()
  18313. // {
  18314. // CountriesId = countriesId,
  18315. // Name_CN = item3.cn,
  18316. // Name_EN = item3.en,
  18317. // Level = 3,
  18318. // ParentId = cityId,
  18319. // IsCapital = 1,
  18320. // CreateUserId = 208,
  18321. // CreateTime = DateTime.Now,
  18322. // IsDel = 0
  18323. // };
  18324. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18325. // //{
  18326. // districts.Add(districtInfo);
  18327. // //}
  18328. // }
  18329. // }
  18330. // }
  18331. // else
  18332. // {
  18333. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  18334. // //{
  18335. // cities.Add(provinceInfo);
  18336. // //}
  18337. // }
  18338. // }
  18339. // }
  18340. // }
  18341. // }
  18342. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  18343. // cities = cities.Distinct().ToList();
  18344. // districts = districts.Distinct().ToList();
  18345. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  18346. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  18347. // cities.AddRange(districts);
  18348. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  18349. // //_sqlSugar.RollbackTran();
  18350. // _sqlSugar.CommitTran();
  18351. // return Ok(JsonView(false, "操作成功!"));
  18352. //}
  18353. //[HttpPost]
  18354. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18355. //{
  18356. // List<CountitiesInfo> infos = dto.MyProperty;
  18357. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18358. // _sqlSugar.BeginTran();
  18359. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18360. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18361. // foreach (var item in infos)
  18362. // {
  18363. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18364. // if (countryInfo != null)
  18365. // {
  18366. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18367. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18368. // if (cityInfo1 != null)
  18369. // {
  18370. // cityInfo1.IsCapital = 0;
  18371. // cityInfos.Add(cityInfo1);
  18372. // }
  18373. // }
  18374. // }
  18375. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18376. // .UpdateColumns(it => it.IsCapital)
  18377. // .WhereColumns(it => it.Id)
  18378. // .ExecuteCommand();
  18379. // //_sqlSugar.RollbackTran();
  18380. // _sqlSugar.CommitTran();
  18381. // return Ok(JsonView(false, "操作成功!"));
  18382. //}
  18383. //public class CounrtiesDto
  18384. //{
  18385. // public List<CountitiesInfo> MyProperty { get; set; }
  18386. //}
  18387. //public class CountitiesInfo
  18388. //{
  18389. // /// <summary>
  18390. // /// 圣约翰
  18391. // /// </summary>
  18392. // public string capital_name_chinese { get; set; }
  18393. // /// <summary>
  18394. // ///
  18395. // /// </summary>
  18396. // public string capital_name { get; set; }
  18397. // /// <summary>
  18398. // ///
  18399. // /// </summary>
  18400. // public string country_type { get; set; }
  18401. // /// <summary>
  18402. // /// 安提瓜和巴布达
  18403. // /// </summary>
  18404. // public string country_name_chinese { get; set; }
  18405. // /// <summary>
  18406. // /// 安提瓜和巴布达
  18407. // /// </summary>
  18408. // public string country_name_chinese_short { get; set; }
  18409. // /// <summary>
  18410. // /// 安提瓜和巴布达
  18411. // /// </summary>
  18412. // public string country_name_chinese_UN { get; set; }
  18413. // /// <summary>
  18414. // ///
  18415. // /// </summary>
  18416. // public string country_name_english_abbreviation { get; set; }
  18417. // /// <summary>
  18418. // ///
  18419. // /// </summary>
  18420. // public string country_name_english_formal { get; set; }
  18421. // /// <summary>
  18422. // ///
  18423. // /// </summary>
  18424. // public string country_name_english_UN { get; set; }
  18425. // /// <summary>
  18426. // ///
  18427. // /// </summary>
  18428. // public string continent_name { get; set; }
  18429. // /// <summary>
  18430. // ///
  18431. // /// </summary>
  18432. // public string subregion_name { get; set; }
  18433. // /// <summary>
  18434. // ///
  18435. // /// </summary>
  18436. // public string country_code2 { get; set; }
  18437. // /// <summary>
  18438. // ///
  18439. // /// </summary>
  18440. // public string country_code3 { get; set; }
  18441. // /// <summary>
  18442. // ///
  18443. // /// </summary>
  18444. // public string phone_code { get; set; }
  18445. //}
  18446. //public class CountriesInfo : BasicInfo
  18447. //{
  18448. // public List<CitiesInfo> c { get; set; }
  18449. //}
  18450. //public class CitiesInfo : BasicInfo
  18451. //{
  18452. // public List<AreaInfo> c { get; set; }
  18453. //}
  18454. //public class AreaInfo : BasicInfo
  18455. //{
  18456. // public List<AreaInfo> c { get; set; }
  18457. //}
  18458. //public class BasicInfo
  18459. //{
  18460. // public string code { get; set; }
  18461. // public string cn { get; set; }
  18462. // public string lv { get; set; }
  18463. // public string en { get; set; }
  18464. //}
  18465. #endregion
  18466. #region 查看邀请方
  18467. /// <summary>
  18468. /// 查看邀请方
  18469. /// 邀请方信息 Init
  18470. /// </summary>
  18471. /// <param name="dto"></param>
  18472. /// <returns></returns>
  18473. [HttpPost]
  18474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18475. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18476. {
  18477. string sqlWhere = string.Empty;
  18478. if (!string.IsNullOrEmpty(dto.Search))
  18479. {
  18480. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18481. }
  18482. string sql = string.Format($@"Select
  18483. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18484. Id,
  18485. UnitName
  18486. From Res_InvitationOfficialActivityData
  18487. Where IsDel = 0
  18488. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18489. RefAsync<int> total = 0;
  18490. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18491. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18492. }
  18493. /// <summary>
  18494. /// 查看邀请方
  18495. /// 国家信息 Init
  18496. /// </summary>
  18497. /// <param name="dto"></param>
  18498. /// <returns></returns>
  18499. [HttpPost]
  18500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18501. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18502. {
  18503. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18504. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18505. var diids = groupInfos.Select(it => it.Id).ToList();
  18506. List<string> countrys = new List<string>();
  18507. foreach (var item in country)
  18508. {
  18509. var data = _groupRepository.FormartTeamName(item);
  18510. var dataArray = _groupRepository.GroupSplitCountry(data);
  18511. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18512. }
  18513. countrys = countrys.Distinct().ToList();
  18514. for (int i = 0; i < countrys.Count; i++)
  18515. {
  18516. string item = countrys[i];
  18517. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18518. {
  18519. countrys.Remove(item);
  18520. i--;
  18521. }
  18522. }
  18523. RefAsync<int> total = 0;
  18524. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18525. .Where(it => countrys.Contains(it.Name_CN))
  18526. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18527. .Select(it => new { id = it.Id, name = it.Name_CN })
  18528. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18529. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18530. }
  18531. /// <summary>
  18532. /// 查看邀请方
  18533. /// 城市信息 Init
  18534. /// </summary>
  18535. /// <param name="dto"></param>
  18536. /// <returns></returns>
  18537. [HttpPost]
  18538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18539. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18540. {
  18541. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18542. RefAsync<int> total = 0;
  18543. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18544. .Where(it => it.CountriesId == dto.CountiesId)
  18545. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18546. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18547. .Select(it => new { id = it.Id, name = it.Name_CN })
  18548. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18549. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18550. }
  18551. /// <summary>
  18552. /// 查看邀请方
  18553. /// 团组名称 Init
  18554. /// </summary>
  18555. /// <param name="dto"></param>
  18556. /// <returns></returns>
  18557. [HttpPost]
  18558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18559. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18560. {
  18561. var watch = new Stopwatch();
  18562. watch.Start();
  18563. RefAsync<int> total = 0;
  18564. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18565. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18566. .Where((oa, di) => oa.IsDel == 0)
  18567. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18568. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18569. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18570. .Distinct()
  18571. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18572. watch.Stop();
  18573. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18574. }
  18575. /// <summary>
  18576. /// 查看邀请方
  18577. /// 团组 & 邀请方信息
  18578. /// </summary>
  18579. /// <param name="dto"></param>
  18580. /// <returns></returns>
  18581. [HttpPost]
  18582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18583. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18584. {
  18585. var watch = new Stopwatch();
  18586. watch.Start();
  18587. RefAsync<int> total = 0;
  18588. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18589. .AS("Grp_DelegationInfo")
  18590. .Includes(x => x.InvitingInfos)
  18591. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18592. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18593. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18594. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18595. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18596. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18597. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18598. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18599. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18600. infos.ForEach(x =>
  18601. {
  18602. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18603. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18604. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18605. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18606. });
  18607. watch.Stop();
  18608. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18609. }
  18610. #endregion
  18611. #region 报批行程
  18612. /// <summary>
  18613. /// 报批行程初始化
  18614. /// </summary>
  18615. /// <param name="dto"></param>
  18616. /// <returns></returns>
  18617. [HttpPost]
  18618. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18619. {
  18620. const int chiNumber = 5;
  18621. var jw = JsonView(false);
  18622. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18623. var group = groupList.First();
  18624. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18625. group = groupList.First(x => x.Id == diid);
  18626. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18627. .Where(x => x.DiId == diid && x.IsDel == 0)
  18628. .ToArray();
  18629. var count = 1;
  18630. foreach (var item in blackCodeList)
  18631. {
  18632. if (string.IsNullOrWhiteSpace(item.Title))
  18633. {
  18634. item.Title = "未设置名称数据" + count;
  18635. }
  18636. count++;
  18637. };
  18638. if (group == null)
  18639. {
  18640. jw.Msg = "暂无团组!";
  18641. return Ok(jw);
  18642. }
  18643. var data = new
  18644. {
  18645. groupList = groupList.Select(x => new
  18646. {
  18647. x.TeamName,
  18648. x.Id
  18649. }),
  18650. content = new ArrayList(),
  18651. groupInfo = new
  18652. {
  18653. group.VisitDays,
  18654. group.TourCode,
  18655. group.VisitPNumber,
  18656. group.TeamName,
  18657. group.Id,
  18658. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18659. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18660. },
  18661. blackCodeList = blackCodeList.Select(x => new
  18662. {
  18663. x.Title,
  18664. x.Id
  18665. }),
  18666. FileTempList = new ArrayList()
  18667. {
  18668. new { Index = 1,FileName = "旧模板" },
  18669. new { Index = 2,FileName = "省外办" },
  18670. new { Index = 3,FileName = "市外办" },
  18671. }
  18672. };
  18673. var resultArr = new ArrayList();
  18674. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18675. #region 默认不生成行程
  18676. //if (content.Count == 0)
  18677. //{
  18678. // var stay = "-";
  18679. // var cityPath = "-";
  18680. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18681. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18682. // .ToList();
  18683. // //添加城市路径以及住宿地
  18684. // //黑屏代码数据
  18685. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18686. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18687. // {
  18688. // jw = JsonView(true, "黑屏代码有误!", data);
  18689. // return Ok(jw);
  18690. // }
  18691. // data = data with
  18692. // {
  18693. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18694. // {
  18695. // x.Title,
  18696. // x.Id,
  18697. // }).ToArray())
  18698. // };
  18699. // foreach (DataRow row in dtBlack.Rows)
  18700. // {
  18701. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18702. // {
  18703. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18704. // return Ok(jw);
  18705. // }
  18706. // }
  18707. // //黑屏代码获取时间区间
  18708. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18709. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18710. // _sqlSugar.BeginTran();
  18711. // for (int i = 0; i < timeArr.Count; i++)
  18712. // {
  18713. // stay = "-";
  18714. // cityPath = "-";
  18715. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18716. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18717. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18718. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18719. // if (tbSelect.Length > 0)
  18720. // {
  18721. // List<string> threeCodeStr = new List<string>();
  18722. // foreach (var item in tbSelect)
  18723. // {
  18724. // var threeCode = item["Three"].ToString() ?? "";
  18725. // if (threeCode.Length == 6)
  18726. // {
  18727. // var start = threeCode.Substring(0, 3);
  18728. // var end = threeCode.Substring(3, 3);
  18729. // if (threeCodeStr.Count == 0)
  18730. // {
  18731. // threeCodeStr.Add(start);
  18732. // threeCodeStr.Add(end);
  18733. // }
  18734. // else
  18735. // {
  18736. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18737. // {
  18738. // threeCodeStr.Add(end);
  18739. // }
  18740. // else
  18741. // {
  18742. // threeCodeStr.Add(start);
  18743. // threeCodeStr.Add(end);
  18744. // }
  18745. // }
  18746. // }
  18747. // }
  18748. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18749. // var last = threeCodeStr.Last();
  18750. // foreach (var item in threeCodeStr)
  18751. // {
  18752. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18753. // if (item.Equals(last))
  18754. // {
  18755. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18756. // }
  18757. // }
  18758. // cityPath = cityPath.Trim('-');
  18759. // }
  18760. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18761. // appro.Diid = diid ?? -1;
  18762. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18763. // appro.Id = thisId;
  18764. // appro.CreateUserId = dto.UserId;
  18765. // appro.CreateTime = DateTime.Now;
  18766. // content.Add(appro);
  18767. // }
  18768. // _sqlSugar.CommitTran();
  18769. //}
  18770. #endregion
  18771. foreach (var x in content)
  18772. {
  18773. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18774. if (chiList.Count < chiNumber)
  18775. {
  18776. for (int i = chiList.Count; i < chiNumber; i++)
  18777. {
  18778. chiList.Add(new Grp_ApprovalTravelDetails());
  18779. }
  18780. }
  18781. resultArr.Add(new
  18782. {
  18783. x.Id,
  18784. x.Date,
  18785. x.Diid,
  18786. chiList = chiList.Select(x1 => new
  18787. {
  18788. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18789. x1.Details,
  18790. x1.ParentId,
  18791. x1.Id
  18792. })
  18793. });
  18794. }
  18795. data = data with
  18796. {
  18797. content = resultArr,
  18798. };
  18799. jw = JsonView(true, "获取成功!", data);
  18800. return Ok(jw);
  18801. }
  18802. /// <summary>
  18803. /// 报批行程删除
  18804. /// </summary>
  18805. /// <param name="dto"></param>
  18806. /// <returns></returns>
  18807. [HttpPost]
  18808. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18809. {
  18810. var jw = JsonView(false);
  18811. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18812. if (group == null)
  18813. {
  18814. jw.Msg = "团组参数有误!";
  18815. return Ok(jw);
  18816. }
  18817. try
  18818. {
  18819. _sqlSugar.BeginTran();
  18820. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18821. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18822. {
  18823. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18824. DeleteUserId = dto.uesrId,
  18825. IsDel = 1
  18826. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18827. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18828. {
  18829. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18830. DeleteUserId = dto.uesrId,
  18831. IsDel = 1
  18832. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18833. _sqlSugar.CommitTran();
  18834. jw = JsonView(true, "删除成功");
  18835. }
  18836. catch (Exception ex)
  18837. {
  18838. jw = JsonView(false, ex.Message);
  18839. }
  18840. return Ok(jw);
  18841. }
  18842. /// <summary>
  18843. /// 报批行程保存
  18844. /// </summary>
  18845. /// <param name="dto"></param>
  18846. /// <returns></returns>
  18847. [HttpPost]
  18848. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18849. {
  18850. var jw = JsonView(false);
  18851. var Find = dto.Arr.Find(x => x.id == 0);
  18852. if (Find != null)
  18853. {
  18854. jw.Msg = "生成的ID为0!";
  18855. return Ok(jw);
  18856. }
  18857. foreach (var item in dto.Arr)
  18858. {
  18859. foreach (var chi in item.chiList)
  18860. {
  18861. if (chi.parentId == 0)
  18862. {
  18863. chi.parentId = item.id;
  18864. }
  18865. }
  18866. }
  18867. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18868. _sqlSugar.BeginTran();
  18869. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18870. {
  18871. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18872. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18873. {
  18874. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18875. DeleteUserId = dto.UserId,
  18876. IsDel = 1
  18877. }).ExecuteCommand();
  18878. }
  18879. try
  18880. {
  18881. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18882. {
  18883. CreateTime = DateTime.Now,
  18884. CreateUserId = dto.UserId,
  18885. Details = x.details,
  18886. ParentId = x.parentId,
  18887. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18888. Remark = "",
  18889. IsDel = 0
  18890. }).ToList()).ExecuteCommand();
  18891. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18892. {
  18893. Id = x.id,
  18894. Details = x.details,
  18895. ParentId = x.parentId,
  18896. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18897. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18898. {
  18899. Details = x.Details,
  18900. ParentId = x.ParentId,
  18901. Time = x.Time
  18902. }).ExecuteCommand();
  18903. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18904. {
  18905. Id = x.id,
  18906. Date = x.date,
  18907. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18908. {
  18909. Date = x.Date
  18910. }).ExecuteCommand();
  18911. _sqlSugar.CommitTran();
  18912. jw = JsonView(true, "保存成功!");
  18913. }
  18914. catch (Exception ex)
  18915. {
  18916. _sqlSugar.RollbackTran();
  18917. jw = JsonView(false, "保存失败!" + ex.Message);
  18918. }
  18919. return Ok(jw);
  18920. }
  18921. /// <summary>
  18922. /// 报批行程生成
  18923. /// </summary>
  18924. /// <param name="dto"></param>
  18925. /// <returns></returns>
  18926. [HttpPost]
  18927. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18928. {
  18929. var jw = JsonView(false);
  18930. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18931. if (group == null)
  18932. {
  18933. jw.Msg = "暂无该团组!";
  18934. return Ok(jw);
  18935. }
  18936. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18937. //黑屏代码数据
  18938. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18939. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18940. {
  18941. jw.Msg = "黑屏代码有误!";
  18942. return Ok(jw);
  18943. }
  18944. foreach (DataRow row in dtBlack.Rows)
  18945. {
  18946. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18947. {
  18948. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18949. return Ok(jw);
  18950. }
  18951. }
  18952. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18953. var resultArr = new ArrayList();
  18954. //if (officialActivitiesArr.Count == 0)
  18955. //{
  18956. // jw.Msg = "暂无公务出访信息!";
  18957. // return Ok(jw);
  18958. //}
  18959. try
  18960. {
  18961. _sqlSugar.BeginTran();
  18962. DeleteApprovalJourney(new
  18963. Domain.Dtos.Groups.DeleteApprovalJourney
  18964. {
  18965. Diid = dto.Diid,
  18966. uesrId = dto.Userid
  18967. });
  18968. var stay = "-";
  18969. var cityPath = "-";
  18970. //添加城市路径以及住宿地
  18971. //黑屏代码获取时间区间
  18972. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18973. var empty = "【未收入该三字码!请机票同事录入】";
  18974. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18975. for (int i = 0; i < timeArr.Count; i++)
  18976. {
  18977. stay = "-";
  18978. cityPath = "-";
  18979. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18980. DateTime NewData = DateTime.Parse(timeArr[i]);
  18981. //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();
  18982. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18983. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18984. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18985. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18986. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18987. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18988. if (tbSelect.Length > 0)
  18989. {
  18990. List<string> threeCodeStr = new List<string>();
  18991. bool isTrade = false;
  18992. string trip = string.Empty;
  18993. var rowLast = tbSelect.Last();
  18994. var rowFirst = tbSelect.First();
  18995. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18996. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18997. var takeOffTime = DateTime.Parse(timeArr[i]);
  18998. var fallToTime = DateTime.Parse(timeArr[i]);
  18999. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  19000. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  19001. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  19002. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  19003. foreach (var item in tbSelect)
  19004. {
  19005. var start = string.Empty;
  19006. var end = string.Empty;
  19007. var threeCode = item["Three"].ToString() ?? "";
  19008. if (threeCode.Length == 6)
  19009. {
  19010. start = threeCode.Substring(0, 3);
  19011. end = threeCode.Substring(3, 3);
  19012. if (threeCodeStr.Count == 0)
  19013. {
  19014. threeCodeStr.Add(start);
  19015. threeCodeStr.Add(end);
  19016. }
  19017. else
  19018. {
  19019. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19020. {
  19021. threeCodeStr.Add(end);
  19022. }
  19023. else
  19024. {
  19025. threeCodeStr.Add(start);
  19026. threeCodeStr.Add(end);
  19027. }
  19028. }
  19029. }
  19030. //处理机票信息
  19031. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  19032. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  19033. if (start_Object == null)
  19034. {
  19035. start_Object = new Res_ThreeCode()
  19036. {
  19037. AirPort = empty,
  19038. AirPort_En = empty,
  19039. City = empty,
  19040. Country = empty,
  19041. Four = empty,
  19042. Three = empty,
  19043. };
  19044. }
  19045. if (end_Object == null)
  19046. {
  19047. end_Object = new Res_ThreeCode()
  19048. {
  19049. AirPort = empty,
  19050. AirPort_En = empty,
  19051. City = empty,
  19052. Country = empty,
  19053. Four = empty,
  19054. Three = empty,
  19055. };
  19056. }
  19057. //机型判断
  19058. string airModel = item["AirModel"].ToString();
  19059. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  19060. string flightTime = item["FlightTime"].ToString();
  19061. if (flightTime!.Contains(":"))
  19062. {
  19063. flightTime = flightTime.Replace(":", "小时");
  19064. flightTime += "分钟";
  19065. }
  19066. if (flightTime.Contains("H"))
  19067. {
  19068. flightTime = flightTime.Replace("H", "小时");
  19069. }
  19070. if (flightTime.Contains("M"))
  19071. {
  19072. flightTime = flightTime.Replace("M", "分钟");
  19073. }
  19074. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  19075. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  19076. {
  19077. flightTime = flightDataTime.Hour > 0
  19078. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  19079. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  19080. ? flightDataTime.Minute.ToString() + "分钟" : "";
  19081. }
  19082. //航班号
  19083. string flightcode = item["Fliagtcode"].ToString();
  19084. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  19085. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  19086. if (aircompany == null)
  19087. {
  19088. aircompany = new Res_AirCompany
  19089. {
  19090. CnName = hsEmpty,
  19091. EnName = hsEmpty,
  19092. ShortCode = hsEmpty,
  19093. };
  19094. }
  19095. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  19096. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  19097. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  19098. if (isTrade)
  19099. {
  19100. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  19101. }
  19102. else
  19103. {
  19104. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  19105. }
  19106. }
  19107. chiarr.Add(new Grp_ApprovalTravelDetails
  19108. {
  19109. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  19110. CreateTime = DateTime.Now,
  19111. CreateUserId = dto.Userid,
  19112. ParentId = 0,
  19113. Details = trip
  19114. });
  19115. //添加乘车语句
  19116. chiarr.Add(new Grp_ApprovalTravelDetails
  19117. {
  19118. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  19119. CreateTime = DateTime.Now,
  19120. CreateUserId = dto.Userid,
  19121. ParentId = 0,
  19122. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  19123. });
  19124. if (i != timeArr.Count - 1)
  19125. {
  19126. fallToTime = fallToTime.AddHours(2.5);
  19127. foreach (var item in Times)
  19128. {
  19129. //排列公务时间
  19130. if (fallToTime.Hour < item.Item1)
  19131. {
  19132. chiarr.Add(new Grp_ApprovalTravelDetails
  19133. {
  19134. Time = $"{item.Item2} - {item.Item3}",
  19135. CreateTime = DateTime.Now,
  19136. CreateUserId = dto.Userid,
  19137. ParentId = 0,
  19138. Details = "公务活动"
  19139. });
  19140. }
  19141. }
  19142. }
  19143. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19144. var last = threeCodeStr.Last();
  19145. foreach (var item in threeCodeStr)
  19146. {
  19147. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19148. if (item.Equals(last))
  19149. {
  19150. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19151. }
  19152. }
  19153. cityPath = cityPath.Trim('-');
  19154. }
  19155. else
  19156. {
  19157. foreach (var item in Times)
  19158. {
  19159. chiarr.Add(new Grp_ApprovalTravelDetails
  19160. {
  19161. Time = $"{item.Item2} - {item.Item3}",
  19162. CreateTime = DateTime.Now,
  19163. CreateUserId = dto.Userid,
  19164. ParentId = 0,
  19165. Details = "公务活动"
  19166. });
  19167. }
  19168. }
  19169. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19170. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19171. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  19172. appro.Diid = dto.Diid;
  19173. appro.CreateUserId = dto.Userid;
  19174. appro.CreateTime = DateTime.Now;
  19175. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19176. appro.Id = thisId;
  19177. //foreach (var item in gwinfo)
  19178. //{
  19179. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  19180. // chi.Details = "拜访" + item.Client;
  19181. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  19182. // {
  19183. // chi.Details += "," + item.ReqSample;
  19184. // }
  19185. // chi.ParentId = thisId;
  19186. // chi.Time = item.Time;
  19187. // chiarr.Add(chi);
  19188. //}
  19189. if (chiarr.Count < 6)
  19190. {
  19191. for (int j = chiarr.Count; j < 6; j++)
  19192. {
  19193. chiarr.Add(new
  19194. Grp_ApprovalTravelDetails());
  19195. }
  19196. }
  19197. resultArr.Add(new
  19198. {
  19199. appro.Id,
  19200. appro.Date,
  19201. appro.Diid,
  19202. chiList = chiarr.Select(x1 => new
  19203. {
  19204. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19205. x1.Details,
  19206. x1.ParentId,
  19207. x1.Id
  19208. })
  19209. });
  19210. }
  19211. _sqlSugar.CommitTran();
  19212. jw = JsonView(true, "生成成功!", resultArr);
  19213. }
  19214. catch (Exception ex)
  19215. {
  19216. jw.Code = 400;
  19217. jw.Msg = "生成失败!" + ex.Message;
  19218. }
  19219. return Ok(jw);
  19220. }
  19221. /// <summary>
  19222. /// 报批行程word导出
  19223. /// </summary>
  19224. /// <param name="dto"></param>
  19225. /// <returns></returns>
  19226. [HttpPost]
  19227. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  19228. {
  19229. var jw = JsonView(false);
  19230. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19231. if (group == null)
  19232. {
  19233. jw.Msg = "暂无该团组!";
  19234. return Ok(jw);
  19235. }
  19236. //模板路径
  19237. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  19238. var fileName = string.Empty;
  19239. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  19240. bool bold = false;
  19241. if (dto.FileIndex == 1)
  19242. {
  19243. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  19244. }
  19245. else if (dto.FileIndex == 2)
  19246. {
  19247. fileName = "省外办-报批.docx";
  19248. bold = false;
  19249. titleFont = "方正黑体简体";
  19250. timeFont = "Times New Roman";
  19251. contentFont = "方正仿宋_GBK";
  19252. }
  19253. else if (dto.FileIndex == 3)
  19254. {
  19255. fileName = "市外办-报批.docx";
  19256. titleFont = "方正黑体简体";
  19257. timeFont = "Times New Roman";
  19258. contentFont = "方正仿宋简体";
  19259. }
  19260. tempPath = tempPath + fileName;
  19261. //载入模板
  19262. Document doc = new Document(tempPath);
  19263. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19264. //获取所填表格的序数
  19265. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19266. Aspose.Words.Tables.Row titleRowClone = null;
  19267. Aspose.Words.Tables.Row CenterRowClone = null;
  19268. int index = 0;
  19269. int indexChi = 0;
  19270. int SetIndex = 0;
  19271. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  19272. //获取数据,放到datatable
  19273. foreach (var item in ApprovalTravelArr)
  19274. {
  19275. if (index > 0)
  19276. {
  19277. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  19278. tableOne.AppendChild(titleRowClone);
  19279. }
  19280. var textTime = item.Date;
  19281. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  19282. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  19283. SetIndex++;
  19284. if (ChiRep.Count > 0)
  19285. {
  19286. foreach (var itemChi in ChiRep)
  19287. {
  19288. var txtTime = itemChi.Time;
  19289. var txtDetail = itemChi.Details;
  19290. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  19291. {
  19292. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  19293. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19294. //indexChi++;
  19295. //SetIndex++;
  19296. break;
  19297. }
  19298. if (indexChi > 0)
  19299. {
  19300. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19301. tableOne.AppendChild(CenterRowClone);
  19302. }
  19303. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  19304. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  19305. indexChi++;
  19306. SetIndex++;
  19307. }
  19308. }
  19309. //else
  19310. //{
  19311. // if (indexChi > 0)
  19312. // {
  19313. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19314. // tableOne.AppendChild(CenterRowClone);
  19315. // }
  19316. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  19317. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19318. // indexChi++;
  19319. // SetIndex++;
  19320. //}
  19321. index++;
  19322. }
  19323. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  19324. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19325. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19326. jw.Code = 200;
  19327. jw.Msg = "";
  19328. return Ok(jw);
  19329. }
  19330. private string intToString(int numberVal)
  19331. {
  19332. string numberval = numberVal.ToString();
  19333. Dictionary<char, string> Number = new Dictionary<char, string>();
  19334. Number.Add('1', "一");
  19335. Number.Add('2', "二");
  19336. Number.Add('3', "三");
  19337. Number.Add('4', "四");
  19338. Number.Add('5', "五");
  19339. Number.Add('6', "六");
  19340. Number.Add('7', "七");
  19341. Number.Add('8', "八");
  19342. Number.Add('9', "九");
  19343. string stringNumberVal = string.Empty;
  19344. for (int i = 0; i < numberval.Length; i++)
  19345. {
  19346. if (i == 0)
  19347. {
  19348. stringNumberVal += Number[numberval[i]];
  19349. }
  19350. else if (i >= 1)
  19351. {
  19352. if (numberval[i] == '0')
  19353. {
  19354. stringNumberVal = "十";
  19355. }
  19356. else
  19357. {
  19358. stringNumberVal += "十" + Number[numberval[i]];
  19359. }
  19360. }
  19361. }
  19362. return stringNumberVal;
  19363. }
  19364. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  19365. {
  19366. //获取table中的某个单元格,从0开始
  19367. Cell lshCell = table.Rows[rows].Cells[cells];
  19368. //将单元格中段落移除
  19369. foreach (Paragraph item in lshCell.Paragraphs)
  19370. {
  19371. lshCell.Paragraphs.Remove(item);
  19372. }
  19373. if (val.Contains("\r\n"))
  19374. {
  19375. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19376. foreach (var item in spArr)
  19377. {
  19378. //新建一个段落
  19379. Paragraph p = new Paragraph(doc);
  19380. var r = new Run(doc, item);
  19381. //设置字体
  19382. if (!string.IsNullOrEmpty(font))
  19383. {
  19384. r.Font.Name = font;
  19385. }
  19386. r.Font.Bold = bold;
  19387. //把设置的值赋给之前新建的段落
  19388. p.AppendChild(r);
  19389. //将此段落加到单元格内
  19390. lshCell.AppendChild(p);
  19391. }
  19392. }
  19393. else
  19394. {
  19395. //新建一个段落
  19396. Paragraph p = new Paragraph(doc);
  19397. var r = new Run(doc, val);
  19398. //设置字体
  19399. if (!string.IsNullOrEmpty(font))
  19400. {
  19401. r.Font.Name = font;
  19402. }
  19403. r.Font.Bold = bold;
  19404. //把设置的值赋给之前新建的段落
  19405. p.AppendChild(r);
  19406. //将此段落加到单元格内
  19407. lshCell.AppendChild(p);
  19408. }
  19409. }
  19410. [HttpPost]
  19411. public async Task<IActionResult> ServerHttp(string paramStr)
  19412. {
  19413. paramStr = paramStr.TrimEnd('\'');
  19414. paramStr = paramStr.TrimStart('\'');
  19415. JsonView jw = JsonView(false);
  19416. JObject param = JObject.Parse(paramStr);
  19417. if (!param.ContainsKey("url"))
  19418. {
  19419. jw.Msg = "url null";
  19420. return Ok(jw);
  19421. }
  19422. string url = param["url"]!.ToString();
  19423. var methon = "get";
  19424. Dictionary<string, string> headValues = null;
  19425. string bodyStr = string.Empty;
  19426. if (param.ContainsKey("methon"))
  19427. {
  19428. methon = param["methon"]!.ToString().ToLower();
  19429. }
  19430. if (param.ContainsKey("header"))
  19431. {
  19432. var header = param["header"]!.ToString();
  19433. JObject headerJobject = JObject.Parse(header);
  19434. headValues = new Dictionary<string, string>();
  19435. foreach (JProperty item in headerJobject.Properties())
  19436. {
  19437. var value = item.Value.ToString();
  19438. var head = item.Path;
  19439. headValues.Add(head, value);
  19440. }
  19441. }
  19442. HttpClient client = new HttpClient();
  19443. string responseString = string.Empty;
  19444. StringContent content = null;
  19445. if (headValues != null)
  19446. {
  19447. foreach (var item in headValues.Keys)
  19448. {
  19449. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19450. {
  19451. if (param.ContainsKey("body"))
  19452. {
  19453. bodyStr = param["body"]!.ToString();
  19454. }
  19455. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19456. }
  19457. else
  19458. {
  19459. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19460. }
  19461. }
  19462. }
  19463. try
  19464. {
  19465. if (methon == "get")
  19466. {
  19467. responseString = await client.GetStringAsync(url);
  19468. }
  19469. else if (methon == "post")
  19470. {
  19471. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19472. {
  19473. Content = content
  19474. };
  19475. var response = await client.SendAsync(request);
  19476. try
  19477. {
  19478. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19479. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19480. {
  19481. using (StreamReader reader = new StreamReader(gzipStream))
  19482. {
  19483. responseString = await reader.ReadToEndAsync();
  19484. }
  19485. }
  19486. }
  19487. catch (Exception)
  19488. {
  19489. responseString = await response.Content.ReadAsStringAsync();
  19490. }
  19491. }
  19492. else
  19493. {
  19494. responseString = "methon error";
  19495. }
  19496. jw = JsonView(true, "success", responseString);
  19497. }
  19498. catch (Exception ex)
  19499. {
  19500. jw.Msg = "error " + ex.Message;
  19501. jw.Data = ex.StackTrace;
  19502. }
  19503. finally
  19504. {
  19505. client.Dispose();
  19506. }
  19507. return Ok(jw);
  19508. }
  19509. #endregion
  19510. #region 团组接待意见调查
  19511. /// <summary>
  19512. /// 团组接待意见调查 - 信息管理
  19513. /// 基础数据(团组)
  19514. /// </summary>
  19515. /// <returns></returns>
  19516. [HttpGet]
  19517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19518. public async Task<IActionResult> OpinionaireInit()
  19519. {
  19520. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19521. .Select(x => new
  19522. {
  19523. x.Id,
  19524. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19525. })
  19526. .OrderByDescending(x => x.Id)
  19527. .ToListAsync();
  19528. return Ok(JsonView(groupData, groupData.Count));
  19529. }
  19530. /// <summary>
  19531. /// 团组接待意见调查 - 信息管理
  19532. /// 列表
  19533. /// </summary>
  19534. /// <param name="groupId"></param>
  19535. /// <returns></returns>
  19536. [HttpGet("{groupId}")]
  19537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19538. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19539. {
  19540. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19541. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19542. .Select(x => new
  19543. {
  19544. x.Id,
  19545. x.TourGuideName,
  19546. x.CityName,
  19547. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19548. x.CreateTime
  19549. })
  19550. .OrderBy(x => x.Id)
  19551. .ToListAsync();
  19552. return Ok(JsonView(data));
  19553. }
  19554. /// <summary>
  19555. /// 团组接待意见调查 - 信息管理
  19556. /// 保存
  19557. /// </summary>
  19558. /// <param name="dto"></param>
  19559. /// <returns></returns>
  19560. [HttpPost]
  19561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19562. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19563. {
  19564. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19565. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19566. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19567. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19568. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19569. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19570. _opinionaireRep.BeginTran();
  19571. if (addData != null && addData.Count > 0)
  19572. {
  19573. foreach (var item in addData)
  19574. {
  19575. item.CreateUserId = currUserInfo.UserId;
  19576. item.DiId = dto.DiId;
  19577. }
  19578. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19579. }
  19580. if (updData != null && updData.Count > 0)
  19581. {
  19582. var upd = await _opinionaireRep._sqlSugar
  19583. .Updateable(updData)
  19584. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19585. .WhereColumns(x => new { x.Id })
  19586. .ExecuteCommandAsync();
  19587. }
  19588. _opinionaireRep.CommitTran();
  19589. return Ok(JsonView("操作成功!"));
  19590. }
  19591. /// <summary>
  19592. /// 团组接待意见调查 - 信息管理
  19593. /// 删除
  19594. /// </summary>
  19595. /// <param name="id"></param>
  19596. /// <returns></returns>
  19597. [HttpDelete("{id}")]
  19598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19599. public async Task<IActionResult> OpinionaireManageDel(int id)
  19600. {
  19601. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19602. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19603. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19604. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19605. if (!del) return Ok(JsonView("操作失败!"));
  19606. return Ok(JsonView("操作成功!"));
  19607. }
  19608. /// <summary>
  19609. /// 团组接待意见调查 - 用户
  19610. /// 列表
  19611. /// </summary>
  19612. /// <param name="diId"></param>
  19613. /// <returns></returns>
  19614. [HttpGet("{diId}")]
  19615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19616. public async Task<IActionResult> OpinionaireUserList(int diId)
  19617. {
  19618. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19619. var sql = string.Format(@"
  19620. SELECT
  19621. o.Id,
  19622. o.DiId,
  19623. di.TeamName AS 'GroupName',
  19624. di.VisitPNumber AS 'PeopleNumber',
  19625. di.ClientName AS 'LeadGroup',
  19626. di.VisitCountry AS 'Travel',
  19627. di.VisitDays AS 'Days',
  19628. o.CityName,
  19629. o.TourGuideName,
  19630. o.Catering,
  19631. o.CateringReason,
  19632. o.Stay,
  19633. o.StayReason,
  19634. o.[Route],
  19635. o.RouteReason,
  19636. o.OfficialActivity,
  19637. o.OfficialActivityReason,
  19638. o.TourGuide,
  19639. o.TourGuideReason,
  19640. o.[Translate],
  19641. o.TranslateReason,
  19642. o.Trip,
  19643. o.TripReason,
  19644. o.ESFileName,
  19645. o.SignatureDate,
  19646. o.Remark
  19647. FROM
  19648. Grp_Opinionaire o
  19649. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19650. WHERE
  19651. o.IsDel = 0
  19652. AND o.DiId = {0}
  19653. ORDER BY
  19654. o.Id ASC", diId);
  19655. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19656. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19657. return Ok(JsonView(data));
  19658. }
  19659. /// <summary>
  19660. /// 团组接待意见调查 - 用户
  19661. /// 保存
  19662. /// </summary>
  19663. /// <param name="dto"></param>
  19664. /// <returns></returns>
  19665. [HttpPost]
  19666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19667. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19668. {
  19669. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19670. foreach (var item in dto)
  19671. {
  19672. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19673. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19674. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19675. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19676. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19677. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19678. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19679. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19680. }
  19681. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19682. if (!Directory.Exists(filePathBase))
  19683. {
  19684. Directory.CreateDirectory(filePathBase);
  19685. }
  19686. #region 上传文件
  19687. var filePaths = new List<string>();
  19688. foreach (var item in dto)
  19689. {
  19690. var file = item.File;
  19691. // 将文件保存到指定位置
  19692. var filePath = Path.Combine(filePathBase, file.FileName);
  19693. using (var stream = new FileStream(filePath, FileMode.Create))
  19694. {
  19695. await file.CopyToAsync(stream);
  19696. }
  19697. //验证文件是否上传成功
  19698. if (!System.IO.File.Exists(filePath))
  19699. {
  19700. foreach (var filePathStr in filePaths)
  19701. {
  19702. System.IO.File.Delete(filePathStr);
  19703. }
  19704. return Ok(JsonView(false, "文件上传失败!"));
  19705. }
  19706. item.ESFileName = file.FileName;
  19707. }
  19708. #endregion
  19709. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19710. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19711. .UpdateColumns(x => new
  19712. {
  19713. x.Catering,
  19714. x.CateringReason,
  19715. x.Stay,
  19716. x.StayReason,
  19717. x.Route,
  19718. x.RouteReason,
  19719. x.OfficialActivity,
  19720. x.OfficialActivityReason,
  19721. x.TourGuide,
  19722. x.TourGuideReason,
  19723. x.Translate,
  19724. x.TranslateReason,
  19725. x.Trip,
  19726. x.TripReason,
  19727. x.ESFileName,
  19728. x.SignatureDate,
  19729. x.Remark
  19730. })
  19731. .WhereColumns(x => new { x.Id })
  19732. .ExecuteCommandAsync();
  19733. if (upd < 1)
  19734. {
  19735. foreach (var filePathStr in filePaths)
  19736. {
  19737. System.IO.File.Delete(filePathStr);
  19738. }
  19739. return Ok(JsonView(false));
  19740. }
  19741. return Ok(JsonView(true));
  19742. }
  19743. #endregion
  19744. #region 团组餐厅相关信息
  19745. /// <summary>
  19746. /// 团组相关餐厅信息
  19747. /// 基础数据(团组)
  19748. /// </summary>
  19749. /// <returns></returns>
  19750. [HttpGet]
  19751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19752. public async Task<IActionResult> RestaurantInit()
  19753. {
  19754. return Ok(await _restaurantRep.InitAsync());
  19755. }
  19756. /// <summary>
  19757. /// 团组相关餐厅信息
  19758. /// Item
  19759. /// </summary>
  19760. /// <param name="dto"></param>
  19761. /// <returns></returns>
  19762. [HttpPost]
  19763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19764. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19765. {
  19766. int portType = dto.PortType,
  19767. groupId = dto.GroupId;
  19768. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19769. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19770. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19771. }
  19772. /// <summary>
  19773. /// 团组相关餐厅信息
  19774. /// List
  19775. /// </summary>
  19776. /// <param name="dto"></param>
  19777. /// <returns></returns>
  19778. [HttpPost]
  19779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19780. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19781. {
  19782. int portType = dto.PortType,
  19783. groupId = dto.GroupId;
  19784. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19785. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19786. var sql = string.Format(@" SELECT
  19787. ri.Id,
  19788. ri.GroupId,
  19789. ri.Date,
  19790. ri.StartTime,
  19791. ri.EndTime,
  19792. CASE WHEN ri.Type = 1 THEN '早餐'
  19793. WHEN ri.Type = 2 THEN '午餐'
  19794. WHEN ri.Type = 3 THEN '晚餐'
  19795. ELSE '其他'
  19796. END AS 'Type',
  19797. ri.Name,
  19798. ri.Address,
  19799. ri.Tel,
  19800. ri.Remark,
  19801. ri.CreateTime,
  19802. u.CnName AS CreateUserName
  19803. FROM
  19804. Grp_RestaurantInfo ri
  19805. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19806. WHERE
  19807. ri.IsDel = 0
  19808. AND ri.GroupId = {0}
  19809. ORDER BY
  19810. ri.Date ASC
  19811. ", groupId);
  19812. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19813. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19814. return Ok(JsonView(infos));
  19815. }
  19816. /// <summary>
  19817. /// 团组相关餐厅信息
  19818. /// Info
  19819. /// </summary>
  19820. /// <param name="dto"></param>
  19821. /// <returns></returns>
  19822. [HttpPost]
  19823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19824. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19825. {
  19826. int portType = dto.PortType,
  19827. id = dto.Id;
  19828. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19829. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19830. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19831. }
  19832. /// <summary>
  19833. /// 团组相关餐厅信息
  19834. /// Op
  19835. /// </summary>
  19836. /// <param name="dto"></param>
  19837. /// <returns></returns>
  19838. [HttpPost]
  19839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19840. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19841. {
  19842. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19843. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19844. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19845. return Ok(await _restaurantRep.OpAsync(dto));
  19846. }
  19847. /// <summary>
  19848. /// 团组相关餐厅信息
  19849. /// Del
  19850. /// </summary>
  19851. /// <param name="dto"></param>
  19852. /// <returns></returns>
  19853. [HttpPost]
  19854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19855. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19856. {
  19857. int userId = dto.DeleteUserId;
  19858. var id = dto.Id;
  19859. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19860. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19861. return Ok(await _restaurantRep.DelAsync(dto));
  19862. }
  19863. #endregion
  19864. // /// <summary>
  19865. // ///
  19866. // /// </summary>
  19867. // /// <param name="_dto"></param>
  19868. // /// <returns></returns>
  19869. // [HttpPost]
  19870. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19871. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19872. // {
  19873. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19874. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19875. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19876. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19877. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19878. // dic_psg.Add("客人", 974);
  19879. // dic_psg.Add("司机", 975);
  19880. // dic_psg.Add("导游", 976);
  19881. // dic_psg.Add("公司内部人员", 977);
  19882. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19883. // foreach (var item in list_visa)
  19884. // {
  19885. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19886. // temp.Id = item.Id;
  19887. // temp.DIId = item.DIId;
  19888. // temp.VisaClient = item.VisaClient;
  19889. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19890. // temp.VisaCurrency = item.VisaCurrency;
  19891. // temp.IsThird = item.IsThird;
  19892. // if (dic_psg.ContainsKey(item.PassengerType))
  19893. // {
  19894. // temp.PassengerType = dic_psg[item.PassengerType];
  19895. // }
  19896. // else {
  19897. // temp.PassengerType = -1;
  19898. // }
  19899. // temp.VisaNumber = item.VisaNumber;
  19900. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19901. // temp.CreateUserId = item.Operators;
  19902. // DateTime dt_ct;
  19903. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19904. // if (b_ct)
  19905. // {
  19906. // temp.CreateTime = dt_ct;
  19907. // }
  19908. // else
  19909. // {
  19910. // temp.CreateTime = DateTime.Now;
  19911. // }
  19912. // temp.DeleteTime = "";
  19913. // temp.DeleteUserId = 0;
  19914. // temp.Remark = item.Remark;
  19915. // if (string.IsNullOrEmpty(temp.Remark)) {
  19916. // temp.Remark = "";
  19917. // }
  19918. // temp.IsDel = item.IsDel;
  19919. // temp.VisaDescription = item.VisaAttachment;
  19920. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19921. //([Id]
  19922. // ,[DIId]
  19923. // ,[VisaClient]
  19924. // ,[VisaPrice]
  19925. // ,[VisaCurrency]
  19926. // ,[IsThird]
  19927. // ,[PassengerType]
  19928. // ,[VisaNumber]
  19929. // ,[VisaFreeNumber]
  19930. // ,[CreateUserId]
  19931. // ,[CreateTime]
  19932. // ,[DeleteTime]
  19933. // ,[DeleteUserId]
  19934. // ,[Remark]
  19935. // ,[IsDel]
  19936. // ,[visaDescription])
  19937. // VALUES
  19938. // ({0},{1},'{2}',{3},{4}
  19939. //,{5},{6},{7},{8},{9}
  19940. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19941. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19942. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19943. //);
  19944. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19945. // }
  19946. // return Ok(JsonView(true, "操作成功!"));
  19947. // }
  19948. /// <summary>
  19949. /// 123132123
  19950. /// </summary>
  19951. /// <param name="_dto"></param>
  19952. /// <returns></returns>
  19953. [HttpPost]
  19954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19955. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19956. {
  19957. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19958. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19959. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19960. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19961. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19962. dicDetail.Add(789, 1034);
  19963. dicDetail.Add(790, 1035);
  19964. dicDetail.Add(791, 1036);
  19965. dicDetail.Add(792, 1037);
  19966. dicDetail.Add(793, 1038);
  19967. dicDetail.Add(794, 1039);
  19968. dicDetail.Add(795, 1040);
  19969. dicDetail.Add(796, 1041);
  19970. dicDetail.Add(797, 1042);
  19971. dicDetail.Add(798, 1043);
  19972. dicDetail.Add(801, 1044);
  19973. dicDetail.Add(802, 1045);
  19974. dicDetail.Add(803, 1046);
  19975. Dictionary<int, int> dic = new Dictionary<int, int>();
  19976. dic.Add(806, 1027);
  19977. dic.Add(807, 1028);
  19978. dic.Add(808, 1029);
  19979. dic.Add(809, 1030);
  19980. dic.Add(810, 1031);
  19981. dic.Add(811, 1032);
  19982. dic.Add(812, 1033);
  19983. foreach (var item in list_visa)
  19984. {
  19985. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19986. temp.Coefficient = item.coefficient;
  19987. DateTime dtCrt;
  19988. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19989. if (b1)
  19990. {
  19991. temp.CreateTime = dtCrt;
  19992. }
  19993. else
  19994. {
  19995. temp.CreateTime = DateTime.Now;
  19996. }
  19997. temp.CreateUserId = item.Operators;
  19998. temp.DeleteTime = "";
  19999. temp.DeleteUserId = 0;
  20000. temp.DiId = int.Parse(item.DIID);
  20001. temp.FilePath = item.FilePath;
  20002. temp.IsDel = item.IsDel;
  20003. temp.Price = item.Price;
  20004. temp.PriceCount = 1;
  20005. temp.PriceCurrency = item.Currency;
  20006. int detailId = 0;
  20007. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  20008. {
  20009. detailId = dicDetail[item.PriceTypeDetail];
  20010. }
  20011. temp.PriceDetailType = detailId;
  20012. temp.PriceDt = DateTime.Now;
  20013. temp.PriceName = item.PriceName;
  20014. temp.PriceSum = item.Price;
  20015. int tid = 0;
  20016. if (dic.ContainsKey(item.PriceType))
  20017. {
  20018. tid = dic[item.PriceType];
  20019. }
  20020. temp.PriceType = tid;
  20021. temp.Remark = item.Remark;
  20022. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  20023. }
  20024. return Ok(JsonView(true, "操作成功!"));
  20025. }
  20026. [HttpPost]
  20027. public IActionResult TimeTest()
  20028. {
  20029. var jw = JsonView(false, "error");
  20030. _sqlSugar.BeginTran();
  20031. try
  20032. {
  20033. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  20034. .Select(x => new Crm_NewClientData
  20035. {
  20036. Id = x.Id,
  20037. Client = x.Client,
  20038. Contact = x.Contact,
  20039. Location = x.Location,
  20040. })
  20041. .ToList();
  20042. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  20043. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  20044. Stopwatch stopwatch = new Stopwatch();
  20045. // 开始计时
  20046. stopwatch.Start();
  20047. foreach (var item in clientList)
  20048. {
  20049. EncryptionProcessor.DecryptProperties(item);
  20050. }
  20051. stopwatch.Stop();
  20052. jw.Code = 200;
  20053. jw.Data = stopwatch.ElapsedMilliseconds;
  20054. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  20055. }
  20056. catch (Exception ex)
  20057. {
  20058. jw.Code = 400;
  20059. jw.Msg = ex.Message;
  20060. }
  20061. return Ok(jw);
  20062. }
  20063. }
  20064. }