GroupsController.cs 1.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using EyeSoft.Runtime.InteropServices;
  7. using Microsoft.AspNetCore.SignalR;
  8. using Microsoft.IdentityModel.Tokens;
  9. using Microsoft.VisualBasic;
  10. using MySqlX.XDevAPI.Relational;
  11. using NetTaste;
  12. using NPOI.HSSF.UserModel;
  13. using NPOI.SS.Formula.Functions;
  14. using NPOI.SS.UserModel;
  15. using NPOI.SS.Util;
  16. using NPOI.XSSF.UserModel;
  17. using OASystem.API.Middlewares;
  18. using OASystem.API.OAMethodLib;
  19. using OASystem.API.OAMethodLib.APNs;
  20. using OASystem.API.OAMethodLib.File;
  21. using OASystem.API.OAMethodLib.Hub.HubClients;
  22. using OASystem.API.OAMethodLib.Hub.Hubs;
  23. using OASystem.API.OAMethodLib.JuHeAPI;
  24. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  25. using OASystem.Domain.AesEncryption;
  26. using OASystem.Domain.Attributes;
  27. using OASystem.Domain.Dtos.CRM;
  28. using OASystem.Domain.Dtos.FileDto;
  29. using OASystem.Domain.Dtos.Financial;
  30. using OASystem.Domain.Dtos.Groups;
  31. using OASystem.Domain.Entities.Customer;
  32. using OASystem.Domain.Entities.Financial;
  33. using OASystem.Domain.Entities.Groups;
  34. using OASystem.Domain.ViewModels.Financial;
  35. using OASystem.Domain.ViewModels.Groups;
  36. using OASystem.Domain.ViewModels.QiYeWeChat;
  37. using OASystem.Domain.ViewModels.Statistics;
  38. using OASystem.Infrastructure.Repositories.CRM;
  39. using OASystem.Infrastructure.Repositories.Financial;
  40. using OASystem.Infrastructure.Repositories.Groups;
  41. using OASystem.Infrastructure.Tools;
  42. using Org.BouncyCastle.Crypto;
  43. using Org.BouncyCastle.Utilities;
  44. using Quartz.Util;
  45. using SqlSugar.Extensions;
  46. using System.Collections;
  47. using System.Data;
  48. using System.Diagnostics;
  49. using System.Globalization;
  50. using System.IO.Compression;
  51. using System.Text.Json;
  52. using System.Web;
  53. using System.Xml.Linq;
  54. using TencentCloud.Ocr.V20181119.Models;
  55. using static OASystem.API.OAMethodLib.JWTHelper;
  56. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  57. using Bookmark = Aspose.Words.Bookmark;
  58. using Cell = Aspose.Words.Tables.Cell;
  59. using Table = Aspose.Words.Tables.Table;
  60. namespace OASystem.API.Controllers
  61. {
  62. /// <summary>
  63. /// 团组相关
  64. /// </summary>
  65. //[Authorize]
  66. [Route("api/[controller]/[action]")]
  67. public class GroupsController : ControllerBase
  68. {
  69. private readonly ILogger<GroupsController> _logger;
  70. private readonly GrpScheduleRepository _grpScheduleRep;
  71. private readonly IMapper _mapper;
  72. private readonly DelegationInfoRepository _groupRepository;
  73. private readonly TaskAssignmentRepository _taskAssignmentRep;
  74. private readonly AirTicketResRepository _airTicketResRep;
  75. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  76. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  77. private readonly DelegationEnDataRepository _delegationEnDataRep;
  78. private readonly DelegationVisaRepository _delegationVisaRep;
  79. private readonly VisaPriceRepository _visaPriceRep;
  80. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  81. private readonly HotelPriceRepository _hotelPriceRep;
  82. private readonly CustomersRepository _customersRep;
  83. private readonly MessageRepository _message;
  84. private readonly SqlSugarClient _sqlSugar;
  85. private readonly TourClientListRepository _tourClientListRep;
  86. private readonly TeamRateRepository _teamRateRep;
  87. #region 成本相关
  88. private readonly CheckBoxsRepository _checkBoxs;
  89. private readonly GroupCostRepository _GroupCostRepository;
  90. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  91. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  92. #endregion
  93. private readonly SetDataRepository _setDataRep;
  94. private string url;
  95. private string path;
  96. private readonly EnterExitCostRepository _enterExitCostRep;
  97. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  98. private readonly UsersRepository _usersRep;
  99. private readonly IJuHeApiService _juHeApi;
  100. private readonly InvertedListRepository _invertedListRep;
  101. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  102. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  103. private readonly ThreeCodeRepository _threeCodeRepository;
  104. private readonly HotelInquiryRepository _hotelInquiryRep;
  105. private readonly FeeAuditRepository _feeAuditRep;
  106. private readonly VisaCommissionRepository _visaCommissionRep;
  107. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  108. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  109. private readonly List<CurrencyInfo> _currencyInit;
  110. private readonly List<int> _portTypeData;
  111. private readonly TableOperationRecordRepository _tableorRep;
  112. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  113. private readonly RestaurantRepository _restaurantRep;
  114. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  115. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  116. /// <summary>
  117. /// 构造函数
  118. /// </summary>
  119. /// <param name="logger"></param>
  120. /// <param name="mapper"></param>
  121. /// <param name="hubContext"></param>
  122. /// <param name="sqlSugar"></param>
  123. /// <param name="grpScheduleRep"></param>
  124. /// <param name="groupRepository"></param>
  125. /// <param name="taskAssignmentRep"></param>
  126. /// <param name="airTicketResRep"></param>
  127. /// <param name="decreasePaymentsRep"></param>
  128. /// <param name="InvitationOfficialActivitiesRep"></param>
  129. /// <param name="delegationEnDataRep"></param>
  130. /// <param name="enterExitCostRep"></param>
  131. /// <param name="delegationVisaRep"></param>
  132. /// <param name="message"></param>
  133. /// <param name="visaPriceRep"></param>
  134. /// <param name="carTouristGuideGroundRep"></param>
  135. /// <param name="checkBoxs"></param>
  136. /// <param name="GroupCostRepository"></param>
  137. /// <param name="CostTypeHotelNumberRepository"></param>
  138. /// <param name="GroupCostParameterRepository"></param>
  139. /// <param name="hotelPriceRep"></param>
  140. /// <param name="customersRep"></param>
  141. /// <param name="setDataRep"></param>
  142. /// <param name="tourClientListRep"></param>
  143. /// <param name="teamRateRep"></param>
  144. /// <param name="usersRep"></param>
  145. /// <param name="juHeApi"></param>
  146. /// <param name="invertedListRep"></param>
  147. /// <param name="visaFeeInfoRep"></param>
  148. /// <param name="ticketBlackCodeRep"></param>
  149. /// <param name="hotelInquiryRep"></param>
  150. /// <param name="threeCodeRepository"></param>
  151. /// <param name="feeAuditRep"></param>
  152. /// <param name="visaCommissionRep"></param>
  153. /// <param name="ffrRep"></param>
  154. /// <param name="opinionaireRep"></param>
  155. /// <param name="tableorRep"></param>
  156. /// <param name="enterExitCostDraftRep"></param>
  157. /// <param name="restaurantRep"></param>
  158. /// <param name="enterExitCostQuoteRep"></param>
  159. public GroupsController(
  160. ILogger<GroupsController> logger,
  161. IMapper mapper,
  162. IHubContext<ChatHub, IChatClient> hubContext,
  163. SqlSugarClient sqlSugar,
  164. GrpScheduleRepository grpScheduleRep,
  165. DelegationInfoRepository groupRepository,
  166. TaskAssignmentRepository taskAssignmentRep,
  167. AirTicketResRepository airTicketResRep,
  168. DecreasePaymentsRepository decreasePaymentsRep,
  169. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  170. DelegationEnDataRepository delegationEnDataRep,
  171. EnterExitCostRepository enterExitCostRep,
  172. DelegationVisaRepository delegationVisaRep,
  173. MessageRepository message,
  174. VisaPriceRepository visaPriceRep,
  175. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  176. CheckBoxsRepository checkBoxs,
  177. GroupCostRepository GroupCostRepository,
  178. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  179. GroupCostParameterRepository GroupCostParameterRepository,
  180. HotelPriceRepository hotelPriceRep,
  181. CustomersRepository customersRep,
  182. SetDataRepository setDataRep,
  183. TourClientListRepository tourClientListRep,
  184. TeamRateRepository teamRateRep,
  185. UsersRepository usersRep, IJuHeApiService juHeApi,
  186. InvertedListRepository invertedListRep,
  187. VisaFeeInfoRepository visaFeeInfoRep,
  188. TicketBlackCodeRepository ticketBlackCodeRep,
  189. HotelInquiryRepository hotelInquiryRep,
  190. ThreeCodeRepository threeCodeRepository,
  191. FeeAuditRepository feeAuditRep,
  192. VisaCommissionRepository visaCommissionRep,
  193. ForeignReceivablesRepository ffrRep,
  194. OpinionaireRepository opinionaireRep,
  195. TableOperationRecordRepository tableorRep,
  196. EnterExitCostDraftRepository enterExitCostDraftRep,
  197. RestaurantRepository restaurantRep,
  198. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  199. GroupOrderPreInfoRepository grpOrderPreInfoRep
  200. )
  201. {
  202. _logger = logger;
  203. _mapper = mapper;
  204. _grpScheduleRep = grpScheduleRep;
  205. _groupRepository = groupRepository;
  206. _taskAssignmentRep = taskAssignmentRep;
  207. _airTicketResRep = airTicketResRep;
  208. _sqlSugar = sqlSugar;
  209. url = AppSettingsHelper.Get("ExcelBaseUrl");
  210. path = AppSettingsHelper.Get("ExcelBasePath");
  211. if (!System.IO.Directory.Exists(path))
  212. {
  213. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  214. }
  215. _decreasePaymentsRep = decreasePaymentsRep;
  216. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  217. _delegationEnDataRep = delegationEnDataRep;
  218. _enterExitCostRep = enterExitCostRep;
  219. _delegationVisaRep = delegationVisaRep;
  220. _message = message;
  221. _visaPriceRep = visaPriceRep;
  222. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  223. _checkBoxs = checkBoxs;
  224. _GroupCostRepository = GroupCostRepository;
  225. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  226. _GroupCostParameterRepository = GroupCostParameterRepository;
  227. _hotelPriceRep = hotelPriceRep;
  228. _customersRep = customersRep;
  229. _setDataRep = setDataRep;
  230. _tourClientListRep = tourClientListRep;
  231. _teamRateRep = teamRateRep;
  232. _hubContext = hubContext;
  233. _usersRep = usersRep;
  234. _juHeApi = juHeApi;
  235. _invertedListRep = invertedListRep;
  236. _visaFeeInfoRep = visaFeeInfoRep;
  237. _ticketBlackCodeRep = ticketBlackCodeRep;
  238. _hotelInquiryRep = hotelInquiryRep;
  239. _threeCodeRepository = threeCodeRepository;
  240. _feeAuditRep = feeAuditRep;
  241. _visaCommissionRep = visaCommissionRep;
  242. _ffrRep = ffrRep;
  243. _opinionaireRep = opinionaireRep;
  244. _currencyInit = new List<CurrencyInfo>()
  245. {
  246. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  247. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  248. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  249. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  250. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  251. };
  252. _portTypeData = new List<int>() { 2, 3 };
  253. _tableorRep = tableorRep;
  254. _enterExitCostDraftRep = enterExitCostDraftRep;
  255. _restaurantRep = restaurantRep;
  256. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  257. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  258. }
  259. #region 流程管控
  260. /// <summary>
  261. /// 获取团组流程管控信息
  262. /// </summary>
  263. /// <param name="_jsonDto"></param>
  264. /// <returns></returns>
  265. [HttpPost]
  266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  267. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  268. {
  269. if (string.IsNullOrEmpty(_jsonDto.Paras))
  270. {
  271. return Ok(JsonView(false, "参数为空"));
  272. }
  273. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  274. if (_ScheduleDto != null)
  275. {
  276. if (_ScheduleDto.SearchType == 2)//获取列表
  277. {
  278. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  279. return Ok(JsonView(_grpScheduleViewList));
  280. }
  281. else//获取对象
  282. {
  283. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  284. if (_grpScheduleView != null)
  285. {
  286. return Ok(JsonView(_grpScheduleView));
  287. }
  288. }
  289. }
  290. else
  291. {
  292. return Ok(JsonView(false, "参数反序列化失败"));
  293. }
  294. return Ok(JsonView(false, "暂无数据!"));
  295. }
  296. /// <summary>
  297. /// 修改团组流程管控详细表数据
  298. /// </summary>
  299. /// <param name="dto"></param>
  300. /// <returns></returns>
  301. [HttpPost]
  302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  303. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  304. {
  305. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  306. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  307. .SetColumns(it => it.Duty == _detail.Duty)
  308. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  309. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  310. .SetColumns(it => it.JobContent == _detail.JobContent)
  311. .SetColumns(it => it.Remark == _detail.Remark)
  312. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  313. .Where(s => s.Id == dto.Id)
  314. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  315. .ExecuteCommandAsync();
  316. if (result > 0)
  317. {
  318. return Ok(JsonView(true, "保存成功!"));
  319. }
  320. return Ok(JsonView(false, "保存失败!"));
  321. }
  322. /// <summary>
  323. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  324. /// </summary>
  325. /// <param name="dto"></param>
  326. /// <returns></returns>
  327. [HttpPost]
  328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  329. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  330. {
  331. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  332. _detail.IsDel = 1;
  333. _detail.DeleteUserId = dto.Duty;
  334. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  335. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  336. .SetColumns(it => it.IsDel == _detail.IsDel)
  337. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  338. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  339. .Where(it => it.Id == dto.Id)
  340. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  341. //.WhereColumns(s => s.Id == dto.Id)
  342. .ExecuteCommandAsync();
  343. if (result > 0)
  344. {
  345. return Ok(JsonView(true, "删除成功!"));
  346. }
  347. return Ok(JsonView(false, "删除失败!"));
  348. }
  349. /// <summary>
  350. /// 增加团组流程管控详细表数据
  351. /// </summary>
  352. /// <param name="dto"></param>
  353. /// <returns></returns>
  354. [HttpPost]
  355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  356. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  357. {
  358. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  359. if (DateTime.Now < _detail.ExpectBeginDt)
  360. {
  361. _detail.StepStatus = 0;
  362. }
  363. else
  364. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  365. _detail.StepStatus = 1;
  366. }
  367. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  368. if (result > 0)
  369. {
  370. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  371. return Ok(JsonView(true, "添加成功!", _result));
  372. }
  373. return Ok(JsonView(false, "添加失败!"));
  374. }
  375. #endregion
  376. #region 团组前期信息
  377. /// <summary>
  378. /// 团组前期信息 List
  379. /// </summary>
  380. /// <returns></returns>
  381. [HttpGet("{userId}")]
  382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  383. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  384. {
  385. //var list = await _sqlSugar.Queryable<Grp_OrderPreInfo, Sys_Users>((opi, u) => new JoinQueryInfos() { JoinType.Left, opi.CreateUserId == u.Id })
  386. // .Select(x => new GroupOrderPreInfoListView() { })
  387. // .ToPageListAsync(dto.PageIndex,dto.PageSize);
  388. return Ok(await _grpOrderPreInfoRep.DataInit(0));
  389. }
  390. /// <summary>
  391. /// 团组前期信息 Init
  392. /// </summary>
  393. /// <returns></returns>
  394. [HttpGet("{userId}")]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  397. {
  398. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  399. }
  400. /// <summary>
  401. /// 国家数据源
  402. /// </summary>
  403. /// <returns></returns>
  404. [HttpGet]
  405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  406. public async Task<IActionResult> CountryInit()
  407. {
  408. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  409. return Ok(JsonView(countrys));
  410. }
  411. /// <summary>
  412. /// 城市数据源
  413. /// </summary>
  414. /// <returns></returns>
  415. [HttpGet("{countryLabel}")]
  416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  417. public async Task<IActionResult> CityByCountry(string countryLabel)
  418. {
  419. countryLabel=HttpUtility.UrlDecode(countryLabel);
  420. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  421. var citys = Array.Empty<string?>();
  422. if (countryList.Any())
  423. {
  424. var cityDatas = await _sqlSugar
  425. .Queryable<Grp_NationalTravelFee>()
  426. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  427. .ToArrayAsync();
  428. foreach (var item in cityDatas)
  429. {
  430. if (item.City.Contains("城市"))
  431. {
  432. item.City = item.Country + "-所有城市";
  433. }
  434. }
  435. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  436. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  437. }
  438. return Ok(JsonView(citys));
  439. }
  440. /// <summary>
  441. /// 团组前期信息 Info
  442. /// </summary>
  443. /// <param name="id">Id</param>
  444. /// <param name="tempId">Id</param>
  445. /// <returns></returns>
  446. [HttpGet("{id}/{tempId}")]
  447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  448. public async Task<IActionResult> GroupOrderPreInfo(int id,int tempId = 1404)
  449. {
  450. return Ok(await _grpOrderPreInfoRep.InfoAsync(id, tempId));
  451. }
  452. /// <summary>
  453. /// 团组前期信息 Save
  454. /// </summary>
  455. /// <param name="dto">Id</param>
  456. /// <returns></returns>
  457. [HttpPost]
  458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  459. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  460. {
  461. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  462. }
  463. /// <summary>
  464. /// 团组前期信息 文件下载
  465. /// </summary>
  466. /// <param name="id">Id</param>
  467. /// <param name="tempId">Id</param>
  468. /// <returns></returns>
  469. [HttpGet("{id}/{tempId}")]
  470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  471. public async Task<IActionResult> GroupOrderPreInfoFileDownload(int id, int tempId = 1404)
  472. {
  473. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  474. var data = view.Data as GrpOrderPreInfoView;
  475. #region Excel
  476. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  477. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  478. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  479. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  480. var fileNamePrefix = string.Empty;
  481. if (tempId == 1405)
  482. {
  483. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  484. fileNamePrefix = $"{data.Name}_无商邀版";
  485. }
  486. else if (tempId == 1406)
  487. {
  488. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  489. fileNamePrefix = $"{data.Name}_有商邀版";
  490. }
  491. else
  492. {
  493. //tempId == 1404 默认下载
  494. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  495. fileNamePrefix = $"{data.Name}_单接送机";
  496. }
  497. foreach (var item in data.Items)
  498. {
  499. var obj = item.NewValue;
  500. if (obj == null) item.OriginVal = "";
  501. else if (obj.Equals("有") || obj.Equals("无"))
  502. {
  503. item.OriginVal = obj.ToString();
  504. }
  505. else if (obj is object[] objArray)
  506. {
  507. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  508. item.OriginVal = string.Join("、", stringArray);
  509. }
  510. else if (obj is string[] stringArray)
  511. {
  512. item.OriginVal = string.Join("、", stringArray);
  513. } else if (obj.Equals("-"))
  514. {
  515. item.OriginVal = "";
  516. }
  517. }
  518. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  519. fileName = CommonFun.ValidFileName(fileName);
  520. //载入模板
  521. WorkbookDesigner designer = new WorkbookDesigner();
  522. designer.Workbook = new Workbook(tempPath);
  523. if (tempId == 1406)
  524. {
  525. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  526. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  527. for (int i = 1; i <= view2.Length; i++)
  528. {
  529. view2[i - 1].Index = i;
  530. }
  531. designer.SetDataSource("View1", view1);
  532. designer.SetDataSource("View2", view2);
  533. }
  534. else
  535. {
  536. designer.SetDataSource("View", data.Items);
  537. }
  538. designer.Process();
  539. if (!Directory.Exists(savePath))
  540. {
  541. Directory.CreateDirectory(savePath);
  542. }
  543. string serverPath = $"{savePath}{fileName}";
  544. designer.Workbook.Save(serverPath);
  545. string rst = $"{servicePath}{ftpPath}{fileName}";
  546. #endregion
  547. return Ok(JsonView(new { url = rst }));
  548. }
  549. #endregion
  550. #region 团组基本信息
  551. /// <summary>
  552. /// 接团信息列表
  553. /// </summary>
  554. /// <param name="dto">团组列表请求dto</param>
  555. /// <returns></returns>
  556. [HttpPost]
  557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  558. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  559. {
  560. var groupData = await _groupRepository.GetGroupList(dto);
  561. if (groupData.Code != 0)
  562. {
  563. return Ok(JsonView(false, groupData.Msg));
  564. }
  565. return Ok(JsonView(groupData.Data));
  566. }
  567. /// <summary>
  568. /// 分页查询团组列表
  569. /// </summary>
  570. /// <param name="dto"></param>
  571. /// <returns></returns>
  572. [HttpPost]
  573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  574. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  575. {
  576. var watch = new Stopwatch();
  577. watch.Start();
  578. RefAsync<int> total = 0;
  579. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  580. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  581. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  582. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  583. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  584. .Distinct()
  585. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  586. watch.Stop();
  587. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  588. }
  589. /// <summary>
  590. /// 接团信息列表 Page Init
  591. /// </summary>
  592. /// <returns></returns>
  593. [HttpPost]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> PostGroupPageListInit()
  596. {
  597. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  598. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  599. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  600. var _view = new
  601. {
  602. depData = depDatas,
  603. rankData = rankDatas
  604. };
  605. return Ok(JsonView(true, "查询成功!", _view));
  606. }
  607. /// <summary>
  608. /// 接团信息列表 Page
  609. /// </summary>
  610. /// <param name="dto">团组列表请求dto</param>
  611. /// <returns></returns>
  612. [HttpPost]
  613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  614. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  615. {
  616. #region 参数验证
  617. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  618. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  619. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  620. #region 页面操作权限验证
  621. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  622. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  623. #endregion
  624. #endregion
  625. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  626. {
  627. string sqlWhere = string.Empty;
  628. if (dto.IsSure == 0) //未完成
  629. {
  630. sqlWhere += string.Format(@" And IsSure = 0");
  631. }
  632. else if (dto.IsSure == 1) //已完成
  633. {
  634. sqlWhere += string.Format(@" And IsSure = 1");
  635. }
  636. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  637. {
  638. string tj = dto.SearchCriteria;
  639. 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}%')",
  640. tj, tj, tj, tj, tj);
  641. }
  642. if (int.TryParse(dto.Rank, out int rankId))
  643. {
  644. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  645. }
  646. string sqlWhere1 = string.Empty;
  647. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  648. {
  649. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  650. }
  651. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  652. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  653. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  654. JietuanOperator,IsSure,CreateTime,IsBid
  655. From (
  656. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  657. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  658. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  659. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  660. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  661. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  662. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  663. From Grp_DelegationInfo gdi
  664. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  665. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  666. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  667. Where gdi.IsDel = 0 {0}
  668. ) temp {1}", sqlWhere, sqlWhere1);
  669. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  670. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  671. var _view = new
  672. {
  673. PageFuncAuth = pageFunAuthView,
  674. Data = _DelegationList
  675. };
  676. return Ok(JsonView(true, "查询成功!", _view, total));
  677. }
  678. else
  679. {
  680. return Ok(JsonView(false, "查询失败"));
  681. }
  682. }
  683. /// <summary>
  684. /// 团组列表
  685. /// </summary>
  686. /// <returns></returns>
  687. [HttpPost]
  688. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  689. {
  690. #region 参数验证
  691. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  692. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  693. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  694. #region 页面操作权限验证
  695. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  696. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  697. #endregion
  698. #endregion
  699. if (dto.PortType != 1 && dto.PortType != 2)
  700. {
  701. return Ok(JsonView(false, "查询失败!"));
  702. }
  703. string orderbyStr = "order by gdi.CreateTime Desc";
  704. string sqlWhere = string.Empty;
  705. if (dto.IsSure == 0) //未完成
  706. {
  707. sqlWhere += string.Format(@" And IsSure = 0");
  708. }
  709. else if (dto.IsSure == 1) //已完成
  710. {
  711. sqlWhere += string.Format(@" And IsSure = 1");
  712. }
  713. //团组类型
  714. if (dto.TeamDid > 0)
  715. {
  716. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  717. }
  718. //团组名称
  719. if (!string.IsNullOrEmpty(dto.TeamName))
  720. {
  721. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  722. }
  723. //客户名称
  724. if (!string.IsNullOrEmpty(dto.ClientName))
  725. {
  726. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  727. }
  728. //客户单位
  729. if (!string.IsNullOrEmpty(dto.ClientUnit))
  730. {
  731. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  732. }
  733. //出访时间
  734. if (!string.IsNullOrEmpty(dto.visitDataTime))
  735. {
  736. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  737. orderbyStr = "order by gdi.VisitDate";
  738. }
  739. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  740. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  741. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  742. JietuanOperator,IsSure,CreateTime
  743. From (
  744. Select row_number() over({0}) as Row_Number,
  745. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  746. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  747. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  748. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  749. From Grp_DelegationInfo gdi
  750. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  751. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  752. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  753. Where gdi.IsDel = 0 {1}
  754. ) temp ", orderbyStr, sqlWhere);
  755. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  756. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  757. #region 处理所属部门
  758. /*
  759. * 1.sq 和 gyy 等显示 市场部
  760. * 2.王鸽和主管及张总还有管理员号统一国交部
  761. * 2-1. 4 管理员 ,21 张海麟
  762. */
  763. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  764. List<int> userIds1 = new List<int>() { 4, 21 };
  765. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  766. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  767. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  768. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  769. .ToList();
  770. foreach (var item in _DelegationList)
  771. {
  772. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  773. }
  774. #endregion
  775. var _view = new
  776. {
  777. PageFuncAuth = pageFunAuthView,
  778. Data = _DelegationList
  779. };
  780. return Ok(JsonView(true, "查询成功!", _view, total));
  781. }
  782. /// <summary>
  783. /// 接团信息详情
  784. /// </summary>
  785. /// <param name="dto">团组info请求dto</param>
  786. /// <returns></returns>
  787. [HttpPost]
  788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  789. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  790. {
  791. var groupData = await _groupRepository.GetGroupInfo(dto);
  792. if (groupData.Code != 0)
  793. {
  794. return Ok(JsonView(false, groupData.Msg));
  795. }
  796. return Ok(JsonView(groupData.Data));
  797. }
  798. /// <summary>
  799. /// 接团信息 编辑添加
  800. /// 基础信息数据源
  801. /// </summary>
  802. /// <param name="dto"></param>
  803. /// <returns></returns>
  804. [HttpPost]
  805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  806. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  807. {
  808. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  809. if (groupData.Code != 0)
  810. {
  811. return Ok(JsonView(false, groupData.Msg));
  812. }
  813. return Ok(JsonView(groupData.Data));
  814. }
  815. /// <summary>
  816. /// 接团信息 操作(增改)
  817. /// </summary>
  818. /// <param name="dto"></param>
  819. /// <returns></returns>
  820. [HttpPost]
  821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  822. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  823. {
  824. // 创建 Stopwatch 实例
  825. Stopwatch stopwatch = Stopwatch.StartNew();
  826. decimal ffrPrice = 0.00M;
  827. DateTime? visitDt = null;
  828. if (dto.Status == 2)
  829. {
  830. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  831. if (groupInfo != null)
  832. {
  833. ffrPrice = groupInfo.PaymentMoney;
  834. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  835. }
  836. }
  837. var groupData = await _groupRepository.GroupOperation(dto);
  838. if (groupData.Code != 0)
  839. {
  840. return Ok(JsonView(false, groupData.Msg));
  841. }
  842. int diId = 0;
  843. try
  844. {
  845. //添加时 默认加入团组汇率
  846. if (dto.Status == 1) //添加
  847. {
  848. diId = groupData.Data;
  849. //添加默认币种
  850. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  851. //默认分配权限
  852. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  853. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  854. var _managerIds = new List<int>() { 22, 32, 21 };
  855. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  856. if (userIds.Count > 0)
  857. {
  858. userIds.Add(208);
  859. //创建团组管控
  860. GroupStepForDelegation.CreateWorkStep(diId);
  861. //发送消息
  862. string groupName = dto.TeamName;
  863. string createGroupUser = string.Empty;
  864. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  865. if (userInfo != null) createGroupUser = userInfo.CnName;
  866. string title = $"系统通知";
  867. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  868. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  869. }
  870. //默认创建倒推表
  871. await _invertedListRep._Create(dto.UserId, diId);
  872. }
  873. else if (dto.Status == 2)
  874. {
  875. diId = dto.Id;
  876. }
  877. #region 签证人员团组时间通知
  878. #region 计算出访起止时间
  879. var startTime = new DateTime();
  880. var endTime = new DateTime();
  881. if (DateTime.TryParse(dto.VisitDate, out startTime))
  882. {
  883. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  884. }
  885. #endregion
  886. #endregion
  887. #region 团组操作默认添加/修改收款账单
  888. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  889. {
  890. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  891. .Where(x => x.IsDel == 0 &&
  892. x.Diid == diId &&
  893. x.Remark.Equals("预付款")
  894. )
  895. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  896. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  897. .FirstAsync();
  898. ffrInfo = new Fin_ForeignReceivables()
  899. {
  900. Diid = diId,
  901. PriceName = dto.ClientUnit,
  902. Price = dto.PaymentMoney,
  903. Count = 1,
  904. Unit = $"元",
  905. ItemSumPrice = dto.PaymentMoney,
  906. Rate = 1.0000M,
  907. Currency = 836,
  908. AddingWay = 0,
  909. CreateUserId = dto.UserId,
  910. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  911. Remark = $"预付款"
  912. };
  913. if (ffrInfo == null) //Add
  914. {
  915. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  916. }
  917. else //修改
  918. {
  919. await _sqlSugar.Updateable(ffrInfo)
  920. .UpdateColumns(x => new
  921. {
  922. x.PriceName,
  923. x.Price,
  924. x.ItemSumPrice,
  925. x.CreateTime,
  926. x.CreateUserId
  927. })
  928. .WhereColumns(x => x.Id)
  929. .ExecuteCommandAsync();
  930. }
  931. }
  932. #endregion
  933. if (diId > 0)
  934. {
  935. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  936. }
  937. // 停止计时
  938. stopwatch.Stop();
  939. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  940. }
  941. catch (Exception ex)
  942. {
  943. // 停止计时
  944. stopwatch.Stop();
  945. Logs("[response]" + JsonConvert.SerializeObject(dto));
  946. Logs(ex.Message);
  947. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  948. }
  949. // 停止计时
  950. stopwatch.Stop();
  951. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  952. }
  953. /// <summary>
  954. /// 接团流程操作(增改)
  955. /// 安卓端使用 建团时添加客户名单
  956. /// </summary>
  957. /// <param name="dto"></param>
  958. /// <returns></returns>
  959. [HttpPost]
  960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  961. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  962. {
  963. #region 参数验证
  964. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  965. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  966. #region 页面操作权限验证
  967. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  968. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  969. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  970. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  971. #endregion
  972. #endregion
  973. try
  974. {
  975. //_sqlSugar.BeginTran();
  976. decimal ffrPrice = 0.00M;
  977. DateTime? visitDt = null;
  978. if (dto.Status == 2)
  979. {
  980. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  981. if (groupInfo != null)
  982. {
  983. ffrPrice = groupInfo.PaymentMoney;
  984. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  985. }
  986. }
  987. var _dto = new GroupOperationDto();
  988. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  989. var groupData = await _groupRepository.GroupOperation(_dto);
  990. if (groupData.Code != 0)
  991. {
  992. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  993. }
  994. int diId = 0;
  995. //添加时 默认加入团组汇率
  996. if (dto.Status == 1) //添加
  997. {
  998. diId = groupData.Data;
  999. //添加默认币种
  1000. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1001. //默认分配权限
  1002. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1003. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1004. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1005. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1006. if (userIds.Count > 0)
  1007. {
  1008. userIds.Add(208);
  1009. //创建团组管控
  1010. GroupStepForDelegation.CreateWorkStep(diId);
  1011. //发送消息
  1012. string groupName = dto.TeamName;
  1013. string createGroupUser = string.Empty;
  1014. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1015. if (userInfo != null) createGroupUser = userInfo.CnName;
  1016. string title = $"系统通知";
  1017. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1018. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1019. }
  1020. #region 应用推送
  1021. try
  1022. {
  1023. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1024. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1025. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1026. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1027. {
  1028. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1029. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1030. }
  1031. }
  1032. catch (Exception ex)
  1033. {
  1034. }
  1035. #endregion
  1036. //默认创建倒推表
  1037. await _invertedListRep._Create(dto.UserId, diId);
  1038. }
  1039. if (dto.Status == 2)
  1040. {
  1041. diId = dto.Id;
  1042. if (diId == 0)
  1043. {
  1044. //_sqlSugar.RollbackTran();
  1045. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1046. }
  1047. }
  1048. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1049. if (viewData.Code != 0)
  1050. {
  1051. //_sqlSugar.RollbackTran();
  1052. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1053. }
  1054. #region 团组操作默认添加/修改收款账单
  1055. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1056. {
  1057. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1058. .Where(x => x.IsDel == 0 &&
  1059. x.Diid == diId &&
  1060. x.Remark.Equals("预付款")
  1061. )
  1062. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1063. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1064. .FirstAsync();
  1065. ffrInfo = new Fin_ForeignReceivables()
  1066. {
  1067. Diid = diId,
  1068. PriceName = dto.ClientUnit,
  1069. Price = dto.PaymentMoney,
  1070. Count = 1,
  1071. Unit = $"元",
  1072. ItemSumPrice = dto.PaymentMoney,
  1073. Rate = 1.0000M,
  1074. Currency = 836,
  1075. AddingWay = 0,
  1076. CreateUserId = dto.UserId,
  1077. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1078. Remark = $"预付款"
  1079. };
  1080. if (ffrInfo == null) //Add
  1081. {
  1082. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1083. }
  1084. else //修改
  1085. {
  1086. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1087. .UpdateColumns(x => new
  1088. {
  1089. x.PriceName,
  1090. x.Price,
  1091. x.ItemSumPrice,
  1092. x.CreateTime,
  1093. x.CreateUserId
  1094. })
  1095. .WhereColumns(x => x.Id)
  1096. .ExecuteCommandAsync();
  1097. }
  1098. }
  1099. #endregion
  1100. #region 签证人员团组时间通知
  1101. #region 计算出访起止时间
  1102. var startTime = new DateTime();
  1103. var endTime = new DateTime();
  1104. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1105. {
  1106. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1107. }
  1108. #endregion
  1109. if (diId > 0)
  1110. {
  1111. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1112. }
  1113. #endregion
  1114. //_sqlSugar.CommitTran();
  1115. return Ok(JsonView(true, "添加成功"));
  1116. }
  1117. catch (Exception ex)
  1118. {
  1119. _sqlSugar.RollbackTran();
  1120. return Ok(JsonView(false, ex.Message));
  1121. }
  1122. }
  1123. /// <summary>
  1124. /// 接团流程操作(增改)
  1125. /// 安卓端使用 建团时添加客户名单
  1126. /// </summary>
  1127. /// <param name="dto"></param>
  1128. /// <returns></returns>
  1129. [HttpPost]
  1130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1131. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1132. {
  1133. #region 参数验证
  1134. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1135. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1136. #region 页面操作权限验证
  1137. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1138. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1139. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1140. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1141. #endregion
  1142. #endregion
  1143. _sqlSugar.BeginTran();
  1144. decimal ffrPrice = 0.00M;
  1145. DateTime? visitDt = null;
  1146. if (dto.Status == 2)
  1147. {
  1148. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1149. if (groupInfo != null)
  1150. {
  1151. ffrPrice = groupInfo.PaymentMoney;
  1152. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1153. }
  1154. }
  1155. var _dto = new GroupOperationDto();
  1156. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1157. var groupData = await _groupRepository.GroupOperation(_dto);
  1158. if (groupData.Code != 0)
  1159. {
  1160. _sqlSugar.RollbackTran();
  1161. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1162. }
  1163. try
  1164. {
  1165. int diId = 0;
  1166. //添加时 默认加入团组汇率
  1167. if (dto.Status == 1) //添加
  1168. {
  1169. diId = groupData.Data;
  1170. //添加默认币种
  1171. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1172. //默认分配权限
  1173. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1174. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1175. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1176. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1177. if (userIds.Count > 0)
  1178. {
  1179. userIds.Add(208);
  1180. //创建团组管控
  1181. GroupStepForDelegation.CreateWorkStep(diId);
  1182. //发送消息
  1183. string groupName = dto.TeamName;
  1184. string createGroupUser = string.Empty;
  1185. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1186. if (userInfo != null) createGroupUser = userInfo.CnName;
  1187. string title = $"系统通知";
  1188. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1189. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1190. }
  1191. #region 应用推送
  1192. try
  1193. {
  1194. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1195. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1196. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1197. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1198. {
  1199. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1200. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1201. }
  1202. }
  1203. catch (Exception ex)
  1204. {
  1205. _sqlSugar.CommitTran();
  1206. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1207. }
  1208. #endregion
  1209. //默认创建倒推表
  1210. await _invertedListRep._Create(dto.UserId, diId);
  1211. }
  1212. else if (dto.Status == 2)
  1213. {
  1214. diId = dto.Id;
  1215. if (diId == 0)
  1216. {
  1217. _sqlSugar.RollbackTran();
  1218. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1219. }
  1220. }
  1221. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1222. if (viewData.Code != 0)
  1223. {
  1224. _sqlSugar.RollbackTran();
  1225. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1226. }
  1227. #region 团组操作默认添加/修改收款账单
  1228. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1229. {
  1230. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1231. .Where(x => x.IsDel == 0 &&
  1232. x.Diid == diId &&
  1233. x.Remark.Equals("预付款")
  1234. )
  1235. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1236. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1237. .FirstAsync();
  1238. ffrInfo = new Fin_ForeignReceivables()
  1239. {
  1240. Diid = diId,
  1241. PriceName = dto.ClientUnit,
  1242. Price = dto.PaymentMoney,
  1243. Count = 1,
  1244. Unit = $"元",
  1245. ItemSumPrice = dto.PaymentMoney,
  1246. Rate = 1.0000M,
  1247. Currency = 836,
  1248. AddingWay = 0,
  1249. CreateUserId = dto.UserId,
  1250. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1251. Remark = $"预付款"
  1252. };
  1253. if (ffrInfo == null) //Add
  1254. {
  1255. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1256. }
  1257. else //修改
  1258. {
  1259. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1260. .UpdateColumns(x => new
  1261. {
  1262. x.PriceName,
  1263. x.Price,
  1264. x.ItemSumPrice,
  1265. x.CreateTime,
  1266. x.CreateUserId
  1267. })
  1268. .WhereColumns(x => x.Id)
  1269. .ExecuteCommandAsync();
  1270. }
  1271. }
  1272. #endregion
  1273. #region 签证人员团组时间通知
  1274. #region 计算出访起止时间
  1275. var startTime = new DateTime();
  1276. var endTime = new DateTime();
  1277. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1278. {
  1279. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1280. }
  1281. #endregion
  1282. if (diId > 0)
  1283. {
  1284. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1285. }
  1286. #endregion
  1287. _sqlSugar.CommitTran();
  1288. return Ok(JsonView(true));
  1289. }
  1290. catch (Exception ex)
  1291. {
  1292. _sqlSugar.RollbackTran();
  1293. return Ok(JsonView(false, ex.Message));
  1294. }
  1295. }
  1296. /// <summary>
  1297. /// 接团信息 操作(删除)
  1298. /// </summary>
  1299. /// <param name="dto"></param>
  1300. /// <returns></returns>
  1301. [HttpPost]
  1302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1303. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1304. {
  1305. var diId = dto.Id;
  1306. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1307. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1308. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1309. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1310. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1311. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1312. #endregion
  1313. var groupData = await _groupRepository.GroupDel(dto);
  1314. if (groupData.Code != 0)
  1315. {
  1316. return Ok(JsonView(false, groupData.Msg));
  1317. }
  1318. return Ok(JsonView(true));
  1319. }
  1320. /// <summary>
  1321. /// 获取团组销售报价号
  1322. /// 团组添加时 使用
  1323. /// </summary>
  1324. /// <returns></returns>
  1325. [HttpPost]
  1326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1327. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1328. {
  1329. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1330. if (groupData.Code != 0)
  1331. {
  1332. return Ok(JsonView(false, groupData.Msg));
  1333. }
  1334. object salesQuoteNo = new
  1335. {
  1336. SalesQuoteNo = groupData.Data
  1337. };
  1338. return Ok(JsonView(salesQuoteNo));
  1339. }
  1340. /// <summary>
  1341. /// 设置确认出团
  1342. /// </summary>
  1343. /// <param name="dto"></param>
  1344. /// <returns></returns>
  1345. [HttpPost]
  1346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1347. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1348. {
  1349. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1350. if (groupData.Code != 0)
  1351. {
  1352. return Ok(JsonView(false, groupData.Msg));
  1353. }
  1354. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1355. #region OA消息推送
  1356. try
  1357. {
  1358. string groupName = groupInfo.TeamName;
  1359. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1360. string title = $"系统通知";
  1361. string content = $"团组[{groupName}]已确认出团!";
  1362. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1363. }
  1364. catch (Exception ex)
  1365. {
  1366. }
  1367. #endregion
  1368. #region 应用推送
  1369. try
  1370. {
  1371. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1372. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1373. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1374. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1375. {
  1376. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1377. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1378. }
  1379. }
  1380. catch (Exception ex)
  1381. {
  1382. }
  1383. #endregion
  1384. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1385. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1386. }
  1387. /// <summary>
  1388. /// 获取团组名称data And 签证国别Data
  1389. /// </summary>
  1390. /// <param name="dto"></param>
  1391. /// <returns></returns>
  1392. [HttpPost]
  1393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1394. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1395. {
  1396. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1397. if (groupData.Code != 0)
  1398. {
  1399. return Ok(JsonView(false, groupData.Msg));
  1400. }
  1401. return Ok(JsonView(groupData.Data));
  1402. }
  1403. /// <summary>
  1404. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1405. /// </summary>
  1406. /// <returns></returns>
  1407. [HttpPost]
  1408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1409. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1410. {
  1411. try
  1412. {
  1413. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1414. if (groupData.Code != 0)
  1415. {
  1416. return Ok(JsonView(false, groupData.Msg));
  1417. }
  1418. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1419. }
  1420. catch (Exception ex)
  1421. {
  1422. return Ok(JsonView(false, "程序错误!"));
  1423. throw;
  1424. }
  1425. }
  1426. /// <summary>
  1427. /// 团组清单 Excel
  1428. /// </summary>
  1429. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1430. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1431. /// <returns></returns>
  1432. [HttpGet]
  1433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1434. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1435. {
  1436. DateTime _beginDt, _endDt;
  1437. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1438. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1439. if (!beginBool && !endBool)
  1440. {
  1441. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1442. }
  1443. string sql = string.Format(@"
  1444. SELECT
  1445. ROW_NUMBER,
  1446. Id,
  1447. SalesQuoteNo,
  1448. TourCode,
  1449. TeamTypeId,
  1450. TeamType,
  1451. TeamLevId,
  1452. TeamLev,
  1453. TeamName,
  1454. ClientName,
  1455. ClientUnit,
  1456. VisitDate,
  1457. VisitDays,
  1458. VisitPNumber,
  1459. JietuanOperatorId,
  1460. JietuanOperator,
  1461. IsSure,
  1462. CreateUserName,
  1463. IsBid
  1464. FROM
  1465. (
  1466. SELECT
  1467. ROW_NUMBER() OVER(
  1468. ORDER BY
  1469. gdi.CreateTime Desc
  1470. ) AS ROW_NUMBER,
  1471. gdi.Id,
  1472. SalesQuoteNo,
  1473. TourCode,
  1474. ssd.Id TeamTypeId,
  1475. ssd.Name TeamType,
  1476. ssd1.Id TeamLevId,
  1477. ssd1.Name TeamLev,
  1478. TeamName,
  1479. ClientName,
  1480. ClientUnit,
  1481. VisitDate,
  1482. VisitDays,
  1483. VisitPNumber,
  1484. JietuanOperator JietuanOperatorId,
  1485. su.CnName JietuanOperator,
  1486. IsSure,
  1487. gdi.CreateTime,
  1488. su1.CnName As CreateUserName,
  1489. gdi.IsBid
  1490. FROM
  1491. Grp_DelegationInfo gdi
  1492. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1493. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1494. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1495. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1496. WHERE
  1497. gdi.IsDel = 0
  1498. AND gdi.IsBid = 0
  1499. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1500. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1501. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1502. #region 处理所属部门
  1503. /*
  1504. * 1.sq 和 gyy 等显示 市场部
  1505. * 2.王鸽和主管及张总还有管理员号统一国交部
  1506. * 2-1. 4 管理员 ,21 张海麟
  1507. */
  1508. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1509. List<int> userIds1 = new List<int>() { 4, 21 };
  1510. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1511. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1512. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1513. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1514. .ToListAsync();
  1515. var droupIds = groupList.Select(it => it.Id).ToList();
  1516. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1517. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1518. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1519. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1520. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1521. {
  1522. DiId = tcl.DiId,
  1523. LastName = dc.LastName,
  1524. FirstName = dc.FirstName,
  1525. Sex = dc.Sex,
  1526. Birthday = dc.BirthDay,
  1527. Company = cc.CompanyFullName,
  1528. Job = dc.Job,
  1529. CreateTime = tcl.CreateTime,
  1530. })
  1531. .ToList();
  1532. foreach (var item in groupList)
  1533. {
  1534. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1535. string groupFirstName = "";
  1536. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1537. if (currDatas.Any())
  1538. {
  1539. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1540. }
  1541. item.GroupFirst = groupFirstName;
  1542. }
  1543. #endregion
  1544. #region Excel
  1545. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1546. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1547. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1548. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1549. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1550. //载入模板
  1551. WorkbookDesigner designer = new WorkbookDesigner();
  1552. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1553. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1554. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1555. dt.TableName = "GroupList";
  1556. designer.SetDataSource(dt);
  1557. designer.Process();
  1558. if (!Directory.Exists(savePath))
  1559. {
  1560. Directory.CreateDirectory(savePath);
  1561. }
  1562. string serverPath = $"{savePath}{fileName}";
  1563. designer.Workbook.Save(serverPath);
  1564. string rst = $"{servicePath}{ftpPath}{fileName}";
  1565. #endregion
  1566. return Ok(JsonView(true, "操作成功!", rst));
  1567. }
  1568. #endregion
  1569. #region 团组&签证
  1570. /// <summary>
  1571. /// 根据团组Id获取签证客户信息List
  1572. /// </summary>
  1573. /// <param name="dto">请求dto</param>
  1574. /// <returns></returns>
  1575. [HttpPost]
  1576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1577. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1578. {
  1579. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1580. if (groupData.Code != 0)
  1581. {
  1582. return Ok(JsonView(false, groupData.Msg));
  1583. }
  1584. return Ok(JsonView(groupData.Data));
  1585. }
  1586. /// <summary>
  1587. /// IOS获取团组签证拍照上传进度01(团组列表)
  1588. /// </summary>
  1589. /// <param name="dto">请求dto</param>
  1590. /// <returns></returns>
  1591. [HttpPost]
  1592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1593. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1594. {
  1595. if (dto == null)
  1596. {
  1597. return Ok(JsonView(false, "参数为空"));
  1598. }
  1599. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1600. return Ok(JsonView(visaList));
  1601. }
  1602. /// <summary>
  1603. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1604. /// </summary>
  1605. /// <returns></returns>
  1606. [HttpPost]
  1607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1608. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1609. {
  1610. if (dto == null)
  1611. {
  1612. return Ok(JsonView(false, "请求错误:"));
  1613. }
  1614. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1615. return Ok(JsonView(list));
  1616. }
  1617. /// <summary>
  1618. /// IOS获取团组签证拍照上传进度03(相册)
  1619. /// </summary>
  1620. /// <returns></returns>
  1621. [HttpPost]
  1622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1623. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1624. {
  1625. if (dto == null)
  1626. {
  1627. return Ok(JsonView(false, "请求错误:"));
  1628. }
  1629. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1630. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1631. list.ForEach(s => s.url = url);
  1632. return Ok(JsonView(list));
  1633. }
  1634. /// <summary>
  1635. /// IOS获取团组签证拍照上传进度04(图片上传)
  1636. /// </summary>
  1637. /// <param name="dto"></param>
  1638. /// <returns></returns>
  1639. [HttpPost]
  1640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1641. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1642. {
  1643. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1644. //if (!string.IsNullOrEmpty(result))
  1645. //{
  1646. //}
  1647. //else {
  1648. // return Ok(JsonView(false, "上传失败"));
  1649. //}
  1650. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1651. int sucNum = 0;
  1652. try
  1653. {
  1654. foreach (var item in dto.base64DataList)
  1655. {
  1656. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1657. string result = DecodeBase64ToImage(item, imageName);
  1658. if (!string.IsNullOrEmpty(result))
  1659. {
  1660. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1661. pic.CreateUserId = dto.CreateUserId;
  1662. pic.PicName = imageName;
  1663. pic.PicPath = result;
  1664. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1665. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1666. if (insertResult > 0)
  1667. {
  1668. sucNum++;
  1669. }
  1670. }
  1671. }
  1672. }
  1673. catch (Exception ex)
  1674. {
  1675. return Ok(JsonView(false, ex.Message));
  1676. }
  1677. string msg = string.Format(@"成功上传{0}张", sucNum);
  1678. return Ok(JsonView(true, msg));
  1679. }
  1680. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1681. {
  1682. string filename = "";//声明一个string类型的相对路径
  1683. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1684. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1685. try//会有异常抛出,try,catch一下
  1686. {
  1687. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1688. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1689. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1690. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1691. //文件名称
  1692. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1693. //上传的文件的路径
  1694. string filePath = "";
  1695. if (!Directory.Exists(fileDir))
  1696. {
  1697. Directory.CreateDirectory(fileDir);
  1698. }
  1699. //上传的文件的路径
  1700. filePath = fileDir + filename;
  1701. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1702. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1703. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1704. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1705. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1706. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1707. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1708. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1709. bitmap.Dispose();
  1710. }
  1711. catch (Exception e)
  1712. {
  1713. string massage = e.Message;
  1714. Logs("IOS图片上传Error:" + massage);
  1715. //filename = e.Message;
  1716. }
  1717. return filename;//返回相对路径
  1718. }
  1719. /// <summary>
  1720. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1721. /// </summary>
  1722. /// <param name="dto"></param>
  1723. /// <returns></returns>
  1724. [HttpPost]
  1725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1726. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1727. {
  1728. if (dto == null)
  1729. {
  1730. return Ok(JsonView(false, "请求错误:"));
  1731. }
  1732. string msg = "参数错误";
  1733. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1734. {
  1735. try
  1736. {
  1737. //_delegationVisaRep.BeginTran();
  1738. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1739. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1740. .Where(s => s.Id == dto.visaProgressCustomerId)
  1741. .ExecuteCommandAsync();
  1742. if (updCount > 0 && dto.publishCode == 1)
  1743. {
  1744. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1745. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1746. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1747. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1748. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1749. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1750. if (groupData == null)
  1751. {
  1752. _delegationVisaRep.RollbackTran();
  1753. }
  1754. string title = string.Format(@"[签证进度更新]");
  1755. string content = string.Format(@"测试文本");
  1756. bool rst = await _message.AddMsg(new MessageDto()
  1757. {
  1758. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1759. IssuerId = dto.publisher,
  1760. Title = title,
  1761. Content = content,
  1762. ReleaseTime = DateTime.Now,
  1763. UIdList = new List<int> {
  1764. 234
  1765. }
  1766. });
  1767. if (rst)
  1768. {
  1769. return Ok(JsonView(true, "发送通知成功"));
  1770. }
  1771. }
  1772. //_delegationVisaRep.CommitTran();
  1773. }
  1774. catch (Exception)
  1775. {
  1776. //_delegationVisaRep.RollbackTran();
  1777. }
  1778. }
  1779. return Ok(JsonView(true, msg));
  1780. }
  1781. #endregion
  1782. #region 团组任务分配
  1783. /// <summary>
  1784. /// 团组任务分配初始化
  1785. /// </summary>
  1786. /// <returns></returns>
  1787. [HttpPost]
  1788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1789. public async Task<IActionResult> GetTaskAssignmen()
  1790. {
  1791. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1792. if (groupData.Code != 0)
  1793. {
  1794. return Ok(JsonView(false, groupData.Msg));
  1795. }
  1796. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1797. }
  1798. /// <summary>
  1799. /// 团组任务分配查询
  1800. /// </summary>
  1801. /// <param name="dto"></param>
  1802. /// <returns></returns>
  1803. [HttpPost]
  1804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1805. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1806. {
  1807. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1808. if (groupData.Code != 0)
  1809. {
  1810. return Ok(JsonView(false, groupData.Msg));
  1811. }
  1812. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1813. }
  1814. /// <summary>
  1815. /// 团组任务分配操作
  1816. /// </summary>
  1817. /// <param name="dto"></param>
  1818. /// <returns></returns>
  1819. [HttpPost]
  1820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1821. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1822. {
  1823. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1824. if (groupData.Code != 0)
  1825. {
  1826. return Ok(JsonView(false, groupData.Msg));
  1827. }
  1828. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1829. }
  1830. /// <summary>
  1831. /// 团组任务分配
  1832. /// 批量分配
  1833. /// 查询团组
  1834. /// </summary>
  1835. /// <param name="dto"></param>
  1836. /// <returns></returns>
  1837. [HttpPost]
  1838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1839. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1840. {
  1841. //参数验证
  1842. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1843. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1844. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1845. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1846. }
  1847. /// <summary>
  1848. /// 团组任务分配
  1849. /// 批量分配
  1850. /// </summary>
  1851. /// <param name="dto"></param>
  1852. /// <returns></returns>
  1853. [HttpPost]
  1854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1855. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1856. {
  1857. //参数验证
  1858. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1859. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1860. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1861. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1862. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1863. }
  1864. #endregion
  1865. #region 团组费用审核
  1866. /// <summary>
  1867. /// 费用审核
  1868. /// 团组列表 Page
  1869. /// </summary>
  1870. /// <param name="_dto">团组列表请求dto</param>
  1871. /// <returns></returns>
  1872. [HttpPost]
  1873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1874. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1875. {
  1876. #region 参数验证
  1877. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1878. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1879. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1880. #region 页面操作权限验证
  1881. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1882. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1883. #endregion
  1884. #endregion
  1885. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1886. {
  1887. string sqlWhere = string.Empty;
  1888. if (_dto.IsSure == 0) //未完成
  1889. {
  1890. sqlWhere += string.Format(@" And IsSure = 0");
  1891. }
  1892. else if (_dto.IsSure == 1) //已完成
  1893. {
  1894. sqlWhere += string.Format(@" And IsSure = 1");
  1895. }
  1896. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1897. {
  1898. string tj = _dto.SearchCriteria;
  1899. 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}%')",
  1900. tj, tj, tj, tj, tj);
  1901. }
  1902. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1903. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1904. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1905. From (
  1906. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1907. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1908. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1909. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1910. From Grp_DelegationInfo gdi
  1911. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1912. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1913. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1914. Where gdi.IsDel = 0 {0}
  1915. ) temp ", sqlWhere);
  1916. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1917. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1918. var _view = new
  1919. {
  1920. PageFuncAuth = pageFunAuthView,
  1921. Data = _DelegationList
  1922. };
  1923. return Ok(JsonView(true, "查询成功!", _view, total));
  1924. }
  1925. else
  1926. {
  1927. return Ok(JsonView(false, "查询失败"));
  1928. }
  1929. }
  1930. /// <summary>
  1931. /// 获取团组费用审核
  1932. /// </summary>
  1933. /// <param name="_dto"></param>
  1934. /// <returns></returns>
  1935. [HttpPost]
  1936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1937. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1938. {
  1939. try
  1940. {
  1941. #region 参数验证
  1942. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1943. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1944. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1945. #region 页面操作权限验证
  1946. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1947. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1948. #endregion
  1949. #endregion
  1950. var _view = new Grp_CreditCardPaymentView();
  1951. var clientNameList = getSimplClientList(_dto.DiId);
  1952. #region 费用清单
  1953. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1954. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1955. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1956. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1957. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1958. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1959. /*
  1960. * 76://酒店预订
  1961. */
  1962. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1963. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1964. /*
  1965. * 79://车/导游地接
  1966. */
  1967. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1968. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1969. /*
  1970. * 80: //签证
  1971. */
  1972. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1973. /*
  1974. *81: //邀请/公务活动
  1975. */
  1976. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1977. /*
  1978. * 82: //团组客户保险
  1979. */
  1980. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1981. /*
  1982. * Lable = 85 机票预订
  1983. */
  1984. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1985. /*
  1986. * 85 机票预定
  1987. */
  1988. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1989. /*
  1990. * 98 其他款项
  1991. */
  1992. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1993. /*
  1994. * 285:收款退还
  1995. */
  1996. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1997. /*
  1998. * 1015: //超支费用
  1999. */
  2000. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2001. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2002. /*
  2003. * 币种信息
  2004. */
  2005. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2006. /*
  2007. * 车/导游地接 费用类型
  2008. */
  2009. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2010. /*
  2011. * 车/导游地接 费用类型
  2012. */
  2013. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2014. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2015. /*
  2016. * 用户信息
  2017. */
  2018. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2019. /*
  2020. * 费用模块
  2021. */
  2022. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2023. string priceModule = string.Empty;
  2024. if (sdPriceName != null)
  2025. {
  2026. priceModule = sdPriceName.Name;
  2027. }
  2028. /*
  2029. * 成本信息
  2030. */
  2031. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2032. decimal _groupRate = 0.0000M;
  2033. string _groupCurrencyCode = "-";
  2034. if (groupCost != null)
  2035. {
  2036. _groupRate = groupCost.Rate;
  2037. if (int.TryParse(groupCost.Currency, out int _currency))
  2038. {
  2039. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2040. }
  2041. else _groupCurrencyCode = groupCost.Currency;
  2042. }
  2043. string costContentSql = $"Select * From Grp_GroupCost";
  2044. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2045. //处理日期为空的天数
  2046. for (int i = 0; i < groupCostDetails.Count; i++)
  2047. if (i != 0)
  2048. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2049. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2050. /*
  2051. * 处理详情数据
  2052. */
  2053. foreach (var entity in entityList)
  2054. {
  2055. var _detail = new Grp_CreditCardPaymentDetailView();
  2056. _detail.Id = entity.Id;
  2057. _detail.PriceName = priceModule;
  2058. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2059. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2060. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2061. //处理金额
  2062. if (entity.CTable == 1015)
  2063. {
  2064. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2065. if (czInfo != null)
  2066. {
  2067. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2068. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2069. }
  2070. }
  2071. /*
  2072. * 应付款金额
  2073. */
  2074. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2075. string PaymentCurrency_WaitPay = "Unknown";
  2076. string hotelCurrncyCode = "Unknown";
  2077. string hotelCurrncyName = "Unknown";
  2078. if (sdPaymentCurrency_WaitPay != null)
  2079. {
  2080. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2081. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2082. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2083. if (hotelCurrncyCode.Equals("CNY"))
  2084. {
  2085. entity.DayRate = 1.0000M;
  2086. }
  2087. }
  2088. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2089. /*
  2090. * 此次付款金额
  2091. */
  2092. decimal CurrPayStr = 0.00M,
  2093. OriginalCurrPay = 0.00M;
  2094. if (entity.PayPercentage == 0)
  2095. {
  2096. if (entity.PayThenMoney != 0)
  2097. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2098. }
  2099. else
  2100. {
  2101. if (entity.PayMoney != 0)
  2102. {
  2103. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2104. }
  2105. }
  2106. //if (_dto.Label == 79)
  2107. //{
  2108. // string original = string.Empty;
  2109. // if (hotelCurrncyCode.Equals("CNY"))
  2110. // {
  2111. // OriginalCurrPay = CurrPayStr;
  2112. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2113. // }
  2114. // else
  2115. // {
  2116. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2117. // //760 EUR(7600.00 CNY)
  2118. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2119. // }
  2120. //}
  2121. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2122. string original = string.Empty;
  2123. if (hotelCurrncyCode.Equals("CNY"))
  2124. {
  2125. OriginalCurrPay = CurrPayStr;
  2126. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2127. }
  2128. else
  2129. {
  2130. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2131. //760 EUR(7600.00 CNY)
  2132. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2133. }
  2134. /*
  2135. * 剩余尾款
  2136. */
  2137. decimal BalanceStr = 0;
  2138. if (CurrPayStr != 0)
  2139. {
  2140. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2141. BalanceStr = 0;
  2142. else
  2143. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2144. }
  2145. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2146. /*
  2147. * Bus名称
  2148. */
  2149. _detail.BusName = "待增加";
  2150. /*
  2151. *费用所属
  2152. */
  2153. switch (entity.CTable)
  2154. {
  2155. case 76://酒店预订
  2156. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2157. if (hotelReservations != null)
  2158. {
  2159. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2160. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2161. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2162. string roomFeeStr = "", roomFeestr1 = "";
  2163. //是否比较房型价格
  2164. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2165. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2166. roomFeeStr += $"<br/>";
  2167. var roomTotal = 0.00M;
  2168. if (hotelReservations.SingleRoomPrice > 0)
  2169. {
  2170. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2171. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2172. //__isSingle = true;
  2173. roomTotal += fee;
  2174. }
  2175. if (hotelReservations.DoubleRoomPrice > 0)
  2176. {
  2177. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2178. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2179. // __isDouble = true;
  2180. roomTotal += fee;
  2181. }
  2182. if (hotelReservations.SuiteRoomPrice > 0)
  2183. {
  2184. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2185. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2186. //__isSuite = true;
  2187. roomTotal += fee;
  2188. }
  2189. if (hotelReservations.OtherRoomPrice > 0)
  2190. {
  2191. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2192. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2193. //__isOther = true;
  2194. roomTotal += fee;
  2195. }
  2196. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2197. else roomFeeStr += " 0.00 * 0";
  2198. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2199. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2200. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2201. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2202. /*
  2203. * 费用类型
  2204. * 1:房费
  2205. * 2:早餐
  2206. * 3:地税
  2207. * 4:城市税
  2208. * </summary>
  2209. */
  2210. //地税
  2211. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2212. if (governmentRentData != null)
  2213. {
  2214. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2215. governmentRentFee = governmentRentData.Price;
  2216. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2217. if (governmentRentCurrData != null)
  2218. {
  2219. governmentRentCode = governmentRentCurrData.Name;
  2220. governmentRentName = $"({governmentRentCurrData.Remark})";
  2221. }
  2222. }
  2223. //城市税
  2224. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2225. if (cityTaxData != null)
  2226. {
  2227. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2228. cityTaxFee = cityTaxData.Price;
  2229. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2230. if (cityTaxCurrData != null)
  2231. {
  2232. cityTaxCode = cityTaxCurrData.Name;
  2233. cityTaxName = $"({cityTaxCurrData.Remark})";
  2234. }
  2235. }
  2236. //酒店早餐
  2237. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2238. if (breakfastData != null)
  2239. {
  2240. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2241. breakfastFee = breakfastData.Price;
  2242. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2243. if (breakfastCurrData != null)
  2244. {
  2245. breakfastCode = breakfastCurrData.Name;
  2246. breakfastName = $"({breakfastCurrData.Remark})";
  2247. }
  2248. }
  2249. //房间费用
  2250. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2251. if (roomData != null)
  2252. {
  2253. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2254. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2255. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2256. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2257. roomFee = roomData.Price;
  2258. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2259. if (roomCurrData != null)
  2260. {
  2261. roomCode = roomCurrData.Name;
  2262. roomName = $"({roomCurrData.Remark})";
  2263. }
  2264. }
  2265. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2266. string hotelCostStr = "";
  2267. decimal hotelCsotTotal = 0.00M;
  2268. if (groupCost != null)
  2269. {
  2270. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2271. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2272. }
  2273. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2274. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2275. string hotelCost_day = "";
  2276. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2277. foreach (var item in hotelCostDetails1)
  2278. {
  2279. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2280. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2281. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2282. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2283. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2284. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2285. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2286. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2287. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2288. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2289. hotelCost_day += @$"<br/>";
  2290. }
  2291. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2292. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2293. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2294. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2295. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2296. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2297. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2298. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2299. $"房间说明: {hotelReservations.Remark} <br/>" +
  2300. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2301. $"{hotelBreakfastStr}" +
  2302. $"{hotelGovernmentRentStr}" +
  2303. $"{hotelCityTaxStr}";
  2304. _detail.PriceNameContent = hotelReservations.HotelName;
  2305. }
  2306. break;
  2307. case 79://车/导游地接
  2308. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2309. if (touristGuideGroundReservations != null)
  2310. {
  2311. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2312. {
  2313. _detail.BusName = touristGuideGroundReservations.BusName;
  2314. }
  2315. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2316. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2317. //if (isInt)
  2318. //{
  2319. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2320. // if (cityInfo != null)
  2321. // {
  2322. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2323. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2324. // if (carFeeItem != null)
  2325. // {
  2326. // nameContent += $@"({carFeeItem.Name})";
  2327. // }
  2328. // _detail.PriceNameContent = nameContent;
  2329. // }
  2330. //}
  2331. //else
  2332. //{
  2333. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2334. //}
  2335. var touristGuideGroundReservationsContents =
  2336. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2337. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2338. foreach (var item in touristGuideGroundReservationsContents)
  2339. {
  2340. string typeName = "Unknown";
  2341. string carCurrencyCode = "Unknown";
  2342. string carCurrencyName = "Unknown";
  2343. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2344. if (carTypeData != null) typeName = carTypeData.Name;
  2345. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2346. if (currencyData != null)
  2347. {
  2348. carCurrencyCode = currencyData.Name;
  2349. carCurrencyName = currencyData.Remark;
  2350. }
  2351. //op、成本 币种是否一致
  2352. bool IsCurrencyAgreement = false;
  2353. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2354. string opCostStr = string.Empty;
  2355. decimal opCostTypePrice = 0.00M;
  2356. #region 处理成本各项费用
  2357. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2358. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2359. if (opCost.Count > 0)
  2360. {
  2361. switch (item.SId)
  2362. {
  2363. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2364. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2365. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2366. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2367. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2368. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2369. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2370. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2371. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2372. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2373. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2374. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2375. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2376. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2377. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2378. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2379. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2380. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2381. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2382. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2383. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2384. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2385. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2386. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2387. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2388. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2389. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2390. }
  2391. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2392. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2393. }
  2394. #endregion
  2395. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2396. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2397. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2398. $"{opTypeStr} {opCostStr}<br/>" +
  2399. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2400. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2401. }
  2402. _detail.PriceMsgContent = priceMsg;
  2403. }
  2404. break;
  2405. case 80: //签证
  2406. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2407. if (visaInfo != null)
  2408. {
  2409. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2410. _detail.PriceNameContent = visaInfo.VisaDescription;
  2411. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2412. }
  2413. break;
  2414. case 81: //邀请/公务活动
  2415. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2416. if (_ioa != null)
  2417. {
  2418. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2419. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2420. sendCurrName = "Unknown", //快递费用币种 Name
  2421. sendCurrCode = "Unknown", //快递费用币种 Code
  2422. eventsCurrName = "Unknown", //公务活动费币种 Name
  2423. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2424. translateCurrName = "Unknown", //公务翻译费 Name
  2425. translateCurrCode = "Unknown"; //公务翻译费 Code
  2426. #region 处理费用币种
  2427. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2428. if (inviteCurrData != null)
  2429. {
  2430. inviteCurrName = inviteCurrData.Remark;
  2431. inviteCurrCode = inviteCurrData.Name;
  2432. }
  2433. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2434. if (sendCurrData != null)
  2435. {
  2436. sendCurrName = sendCurrData.Remark;
  2437. sendCurrCode = sendCurrData.Name;
  2438. }
  2439. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2440. if (eventsCurrData != null)
  2441. {
  2442. eventsCurrName = eventsCurrData.Remark;
  2443. eventsCurrCode = eventsCurrData.Name;
  2444. }
  2445. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2446. if (translateCurrData != null)
  2447. {
  2448. translateCurrName = translateCurrData.Remark;
  2449. translateCurrCode = translateCurrData.Name;
  2450. }
  2451. #endregion
  2452. _detail.PriceNameContent = _ioa.InviterArea;
  2453. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2454. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2455. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2456. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2457. $@"备注:" + _ioa.Remark + "<br/>";
  2458. }
  2459. break;
  2460. case 82: //团组客户保险
  2461. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2462. if (customers != null)
  2463. {
  2464. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2465. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2466. }
  2467. break;
  2468. case 85: //机票预订
  2469. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2470. if (jpRes != null)
  2471. {
  2472. string FlightsDescription = jpRes.FlightsDescription;
  2473. string PriceDescription = jpRes.PriceDescription;
  2474. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2475. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2476. }
  2477. break;
  2478. case 98://其他款项
  2479. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2480. if (gdpRes != null)
  2481. {
  2482. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2483. _detail.PriceNameContent = gdpRes.PriceName;
  2484. }
  2485. break;
  2486. case 285://收款退还
  2487. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2488. if (refundAndOtherMoney != null)
  2489. {
  2490. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2491. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2492. }
  2493. break;
  2494. case 751://酒店早餐
  2495. break;
  2496. case 1015://超支费用
  2497. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2498. if (groupExtraCost != null)
  2499. {
  2500. _detail.PriceNameContent = groupExtraCost.PriceName;
  2501. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2502. }
  2503. break;
  2504. default:
  2505. break;
  2506. }
  2507. /*
  2508. * 申请人
  2509. */
  2510. string operatorName = " - ";
  2511. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2512. if (_opUser != null)
  2513. {
  2514. operatorName = _opUser.CnName;
  2515. }
  2516. _detail.OperatorName = operatorName;
  2517. /*
  2518. * 审核人
  2519. */
  2520. string auditOperatorName = "Unknown";
  2521. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2522. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2523. else
  2524. {
  2525. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2526. if (_adUser != null)
  2527. {
  2528. auditOperatorName = _adUser.CnName;
  2529. }
  2530. }
  2531. _detail.AuditOperatorName = auditOperatorName;
  2532. /*
  2533. * 超预算比例
  2534. */
  2535. string overBudgetStr = "";
  2536. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2537. else if (entity.ExceedBudget == 0)
  2538. {
  2539. if (entity.CTable == 76 || entity.CTable == 79)
  2540. {
  2541. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2542. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2543. }
  2544. else
  2545. {
  2546. overBudgetStr = "未超预算";
  2547. }
  2548. }
  2549. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2550. _detail.OverBudget = overBudgetStr;
  2551. decimal auditFee = 0.00M; //已审核金额 人名币
  2552. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2553. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2554. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2555. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2556. {
  2557. auditedFeeOriginal = entity.PayMoney;
  2558. auditFee = CurrPayStr;
  2559. }
  2560. else if (entity.IsAuditGM == 0)
  2561. {
  2562. unAuditFeeCNY = CurrPayStr;
  2563. unAuditFeeOriginal = OriginalCurrPay;
  2564. OriginalCurrPay = 0.00M;
  2565. }
  2566. /*
  2567. * 费用总计
  2568. */
  2569. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2570. {
  2571. CurrencyId = entity.PaymentCurrency,
  2572. CurrencyName = PaymentCurrency_WaitPay,
  2573. AmountPayable = entity.PayMoney,
  2574. ThisPayment = OriginalCurrPay,
  2575. BalancePayment = BalanceStr,
  2576. AuditedFunds = auditFee,
  2577. AuditedFundsOriginal = auditedFeeOriginal,
  2578. UnAuditFundsCNY = unAuditFeeCNY,
  2579. UnAuditFundsOriginal = unAuditFeeOriginal
  2580. });
  2581. _detail.IsAuditGM = entity.IsAuditGM;
  2582. detailList.Add(_detail);
  2583. }
  2584. #endregion
  2585. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2586. /*
  2587. * 下方描述处理
  2588. */
  2589. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2590. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2591. if (ccpCurrencyPrice != null)
  2592. {
  2593. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2594. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2595. }
  2596. else
  2597. {
  2598. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2599. }
  2600. string amountPayableStr = string.Format(@"应付款总金额: ");
  2601. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2602. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2603. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2604. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2605. foreach (var item in nonDuplicat)
  2606. {
  2607. var currencyName = item.CurrencyName;
  2608. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2609. if (strs.Count > 0)
  2610. {
  2611. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2612. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2613. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2614. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2615. //单独处理此次付款金额
  2616. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2617. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2618. //单独处理已审核费用
  2619. //if (item.CurrencyId == 836) //人民币
  2620. //{
  2621. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2622. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2623. //}
  2624. //else
  2625. //{
  2626. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2627. //}
  2628. if (currencyName.Equals("CNY"))
  2629. {
  2630. //已审核费用
  2631. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2632. //未审核费用
  2633. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2634. }
  2635. else
  2636. {
  2637. //已审核费用
  2638. 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"));
  2639. //未审核费用
  2640. 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"));
  2641. }
  2642. }
  2643. }
  2644. _view.TotalStr1 = amountPayableStr[..^1];
  2645. _view.TotalStr2 = thisPaymentStr[..^1];
  2646. _view.TotalStr3 = balancePaymentStr[..^1];
  2647. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2648. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2649. var _view1 = new
  2650. {
  2651. PageFuncAuth = pageFunAuthView,
  2652. Data = _view
  2653. };
  2654. return Ok(JsonView(_view1));
  2655. }
  2656. catch (Exception ex)
  2657. {
  2658. return Ok(JsonView(false, ex.Message));
  2659. }
  2660. }
  2661. /// <summary>
  2662. /// 费用审核
  2663. /// 修改团组费用审核状态
  2664. /// </summary>
  2665. /// <param name="_dto">参数Json字符串</param>
  2666. /// <returns></returns>
  2667. [HttpPost]
  2668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2669. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2670. {
  2671. #region 参数验证
  2672. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2673. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2674. #endregion
  2675. #region 页面操作权限验证
  2676. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2677. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2678. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2679. #endregion
  2680. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2681. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2682. DateTime dtNow = DateTime.Now;
  2683. _groupRepository.BeginTran();
  2684. int rst = 0;
  2685. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2686. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2687. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2688. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2689. List<dynamic> msgDatas = new List<dynamic>();
  2690. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2691. foreach (var item in idList)
  2692. {
  2693. int CreditId = int.Parse(item);
  2694. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2695. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2696. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2697. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2698. .Where(s => s.Id == CreditId)
  2699. .ExecuteCommandAsync();
  2700. if (result < 1)
  2701. {
  2702. rst = -1;
  2703. _groupRepository.RollbackTran();
  2704. return Ok(JsonView(false, "操作失败并回滚!"));
  2705. }
  2706. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2707. if (creditData != null)
  2708. {
  2709. #region 应用通知配置
  2710. try
  2711. {
  2712. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2713. }
  2714. catch (Exception ex)
  2715. {
  2716. }
  2717. #endregion
  2718. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2719. string groupNameStr = string.Empty;
  2720. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2721. if (groupData != null) groupNameStr = groupData.TeamName;
  2722. string creditTypeStr = string.Empty;
  2723. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2724. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2725. string creditCurrency = string.Empty;
  2726. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2727. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2728. if (creditCurrency.Equals("CNY"))
  2729. {
  2730. creditData.DayRate = 1.0000M;
  2731. }
  2732. if (creditData.PayPercentage == 0.00M)
  2733. {
  2734. creditData.PayPercentage = 100M;
  2735. }
  2736. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2737. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2738. string msgContent = "";
  2739. if (creditCurrency.Equals("CNY"))
  2740. {
  2741. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2742. }
  2743. else
  2744. {
  2745. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2746. }
  2747. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2748. }
  2749. }
  2750. if (rst == 0)
  2751. {
  2752. _groupRepository.CommitTran();
  2753. foreach (var item in msgDatas)
  2754. {
  2755. //发送消息
  2756. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2757. }
  2758. #region 应用推送
  2759. try
  2760. {
  2761. foreach (var ccpId in dic_ccp_user.Keys)
  2762. {
  2763. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2764. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2765. }
  2766. }
  2767. catch (Exception)
  2768. {
  2769. }
  2770. #endregion
  2771. return Ok(JsonView(true, "操作成功!"));
  2772. }
  2773. return Ok(JsonView(false, "操作失败!"));
  2774. }
  2775. #endregion
  2776. #region 机票费用录入
  2777. /// <summary>
  2778. /// 机票录入当前登录人可操作团组
  2779. /// </summary>
  2780. /// <param name="dto"></param>
  2781. /// <returns></returns>
  2782. [HttpPost]
  2783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2784. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2785. {
  2786. try
  2787. {
  2788. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2789. if (groupData.Code != 0)
  2790. {
  2791. return Ok(JsonView(false, groupData.Msg));
  2792. }
  2793. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2794. }
  2795. catch (Exception ex)
  2796. {
  2797. return Ok(JsonView(false, "程序错误!"));
  2798. throw;
  2799. }
  2800. }
  2801. /// <summary>
  2802. /// 机票费用录入列表
  2803. /// </summary>
  2804. /// <param name="dto"></param>
  2805. /// <returns></returns>
  2806. [HttpPost]
  2807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2808. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2809. {
  2810. try
  2811. {
  2812. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2813. if (groupData.Code != 0)
  2814. {
  2815. return Ok(JsonView(false, groupData.Msg));
  2816. }
  2817. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2818. }
  2819. catch (Exception ex)
  2820. {
  2821. return Ok(JsonView(false, ex.Message));
  2822. throw;
  2823. }
  2824. }
  2825. /// <summary>
  2826. /// 根据id查询费用录入信息
  2827. /// </summary>
  2828. /// <param name="dto"></param>
  2829. /// <returns></returns>
  2830. [HttpPost]
  2831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2832. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2833. {
  2834. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2835. if (groupData.Code != 0)
  2836. {
  2837. return Ok(JsonView(false, groupData.Msg));
  2838. }
  2839. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2840. }
  2841. /// <summary>
  2842. /// 机票费用录入操作(Status:1.新增,2.修改)
  2843. /// </summary>
  2844. /// <param name="dto"></param>
  2845. /// <returns></returns>
  2846. [HttpPost]
  2847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2848. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2849. {
  2850. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2851. if (groupData.Code != 0)
  2852. {
  2853. return Ok(JsonView(false, groupData.Msg));
  2854. }
  2855. #region 应用推送
  2856. try
  2857. {
  2858. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2859. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2860. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2861. //2024-10-21 新增LZ UID
  2862. var userIds = new List<int>() { 21 };
  2863. string title = $"系统通知";
  2864. string content = "";
  2865. var diId = dto.AirTicketResOpData.DiId;
  2866. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2867. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2868. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2869. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2870. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2871. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2872. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2873. }
  2874. catch (Exception ex)
  2875. {
  2876. }
  2877. #endregion
  2878. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2879. }
  2880. /// <summary>
  2881. /// 根据舱位类型查询接团客户名单信息
  2882. /// </summary>
  2883. /// <param name="dto"></param>
  2884. /// <returns></returns>
  2885. [HttpPost]
  2886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2887. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2888. {
  2889. try
  2890. {
  2891. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2892. if (crm_Groups.Count != 0)
  2893. {
  2894. List<dynamic> Customer = new List<dynamic>();
  2895. foreach (var item in crm_Groups)
  2896. {
  2897. var data = new
  2898. {
  2899. Id = item.Id,
  2900. Pinyin = item.Pinyin,
  2901. Name = item.LastName + item.FirstName
  2902. };
  2903. Customer.Add(data);
  2904. }
  2905. return Ok(JsonView(true, "查询成功!", Customer));
  2906. }
  2907. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2908. }
  2909. catch (Exception ex)
  2910. {
  2911. return Ok(JsonView(false, "程序错误!"));
  2912. throw;
  2913. }
  2914. }
  2915. /// <summary>
  2916. /// 根据团号获取客户信息
  2917. /// </summary>
  2918. /// <param name="dto"></param>
  2919. /// <returns></returns>
  2920. [HttpPost]
  2921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2922. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2923. {
  2924. var jw = JsonView(false);
  2925. if (dto.DIID < 1)
  2926. {
  2927. jw.Msg += "请输入正确的diid";
  2928. return Ok(jw);
  2929. }
  2930. var arr = getSimplClientList(dto.DIID);
  2931. jw = JsonView(true, "获取成功!", arr);
  2932. return Ok(jw);
  2933. }
  2934. private List<SimplClientInfo> getSimplClientList(int diId)
  2935. {
  2936. 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);
  2937. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2938. foreach (var item in arr)
  2939. {
  2940. EncryptionProcessor.DecryptProperties(item);
  2941. }
  2942. return arr;
  2943. }
  2944. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2945. {
  2946. string result = origin;
  2947. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2948. {
  2949. string[] temparr = origin.Split(',');
  2950. string fistrStr = temparr[0];
  2951. int count = temparr.Count();
  2952. int tempId;
  2953. bool success = int.TryParse(fistrStr, out tempId);
  2954. if (success)
  2955. {
  2956. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2957. if (tempInfo != null)
  2958. {
  2959. if (count > 1)
  2960. {
  2961. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2962. }
  2963. else
  2964. {
  2965. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2966. }
  2967. }
  2968. }
  2969. }
  2970. return result;
  2971. }
  2972. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2973. {
  2974. string result = origin;
  2975. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2976. {
  2977. string[] temparr = origin.Split(',');
  2978. result = "";
  2979. foreach (var item in temparr)
  2980. {
  2981. int tempId;
  2982. bool success = int.TryParse(item, out tempId);
  2983. if (success)
  2984. {
  2985. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2986. if (tempInfo != null)
  2987. {
  2988. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2989. }
  2990. }
  2991. }
  2992. }
  2993. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2994. return result;
  2995. }
  2996. /// <summary>
  2997. /// 机票费用录入,删除
  2998. /// </summary>
  2999. /// <param name="dto"></param>
  3000. /// <returns></returns>
  3001. [HttpPost]
  3002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3003. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3004. {
  3005. try
  3006. {
  3007. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3008. if (res)
  3009. {
  3010. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3011. {
  3012. IsDel = 1,
  3013. DeleteUserId = dto.DeleteUserId,
  3014. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3015. }).ExecuteCommandAsync();
  3016. return Ok(JsonView(true, "删除成功!"));
  3017. }
  3018. return Ok(JsonView(false, "删除失败!"));
  3019. }
  3020. catch (Exception ex)
  3021. {
  3022. return Ok(JsonView(false, "程序错误!"));
  3023. throw;
  3024. }
  3025. }
  3026. /// <summary>
  3027. /// 导出机票录入报表
  3028. /// </summary>
  3029. /// <param name="dto"></param>
  3030. /// <returns></returns>
  3031. [HttpPost]
  3032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3033. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3034. {
  3035. try
  3036. {
  3037. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3038. if (groupData.Code != 0)
  3039. {
  3040. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3041. }
  3042. else
  3043. {
  3044. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3045. if (AirTicketReservations.Count != 0)
  3046. {
  3047. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3048. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3049. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3050. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3051. WorkbookDesigner designer = new WorkbookDesigner();
  3052. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3053. decimal countCost = 0;
  3054. foreach (var item in AirTicketReservations)
  3055. {
  3056. #region 处理客人姓名
  3057. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3058. item.ClientName = clientNames;
  3059. #endregion
  3060. if (item.BankType == "其他")
  3061. {
  3062. item.BankNo = "--";
  3063. }
  3064. else
  3065. {
  3066. if (!string.IsNullOrEmpty(item.BankType))
  3067. {
  3068. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3069. }
  3070. }
  3071. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3072. item.Price = System.Decimal.Round(item.Price, 2);
  3073. countCost += Convert.ToDecimal(item.Price);
  3074. }
  3075. designer.SetDataSource("Export", AirTicketReservations);
  3076. designer.SetDataSource("ExportDiCode", diCode);
  3077. designer.SetDataSource("ExportDiName", diName);
  3078. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3079. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3080. designer.Process();
  3081. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3082. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3083. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3084. return Ok(JsonView(true, "成功", url = rst));
  3085. }
  3086. else
  3087. {
  3088. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3089. }
  3090. }
  3091. }
  3092. catch (Exception ex)
  3093. {
  3094. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3095. throw;
  3096. }
  3097. }
  3098. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3099. /// <summary>
  3100. /// 行程单导出
  3101. /// </summary>
  3102. /// <param name="dto"></param>
  3103. /// <returns></returns>
  3104. [HttpPost]
  3105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3106. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3107. {
  3108. try
  3109. {
  3110. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3111. if (groupData.Code != 0)
  3112. {
  3113. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3114. }
  3115. else
  3116. {
  3117. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3118. if (dto.Language == "CN")
  3119. {
  3120. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3121. DocumentBuilder builder = new DocumentBuilder(doc);
  3122. int tableIndex = 0;//表格索引
  3123. //得到文档中的第一个表格
  3124. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3125. foreach (var item in _AirTicketReservations)
  3126. {
  3127. #region 处理固定数据
  3128. string[] FlightsCode = item.FlightsCode.Split('/');
  3129. if (FlightsCode.Length != 0)
  3130. {
  3131. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3132. if (_AirCompany != null)
  3133. {
  3134. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3135. }
  3136. else
  3137. {
  3138. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3139. }
  3140. }
  3141. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3142. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3143. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3144. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3145. string name = "";
  3146. foreach (string clientName in nameArray)
  3147. {
  3148. if (!name.Contains(clientName))
  3149. {
  3150. name += clientName + ",";
  3151. }
  3152. }
  3153. if (!string.IsNullOrWhiteSpace(name))
  3154. {
  3155. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3156. }
  3157. else
  3158. {
  3159. table.Range.Bookmarks["ClientName"].Text = "--";
  3160. }
  3161. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3162. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3163. table.Range.Bookmarks["JointTicket"].Text = "--";
  3164. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3165. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3166. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3167. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3168. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3169. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3170. #endregion
  3171. #region 循环数据处理
  3172. List<AirInfo> airs = new List<AirInfo>();
  3173. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3174. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3175. for (int i = 0; i < FlightsCode.Length; i++)
  3176. {
  3177. AirInfo air = new AirInfo();
  3178. string[] tempstr = DayArray[i]
  3179. .Replace("\r\n", string.Empty)
  3180. .Replace("\\r\\n", string.Empty)
  3181. .TrimStart().TrimEnd()
  3182. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3183. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3184. string starCity = "";
  3185. if (star_Three != null)
  3186. {
  3187. starCity = star_Three.AirPort;
  3188. }
  3189. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3190. string EndCity = "";
  3191. if (End_Three != null)
  3192. {
  3193. EndCity = End_Three.AirPort;
  3194. }
  3195. air.Destination = starCity + "/" + EndCity;
  3196. air.Flight = FlightsCode[i];
  3197. air.SeatingClass = item.CTypeName;
  3198. string dateTime = tempstr[2];
  3199. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3200. air.FlightDate = DateTemp;
  3201. air.DepartureTime = tempstr[5];
  3202. air.LandingTime = tempstr[6];
  3203. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3204. air.TicketStatus = "--";
  3205. air.Luggage = "--";
  3206. air.DepartureTerminal = "--";
  3207. air.LandingTerminal = "--";
  3208. airs.Add(air);
  3209. }
  3210. int row = 13;
  3211. for (int i = 0; i < airs.Count; i++)
  3212. {
  3213. if (airs.Count > 2)
  3214. {
  3215. for (int j = 0; j < airs.Count - 2; j++)
  3216. {
  3217. var CopyRow = table.Rows[12].Clone(true);
  3218. table.Rows.Add(CopyRow);
  3219. }
  3220. }
  3221. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3222. int index = 0;
  3223. foreach (PropertyInfo property in properties)
  3224. {
  3225. string value = property.GetValue(airs[i]).ToString();
  3226. Cell ishcel0 = table.Rows[row].Cells[index];
  3227. Paragraph p = new Paragraph(doc);
  3228. string s = value;
  3229. p.AppendChild(new Run(doc, s));
  3230. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3231. ishcel0.AppendChild(p);
  3232. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3233. index++;
  3234. }
  3235. row++;
  3236. }
  3237. #endregion
  3238. Paragraph lastParagraph = new Paragraph(doc);
  3239. //第一个表格末尾加段落
  3240. table.ParentNode.InsertAfter(lastParagraph, table);
  3241. //复制第一个表格
  3242. Table cloneTable = (Table)table.Clone(true);
  3243. //在文档末尾段落后面加入复制的表格
  3244. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3245. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3246. {
  3247. int rownewsIndex = 13;
  3248. for (int i = 0; i < 2; i++)
  3249. {
  3250. var CopyRow = table.Rows[12].Clone(true);
  3251. table.Rows.RemoveAt(13);
  3252. table.Rows.Add(CopyRow);
  3253. rownewsIndex++;
  3254. }
  3255. }
  3256. else
  3257. {
  3258. table.Rows.RemoveAt(12);
  3259. }
  3260. cloneTable.Rows.RemoveAt(12);
  3261. }
  3262. if (_AirTicketReservations.Count != 0)
  3263. {
  3264. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3265. if (FlightsCode.Length != 0)
  3266. {
  3267. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3268. if (_AirCompany != null)
  3269. {
  3270. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3271. }
  3272. else
  3273. {
  3274. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3275. }
  3276. }
  3277. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3278. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3279. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3280. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3281. string name = "";
  3282. foreach (string clientName in nameArray)
  3283. {
  3284. if (!name.Contains(clientName))
  3285. {
  3286. name += clientName + ",";
  3287. }
  3288. }
  3289. if (!string.IsNullOrWhiteSpace(name))
  3290. {
  3291. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3292. }
  3293. else
  3294. {
  3295. table.Range.Bookmarks["ClientName"].Text = "--";
  3296. }
  3297. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3298. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3299. table.Range.Bookmarks["JointTicket"].Text = "--";
  3300. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3301. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3302. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3303. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3304. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3305. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3306. }
  3307. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3308. //保存合并后的文档
  3309. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3310. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3311. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3312. return Ok(JsonView(true, "成功!", rst));
  3313. }
  3314. else
  3315. {
  3316. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3317. DocumentBuilder builder = new DocumentBuilder(doc);
  3318. int tableIndex = 0;//表格索引
  3319. //得到文档中的第一个表格
  3320. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3321. List<string> texts = new List<string>();
  3322. foreach (var item in _AirTicketReservations)
  3323. {
  3324. string[] FlightsCode = item.FlightsCode.Split('/');
  3325. if (FlightsCode.Length != 0)
  3326. {
  3327. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3328. if (_AirCompany != null)
  3329. {
  3330. if (!transDic.ContainsKey(_AirCompany.CnName))
  3331. {
  3332. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3333. }
  3334. }
  3335. else
  3336. {
  3337. if (!transDic.ContainsKey("--"))
  3338. {
  3339. transDic.Add("--", "--");
  3340. }
  3341. }
  3342. }
  3343. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3344. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3345. string name = "";
  3346. foreach (string clientName in nameArray)
  3347. {
  3348. name += clientName + ",";
  3349. }
  3350. if (!texts.Contains(name))
  3351. {
  3352. texts.Add(name);
  3353. }
  3354. List<AirInfo> airs = new List<AirInfo>();
  3355. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3356. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3357. for (int i = 0; i < FlightsCode.Length; i++)
  3358. {
  3359. AirInfo air = new AirInfo();
  3360. string[] tempstr = DayArray[i]
  3361. .Replace("\r\n", string.Empty)
  3362. .Replace("\\r\\n", string.Empty)
  3363. .TrimStart().TrimEnd()
  3364. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3365. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3366. if (star_Three != null)
  3367. {
  3368. if (!transDic.ContainsKey(star_Three.AirPort))
  3369. {
  3370. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3371. }
  3372. }
  3373. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3374. if (End_Three != null)
  3375. {
  3376. if (!transDic.ContainsKey(End_Three.AirPort))
  3377. {
  3378. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3379. }
  3380. }
  3381. if (!texts.Contains(item.CTypeName))
  3382. {
  3383. texts.Add(item.CTypeName);
  3384. }
  3385. }
  3386. }
  3387. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3388. if (transData.Count > 0)
  3389. {
  3390. foreach (TranslateResult item in transData)
  3391. {
  3392. if (!transDic.ContainsKey(item.Query))
  3393. {
  3394. transDic.Add(item.Query, item.Translation);
  3395. }
  3396. }
  3397. }
  3398. foreach (var item in _AirTicketReservations)
  3399. {
  3400. #region 处理固定数据
  3401. string[] FlightsCode = item.FlightsCode.Split('/');
  3402. if (FlightsCode.Length != 0)
  3403. {
  3404. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3405. if (_AirCompany != null)
  3406. {
  3407. string str = "--";
  3408. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3409. if (!string.IsNullOrEmpty(translateResult))
  3410. {
  3411. str = translateResult;
  3412. str = _airTicketResRep.Processing(str);
  3413. }
  3414. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3415. }
  3416. else
  3417. {
  3418. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3419. }
  3420. }
  3421. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3422. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3423. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3424. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3425. string names = "";
  3426. foreach (string clientName in nameArray)
  3427. {
  3428. names += clientName + ",";
  3429. }
  3430. if (!string.IsNullOrWhiteSpace(names))
  3431. {
  3432. string str = "--";
  3433. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3434. if (!string.IsNullOrEmpty(translateResult))
  3435. {
  3436. str = translateResult;
  3437. str = _airTicketResRep.Processing(str);
  3438. }
  3439. table.Range.Bookmarks["ClientName"].Text = str;
  3440. }
  3441. else
  3442. {
  3443. table.Range.Bookmarks["ClientName"].Text = "--";
  3444. }
  3445. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3446. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3447. table.Range.Bookmarks["JointTicket"].Text = "--";
  3448. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3449. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3450. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3451. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3452. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3453. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3454. #endregion
  3455. #region 循环数据处理
  3456. List<AirInfo> airs = new List<AirInfo>();
  3457. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3458. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3459. for (int i = 0; i < FlightsCode.Length; i++)
  3460. {
  3461. AirInfo air = new AirInfo();
  3462. string[] tempstr = DayArray[i]
  3463. .Replace("\r\n", string.Empty)
  3464. .Replace("\\r\\n", string.Empty)
  3465. .TrimStart().TrimEnd()
  3466. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3467. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3468. string starCity = "";
  3469. if (star_Three != null)
  3470. {
  3471. string str2 = "--";
  3472. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3473. if (!string.IsNullOrEmpty(translateResult2))
  3474. {
  3475. str2 = translateResult2;
  3476. str2 = _airTicketResRep.Processing(str2);
  3477. }
  3478. starCity = str2;
  3479. }
  3480. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3481. string EndCity = "";
  3482. if (End_Three != null)
  3483. {
  3484. string str1 = "--";
  3485. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3486. if (!string.IsNullOrEmpty(translateResult1))
  3487. {
  3488. str1 = translateResult1;
  3489. str1 = _airTicketResRep.Processing(str1);
  3490. }
  3491. EndCity = str1;
  3492. }
  3493. air.Destination = starCity + "/" + EndCity;
  3494. air.Flight = FlightsCode[i];
  3495. string str = "--";
  3496. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3497. if (!string.IsNullOrEmpty(translateResult))
  3498. {
  3499. str = translateResult;
  3500. str = _airTicketResRep.Processing(str);
  3501. }
  3502. air.SeatingClass = str;
  3503. string dateTime = tempstr[2];
  3504. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3505. air.FlightDate = DateTemp;
  3506. air.DepartureTime = tempstr[5];
  3507. air.LandingTime = tempstr[6];
  3508. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3509. air.TicketStatus = "--";
  3510. air.Luggage = "--";
  3511. air.DepartureTerminal = "--";
  3512. air.LandingTerminal = "--";
  3513. airs.Add(air);
  3514. }
  3515. int row = 13;
  3516. for (int i = 0; i < airs.Count; i++)
  3517. {
  3518. if (airs.Count > 2)
  3519. {
  3520. for (int j = 0; j < airs.Count - 2; j++)
  3521. {
  3522. var CopyRow = table.Rows[12].Clone(true);
  3523. table.Rows.Add(CopyRow);
  3524. }
  3525. }
  3526. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3527. int index = 0;
  3528. foreach (PropertyInfo property in properties)
  3529. {
  3530. string value = property.GetValue(airs[i]).ToString();
  3531. Cell ishcel0 = table.Rows[row].Cells[index];
  3532. Paragraph p = new Paragraph(doc);
  3533. string s = value;
  3534. p.AppendChild(new Run(doc, s));
  3535. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3536. ishcel0.AppendChild(p);
  3537. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3538. //ishcel0.CellFormat.VerticalAlignment=
  3539. index++;
  3540. }
  3541. row++;
  3542. }
  3543. #endregion
  3544. Paragraph lastParagraph = new Paragraph(doc);
  3545. //第一个表格末尾加段落
  3546. table.ParentNode.InsertAfter(lastParagraph, table);
  3547. //复制第一个表格
  3548. Table cloneTable = (Table)table.Clone(true);
  3549. //在文档末尾段落后面加入复制的表格
  3550. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3551. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3552. {
  3553. int rownewsIndex = 13;
  3554. for (int i = 0; i < 2; i++)
  3555. {
  3556. var CopyRow = table.Rows[12].Clone(true);
  3557. table.Rows.RemoveAt(13);
  3558. table.Rows.Add(CopyRow);
  3559. rownewsIndex++;
  3560. }
  3561. }
  3562. else
  3563. {
  3564. table.Rows.RemoveAt(12);
  3565. }
  3566. cloneTable.Rows.RemoveAt(12);
  3567. }
  3568. if (_AirTicketReservations.Count != 0)
  3569. {
  3570. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3571. if (FlightsCode.Length != 0)
  3572. {
  3573. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3574. if (_AirCompany != null)
  3575. {
  3576. string str = "--";
  3577. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3578. if (!string.IsNullOrEmpty(translateResult))
  3579. {
  3580. str = translateResult;
  3581. str = _airTicketResRep.Processing(str);
  3582. }
  3583. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3584. }
  3585. else
  3586. {
  3587. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3588. }
  3589. }
  3590. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3591. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3592. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3593. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3594. string names = "";
  3595. foreach (string clientName in nameArray)
  3596. {
  3597. names += clientName + ",";
  3598. }
  3599. if (!string.IsNullOrWhiteSpace(names))
  3600. {
  3601. string str = "--";
  3602. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3603. if (!string.IsNullOrEmpty(translateResult))
  3604. {
  3605. str = translateResult;
  3606. str = _airTicketResRep.Processing(str);
  3607. }
  3608. table.Range.Bookmarks["ClientName"].Text = str;
  3609. }
  3610. else
  3611. {
  3612. table.Range.Bookmarks["ClientName"].Text = "--";
  3613. }
  3614. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3615. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3616. table.Range.Bookmarks["JointTicket"].Text = "--";
  3617. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3618. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3619. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3620. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3621. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3622. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3623. }
  3624. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3625. //保存合并后的文档
  3626. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3627. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3628. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3629. return Ok(JsonView(true, "成功!", rst));
  3630. }
  3631. }
  3632. }
  3633. catch (Exception ex)
  3634. {
  3635. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3636. throw;
  3637. }
  3638. }
  3639. #endregion
  3640. #region 团组增减款项 --> 其他款项
  3641. /// <summary>
  3642. /// 团组增减款项下拉框绑定
  3643. /// </summary>
  3644. /// <param name="dto"></param>
  3645. /// <returns></returns>
  3646. [HttpPost]
  3647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3648. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3649. {
  3650. #region 参数验证
  3651. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3652. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3653. #endregion
  3654. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3655. }
  3656. /// <summary>
  3657. /// 根据团组Id查询团组增减款项
  3658. /// </summary>
  3659. /// <param name="dto"></param>
  3660. /// <returns></returns>
  3661. [HttpPost]
  3662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3663. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3664. {
  3665. #region 参数验证
  3666. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3667. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3668. #endregion
  3669. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3670. }
  3671. /// <summary>
  3672. /// 团组增减款项操作(Status:1.新增,2.修改)
  3673. /// </summary>
  3674. /// <param name="dto"></param>
  3675. /// <returns></returns>
  3676. [HttpPost]
  3677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3678. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3679. {
  3680. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3681. if (groupData.Code != 200)
  3682. {
  3683. return Ok(JsonView(false, groupData.Msg));
  3684. }
  3685. #region 应用推送
  3686. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3687. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3688. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3689. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3690. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3691. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3692. //自动审核
  3693. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3694. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3695. //2024-10-21 新增LZ UID
  3696. var userIds = new List<int>() { 21 };
  3697. string title = $"系统通知";
  3698. string content = "";
  3699. var diId = dto.DiId;
  3700. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3701. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3702. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3703. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3704. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3705. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3706. #endregion
  3707. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3708. }
  3709. /// <summary>
  3710. /// 团组增减款项操作 删除
  3711. /// </summary>
  3712. /// <param name="dto"></param>
  3713. /// <returns></returns>
  3714. [HttpPost]
  3715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3716. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3717. {
  3718. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3719. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3720. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3721. if (res.Code == 0)
  3722. {
  3723. return Ok(JsonView(true, "删除成功!"));
  3724. }
  3725. return Ok(JsonView(false, "删除失败!"));
  3726. }
  3727. /// <summary>
  3728. /// 根据团组增减款项Id查询
  3729. /// </summary>
  3730. /// <param name="dto"></param>
  3731. /// <returns></returns>
  3732. [HttpPost]
  3733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3734. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3735. {
  3736. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3737. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3738. }
  3739. /// <summary>
  3740. /// 查询供应商名称
  3741. /// </summary>
  3742. /// <param name="dto"></param>
  3743. /// <returns></returns>
  3744. [HttpPost]
  3745. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3746. {
  3747. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3748. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3749. ?? new List<Grp_DecreasePayments>();
  3750. dbResult = dbResult.Distinct(new
  3751. ProductComparer()).ToList();
  3752. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3753. {
  3754. x.Id,
  3755. x.SupplierAddress,
  3756. x.SupplierArea,
  3757. x.SupplierContact,
  3758. x.SupplierContactNumber,
  3759. x.SupplierEmail,
  3760. x.SupplierName,
  3761. x.SupplierSocialAccount,
  3762. x.SupplierTypeId,
  3763. }).ToList());
  3764. return Ok(jw);
  3765. }
  3766. /// <summary>
  3767. /// 团组增减款项 OTA匹配
  3768. /// </summary>
  3769. /// <param name="file"></param>
  3770. /// <returns></returns>
  3771. [HttpPost]
  3772. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3773. {
  3774. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3775. string fileName = file.FileName;
  3776. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3777. {
  3778. return Ok(JsonView(false, "请上传Excel文件!"));
  3779. }
  3780. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3781. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3782. if (!Directory.Exists(path))
  3783. {
  3784. Directory.CreateDirectory(path);
  3785. }
  3786. var filePath = @$"{path}/{fileName}";
  3787. //保存文件
  3788. using (FileStream fs = System.IO.File.Create(filePath))
  3789. {
  3790. file.CopyTo(fs);
  3791. fs.Flush();
  3792. }
  3793. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3794. //读取ExcelFile
  3795. DataTable dt = ConvertExcelToDataTable(filePath);
  3796. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3797. dt.TableName = "TB";
  3798. //修改table列名
  3799. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3800. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3801. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3802. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3803. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3804. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3805. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3806. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3807. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3808. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3809. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3810. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3811. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3812. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3813. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3814. var otaOrderNos = new List<string>();
  3815. foreach (DataRow item in dt.Rows)
  3816. {
  3817. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3818. }
  3819. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3820. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3821. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3822. .Select((dp, di) => new
  3823. {
  3824. dp.PriceName,
  3825. dp.OTAOrderNo,
  3826. dp.FeeTotal,
  3827. di.TeamName,
  3828. })
  3829. .ToListAsync();
  3830. foreach (DataRow item in dt.Rows)
  3831. {
  3832. var otaOrderNo = item["OTAOrderNo"].ToString();
  3833. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3834. if (oaData == null) continue;
  3835. item["GroupName"] = oaData.TeamName;
  3836. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3837. }
  3838. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3839. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3840. List<DataTable> datas = new List<DataTable>();
  3841. datas.Add(dt);
  3842. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3843. return Ok(JsonView(true, "操作成功", new { url = url }));
  3844. }
  3845. #region
  3846. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3847. {
  3848. // 创建Workbook对象
  3849. Workbook workbook = new Workbook(excelFilePath);
  3850. // 获取第一个工作表
  3851. Worksheet worksheet = workbook.Worksheets[0];
  3852. // 将工作表转换为DataTable
  3853. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3854. return dataTable;
  3855. }
  3856. #endregion
  3857. #endregion
  3858. #region 文件上传、删除
  3859. /// <summary>
  3860. /// region 文件上传 可以带参数
  3861. /// </summary>
  3862. /// <param name="file"></param>
  3863. /// <returns></returns>
  3864. [HttpPost]
  3865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3866. public async Task<IActionResult> UploadProject(IFormFile file)
  3867. {
  3868. //var TypeName = Request.Headers["TypeName"].ToString();
  3869. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3870. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3871. ////文件名称
  3872. //string projectFileName = file.FileName;
  3873. ////上传的文件的路径
  3874. //string filePath = $"{fileDir}/{projectFileName}";
  3875. //if (TypeName == "A")//A代表团组增减款项
  3876. //{
  3877. // filePath = fileDir + $@"\团组增减款项相关文件";
  3878. // if (!Directory.Exists(filePath))
  3879. // {
  3880. // Directory.CreateDirectory(filePath);
  3881. // }
  3882. // //上传的文件的路径
  3883. // filePath += $@"\{projectFileName}";
  3884. //}
  3885. //else if (TypeName == "B")//B代表商邀相关文件
  3886. //{
  3887. // //上传的文件的路径
  3888. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3889. // if (!Directory.Exists(filePath))
  3890. // {
  3891. // Directory.CreateDirectory(filePath);
  3892. // }
  3893. // //上传的文件的路径
  3894. // filePath = $@"\{projectFileName}";
  3895. //}
  3896. //try
  3897. //{
  3898. // using (FileStream fs = System.IO.File.Create(filePath))
  3899. // {
  3900. // file.CopyTo(fs);
  3901. // fs.Flush();
  3902. // }
  3903. //}
  3904. //catch (Exception ex)
  3905. //{
  3906. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3907. //}
  3908. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3909. try
  3910. {
  3911. var TypeName = Request.Headers["TypeName"].ToString();
  3912. if (file != null)
  3913. {
  3914. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3915. //文件名称
  3916. string projectFileName = file.FileName;
  3917. //上传的文件的路径
  3918. string filePath = $"{fileDir}/{projectFileName}";
  3919. if (TypeName == "A")//A代表团组增减款项
  3920. {
  3921. if (!Directory.Exists(fileDir))
  3922. {
  3923. Directory.CreateDirectory(fileDir);
  3924. }
  3925. //上传的文件的路径
  3926. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3927. }
  3928. else if (TypeName == "B")//B代表商邀相关文件
  3929. {
  3930. if (!Directory.Exists(fileDir))
  3931. {
  3932. Directory.CreateDirectory(fileDir);
  3933. }
  3934. //上传的文件的路径
  3935. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3936. }
  3937. using (FileStream fs = System.IO.File.Create(filePath))
  3938. {
  3939. file.CopyTo(fs);
  3940. fs.Flush();
  3941. }
  3942. return Ok(JsonView(true, "上传成功!", projectFileName));
  3943. }
  3944. else
  3945. {
  3946. return Ok(JsonView(false, "上传失败!"));
  3947. }
  3948. }
  3949. catch (Exception ex)
  3950. {
  3951. return Ok(JsonView(false, "程序错误!"));
  3952. }
  3953. }
  3954. /// <summary>
  3955. /// 删除指定文件
  3956. /// </summary>
  3957. /// <param name="dto"></param>
  3958. /// <returns></returns>
  3959. [HttpPost]
  3960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3961. public async Task<IActionResult> DelFile(DelFileDto dto)
  3962. {
  3963. try
  3964. {
  3965. var TypeName = Request.Headers["TypeName"].ToString();
  3966. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3967. string filePath = "";
  3968. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3969. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3970. int id = 0;
  3971. if (TypeName == "A")
  3972. {
  3973. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3974. // 删除该文件
  3975. System.IO.File.Delete(filePath);
  3976. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3977. .Where(a => a.Id == dto.Id)
  3978. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3979. .ExecuteCommandAsync();
  3980. }
  3981. else if (TypeName == "B")
  3982. {
  3983. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3984. // 删除该文件
  3985. System.IO.File.Delete(filePath);
  3986. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3987. if (info != null)
  3988. {
  3989. string[] files = new string[] { };
  3990. if (!string.IsNullOrEmpty(info.Attachment))
  3991. {
  3992. try
  3993. {
  3994. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3995. }
  3996. catch (Exception)
  3997. {
  3998. files = new List<string>() { info.Attachment }.ToArray();
  3999. }
  4000. }
  4001. if (files.Length > 0)
  4002. {
  4003. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4004. string filePath2 = string.Empty;
  4005. if (files1.Length > 0)
  4006. {
  4007. filePath2 = JsonConvert.SerializeObject(files1);
  4008. }
  4009. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4010. .Where(a => a.Id == dto.Id)
  4011. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4012. .ExecuteCommandAsync();
  4013. }
  4014. }
  4015. }
  4016. if (id != 0)
  4017. {
  4018. return Ok(JsonView(true, "成功!"));
  4019. }
  4020. else
  4021. {
  4022. return Ok(JsonView(false, "失败!"));
  4023. }
  4024. }
  4025. catch (Exception ex)
  4026. {
  4027. return Ok(JsonView(false, "程序错误!"));
  4028. throw;
  4029. }
  4030. }
  4031. /// <summary>
  4032. /// 文件上传多个文件 可以带参数
  4033. /// </summary>
  4034. /// <param name="files"></param>
  4035. /// <returns></returns>
  4036. [HttpPost]
  4037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4038. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4039. {
  4040. try
  4041. {
  4042. var TypeName = Request.Headers["TypeName"].ToString();
  4043. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4044. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4045. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4046. var filePahts = new List<string>();
  4047. foreach (var file in files)
  4048. {
  4049. //文件名称
  4050. string projectFileName = file.FileName;
  4051. //上传的文件的路径
  4052. string filePath = $"{fileDir}/{projectFileName}";
  4053. if (TypeName == "A")//A代表团组增减款项
  4054. {
  4055. if (!Directory.Exists(fileDir))
  4056. {
  4057. Directory.CreateDirectory(fileDir);
  4058. }
  4059. //上传的文件的路径
  4060. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4061. }
  4062. else if (TypeName == "B")//B代表商邀相关文件
  4063. {
  4064. if (!Directory.Exists(fileDir))
  4065. {
  4066. Directory.CreateDirectory(fileDir);
  4067. }
  4068. //上传的文件的路径
  4069. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4070. }
  4071. using (FileStream fs = System.IO.File.Create(filePath))
  4072. {
  4073. file.CopyTo(fs);
  4074. fs.Flush();
  4075. }
  4076. filePahts.Add(projectFileName);
  4077. }
  4078. return Ok(JsonView(true, "上传成功!", filePahts));
  4079. }
  4080. catch (Exception ex)
  4081. {
  4082. return Ok(JsonView(false, "程序错误!"));
  4083. }
  4084. }
  4085. #endregion
  4086. #region 商邀费用录入
  4087. /// <summary>
  4088. /// 根据团组Id查询商邀费用列表
  4089. /// </summary>
  4090. /// <param name="dto"></param>
  4091. /// <returns></returns>
  4092. [HttpPost]
  4093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4094. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4095. {
  4096. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4097. if (groupData.Code != 0)
  4098. {
  4099. return Ok(JsonView(false, groupData.Msg));
  4100. }
  4101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4102. }
  4103. /// <summary>
  4104. /// 商邀费用列表
  4105. /// 下载文件
  4106. /// </summary>
  4107. /// <param name="id"></param>
  4108. /// <returns></returns>
  4109. [HttpGet("{id}")]
  4110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4111. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4112. {
  4113. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4114. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4115. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4116. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4117. var filePaths = new List<string>();
  4118. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4119. try
  4120. {
  4121. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4122. }
  4123. catch (Exception ex)
  4124. {
  4125. filePaths.Add(info.Attachment);
  4126. }
  4127. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4128. for (int i = 0; i < filePaths.Count; i++)
  4129. {
  4130. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4131. }
  4132. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4133. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4134. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4135. {
  4136. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4137. {
  4138. foreach (string filePath in filePaths)
  4139. {
  4140. if (System.IO.File.Exists(filePath))
  4141. {
  4142. // 获取文件名
  4143. string fileName = Path.GetFileName(filePath);
  4144. // 将文件添加到ZIP归档中
  4145. zipArchive.CreateEntryFromFile(filePath, fileName);
  4146. }
  4147. }
  4148. }
  4149. }
  4150. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4151. }
  4152. /// <summary>
  4153. /// 商邀费用 Info Page 基础数据源
  4154. /// </summary>
  4155. /// <returns></returns>
  4156. [HttpPost]
  4157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4158. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4159. {
  4160. try
  4161. {
  4162. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4163. if (groupData.Code != 0)
  4164. {
  4165. return Ok(JsonView(false, groupData.Msg));
  4166. }
  4167. return Ok(JsonView(true, "操作成功", groupData.Data));
  4168. }
  4169. catch (Exception ex)
  4170. {
  4171. return Ok(JsonView(false, ex.Message));
  4172. throw;
  4173. }
  4174. }
  4175. /// <summary>
  4176. /// 根据商邀费用ID查询C表和商邀费用数据
  4177. /// </summary>
  4178. /// <param name="dto"></param>
  4179. /// <returns></returns>
  4180. [HttpPost]
  4181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4182. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4183. {
  4184. try
  4185. {
  4186. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4187. if (groupData.Code != 0)
  4188. {
  4189. return Ok(JsonView(false, groupData.Msg));
  4190. }
  4191. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4192. }
  4193. catch (Exception ex)
  4194. {
  4195. return Ok(JsonView(false, ex.Message));
  4196. throw;
  4197. }
  4198. }
  4199. /// <summary>
  4200. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4201. /// </summary>
  4202. /// <param name="dto"></param>
  4203. /// <returns></returns>
  4204. [HttpPost]
  4205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4206. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4207. {
  4208. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4209. if (groupData.Code != 0)
  4210. {
  4211. return Ok(JsonView(false, groupData.Msg));
  4212. }
  4213. #region 应用推送
  4214. try
  4215. {
  4216. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4217. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4218. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4219. //2024-10-21 新增LZ UID
  4220. var userIds = new List<int>() { 21 };
  4221. string title = $"系统通知";
  4222. string content = "";
  4223. var diId = dto.DiId;
  4224. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4225. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4226. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4227. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4228. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4229. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4230. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4231. }
  4232. catch (Exception ex)
  4233. {
  4234. }
  4235. #endregion
  4236. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4237. }
  4238. /// <summary>
  4239. /// 商邀删除
  4240. /// </summary>
  4241. /// <param name="dto"></param>
  4242. /// <returns></returns>
  4243. [HttpPost]
  4244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4245. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4246. {
  4247. try
  4248. {
  4249. _sqlSugar.BeginTran();
  4250. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4251. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4252. {
  4253. IsDel = 1,
  4254. DeleteUserId = dto.DeleteUserId,
  4255. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4256. })
  4257. .Where(it => it.Id == dto.Id)
  4258. .ExecuteCommand();
  4259. if (res1 > 0)
  4260. {
  4261. int _diId = 0;
  4262. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4263. if (_ioaInfo != null)
  4264. {
  4265. _diId = _ioaInfo.DiId;
  4266. }
  4267. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4268. .SetColumns(a => new Grp_CreditCardPayment()
  4269. {
  4270. IsDel = 1,
  4271. DeleteUserId = dto.DeleteUserId,
  4272. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4273. })
  4274. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4275. .ExecuteCommand();
  4276. if (res2 > 0)
  4277. {
  4278. _sqlSugar.CommitTran();
  4279. return Ok(JsonView(true, "删除成功!"));
  4280. }
  4281. }
  4282. _sqlSugar.RollbackTran();
  4283. return Ok(JsonView(false, "删除失败"));
  4284. }
  4285. catch (Exception ex)
  4286. {
  4287. _sqlSugar.RollbackTran();
  4288. return Ok(JsonView(false, ex.Message));
  4289. }
  4290. }
  4291. /// <summary>
  4292. /// 团组模块文件上传
  4293. /// </summary>
  4294. /// <param name="dto"></param>
  4295. /// <returns></returns>
  4296. [HttpPost]
  4297. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4298. {
  4299. var jw = JsonView(false);
  4300. long M = 1024 * 1024;
  4301. if (dto.Files == null || dto.Files.Count == 0)
  4302. {
  4303. jw.Msg = "无文件信息!";
  4304. return Ok(jw);
  4305. }
  4306. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4307. {
  4308. jw.Msg = "文件大小超过20M!";
  4309. return Ok(jw);
  4310. }
  4311. //var nameSp = dto.File.FileName.Split(".");
  4312. //if (nameSp.Length < 2)
  4313. //{
  4314. // jw.Msg = "拓展名称有误!";
  4315. // return Ok(jw);
  4316. //}
  4317. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4318. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4319. //{
  4320. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4321. // return Ok(jw);
  4322. //}
  4323. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4324. if (Ctable == null)
  4325. {
  4326. jw.Msg = "Ctable指向有误!";
  4327. return Ok(jw);
  4328. }
  4329. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4330. if (groupInfo == null)
  4331. {
  4332. jw.Msg = "团组信息不存在!";
  4333. return Ok(jw);
  4334. }
  4335. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4336. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4337. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4338. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4339. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4340. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4341. try
  4342. {
  4343. if (!Directory.Exists(fileBase))
  4344. {
  4345. Directory.CreateDirectory(fileBase);
  4346. }
  4347. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4348. foreach (var fileStream in dto.Files)
  4349. {
  4350. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4351. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4352. {
  4353. Cid = dto.Cid,
  4354. CreateTime = DateTime.Now,
  4355. CreateUserId = dto.Userid,
  4356. Ctable = dto.Ctable,
  4357. Diid = dto.Diid,
  4358. IsDel = 0,
  4359. FilePath = saveFilePath,
  4360. FileName = fileStream.FileName
  4361. };
  4362. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4363. {
  4364. fileStream.CopyTo(fs);
  4365. fs.Flush();
  4366. }
  4367. saveArr.Add(file);
  4368. }
  4369. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4370. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4371. jw = JsonView(true, "保存成功!", new
  4372. {
  4373. count = addResult,
  4374. filesName = saveArr.Select(x => x.FileName)
  4375. });
  4376. }
  4377. catch (Exception ex)
  4378. {
  4379. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4380. {
  4381. count = 0,
  4382. filesName = new string[0],
  4383. });
  4384. }
  4385. return Ok(jw);
  4386. }
  4387. /// <summary>
  4388. /// 查询各模块已保存文件
  4389. /// </summary>
  4390. /// <param name="dto"></param>
  4391. /// <returns></returns>
  4392. [HttpPost]
  4393. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4394. {
  4395. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4396. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4397. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4398. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4399. {
  4400. expression = Expressionable.Create<Grp_GroupModelFile>()
  4401. .And(x => visaIds.Contains(x.CreateUserId));
  4402. }
  4403. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4404. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4405. .Where(expression.ToExpression())
  4406. .ToList();
  4407. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4408. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4409. {
  4410. x.FileName,
  4411. x.Id,
  4412. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4413. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4414. })));
  4415. }
  4416. /// <summary>
  4417. /// 下载该团组下的所有文件
  4418. /// </summary>
  4419. /// <param name="dto"></param>
  4420. /// <returns></returns>
  4421. [HttpPost]
  4422. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4423. {
  4424. var jw = JsonView(false);
  4425. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4426. if (groupInfo == null)
  4427. {
  4428. jw.Msg = "团组信息不存在!";
  4429. return Ok(jw);
  4430. }
  4431. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4432. var isModule = Convert.ToBoolean(dto.isModule);
  4433. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4434. IOOperatorHelper io = new IOOperatorHelper();
  4435. if (isModule)
  4436. {
  4437. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4438. foreach (var moduleArr in moduleGroup)
  4439. {
  4440. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4441. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4442. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4443. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4444. foreach (var item in moduleArr)
  4445. {
  4446. if (System.IO.File.Exists(item.FilePath))
  4447. {
  4448. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4449. {
  4450. byte[] bytes = new byte[fileStream.Length];
  4451. fileStream.Read(bytes, 0, bytes.Length);
  4452. fileStream.Close();
  4453. Stream stream = new MemoryStream(bytes);
  4454. chiZips.Add(item.FileName, stream);
  4455. }
  4456. }
  4457. }
  4458. if (chiZips.Count > 0)
  4459. {
  4460. var byts = io.ConvertZipStream(chiZips);
  4461. Stream stream = new MemoryStream(byts);
  4462. Zips.Add(key.Name + "_.zip", stream);
  4463. }
  4464. }
  4465. }
  4466. else
  4467. {
  4468. foreach (var item in dbQuery)
  4469. {
  4470. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4471. {
  4472. byte[] bytes = new byte[fileStream.Length];
  4473. fileStream.Read(bytes, 0, bytes.Length);
  4474. fileStream.Close();
  4475. Stream stream = new MemoryStream(bytes);
  4476. while (Zips.Keys.Contains(item.FileName))
  4477. {
  4478. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4479. }
  4480. Zips.Add(item.FileName, stream);
  4481. }
  4482. }
  4483. }
  4484. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4485. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4486. if (Zips.Count > 0)
  4487. {
  4488. var byts = io.ConvertZipStream(Zips);
  4489. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4490. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4491. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4492. }
  4493. else
  4494. {
  4495. jw.Msg = "暂无生成文件!";
  4496. }
  4497. return Ok(jw);
  4498. }
  4499. /// <summary>
  4500. /// 下载该团组下此模块的所有文件
  4501. /// </summary>
  4502. /// <param name="dto"></param>
  4503. /// <returns></returns>
  4504. [HttpPost]
  4505. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4506. {
  4507. var jw = JsonView(false);
  4508. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4509. if (groupInfo == null)
  4510. {
  4511. jw.Msg = "团组信息不存在!";
  4512. return Ok(jw);
  4513. }
  4514. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4515. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4516. && x.IsDel == 0);
  4517. if (key == null)
  4518. {
  4519. jw.Msg = "Ctable指向错误!";
  4520. return Ok(jw);
  4521. }
  4522. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4523. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4524. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4525. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4526. IOOperatorHelper io = new IOOperatorHelper();
  4527. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4528. foreach (var item in dbQuery)
  4529. {
  4530. if (System.IO.File.Exists(item.FilePath))
  4531. {
  4532. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4533. {
  4534. byte[] bytes = new byte[fileStream.Length];
  4535. fileStream.Read(bytes, 0, bytes.Length);
  4536. fileStream.Close();
  4537. Stream stream = new MemoryStream(bytes);
  4538. while (Zips.Keys.Contains(item.FileName))
  4539. {
  4540. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4541. }
  4542. Zips.Add(item.FileName, stream);
  4543. }
  4544. }
  4545. }
  4546. if (Zips.Count > 0)
  4547. {
  4548. var byts = io.ConvertZipStream(Zips);
  4549. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4550. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4551. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4552. }
  4553. else
  4554. {
  4555. jw.Msg = "暂无生成文件!";
  4556. }
  4557. return Ok(jw);
  4558. }
  4559. /// <summary>
  4560. /// 删除该团组下的指定文件
  4561. /// </summary>
  4562. /// <param name="dto"></param>
  4563. /// <returns></returns>
  4564. [HttpPost]
  4565. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4566. {
  4567. var jw = JsonView(false);
  4568. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4569. if (sing == null)
  4570. {
  4571. jw.Msg = "暂无";
  4572. return Ok(jw);
  4573. }
  4574. if (System.IO.File.Exists(sing.FilePath))
  4575. {
  4576. try
  4577. {
  4578. System.IO.File.Delete(sing.FilePath);
  4579. }
  4580. catch (Exception ex)
  4581. {
  4582. jw.Msg = "删除失败!" + ex.Message;
  4583. return Ok(jw);
  4584. }
  4585. }
  4586. sing.IsDel = 1;
  4587. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4588. sing.DeleteUserId = dto.UserId;
  4589. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4590. jw = JsonView(true, "删除成功!");
  4591. return Ok(jw);
  4592. }
  4593. #endregion
  4594. #region 团组英文资料
  4595. /// <summary>
  4596. /// 查询团组英文所有资料
  4597. /// </summary>
  4598. /// <param name="dto"></param>
  4599. /// <returns></returns>
  4600. [HttpPost]
  4601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4602. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4603. {
  4604. try
  4605. {
  4606. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4607. if (groupData.Code != 0)
  4608. {
  4609. return Ok(JsonView(false, groupData.Msg));
  4610. }
  4611. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4612. }
  4613. catch (Exception ex)
  4614. {
  4615. return Ok(JsonView(false, "程序错误!"));
  4616. throw;
  4617. }
  4618. }
  4619. /// <summary>
  4620. /// 团组英文资料操作(Status:1.新增,2.修改)
  4621. /// </summary>
  4622. /// <param name="dto"></param>
  4623. /// <returns></returns>
  4624. [HttpPost]
  4625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4626. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4627. {
  4628. try
  4629. {
  4630. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4631. if (groupData.Code != 0)
  4632. {
  4633. return Ok(JsonView(false, groupData.Msg));
  4634. }
  4635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4636. }
  4637. catch (Exception ex)
  4638. {
  4639. return Ok(JsonView(false, "程序错误!"));
  4640. throw;
  4641. }
  4642. }
  4643. /// <summary>
  4644. /// 团组英文资料Id查询数据
  4645. /// </summary>
  4646. /// <param name="dto"></param>
  4647. /// <returns></returns>
  4648. [HttpPost]
  4649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4650. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4651. {
  4652. try
  4653. {
  4654. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4655. if (_DelegationEnData != null)
  4656. {
  4657. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4658. }
  4659. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4660. }
  4661. catch (Exception ex)
  4662. {
  4663. return Ok(JsonView(false, "程序错误!"));
  4664. throw;
  4665. }
  4666. }
  4667. /// <summary>
  4668. /// 团组英文资料删除
  4669. /// </summary>
  4670. /// <param name="dto"></param>
  4671. /// <returns></returns>
  4672. [HttpPost]
  4673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4674. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4675. {
  4676. try
  4677. {
  4678. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4679. if (!res)
  4680. {
  4681. return Ok(JsonView(false, "删除失败"));
  4682. }
  4683. return Ok(JsonView(true, "删除成功!"));
  4684. }
  4685. catch (Exception ex)
  4686. {
  4687. return Ok(JsonView(false, "程序错误!"));
  4688. throw;
  4689. }
  4690. }
  4691. #endregion
  4692. #region 导出邀请函
  4693. /// <summary>
  4694. /// 导出邀请函页面初始化
  4695. /// </summary>
  4696. /// <param name="dto"></param>
  4697. /// <returns></returns>
  4698. [HttpPost]
  4699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4700. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4701. {
  4702. try
  4703. {
  4704. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4705. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4706. if (dto.DiId == 0)
  4707. {
  4708. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4709. }
  4710. else
  4711. {
  4712. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4713. }
  4714. return Ok(JsonView(true, "查询成功!", new
  4715. {
  4716. deleClient = crm_Deles,
  4717. delegations = grp_Delegations
  4718. }));
  4719. }
  4720. catch (Exception ex)
  4721. {
  4722. return Ok(JsonView(false, "程序错误!"));
  4723. throw;
  4724. }
  4725. }
  4726. /// <summary>
  4727. /// 导出邀请函
  4728. /// </summary>
  4729. /// <param name="dto"></param>
  4730. /// <returns></returns>
  4731. [HttpPost]
  4732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4733. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4734. {
  4735. #region 参数验证
  4736. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4737. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4738. #endregion
  4739. try
  4740. {
  4741. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4742. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4743. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4744. From Grp_TourClientList tcl
  4745. Left Join
  4746. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4747. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4748. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4749. From Crm_DeleClient dc
  4750. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4751. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4752. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4753. Where dc.IsDel = 0) temp
  4754. On temp.DcId =tcl.ClientId
  4755. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4756. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4757. List<string> texts = new List<string>();
  4758. if (datas.Count != 0)
  4759. {
  4760. foreach (TourClientListDetailsView item in datas)
  4761. {
  4762. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4763. {
  4764. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4765. }
  4766. else
  4767. {
  4768. string name = item.LastName + item.FirstName;
  4769. texts.Add(name);
  4770. }
  4771. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4772. {
  4773. if (!transDic.ContainsKey(item.Job))
  4774. {
  4775. texts.Add(item.Job);
  4776. }
  4777. }
  4778. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4779. {
  4780. texts.Add(item.CompanyFullName);
  4781. }
  4782. }
  4783. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4784. if (transData.Count > 0)
  4785. {
  4786. foreach (TranslateResult item in transData)
  4787. {
  4788. if (!transDic.ContainsKey(item.Query))
  4789. {
  4790. transDic.Add(item.Query, item.Translation);
  4791. }
  4792. }
  4793. }
  4794. List<GuestList> list = new List<GuestList>();
  4795. foreach (TourClientListDetailsView dele in datas)
  4796. {
  4797. GuestList guestList = new GuestList();
  4798. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4799. {
  4800. guestList.Name = dele.Pinyin;
  4801. }
  4802. else
  4803. {
  4804. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4805. guestList.Name = Name;
  4806. }
  4807. if (dele.Sex == 0)
  4808. {
  4809. guestList.Sex = "Male";
  4810. }
  4811. else if (dele.Sex == 1)
  4812. {
  4813. guestList.Sex = "Female";
  4814. }
  4815. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4816. if (!string.IsNullOrEmpty(dele.Job))
  4817. {
  4818. guestList.Job = dele.Job;
  4819. }
  4820. list.Add(guestList);
  4821. }
  4822. //载入模板
  4823. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4824. DocumentBuilder builder = new DocumentBuilder(doc);
  4825. //获取word里所有表格
  4826. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4827. //获取所填表格的序数
  4828. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4829. var rowStart = tableOne.Rows[0]; //获取第1行
  4830. //循环赋值
  4831. for (int i = 0; i < list.Count; i++)
  4832. {
  4833. builder.MoveToCell(0, i + 1, 0, 0);
  4834. builder.Write(list[i].Name.ToString());
  4835. builder.MoveToCell(0, i + 1, 1, 0);
  4836. builder.Write(list[i].Sex.ToString());
  4837. builder.MoveToCell(0, i + 1, 2, 0);
  4838. builder.Write(list[i].DOB.ToString());
  4839. builder.MoveToCell(0, i + 1, 3, 0);
  4840. builder.Write(list[i].Job.ToString());
  4841. }
  4842. //删除多余行
  4843. while (tableOne.Rows.Count > list.Count + 1)
  4844. {
  4845. tableOne.Rows.RemoveAt(list.Count + 1);
  4846. }
  4847. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4848. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4849. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4850. doc.Save(filePath);
  4851. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4852. return Ok(JsonView(true, "操作成功!", Url));
  4853. }
  4854. else
  4855. {
  4856. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4857. }
  4858. }
  4859. catch (Exception ex)
  4860. {
  4861. return Ok(JsonView(false, ex.Message));
  4862. throw;
  4863. }
  4864. }
  4865. #endregion
  4866. #region 团组经理模块 出入境费用
  4867. /// <summary>
  4868. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4869. /// </summary>
  4870. /// <returns></returns>
  4871. [HttpPost]
  4872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4873. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4874. {
  4875. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4876. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4877. //SetDataInfoView
  4878. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4879. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4880. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4881. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4882. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4883. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4884. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4885. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4886. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4887. return Ok(JsonView(true, "查询成功!", new
  4888. {
  4889. GroupNameData = groupNameData.Data,
  4890. CurrencyData = _CurrencyData,
  4891. WordTypeData = _WordTypeData,
  4892. ExcelTypeData = _ExcelTypeData,
  4893. CurrencyInit = _currencyInfos,
  4894. ViewPermissionData = viewPermissionData
  4895. }));
  4896. }
  4897. /// <summary>
  4898. /// 团组模块 - 出入境费用
  4899. /// 实时汇率 tips
  4900. /// 签证费用 tips
  4901. /// 机票费用 tips
  4902. /// </summary>
  4903. /// <returns></returns>
  4904. [HttpPost]
  4905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4906. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4907. {
  4908. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4909. //默认币种显示
  4910. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4911. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4912. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4913. return Ok(JsonView(true, "查询成功!", new
  4914. {
  4915. //GroupNameData = groupNameData.Data,
  4916. visaData = visaData.Data,
  4917. airData = airData.Data,
  4918. reteInfos = reteInfos
  4919. }));
  4920. }
  4921. /// <summary>
  4922. /// 团组模块 - 出入境费用 - Info
  4923. /// </summary>
  4924. /// <returns></returns>
  4925. [HttpPost]
  4926. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4928. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4929. {
  4930. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4931. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4932. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4933. }
  4934. /// <summary>
  4935. /// 团组模块 - 出入境费用 - 设置view权限
  4936. /// </summary>
  4937. /// <returns></returns>
  4938. [HttpPost]
  4939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4940. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4941. {
  4942. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4943. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4944. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4945. var permissions = new List<Grp_EnterExitCostPermission>();
  4946. foreach (var userId in dto.UserIds)
  4947. {
  4948. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4949. }
  4950. if (permissions.Any())
  4951. {
  4952. _sqlSugar.BeginTran();
  4953. try
  4954. {
  4955. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4956. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4957. if (result < 1)
  4958. {
  4959. _sqlSugar.RollbackTran();
  4960. return Ok(JsonView(false));
  4961. }
  4962. }
  4963. catch (Exception ex)
  4964. {
  4965. _sqlSugar.RollbackTran();
  4966. return Ok(JsonView(false, ex.Message));
  4967. }
  4968. _sqlSugar.CommitTran();
  4969. return Ok(JsonView(true));
  4970. }
  4971. return Ok(JsonView(false));
  4972. }
  4973. /// <summary>
  4974. /// 团组模块 - 出入境费用 - Add And Update
  4975. /// </summary>
  4976. /// <returns></returns>
  4977. [HttpPost]
  4978. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4980. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4981. {
  4982. try
  4983. {
  4984. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4985. if (dto.DayOtherPriceData.Any())
  4986. {
  4987. var inserList = dto.DayOtherPriceData
  4988. .Where(x => x.Id == 0)
  4989. .Select(x => new Grp_DayOtherPrice
  4990. {
  4991. Cost = x.Cost,
  4992. Id = x.Id,
  4993. CreateTime = DateTime.Now,
  4994. CreateUserId = dto.UserId,
  4995. Currency = x.Currency,
  4996. Diid = x.DiId,
  4997. Index = x.Index,
  4998. IsDel = 0,
  4999. SetDataId = x.SetDataId,
  5000. SubTotal = x.SubTotal,
  5001. Remark = x.Remark
  5002. })
  5003. .ToList();
  5004. var updateList = dto.DayOtherPriceData
  5005. .Where(x => x.Id != 0)
  5006. .Select(x => new Grp_DayOtherPrice
  5007. {
  5008. Cost = x.Cost,
  5009. Id = x.Id,
  5010. CreateTime = DateTime.Now,
  5011. CreateUserId = dto.UserId,
  5012. Currency = x.Currency,
  5013. Diid = x.DiId,
  5014. Index = x.Index,
  5015. IsDel = 0,
  5016. SetDataId = x.SetDataId,
  5017. SubTotal = x.SubTotal,
  5018. Remark = x.Remark
  5019. })
  5020. .ToList();
  5021. //添加
  5022. _sqlSugar.BeginTran();
  5023. if (inserList.Any())
  5024. {
  5025. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5026. }
  5027. if (updateList.Any())
  5028. {
  5029. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5030. }
  5031. _sqlSugar.CommitTran();
  5032. }
  5033. if (data.Code != 0)
  5034. {
  5035. return Ok(JsonView(false, data.Msg));
  5036. }
  5037. //生成默认文件pdf并且通知人员
  5038. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5039. {
  5040. DiId = dto.DiId,
  5041. ExportType = 1,
  5042. SubTypeId = 1005
  5043. }, "pdf");
  5044. //发送通知
  5045. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5046. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5047. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5048. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5049. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5050. //汇率信息记录
  5051. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5052. return Ok(JsonView(true, data.Msg, data.Data));
  5053. }
  5054. catch (Exception ex)
  5055. {
  5056. return Ok(JsonView(false, ex.Message));
  5057. }
  5058. }
  5059. /// <summary>
  5060. /// 团组模块 - 出入境费用 - Confirm 费用
  5061. /// </summary>
  5062. /// <returns></returns>
  5063. [HttpPost]
  5064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5065. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5066. {
  5067. //TODO:测试完毕需把对应的用户ID更改
  5068. //1、数据表添加字段
  5069. //2、更改字段接口()
  5070. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5071. //3、确认成功 给财务发送消息
  5072. if (_view.Code == 200)
  5073. {
  5074. if (dto.Type == 1)
  5075. {
  5076. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5077. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5078. }
  5079. }
  5080. return Ok(_view);
  5081. }
  5082. /// <summary>
  5083. /// 团组模块 - 出入境费用 - File download
  5084. /// </summary>
  5085. /// <param name="dto"></param>
  5086. /// <returns></returns>
  5087. [HttpPost]
  5088. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5090. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5091. {
  5092. try
  5093. {
  5094. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5095. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5096. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5097. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5098. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5099. 3 团组成员名单 1 团组成员名单", ""));
  5100. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5101. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5102. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5103. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5104. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5105. //数据源
  5106. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5107. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5108. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5109. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5110. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5111. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5112. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5113. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5114. .Select((x, a, b) => new
  5115. {
  5116. x.Index,
  5117. itemName = a.Name,
  5118. CurrencyStr = b.Name,
  5119. x.Cost,
  5120. x.SubTotal,
  5121. x.Remark
  5122. })
  5123. .OrderBy((x) => x.Index)
  5124. .ToList(); //其他款项费用
  5125. var peiceItemCurrencys = new List<string>();
  5126. if (_DayAndCosts.Any())
  5127. {
  5128. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5129. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5130. }
  5131. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5132. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5133. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5134. {
  5135. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5136. }
  5137. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5138. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5139. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5140. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5141. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5142. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5143. .Select((tcl, dc, cc) => new ClientInfo
  5144. {
  5145. LastName = dc.LastName,
  5146. FirstName = dc.FirstName,
  5147. Sex = dc.Sex,
  5148. Birthday = dc.BirthDay,
  5149. Company = cc.CompanyFullName,
  5150. Job = dc.Job
  5151. })
  5152. .ToList();
  5153. foreach (var item in DeleClientList)
  5154. {
  5155. EncryptionProcessor.DecryptProperties(item);
  5156. }
  5157. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5158. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5159. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5160. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5161. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5162. if (dto.ExportType == 1) //明细表
  5163. {
  5164. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5165. {
  5166. //获取模板
  5167. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5168. //载入模板
  5169. Document doc = new Document(tempPath);
  5170. DocumentBuilder builder = new DocumentBuilder(doc);
  5171. //利用键值对存放数据
  5172. Dictionary<string, string> dic = new Dictionary<string, string>();
  5173. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5174. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5175. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5176. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5177. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5178. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5179. //境内费用(其他费用)
  5180. if (_EnterExitCosts.ChoiceOne == 1)
  5181. {
  5182. string row1_1 = "";
  5183. if (_EnterExitCosts.Visa > 0)
  5184. {
  5185. //insidePayTotal += _EnterExitCosts.Visa;
  5186. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5187. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5188. {
  5189. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5190. }
  5191. }
  5192. string row1_2 = "";
  5193. if (_EnterExitCosts.YiMiao > 0)
  5194. {
  5195. //insidePayTotal += _EnterExitCosts.YiMiao;
  5196. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5197. }
  5198. if (_EnterExitCosts.HeSuan > 0)
  5199. {
  5200. //insidePayTotal += _EnterExitCosts.HeSuan;
  5201. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5202. }
  5203. if (_EnterExitCosts.Service > 0)
  5204. {
  5205. //insidePayTotal += _EnterExitCosts.Service;
  5206. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5207. }
  5208. string row1_3 = "";
  5209. if (_EnterExitCosts.Safe > 0)
  5210. {
  5211. //insidePayTotal += _EnterExitCosts.Safe;
  5212. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5213. }
  5214. if (_EnterExitCosts.Ticket > 0)
  5215. {
  5216. //insidePayTotal += _EnterExitCosts.Ticket;
  5217. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5218. }
  5219. string row1 = "";
  5220. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5221. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5222. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5223. row1 += $"备注:{_EnterExitCosts.Remark}";
  5224. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5225. dic.Add("Row1Str", row1);
  5226. }
  5227. string airTotalStr = string.Empty,
  5228. airPriceStr = string.Empty;
  5229. //经济舱
  5230. if (_EnterExitCosts.SumJJC == 1)
  5231. {
  5232. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5233. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5234. }
  5235. //公务舱
  5236. if (_EnterExitCosts.SumGWC == 1)
  5237. {
  5238. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5239. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5240. }
  5241. //头等舱
  5242. if (_EnterExitCosts.SumTDC == 1)
  5243. {
  5244. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5245. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5246. }
  5247. //汇率描述
  5248. string rateStr = "";
  5249. if (peiceItemCurrencyInfos.Any())
  5250. {
  5251. rateStr = "\r\n汇率描述:";
  5252. foreach (var item in peiceItemCurrencyInfos)
  5253. {
  5254. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5255. }
  5256. }
  5257. string twoItemRemark = "备注:";
  5258. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5259. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5260. dic.Add("AirTotalStr", airTotalStr);
  5261. dic.Add("AirPriceStr", airPriceStr);
  5262. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5263. dic.Add("TwoItemRemark", twoItemRemark);
  5264. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5265. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5266. int table1Row = 0,
  5267. table2Row = 0,
  5268. table3Row = 0,
  5269. table4Row = 0,
  5270. table5Row = 0;
  5271. //住宿费
  5272. if (_EnterExitCosts.ChoiceThree == 1)
  5273. {
  5274. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5275. table1Row = dac1.Count;
  5276. #region 填充word表格内容
  5277. for (int i = 0; i < dac1.Count; i++)
  5278. {
  5279. Grp_DayAndCost dac = dac1[i];
  5280. if (dac == null) continue;
  5281. builder.MoveToCell(0, i, 0, 0);
  5282. builder.Write("第" + dac.Days.ToString() + "晚:");
  5283. builder.MoveToCell(0, i, 1, 0);
  5284. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5285. //builder.Write(dac.Place == null ? "" : dac.Place);
  5286. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5287. builder.MoveToCell(0, i, 2, 0);
  5288. builder.Write("费用标准:");
  5289. string curr = "";
  5290. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5291. if (currData != null)
  5292. {
  5293. curr = currData.Name;
  5294. }
  5295. builder.MoveToCell(0, i, 3, 0);
  5296. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5297. builder.MoveToCell(0, i, 4, 0);
  5298. builder.Write("费用小计:");
  5299. builder.MoveToCell(0, i, 5, 0);
  5300. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5301. }
  5302. #endregion
  5303. }
  5304. else dic.Add("SubZS", "0.00");
  5305. //删除多余行
  5306. while (table1.Rows.Count > table1Row)
  5307. {
  5308. table1.Rows.RemoveAt(table1Row);
  5309. }
  5310. //伙食费
  5311. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5312. if (_EnterExitCosts.ChoiceFour == 1)
  5313. {
  5314. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5315. table2Row = dac2.Count;
  5316. #region 填充word表格内容
  5317. for (int i = 0; i < dac2.Count; i++)
  5318. {
  5319. Grp_DayAndCost dac = dac2[i];
  5320. if (dac == null) continue;
  5321. builder.MoveToCell(1, i, 0, 0);
  5322. builder.Write("第" + dac.Days.ToString() + "天:");
  5323. builder.MoveToCell(1, i, 1, 0);
  5324. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5325. builder.MoveToCell(1, i, 2, 0);
  5326. builder.Write("费用标准:");
  5327. string curr = "";
  5328. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5329. if (currData != null)
  5330. {
  5331. curr = currData.Name;
  5332. }
  5333. builder.MoveToCell(1, i, 3, 0);
  5334. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5335. builder.MoveToCell(1, i, 4, 0);
  5336. builder.Write("费用小计:");
  5337. builder.MoveToCell(1, i, 5, 0);
  5338. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5339. }
  5340. #endregion
  5341. }
  5342. else dic.Add("SubHS", "0.00");
  5343. //删除多余行
  5344. while (table2.Rows.Count > table2Row)
  5345. {
  5346. table2.Rows.RemoveAt(table2Row);
  5347. }
  5348. //公杂费
  5349. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5350. if (_EnterExitCosts.ChoiceFive == 1)
  5351. {
  5352. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5353. table3Row = dac3.Count;
  5354. #region 填充word表格内容
  5355. for (int i = 0; i < dac3.Count; i++)
  5356. {
  5357. Grp_DayAndCost dac = dac3[i];
  5358. if (dac == null) continue;
  5359. builder.MoveToCell(2, i, 0, 0);
  5360. builder.Write("第" + dac.Days.ToString() + "天:");
  5361. builder.MoveToCell(2, i, 1, 0);
  5362. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5363. builder.MoveToCell(2, i, 2, 0);
  5364. builder.Write("费用标准:");
  5365. string curr = "";
  5366. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5367. if (currData != null)
  5368. {
  5369. curr = currData.Name;
  5370. }
  5371. builder.MoveToCell(2, i, 3, 0);
  5372. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5373. builder.MoveToCell(2, i, 4, 0);
  5374. builder.Write("费用小计:");
  5375. builder.MoveToCell(2, i, 5, 0);
  5376. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5377. }
  5378. //删除多余行
  5379. while (table3.Rows.Count > table3Row)
  5380. {
  5381. table3.Rows.RemoveAt(table3Row);
  5382. }
  5383. #endregion
  5384. }
  5385. else dic.Add("SubGZF", "0.00");
  5386. //删除多余行
  5387. while (table3.Rows.Count > table3Row)
  5388. {
  5389. table3.Rows.RemoveAt(table3Row);
  5390. }
  5391. //培训费
  5392. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5393. if (_EnterExitCosts.ChoiceSix == 1)
  5394. {
  5395. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5396. dic.Add("SubPX", pxStr);
  5397. table4Row = dac4.Count;
  5398. #region 填充word表格内容
  5399. for (int i = 0; i < dac4.Count; i++)
  5400. {
  5401. Grp_DayAndCost dac = dac4[i];
  5402. if (dac == null) continue;
  5403. builder.MoveToCell(3, i, 0, 0);
  5404. builder.Write("第" + dac.Days.ToString() + "天:");
  5405. builder.MoveToCell(3, i, 1, 0);
  5406. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5407. builder.MoveToCell(3, i, 2, 0);
  5408. builder.Write("费用标准:");
  5409. string curr = "";
  5410. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5411. if (currData != null)
  5412. {
  5413. curr = currData.Name;
  5414. }
  5415. builder.MoveToCell(3, i, 3, 0);
  5416. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5417. builder.MoveToCell(3, i, 4, 0);
  5418. builder.Write("费用小计:");
  5419. builder.MoveToCell(3, i, 5, 0);
  5420. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5421. }
  5422. #endregion
  5423. }
  5424. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5425. //删除多余行
  5426. while (table4.Rows.Count > table4Row)
  5427. {
  5428. table4.Rows.RemoveAt(table4Row);
  5429. }
  5430. //其他费用
  5431. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5432. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5433. {
  5434. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5435. dic.Add("titleQi", qtStr);
  5436. table5Row = dac5.Count;
  5437. #region 填充word表格内容
  5438. for (int i = 0; i < dac5.Count; i++)
  5439. {
  5440. var dac = dac5[i];
  5441. if (dac == null) continue;
  5442. builder.MoveToCell(4, i, 0, 0);
  5443. builder.Write("第" + dac.Index.ToString() + "项:");
  5444. builder.MoveToCell(4, i, 1, 0);
  5445. builder.Write(dac.itemName);
  5446. builder.MoveToCell(4, i, 2, 0);
  5447. builder.Write("费用标准:");
  5448. builder.MoveToCell(4, i, 3, 0);
  5449. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5450. builder.MoveToCell(4, i, 4, 0);
  5451. builder.Write("费用小计:");
  5452. builder.MoveToCell(4, i, 5, 0);
  5453. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5454. builder.MoveToCell(4, i, 6, 0);
  5455. builder.Write("备注:");
  5456. builder.MoveToCell(4, i, 7, 0);
  5457. builder.Write(dac.Remark);
  5458. }
  5459. #endregion
  5460. }
  5461. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5462. //删除多余行
  5463. while (table5.Rows.Count > table5Row)
  5464. {
  5465. table5.Rows.RemoveAt(table5Row);
  5466. }
  5467. //加上其他费用
  5468. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5469. decimal subJJC = 0.00M,
  5470. subGWC = 0.00M,
  5471. subTDC = 0.00M;
  5472. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5473. string totalLabel = string.Format("全部费用总计:");
  5474. //经济舱
  5475. if (_EnterExitCosts.SumJJC == 1)
  5476. {
  5477. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5478. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5479. }
  5480. //公务舱
  5481. if (_EnterExitCosts.SumGWC == 1) {
  5482. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5483. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5484. }
  5485. //头等舱
  5486. if (_EnterExitCosts.SumTDC == 1)
  5487. {
  5488. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5489. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5490. }
  5491. //TotalLabel
  5492. dic.Add("TotalLabel", totalLabel);
  5493. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5494. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5495. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5496. #region 填充word模板书签内容
  5497. foreach (var key in dic.Keys)
  5498. {
  5499. Bookmark bookmark = doc.Range.Bookmarks[key];
  5500. if (bookmark != null)
  5501. {
  5502. builder.MoveToBookmark(key);
  5503. builder.Write(dic[key]);
  5504. }
  5505. }
  5506. #endregion
  5507. #region 设置页眉
  5508. string userLabel = string.Empty;
  5509. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5510. if (currUserInfo != null)
  5511. {
  5512. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5513. if (userInfo != null)
  5514. {
  5515. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5516. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5517. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5518. }
  5519. }
  5520. //设置页脚
  5521. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5522. #endregion
  5523. //文件名
  5524. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5525. AsposeHelper.removewatermark_v2180();
  5526. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5527. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5528. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5529. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5530. }
  5531. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5532. {
  5533. //获取模板
  5534. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5535. //载入模板
  5536. Document doc = new Document(tempPath);
  5537. DocumentBuilder builder = new DocumentBuilder(doc);
  5538. Dictionary<string, string> dic = new Dictionary<string, string>();
  5539. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5540. {
  5541. List<string> list = new List<string>();
  5542. try
  5543. {
  5544. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5545. foreach (var item in spilitArr)
  5546. {
  5547. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5548. var depCode = spDotandEmpty[2].Substring(0, 3);
  5549. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5550. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5551. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5552. list.Add(depName);
  5553. list.Add(arrName);
  5554. }
  5555. list = list.Distinct().ToList();
  5556. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5557. }
  5558. catch (Exception)
  5559. {
  5560. dic.Add("ReturnCode", "行程录入不正确!");
  5561. }
  5562. }
  5563. else
  5564. {
  5565. dic.Add("ReturnCode", "未录入行程!");
  5566. }
  5567. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5568. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5569. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5570. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5571. {
  5572. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5573. dic.Add("Day", sp.Days.ToString());
  5574. }
  5575. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5576. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5577. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5578. //dic.Add("Names", Names);
  5579. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5580. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5581. decimal dac1totalPrice = 0.00M;
  5582. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5583. foreach (var dac in dac1)
  5584. {
  5585. if (dac.SubTotal == 0.00M)
  5586. {
  5587. continue;
  5588. }
  5589. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5590. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5591. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5592. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5593. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5594. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5595. builder.Write(currency);//币种
  5596. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5597. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5598. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5599. builder.Write("");//人数
  5600. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5601. builder.Write("");//天数
  5602. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5603. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5604. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5605. decimal rate = 0.00M;
  5606. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5607. builder.Write(rate.ToString("#0.0000"));//汇率
  5608. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5609. decimal rbmPrice = dac.SubTotal;
  5610. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5611. accommodationStartIndex++;
  5612. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5613. }
  5614. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5615. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5616. {
  5617. table1.Rows.RemoveAt(i - 1);
  5618. foodandotherStartIndex--;
  5619. }
  5620. if (dac2.Count == dac3.Count)//国家 币种 金额
  5621. {
  5622. for (int i = 0; i < dac2.Count; i++)
  5623. {
  5624. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5625. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5626. }
  5627. }
  5628. decimal dac2totalPrice = 0.00M;
  5629. foreach (var dac in dac2)
  5630. {
  5631. if (dac.SubTotal == 0)
  5632. {
  5633. continue;
  5634. }
  5635. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5636. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5637. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5638. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5639. builder.Write(currency);//币种
  5640. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5641. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5642. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5643. builder.Write("");//人数
  5644. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5645. builder.Write("");//天数
  5646. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5647. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5648. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5649. decimal rate = 0.00M;
  5650. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5651. builder.Write(rate.ToString("#0.0000"));//汇率
  5652. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5653. decimal rbmPrice = dac.SubTotal;
  5654. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5655. foodandotherStartIndex++;
  5656. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5657. }
  5658. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5659. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5660. {
  5661. table1.Rows.RemoveAt(i - 1);
  5662. }
  5663. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5664. string otherFeeStr = "";
  5665. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5666. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5667. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5668. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5669. foreach (var otherInfo in dac5)
  5670. {
  5671. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5672. }
  5673. #endregion
  5674. if (otherFeeStr.Length > 0)
  5675. {
  5676. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5677. otherFeeStr = $"({otherFeeStr})";
  5678. dic.Add("OtherFeeStr", otherFeeStr);
  5679. }
  5680. //总计
  5681. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5682. //国际旅费
  5683. string outsideAir = string.Empty;
  5684. string allPriceAir = string.Empty;
  5685. if (_EnterExitCosts.SumJJC == 1)
  5686. {
  5687. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5688. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5689. }
  5690. if (_EnterExitCosts.SumGWC == 1)
  5691. {
  5692. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5693. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5694. }
  5695. if (_EnterExitCosts.SumTDC == 1)
  5696. {
  5697. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5698. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5699. }
  5700. dic.Add("InTravelPrice", $"({outsideAir})");
  5701. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5702. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5703. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5704. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5705. foreach (var key in dic.Keys)
  5706. {
  5707. builder.MoveToBookmark(key);
  5708. builder.Write(dic[key]);
  5709. }
  5710. //模板文件名
  5711. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5712. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5713. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5714. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5715. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5716. }
  5717. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5718. {
  5719. //获取模板
  5720. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5721. //载入模板
  5722. WorkbookDesigner designer = new WorkbookDesigner();
  5723. designer.Workbook = new Workbook(tempPath);
  5724. Dictionary<string, string> dic = new Dictionary<string, string>();
  5725. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5726. {
  5727. List<string> list = new List<string>();
  5728. try
  5729. {
  5730. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5731. foreach (var item in spilitArr)
  5732. {
  5733. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5734. var depCode = spDotandEmpty[2].Substring(0, 3);
  5735. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5736. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5737. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5738. list.Add(depName);
  5739. list.Add(arrName);
  5740. }
  5741. list = list.Distinct().ToList();
  5742. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5743. }
  5744. catch (Exception)
  5745. {
  5746. dic.Add("ReturnCode", "行程录入不正确!");
  5747. }
  5748. }
  5749. else
  5750. {
  5751. dic.Add("ReturnCode", "未录入行程!");
  5752. }
  5753. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5754. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5755. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5756. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5757. {
  5758. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5759. dic.Add("Day", sp.Days.ToString());
  5760. }
  5761. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5762. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5763. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5764. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5765. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5766. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5767. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5768. designer.SetDataSource("Name", Names);
  5769. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5770. designer.SetDataSource("Day", dic["Day"] + "天");
  5771. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5772. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5773. int startIndex = 10;
  5774. const int startIndexcopy = 10;
  5775. if (dac2.Count == dac3.Count)//国家 币种 金额
  5776. {
  5777. for (int i = 0; i < dac2.Count; i++)
  5778. {
  5779. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5780. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5781. }
  5782. }
  5783. DataTable dtdac1 = new DataTable();
  5784. List<string> place = new List<string>();
  5785. dtdac1.Columns.AddRange(new DataColumn[] {
  5786. new DataColumn(){ ColumnName = "city"},
  5787. new DataColumn(){ ColumnName = "curr"},
  5788. new DataColumn(){ ColumnName = "criterion"},
  5789. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5790. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5791. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5792. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5793. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5794. });
  5795. DataTable dtdac2 = new DataTable();
  5796. dtdac2.Columns.AddRange(new DataColumn[] {
  5797. new DataColumn(){ ColumnName = "city"},
  5798. new DataColumn(){ ColumnName = "curr"},
  5799. new DataColumn(){ ColumnName = "criterion"},
  5800. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5801. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5802. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5803. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5804. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5805. });
  5806. dtdac1.TableName = "tb1";
  5807. dtdac2.TableName = "tb2";
  5808. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5809. foreach (var item in dac1)
  5810. {
  5811. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5812. if (place.Contains(item.Place))
  5813. {
  5814. continue;
  5815. }
  5816. DataRow row = dtdac1.NewRow();
  5817. row["city"] = item.Place;
  5818. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5819. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5820. row["curr"] = currency;
  5821. row["rate"] = rate.ToString("#0.0000");
  5822. row["criterion"] = item.Cost.ToString("#0.00");
  5823. row["number"] = 1;
  5824. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5825. //row["costRMB"] = rbmPrice;
  5826. dtdac1.Rows.Add(row);
  5827. place.Add(item.Place);
  5828. }
  5829. place = new List<string>();
  5830. foreach (var item in dac2)
  5831. {
  5832. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5833. if (place.Contains(item.Place))
  5834. {
  5835. continue;
  5836. }
  5837. DataRow row = dtdac2.NewRow();
  5838. row["city"] = item.Place;
  5839. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5840. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5841. row["curr"] = currency;
  5842. row["rate"] = rate.ToString("#0.0000");
  5843. row["criterion"] = item.Cost.ToString("#0.00");
  5844. row["number"] = 1;
  5845. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5846. //row["cost"] = item.SubTotal;
  5847. //row["costRMB"] = rbmPrice;
  5848. dtdac2.Rows.Add(row);
  5849. place.Add(item.Place);
  5850. //dac2totalPrice += rbmPrice;
  5851. }
  5852. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5853. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5854. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5855. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5856. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5857. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5858. string cell4Str1 = string.Empty;
  5859. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5860. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5861. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5862. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5863. string cellStr = $" 5.其他费用(";
  5864. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5865. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5866. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5867. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5868. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5869. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5870. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5871. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5872. foreach (var otherInfo in dac5)
  5873. {
  5874. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5875. }
  5876. #endregion
  5877. if (cellStr.Length > 8)
  5878. {
  5879. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5880. }
  5881. cellStr += ")";
  5882. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5883. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5884. decimal pxFee = dac4.Sum(it => it.Cost);
  5885. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5886. string celllastStr1 = "";
  5887. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5888. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5889. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5890. celllastStr1 += $",国际旅费 元";
  5891. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5892. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5893. designer.SetDataSource("cell4Str", cell4Str);
  5894. designer.SetDataSource("cellStr", cellStr);
  5895. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5896. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5897. designer.SetDataSource("celllastStr", celllastStr);
  5898. Workbook wb = designer.Workbook;
  5899. var sheet = wb.Worksheets[0];
  5900. //绑定datatable数据集
  5901. designer.SetDataSource(dtdac1);
  5902. designer.SetDataSource(dtdac2);
  5903. designer.Process();
  5904. var rowStart = dtdac1.Rows.Count;
  5905. while (rowStart > 0)
  5906. {
  5907. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5908. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5909. startIndex++;
  5910. rowStart--;
  5911. }
  5912. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5913. startIndex += 1; //总计行
  5914. rowStart = dtdac2.Rows.Count;
  5915. while (rowStart > 0)
  5916. {
  5917. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5918. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5919. startIndex++;
  5920. rowStart--;
  5921. }
  5922. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5923. wb.CalculateFormula(true);
  5924. //模板文件名
  5925. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5926. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5927. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5928. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5929. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5930. }
  5931. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5932. {
  5933. //获取模板
  5934. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5935. //载入模板
  5936. Document doc = new Document(tempPath);
  5937. DocumentBuilder builder = new DocumentBuilder(doc);
  5938. Dictionary<string, string> dic = new Dictionary<string, string>();
  5939. dic.Add("GroupName", _DelegationInfo.TeamName);
  5940. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5941. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5942. string missionLeaderJob = "";//负责人job
  5943. //int groupNumber = 0; //团人数
  5944. if (DeleClientList.Count > 0)
  5945. {
  5946. missionLeader = DeleClientList[0]?.Name ?? "";
  5947. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5948. }
  5949. dic.Add("MissionLeader", missionLeader); //团负责人
  5950. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5951. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5952. #region MyRegion
  5953. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5954. //{
  5955. // List<string> list = new List<string>();
  5956. // try
  5957. // {
  5958. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5959. // foreach (var item in spilitArr)
  5960. // {
  5961. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5962. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5963. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5964. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5965. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5966. // list.Add(depName);
  5967. // list.Add(arrName);
  5968. // }
  5969. // list = list.Distinct().ToList();
  5970. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5971. // }
  5972. // catch (Exception)
  5973. // {
  5974. // dic.Add("ReturnCode", "行程录入不正确!");
  5975. // }
  5976. //}
  5977. //else
  5978. //{
  5979. // dic.Add("ReturnCode", "未录入行程!");
  5980. //}
  5981. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5982. dic.Add("ReturnCode", string.Join("、", countrys));
  5983. #endregion
  5984. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5985. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5986. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5987. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5988. //{
  5989. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5990. // dic.Add("Day", sp.Days.ToString());
  5991. //}
  5992. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5993. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5994. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5995. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5996. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5997. //培训人员名单
  5998. int cultivateRowIndex = 7;
  5999. foreach (var item in DeleClientList)
  6000. {
  6001. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6002. builder.Write(item.Name);
  6003. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6004. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6005. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6006. string birthDay = "";
  6007. if (item.Birthday != null)
  6008. {
  6009. DateTime dt = Convert.ToDateTime(item.Birthday);
  6010. birthDay = $"{dt.Year}.{dt.Month}";
  6011. }
  6012. builder.Write(birthDay);
  6013. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6014. builder.Write(item.Company);
  6015. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6016. builder.Write(item.Job);
  6017. cultivateRowIndex++;
  6018. }
  6019. //删除多余行
  6020. //cultivateRowIndex -= 2;
  6021. int delRows = 10 + 7 - cultivateRowIndex;
  6022. if (delRows > 0)
  6023. {
  6024. for (int i = 0; i < delRows; i++)
  6025. {
  6026. table1.Rows.RemoveAt(cultivateRowIndex);
  6027. //cultivateRowIndex++;
  6028. }
  6029. }
  6030. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6031. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6032. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6033. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6034. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6035. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6036. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6037. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6038. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6039. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6040. //其他费用
  6041. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6042. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6043. //其他费用合计
  6044. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6045. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6046. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6047. //公务舱合计
  6048. //国际旅费
  6049. //string outsideJJ = "";
  6050. //string allPriceJJ = "";
  6051. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6052. {
  6053. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6054. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6055. }
  6056. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6057. {
  6058. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6059. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6060. }
  6061. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6062. {
  6063. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6064. dic.Add("AirFeeTotal", airFeeTotalStr);
  6065. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6066. dic.Add("FeeTotal", feeTotalStr);
  6067. }
  6068. foreach (var key in dic.Keys)
  6069. {
  6070. builder.MoveToBookmark(key);
  6071. builder.Write(dic[key]);
  6072. }
  6073. //模板文件名
  6074. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6075. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6076. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6077. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6078. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6079. }
  6080. }
  6081. else if (dto.ExportType == 2) //表格
  6082. {
  6083. //利用键值对存放数据
  6084. Dictionary<string, string> dic = new Dictionary<string, string>();
  6085. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6086. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6087. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6088. dic.Add("Day", sp.Days.ToString());
  6089. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6090. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6091. {
  6092. //获取模板
  6093. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6094. //载入模板
  6095. Document doc = new Document(tempPath);
  6096. DocumentBuilder builder = new DocumentBuilder(doc);
  6097. dic.Add("TeamName", _DelegationInfo.TeamName);
  6098. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6099. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6100. string missionLeaderName = "",
  6101. missionLeaderJob = "";
  6102. if (DeleClientList.Count > 0)
  6103. {
  6104. missionLeaderName = DeleClientList[0].Name;
  6105. missionLeaderJob = DeleClientList[0].Job;
  6106. }
  6107. dic.Add("MissionLeaderName", missionLeaderName);
  6108. dic.Add("MissionLeaderJob", missionLeaderJob);
  6109. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6110. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6111. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6112. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6113. int rowCount = 10;//总人数行
  6114. int startRowIndex = 7; //起始行
  6115. for (int i = 0; i < DeleClientList.Count; i++)
  6116. {
  6117. builder.MoveToCell(0, startRowIndex, 0, 0);
  6118. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6119. builder.MoveToCell(0, startRowIndex, 1, 0);
  6120. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6121. builder.Write(sex);//性别
  6122. builder.MoveToCell(0, startRowIndex, 2, 0);
  6123. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6124. builder.MoveToCell(0, startRowIndex, 3, 0);
  6125. builder.Write(DeleClientList[i].Company);//工作单位
  6126. builder.MoveToCell(0, startRowIndex, 4, 0);
  6127. builder.Write(DeleClientList[i].Job);//职务及级别
  6128. builder.MoveToCell(0, startRowIndex, 5, 0);
  6129. builder.Write("");//人员属性
  6130. builder.MoveToCell(0, startRowIndex, 6, 0);
  6131. builder.Write("");//上次出国时间
  6132. startRowIndex++;
  6133. }
  6134. int nullRow = rowCount - DeleClientList.Count;//空行
  6135. for (int i = 0; i < nullRow; i++)
  6136. {
  6137. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6138. }
  6139. foreach (var key in dic.Keys)
  6140. {
  6141. builder.MoveToBookmark(key);
  6142. builder.Write(dic[key]);
  6143. }
  6144. //模板文件名
  6145. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6146. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6147. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6148. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6149. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6150. }
  6151. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6152. {
  6153. //获取模板
  6154. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6155. //载入模板
  6156. Document doc = new Document(tempPath);
  6157. DocumentBuilder builder = new DocumentBuilder(doc);
  6158. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6159. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6160. dic.Add("Names", Names);
  6161. int accommodationRows = 12;
  6162. //int foodandotherRows = 12;
  6163. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6164. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6165. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6166. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6167. int accommodationStartIndex = 6;
  6168. decimal dac1totalPrice = 0.00M;
  6169. foreach (var dac in dac1)
  6170. {
  6171. if (dac.SubTotal == 0)
  6172. {
  6173. continue;
  6174. }
  6175. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6176. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6177. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6178. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6179. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6180. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6181. builder.Write(currency);//币种
  6182. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6183. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6184. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6185. builder.Write("");//人数
  6186. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6187. builder.Write("");//天数
  6188. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6189. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6190. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6191. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6192. builder.Write(rate.ToString("#0.0000"));//汇率
  6193. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6194. decimal rbmPrice = rate * dac.SubTotal;
  6195. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6196. accommodationStartIndex++;
  6197. dac1totalPrice += rbmPrice;
  6198. }
  6199. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6200. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6201. builder.Write("小计");
  6202. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6203. builder.Write(dac1totalPrice.ToString("#0.00"));
  6204. accommodationStartIndex++;
  6205. int nullRow = accommodationRows - dac1.Count;
  6206. //删除空行
  6207. //if (nullRow > 0)
  6208. //{
  6209. // int rowIndex = accommodationStartIndex;
  6210. // for (int i = 0; i < nullRow; i++)
  6211. // {
  6212. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6213. // row.Remove();
  6214. // rowIndex++;
  6215. // }
  6216. //}
  6217. if (dac2.Count == dac3.Count)//国家 币种 金额
  6218. {
  6219. for (int i = 0; i < dac2.Count; i++)
  6220. {
  6221. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6222. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6223. }
  6224. }
  6225. int foodandotherStartIndex = 19;//
  6226. decimal dac2totalPrice = 0.00M;
  6227. foreach (var dac in dac2)
  6228. {
  6229. if (dac.SubTotal == 0)
  6230. {
  6231. continue;
  6232. }
  6233. //foodandotherStartIndex = 12;
  6234. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6235. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6236. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6237. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6238. builder.Write(currency);//币种
  6239. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6240. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6241. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6242. builder.Write("");//人数
  6243. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6244. builder.Write("");//天数
  6245. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6246. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6247. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6248. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6249. builder.Write(rate.ToString("#0.0000"));//汇率
  6250. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6251. decimal rbmPrice = rate * dac.SubTotal;
  6252. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6253. foodandotherStartIndex++;
  6254. dac2totalPrice += rbmPrice;
  6255. }
  6256. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6257. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6258. //删除空行
  6259. //if (dac2.Count < foodandotherRows)
  6260. //{
  6261. // while (table2.Rows.Count > dac2.Count)
  6262. // {
  6263. // table2.Rows.RemoveAt(dac2.Count);
  6264. // }
  6265. //}
  6266. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6267. string otherFeeStr = "";
  6268. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6269. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6270. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6271. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6272. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6273. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6274. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6275. foreach (var otherInfo in dac5)
  6276. {
  6277. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6278. }
  6279. #endregion
  6280. if (otherFeeStr.Length > 0)
  6281. {
  6282. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6283. otherFeeStr = $"({otherFeeStr})";
  6284. dic.Add("OtherFeeStr", otherFeeStr);
  6285. }
  6286. foreach (var key in dic.Keys)
  6287. {
  6288. builder.MoveToBookmark(key);
  6289. builder.Write(dic[key]);
  6290. }
  6291. //模板文件名
  6292. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6293. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6294. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6295. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6296. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6297. }
  6298. }
  6299. else if (dto.ExportType == 3)
  6300. {
  6301. if (dto.SubTypeId == 1) //团组成员名单
  6302. {
  6303. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6304. //获取模板
  6305. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6306. //载入模板
  6307. Document doc = new Document(tempPath);
  6308. DocumentBuilder builder = new DocumentBuilder(doc);
  6309. //获取word里所有表格
  6310. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6311. //获取所填表格的序数
  6312. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6313. var rowStart = tableOne.Rows[0]; //获取第1行
  6314. //循环赋值
  6315. for (int i = 0; i < DeleClientList.Count; i++)
  6316. {
  6317. builder.MoveToCell(0, i + 1, 0, 0);
  6318. builder.Write(DeleClientList[i].Name);
  6319. builder.MoveToCell(0, i + 1, 1, 0);
  6320. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6321. builder.Write(sex);
  6322. builder.MoveToCell(0, i + 1, 2, 0);
  6323. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6324. builder.MoveToCell(0, i + 1, 3, 0);
  6325. builder.Write(DeleClientList[i].Company);
  6326. builder.MoveToCell(0, i + 1, 4, 0);
  6327. builder.Write(DeleClientList[i].Job);
  6328. }
  6329. //删除多余行
  6330. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6331. {
  6332. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6333. }
  6334. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6335. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6336. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6337. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6338. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6339. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6340. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6341. }
  6342. }
  6343. return Ok(JsonView(400, "操作失败!", ""));
  6344. }
  6345. catch (Exception ex)
  6346. {
  6347. return Ok(JsonView(400, ex.Message, ""));
  6348. }
  6349. }
  6350. /// <summary>
  6351. /// 获取三公费用标准city
  6352. /// </summary>
  6353. /// <param name="placeData"></param>
  6354. /// <param name="nationalTravelFeeId"></param>
  6355. /// <returns></returns>
  6356. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6357. {
  6358. string _city = string.Empty;
  6359. if (placeData.Count < 1) return _city;
  6360. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6361. if (data == null) return _city;
  6362. string country = data.Country;
  6363. string city = data.City;
  6364. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6365. else _city = city;
  6366. return _city;
  6367. }
  6368. /// <summary>
  6369. /// 团组模块 - 出入境费用 - 明细表导出
  6370. /// </summary>
  6371. /// <returns></returns>
  6372. [HttpPost]
  6373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6374. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6375. {
  6376. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6377. if (data.Code != 0)
  6378. {
  6379. return Ok(JsonView(false, data.Msg));
  6380. }
  6381. return Ok(JsonView(true, data.Msg, data.Data));
  6382. }
  6383. /// <summary>
  6384. /// 团组模块 - 出入境费用 - 一键清空
  6385. /// </summary>
  6386. /// <returns></returns>
  6387. [HttpPost]
  6388. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6390. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6391. {
  6392. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6393. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6394. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6395. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6396. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6397. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6398. .SetColumns(x => new Grp_DayOtherPrice
  6399. {
  6400. IsDel = 1,
  6401. DeleteUserId = dto.UserId,
  6402. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6403. })
  6404. .ExecuteCommandAsync();
  6405. if (_view.Code == 0)
  6406. {
  6407. return Ok(JsonView(true, "操作成功"));
  6408. }
  6409. return Ok(JsonView(false, "操作失败"));
  6410. }
  6411. /// <summary>
  6412. /// 团组模块 - 出入境费用 - 子项删除
  6413. /// </summary>
  6414. /// <returns></returns>
  6415. [HttpPost]
  6416. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6418. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6419. {
  6420. try
  6421. {
  6422. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6423. if (data.Code != 0)
  6424. {
  6425. return Ok(JsonView(false, data.Msg));
  6426. }
  6427. return Ok(JsonView(true, "操作成功!", data.Data));
  6428. }
  6429. catch (Exception ex)
  6430. {
  6431. return Ok(JsonView(false, ex.Message));
  6432. }
  6433. }
  6434. /// <summary>
  6435. /// 删除三公其他费用
  6436. /// </summary>
  6437. /// <param name="dto"></param>
  6438. /// <returns></returns>
  6439. [HttpPost]
  6440. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6441. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6442. {
  6443. var jw = JsonView(false, "删除失败!");
  6444. var data = new Grp_DayOtherPrice()
  6445. {
  6446. Id = dto.Id,
  6447. IsDel = 1,
  6448. DeleteUserId = dto.DeleteUserId,
  6449. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6450. };
  6451. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6452. if (del > 0)
  6453. {
  6454. jw.Code = 200;
  6455. jw.Msg = "删除成功!";
  6456. }
  6457. return Ok(jw);
  6458. }
  6459. /// <summary>
  6460. /// 团组模块 - 出入境国家费用标准 List
  6461. /// </summary>
  6462. /// <returns></returns>
  6463. [HttpPost]
  6464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6465. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6466. {
  6467. try
  6468. {
  6469. Stopwatch sw = new Stopwatch();
  6470. sw.Start();
  6471. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6472. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6473. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6474. Where gntf.Isdel = 0");
  6475. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6476. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6477. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6478. //foreach (var item in nationalTravel)
  6479. //{
  6480. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6481. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6482. // if (otherData != null)
  6483. // {
  6484. // cityData.Remove(otherData);
  6485. // cityData.Add(otherData);
  6486. // }
  6487. // nationalTravelFeeData1.Add(new
  6488. // {
  6489. // Country = item.Country,
  6490. // CityData = cityData
  6491. // });
  6492. //}
  6493. sw.Stop();
  6494. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6495. }
  6496. catch (Exception ex)
  6497. {
  6498. return Ok(JsonView(false, ex.Message));
  6499. throw;
  6500. }
  6501. }
  6502. /// <summary>
  6503. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6504. /// </summary>
  6505. /// <returns></returns>
  6506. [HttpPost]
  6507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6508. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6509. {
  6510. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6511. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6512. List<string> countryData = new List<string>();
  6513. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6514. countryData = countryData.Distinct().ToList();
  6515. List<dynamic> dataSource = new List<dynamic>();
  6516. foreach (var item in countryData)
  6517. {
  6518. var cityData1 = new List<string>();
  6519. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6520. var countryData2 = new
  6521. {
  6522. CountryName = item,
  6523. CityData = cityData1
  6524. };
  6525. dataSource.Add(countryData2);
  6526. }
  6527. return Ok(JsonView(true, "查询成功!", dataSource));
  6528. }
  6529. /// <summary>
  6530. /// 团组模块 - 出入境国家费用标准 Page List
  6531. /// </summary>
  6532. /// <returns></returns>
  6533. [HttpPost]
  6534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6535. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6536. {
  6537. int portId = dto.PortType;
  6538. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6539. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6540. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6541. string whereSql = string.Empty;
  6542. if (!string.IsNullOrEmpty(dto.Country))
  6543. {
  6544. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6545. }
  6546. if (!string.IsNullOrEmpty(dto.City))
  6547. {
  6548. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6549. }
  6550. string pageSql = string.Format(@"Select * From (
  6551. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6552. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6553. From Grp_NationalTravelFee gntf
  6554. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6555. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6556. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6557. RefAsync<int> total = 0;
  6558. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6559. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6560. }
  6561. /// <summary>
  6562. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6563. /// </summary>
  6564. /// <returns></returns>
  6565. [HttpPost]
  6566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6567. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6568. {
  6569. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6570. int portId = dto.PortType;
  6571. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6572. string whereSql = string.Empty;
  6573. if (!string.IsNullOrEmpty(dto.Country))
  6574. {
  6575. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6576. }
  6577. if (!string.IsNullOrEmpty(dto.City))
  6578. {
  6579. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6580. }
  6581. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6582. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6583. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6584. From Grp_NationalTravelFee gntf
  6585. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6586. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6587. Where gntf.Isdel = 0 {0} ", whereSql);
  6588. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6589. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6590. }
  6591. /// <summary>
  6592. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6593. /// </summary>
  6594. /// <returns></returns>
  6595. [HttpPost]
  6596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6597. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6598. {
  6599. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6600. if (data.Code != 0)
  6601. {
  6602. return Ok(JsonView(false, data.Msg));
  6603. }
  6604. return Ok(JsonView(true, "操作成功!", data.Data));
  6605. }
  6606. /// <summary>
  6607. /// 团组模块 - 出入境国家费用标准 - Del
  6608. /// </summary>
  6609. /// <returns></returns>
  6610. [HttpPost]
  6611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6612. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6613. {
  6614. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6615. {
  6616. Id = dto.Id,
  6617. DeleteUserId = dto.DeleteUserId,
  6618. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6619. IsDel = 1
  6620. };
  6621. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6622. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6623. .WhereColumns(it => new { it.Id })
  6624. .ExecuteCommandAsync();
  6625. if (delStatus <= 0)
  6626. {
  6627. return Ok(JsonView(false, "删除失败!"));
  6628. }
  6629. return Ok(JsonView(true, "操作成功!"));
  6630. }
  6631. /// <summary>
  6632. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6633. /// 注:Get 请求Headers 加 Token
  6634. /// </summary>
  6635. /// <param name="groupId"></param>
  6636. /// <returns></returns>
  6637. [HttpGet("{groupId}")]
  6638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6639. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6640. {
  6641. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6642. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6643. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6644. data.ForEach(x =>
  6645. {
  6646. x.CreateUserId = _currUserInfo.UserId;
  6647. });
  6648. if (data.Any())
  6649. {
  6650. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6651. if (add > 0)
  6652. {
  6653. return Ok(JsonView(true, "操作成功!"));
  6654. }
  6655. }
  6656. return Ok(JsonView(false, "未操作!"));
  6657. }
  6658. #endregion
  6659. #region 团组经理模块 出入境费用-草稿
  6660. /// <summary>
  6661. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6662. /// </summary>
  6663. /// <returns></returns>
  6664. [HttpPost]
  6665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6666. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6667. {
  6668. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6669. .Where(x => x.IsDel == 0)
  6670. .OrderByDescending(x => x.CreateTime)
  6671. .Select(x => new { x.Id, x.DraftName })
  6672. .ToListAsync();
  6673. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6674. //SetDataInfoView
  6675. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6676. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6677. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6678. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6679. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6680. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6681. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6682. //默认币种显示
  6683. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6684. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6685. return Ok(JsonView(true, "查询成功!", new
  6686. {
  6687. DraftNameDatas = draftNameDatas,
  6688. CurrencyData = _CurrencyData,
  6689. WordTypeData = _WordTypeData,
  6690. ExcelTypeData = _ExcelTypeData,
  6691. CurrencyInit = _currencyInfos,
  6692. ViewPermissionData = viewPermissionData
  6693. }));
  6694. }
  6695. /// <summary>
  6696. /// 团组模块 - 出入境费用-草稿
  6697. /// 实时汇率 tips
  6698. /// 机票费用 tips
  6699. /// </summary>
  6700. /// <returns></returns>
  6701. [HttpPost]
  6702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6703. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6704. {
  6705. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6706. return Ok(JsonView(true, "查询成功!", new
  6707. {
  6708. //GroupNameData = groupNameData.Data,
  6709. //visaData = visaData.Data,
  6710. //airData = airData.Data,
  6711. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6712. }));
  6713. }
  6714. /// <summary>
  6715. /// 团组模块 - 出入境费用-草稿
  6716. /// 签证费用 tips
  6717. /// </summary>
  6718. /// <returns></returns>
  6719. [HttpPost]
  6720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6721. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6722. {
  6723. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6724. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6725. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6726. .Select(x => x.NationalTravelFeeId)
  6727. .Distinct()
  6728. .ToListAsync();
  6729. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6730. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6731. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6732. .Select(x => x.Country)
  6733. .Distinct()
  6734. .ToArrayAsync();
  6735. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6736. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6737. return Ok(JsonView(true, "查询成功!", new
  6738. {
  6739. totalAmt = totalAmt,
  6740. remark = remark
  6741. }));
  6742. }
  6743. /// <summary>
  6744. /// 团组模块 - 出入境费用-草稿 - Info
  6745. /// </summary>
  6746. /// <returns></returns>
  6747. [HttpPost]
  6748. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6750. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6751. {
  6752. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6753. }
  6754. /// <summary>
  6755. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6756. /// </summary>
  6757. /// <returns></returns>
  6758. [HttpPost]
  6759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6760. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6761. {
  6762. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6763. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6764. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6765. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6766. foreach (var userId in dto.UserIds)
  6767. {
  6768. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6769. }
  6770. if (permissions.Any())
  6771. {
  6772. _sqlSugar.BeginTran();
  6773. try
  6774. {
  6775. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6776. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6777. if (result < 1)
  6778. {
  6779. _sqlSugar.RollbackTran();
  6780. return Ok(JsonView(false));
  6781. }
  6782. }
  6783. catch (Exception ex)
  6784. {
  6785. _sqlSugar.RollbackTran();
  6786. return Ok(JsonView(false, ex.Message));
  6787. }
  6788. _sqlSugar.CommitTran();
  6789. return Ok(JsonView(true));
  6790. }
  6791. return Ok(JsonView(false));
  6792. }
  6793. /// <summary>
  6794. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6795. /// </summary>
  6796. /// <returns></returns>
  6797. [HttpPost]
  6798. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6800. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6801. {
  6802. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6803. if (data.Code != 0)
  6804. {
  6805. return Ok(JsonView(false, data.Msg));
  6806. }
  6807. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6808. //汇率信息记录
  6809. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6810. return Ok(JsonView(true, data.Msg, data.Data));
  6811. }
  6812. /// <summary>
  6813. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6814. /// </summary>
  6815. /// <param name="dto"></param>
  6816. /// <returns></returns>
  6817. [HttpPost]
  6818. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6820. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6821. {
  6822. try
  6823. {
  6824. var id = dto.Id;
  6825. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6826. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6827. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6828. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6829. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6830. 3 团组成员名单 1 团组成员名单", ""));
  6831. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6832. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6833. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6834. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6835. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6836. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6837. //数据源
  6838. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6839. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6840. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6841. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6842. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6843. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6844. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6845. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6846. .Select((x, a, b) => new
  6847. {
  6848. x.Index,
  6849. itemName = a.Name,
  6850. CurrencyStr = b.Name,
  6851. x.Cost,
  6852. x.SubTotal,
  6853. x.Remark
  6854. })
  6855. .OrderBy((x) => x.Index)
  6856. .ToList(); //其他款项费用
  6857. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6858. var peiceItemCurrencys = new List<string>();
  6859. if (_DayAndCosts.Any())
  6860. {
  6861. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6862. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6863. }
  6864. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6865. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6866. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6867. {
  6868. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6869. }
  6870. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6871. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6872. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6873. if (dto.ExportType == 1) //明细表
  6874. {
  6875. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6876. {
  6877. //获取模板
  6878. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6879. //载入模板
  6880. Document doc = new Document(tempPath);
  6881. DocumentBuilder builder = new DocumentBuilder(doc);
  6882. //利用键值对存放数据
  6883. Dictionary<string, string> dic = new Dictionary<string, string>();
  6884. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6885. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6886. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6887. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6888. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6889. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6890. //境内费用(其他费用)
  6891. if (_EnterExitCosts.ChoiceOne == 1)
  6892. {
  6893. string row1_1 = "";
  6894. if (_EnterExitCosts.Visa > 0)
  6895. {
  6896. //insidePayTotal += _EnterExitCosts.Visa;
  6897. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6898. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6899. {
  6900. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6901. }
  6902. }
  6903. string row1_2 = "";
  6904. if (_EnterExitCosts.YiMiao > 0)
  6905. {
  6906. //insidePayTotal += _EnterExitCosts.YiMiao;
  6907. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6908. }
  6909. if (_EnterExitCosts.HeSuan > 0)
  6910. {
  6911. //insidePayTotal += _EnterExitCosts.HeSuan;
  6912. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6913. }
  6914. if (_EnterExitCosts.Service > 0)
  6915. {
  6916. //insidePayTotal += _EnterExitCosts.Service;
  6917. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6918. }
  6919. string row1_3 = "";
  6920. if (_EnterExitCosts.Safe > 0)
  6921. {
  6922. //insidePayTotal += _EnterExitCosts.Safe;
  6923. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6924. }
  6925. if (_EnterExitCosts.Ticket > 0)
  6926. {
  6927. //insidePayTotal += _EnterExitCosts.Ticket;
  6928. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6929. }
  6930. string row1 = "";
  6931. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6932. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6933. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6934. row1 += $"备注:{_EnterExitCosts.Remark}";
  6935. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6936. dic.Add("Row1Str", row1);
  6937. }
  6938. string airTotalStr = string.Empty,
  6939. airPriceStr = string.Empty;
  6940. //经济舱
  6941. if (_EnterExitCosts.SumJJC == 1)
  6942. {
  6943. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6944. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6945. }
  6946. //公务舱
  6947. if (_EnterExitCosts.SumGWC == 1)
  6948. {
  6949. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6950. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6951. }
  6952. //头等舱
  6953. if (_EnterExitCosts.SumTDC == 1)
  6954. {
  6955. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6956. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6957. }
  6958. //汇率描述
  6959. string rateStr = "";
  6960. if (peiceItemCurrencyInfos.Any())
  6961. {
  6962. rateStr = "\r\n汇率描述:";
  6963. foreach (var item in peiceItemCurrencyInfos)
  6964. {
  6965. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6966. }
  6967. }
  6968. string twoItemRemark = "备注:";
  6969. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6970. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6971. dic.Add("AirTotalStr", airTotalStr);
  6972. dic.Add("AirPriceStr", airPriceStr);
  6973. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6974. dic.Add("TwoItemRemark", twoItemRemark);
  6975. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6976. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6977. int table1Row = 0,
  6978. table2Row = 0,
  6979. table3Row = 0,
  6980. table4Row = 0,
  6981. table5Row = 0;
  6982. //住宿费
  6983. if (_EnterExitCosts.ChoiceThree == 1)
  6984. {
  6985. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6986. table1Row = dac1.Count;
  6987. #region 填充word表格内容
  6988. for (int i = 0; i < dac1.Count; i++)
  6989. {
  6990. var dac = dac1[i];
  6991. if (dac == null) continue;
  6992. builder.MoveToCell(0, i, 0, 0);
  6993. builder.Write("第" + dac.Days.ToString() + "晚:");
  6994. builder.MoveToCell(0, i, 1, 0);
  6995. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6996. //builder.Write(dac.Place == null ? "" : dac.Place);
  6997. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6998. builder.MoveToCell(0, i, 2, 0);
  6999. builder.Write("费用标准:");
  7000. string curr = "";
  7001. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7002. if (currData != null)
  7003. {
  7004. curr = currData.Name;
  7005. }
  7006. builder.MoveToCell(0, i, 3, 0);
  7007. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7008. builder.MoveToCell(0, i, 4, 0);
  7009. builder.Write("费用小计:");
  7010. builder.MoveToCell(0, i, 5, 0);
  7011. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7012. }
  7013. #endregion
  7014. }
  7015. else dic.Add("SubZS", "0.00");
  7016. //删除多余行
  7017. while (table1.Rows.Count > table1Row)
  7018. {
  7019. table1.Rows.RemoveAt(table1Row);
  7020. }
  7021. //伙食费
  7022. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7023. if (_EnterExitCosts.ChoiceFour == 1)
  7024. {
  7025. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7026. table2Row = dac2.Count;
  7027. #region 填充word表格内容
  7028. for (int i = 0; i < dac2.Count; i++)
  7029. {
  7030. var dac = dac2[i];
  7031. if (dac == null) continue;
  7032. builder.MoveToCell(1, i, 0, 0);
  7033. builder.Write("第" + dac.Days.ToString() + "天:");
  7034. builder.MoveToCell(1, i, 1, 0);
  7035. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7036. builder.MoveToCell(1, i, 2, 0);
  7037. builder.Write("费用标准:");
  7038. string curr = "";
  7039. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7040. if (currData != null)
  7041. {
  7042. curr = currData.Name;
  7043. }
  7044. builder.MoveToCell(1, i, 3, 0);
  7045. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7046. builder.MoveToCell(1, i, 4, 0);
  7047. builder.Write("费用小计:");
  7048. builder.MoveToCell(1, i, 5, 0);
  7049. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7050. }
  7051. #endregion
  7052. }
  7053. else dic.Add("SubHS", "0.00");
  7054. //删除多余行
  7055. while (table2.Rows.Count > table2Row)
  7056. {
  7057. table2.Rows.RemoveAt(table2Row);
  7058. }
  7059. //公杂费
  7060. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7061. if (_EnterExitCosts.ChoiceFive == 1)
  7062. {
  7063. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7064. table3Row = dac3.Count;
  7065. #region 填充word表格内容
  7066. for (int i = 0; i < dac3.Count; i++)
  7067. {
  7068. var dac = dac3[i];
  7069. if (dac == null) continue;
  7070. builder.MoveToCell(2, i, 0, 0);
  7071. builder.Write("第" + dac.Days.ToString() + "天:");
  7072. builder.MoveToCell(2, i, 1, 0);
  7073. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7074. builder.MoveToCell(2, i, 2, 0);
  7075. builder.Write("费用标准:");
  7076. string curr = "";
  7077. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7078. if (currData != null)
  7079. {
  7080. curr = currData.Name;
  7081. }
  7082. builder.MoveToCell(2, i, 3, 0);
  7083. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7084. builder.MoveToCell(2, i, 4, 0);
  7085. builder.Write("费用小计:");
  7086. builder.MoveToCell(2, i, 5, 0);
  7087. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7088. }
  7089. //删除多余行
  7090. while (table3.Rows.Count > table3Row)
  7091. {
  7092. table3.Rows.RemoveAt(table3Row);
  7093. }
  7094. #endregion
  7095. }
  7096. else dic.Add("SubGZF", "0.00");
  7097. //删除多余行
  7098. while (table3.Rows.Count > table3Row)
  7099. {
  7100. table3.Rows.RemoveAt(table3Row);
  7101. }
  7102. //培训费
  7103. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7104. if (_EnterExitCosts.ChoiceSix == 1)
  7105. {
  7106. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7107. dic.Add("SubPX", pxStr);
  7108. table4Row = dac4.Count;
  7109. #region 填充word表格内容
  7110. for (int i = 0; i < dac4.Count; i++)
  7111. {
  7112. var dac = dac4[i];
  7113. if (dac == null) continue;
  7114. builder.MoveToCell(3, i, 0, 0);
  7115. builder.Write("第" + dac.Days.ToString() + "天:");
  7116. builder.MoveToCell(3, i, 1, 0);
  7117. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7118. builder.MoveToCell(3, i, 2, 0);
  7119. builder.Write("费用标准:");
  7120. string curr = "";
  7121. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7122. if (currData != null)
  7123. {
  7124. curr = currData.Name;
  7125. }
  7126. builder.MoveToCell(3, i, 3, 0);
  7127. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7128. builder.MoveToCell(3, i, 4, 0);
  7129. builder.Write("费用小计:");
  7130. builder.MoveToCell(3, i, 5, 0);
  7131. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7132. }
  7133. #endregion
  7134. }
  7135. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7136. //删除多余行
  7137. while (table4.Rows.Count > table4Row)
  7138. {
  7139. table4.Rows.RemoveAt(table4Row);
  7140. }
  7141. //其他费用
  7142. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7143. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7144. {
  7145. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7146. dic.Add("titleQi", qtStr);
  7147. table5Row = dac5.Count;
  7148. #region 填充word表格内容
  7149. for (int i = 0; i < dac5.Count; i++)
  7150. {
  7151. var dac = dac5[i];
  7152. if (dac == null) continue;
  7153. builder.MoveToCell(4, i, 0, 0);
  7154. builder.Write("第" + dac.Index.ToString() + "项:");
  7155. builder.MoveToCell(4, i, 1, 0);
  7156. builder.Write(dac.itemName);
  7157. builder.MoveToCell(4, i, 2, 0);
  7158. builder.Write("费用标准:");
  7159. builder.MoveToCell(4, i, 3, 0);
  7160. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7161. builder.MoveToCell(4, i, 4, 0);
  7162. builder.Write("费用小计:");
  7163. builder.MoveToCell(4, i, 5, 0);
  7164. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7165. builder.MoveToCell(4, i, 6, 0);
  7166. builder.Write("备注:");
  7167. builder.MoveToCell(4, i, 7, 0);
  7168. builder.Write(dac.Remark);
  7169. }
  7170. #endregion
  7171. }
  7172. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7173. //删除多余行
  7174. while (table5.Rows.Count > table5Row)
  7175. {
  7176. table5.Rows.RemoveAt(table5Row);
  7177. }
  7178. //加上其他费用
  7179. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7180. decimal subJJC = 0.00M,
  7181. subGWC = 0.00M,
  7182. subTDC = 0.00M;
  7183. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7184. string totalLabel = string.Format("全部费用总计:");
  7185. //经济舱
  7186. if (_EnterExitCosts.SumJJC == 1)
  7187. {
  7188. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7189. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7190. }
  7191. //公务舱
  7192. if (_EnterExitCosts.SumGWC == 1)
  7193. {
  7194. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7195. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7196. }
  7197. //头等舱
  7198. if (_EnterExitCosts.SumTDC == 1)
  7199. {
  7200. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7201. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7202. }
  7203. //TotalLabel
  7204. dic.Add("TotalLabel", totalLabel);
  7205. #region 填充word模板书签内容
  7206. foreach (var key in dic.Keys)
  7207. {
  7208. Bookmark bookmark = doc.Range.Bookmarks[key];
  7209. if (bookmark != null)
  7210. {
  7211. builder.MoveToBookmark(key);
  7212. builder.Write(dic[key]);
  7213. }
  7214. }
  7215. #endregion
  7216. //文件名
  7217. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7218. strFileName = CommonFun.ValidFileName(strFileName);
  7219. AsposeHelper.removewatermark_v2180();
  7220. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7221. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7222. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7223. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7224. }
  7225. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7226. {
  7227. //获取模板
  7228. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7229. //载入模板
  7230. Document doc = new Document(tempPath);
  7231. DocumentBuilder builder = new DocumentBuilder(doc);
  7232. Dictionary<string, string> dic = new Dictionary<string, string>();
  7233. string returnCodeLabel = string.Empty;
  7234. if (nationalTravelFeeData.Any())
  7235. {
  7236. List<string> list = new List<string>();
  7237. foreach (var item in nationalTravelFeeData)
  7238. {
  7239. list.Add($"{item.Country}({item.City})");
  7240. }
  7241. list = list.Distinct().ToList();
  7242. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7243. }
  7244. var countryLabel = string.Empty;
  7245. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7246. if (countryData.Any())
  7247. {
  7248. countryLabel = string.Join("、", countryData);
  7249. }
  7250. dic.Add("ReturnCodeAir", returnCodeLabel);
  7251. dic.Add("VisitStartDate", "-");
  7252. dic.Add("VisitEndDate", "-");
  7253. dic.Add("Day", "-");
  7254. dic.Add("VisitCountry", countryLabel);
  7255. dic.Add("ClientUnit", "-");
  7256. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7257. //dic.Add("Names", Names);
  7258. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7259. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7260. decimal dac1totalPrice = 0.00M;
  7261. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7262. foreach (var dac in dac1)
  7263. {
  7264. if (dac.SubTotal == 0.00M)
  7265. {
  7266. continue;
  7267. }
  7268. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7269. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7270. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7271. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7272. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7273. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7274. builder.Write(currency);//币种
  7275. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7276. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7277. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7278. builder.Write("");//人数
  7279. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7280. builder.Write("");//天数
  7281. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7282. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7283. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7284. decimal rate = 0.00M;
  7285. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7286. builder.Write(rate.ToString("#0.0000"));//汇率
  7287. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7288. decimal rbmPrice = dac.SubTotal;
  7289. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7290. accommodationStartIndex++;
  7291. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7292. }
  7293. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7294. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7295. {
  7296. table1.Rows.RemoveAt(i - 1);
  7297. foodandotherStartIndex--;
  7298. }
  7299. if (dac2.Count == dac3.Count)//国家 币种 金额
  7300. {
  7301. for (int i = 0; i < dac2.Count; i++)
  7302. {
  7303. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7304. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7305. }
  7306. }
  7307. decimal dac2totalPrice = 0.00M;
  7308. foreach (var dac in dac2)
  7309. {
  7310. if (dac.SubTotal == 0)
  7311. {
  7312. continue;
  7313. }
  7314. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7315. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7316. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7317. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7318. builder.Write(currency);//币种
  7319. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7320. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7321. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7322. builder.Write("");//人数
  7323. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7324. builder.Write("");//天数
  7325. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7326. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7327. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7328. decimal rate = 0.00M;
  7329. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7330. builder.Write(rate.ToString("#0.0000"));//汇率
  7331. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7332. decimal rbmPrice = dac.SubTotal;
  7333. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7334. foodandotherStartIndex++;
  7335. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7336. }
  7337. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7338. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7339. {
  7340. table1.Rows.RemoveAt(i - 1);
  7341. }
  7342. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7343. string otherFeeStr = "";
  7344. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7345. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7346. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7347. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7348. foreach (var otherInfo in dac5)
  7349. {
  7350. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7351. }
  7352. #endregion
  7353. if (otherFeeStr.Length > 0)
  7354. {
  7355. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7356. otherFeeStr = $"({otherFeeStr})";
  7357. dic.Add("OtherFeeStr", otherFeeStr);
  7358. }
  7359. //总计
  7360. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7361. //国际旅费
  7362. string outsideAir = string.Empty;
  7363. string allPriceAir = string.Empty;
  7364. if (_EnterExitCosts.SumJJC == 1)
  7365. {
  7366. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7367. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7368. }
  7369. if (_EnterExitCosts.SumGWC == 1)
  7370. {
  7371. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7372. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7373. }
  7374. if (_EnterExitCosts.SumTDC == 1)
  7375. {
  7376. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7377. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7378. }
  7379. dic.Add("InTravelPrice", $"({outsideAir})");
  7380. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7381. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7382. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7383. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7384. foreach (var key in dic.Keys)
  7385. {
  7386. builder.MoveToBookmark(key);
  7387. builder.Write(dic[key]);
  7388. }
  7389. //模板文件名
  7390. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7391. strFileName = CommonFun.ValidFileName(strFileName);
  7392. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7393. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7394. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7395. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7396. }
  7397. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7398. {
  7399. //获取模板
  7400. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7401. //载入模板
  7402. WorkbookDesigner designer = new WorkbookDesigner();
  7403. designer.Workbook = new Workbook(tempPath);
  7404. Dictionary<string, string> dic = new Dictionary<string, string>();
  7405. string returnCodeLabel = string.Empty;
  7406. if (nationalTravelFeeData.Any())
  7407. {
  7408. List<string> list = new List<string>();
  7409. foreach (var item in nationalTravelFeeData)
  7410. {
  7411. list.Add($"{item.Country}({item.City})");
  7412. }
  7413. list = list.Distinct().ToList();
  7414. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7415. }
  7416. var countryLabel = string.Empty;
  7417. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7418. if (countryData.Any())
  7419. {
  7420. countryLabel = string.Join("、", countryData);
  7421. }
  7422. dic.Add("ReturnCodeAir", returnCodeLabel);
  7423. dic.Add("VisitStartDate", "-");
  7424. dic.Add("VisitEndDate", "-");
  7425. dic.Add("Day", "0");
  7426. dic.Add("VisitCountry", countryLabel);
  7427. dic.Add("ClientUnit", "-");
  7428. designer.SetDataSource("ClientUnit", "-");
  7429. designer.SetDataSource("VisitCountry", countryLabel);
  7430. designer.SetDataSource("Group", "-");
  7431. designer.SetDataSource("ClientUnitTitle", "-");
  7432. designer.SetDataSource("Name", "-");
  7433. designer.SetDataSource("VisitStartDate", "-");
  7434. designer.SetDataSource("Day", "0");
  7435. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7436. designer.SetDataSource("ReturnCodeAir", "-");
  7437. int startIndex = 10;
  7438. const int startIndexcopy = 10;
  7439. if (dac2.Count == dac3.Count)//国家 币种 金额
  7440. {
  7441. for (int i = 0; i < dac2.Count; i++)
  7442. {
  7443. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7444. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7445. }
  7446. }
  7447. DataTable dtdac1 = new DataTable();
  7448. List<string> place = new List<string>();
  7449. dtdac1.Columns.AddRange(new DataColumn[] {
  7450. new DataColumn(){ ColumnName = "city"},
  7451. new DataColumn(){ ColumnName = "curr"},
  7452. new DataColumn(){ ColumnName = "criterion"},
  7453. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7454. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7455. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7456. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7457. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7458. });
  7459. DataTable dtdac2 = new DataTable();
  7460. dtdac2.Columns.AddRange(new DataColumn[] {
  7461. new DataColumn(){ ColumnName = "city"},
  7462. new DataColumn(){ ColumnName = "curr"},
  7463. new DataColumn(){ ColumnName = "criterion"},
  7464. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7465. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7466. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7467. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7468. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7469. });
  7470. dtdac1.TableName = "tb1";
  7471. dtdac2.TableName = "tb2";
  7472. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7473. foreach (var item in dac1)
  7474. {
  7475. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7476. if (place.Contains(item.Place))
  7477. {
  7478. continue;
  7479. }
  7480. DataRow row = dtdac1.NewRow();
  7481. row["city"] = item.Place;
  7482. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7483. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7484. row["curr"] = currency;
  7485. row["rate"] = rate.ToString("#0.0000");
  7486. row["criterion"] = item.Cost.ToString("#0.00");
  7487. row["number"] = 1;
  7488. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7489. //row["costRMB"] = rbmPrice;
  7490. dtdac1.Rows.Add(row);
  7491. place.Add(item.Place);
  7492. }
  7493. place = new List<string>();
  7494. foreach (var item in dac2)
  7495. {
  7496. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7497. if (place.Contains(item.Place))
  7498. {
  7499. continue;
  7500. }
  7501. DataRow row = dtdac2.NewRow();
  7502. row["city"] = item.Place;
  7503. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7504. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7505. row["curr"] = currency;
  7506. row["rate"] = rate.ToString("#0.0000");
  7507. row["criterion"] = item.Cost.ToString("#0.00");
  7508. row["number"] = 1;
  7509. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7510. //row["cost"] = item.SubTotal;
  7511. //row["costRMB"] = rbmPrice;
  7512. dtdac2.Rows.Add(row);
  7513. place.Add(item.Place);
  7514. //dac2totalPrice += rbmPrice;
  7515. }
  7516. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7517. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7518. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7519. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7520. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7521. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7522. string cell4Str1 = string.Empty;
  7523. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7524. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7525. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7526. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7527. string cellStr = $" 5.其他费用(";
  7528. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7529. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7530. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7531. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7532. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7533. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7534. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7535. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7536. foreach (var otherInfo in dac5)
  7537. {
  7538. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7539. }
  7540. #endregion
  7541. if (cellStr.Length > 8)
  7542. {
  7543. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7544. }
  7545. cellStr += ")";
  7546. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7547. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7548. decimal pxFee = dac4.Sum(it => it.Cost);
  7549. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7550. string celllastStr1 = "";
  7551. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7552. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7553. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7554. celllastStr1 += $",国际旅费 元";
  7555. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7556. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7557. designer.SetDataSource("cell4Str", cell4Str);
  7558. designer.SetDataSource("cellStr", cellStr);
  7559. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7560. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7561. designer.SetDataSource("celllastStr", celllastStr);
  7562. Workbook wb = designer.Workbook;
  7563. var sheet = wb.Worksheets[0];
  7564. //绑定datatable数据集
  7565. designer.SetDataSource(dtdac1);
  7566. designer.SetDataSource(dtdac2);
  7567. designer.Process();
  7568. var rowStart = dtdac1.Rows.Count;
  7569. while (rowStart > 0)
  7570. {
  7571. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7572. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7573. startIndex++;
  7574. rowStart--;
  7575. }
  7576. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7577. startIndex += 1; //总计行
  7578. rowStart = dtdac2.Rows.Count;
  7579. while (rowStart > 0)
  7580. {
  7581. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7582. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7583. startIndex++;
  7584. rowStart--;
  7585. }
  7586. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7587. wb.CalculateFormula(true);
  7588. //模板文件名
  7589. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7590. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7591. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7592. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7593. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7594. }
  7595. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7596. {
  7597. //获取模板
  7598. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7599. //载入模板
  7600. Document doc = new Document(tempPath);
  7601. DocumentBuilder builder = new DocumentBuilder(doc);
  7602. Dictionary<string, string> dic = new Dictionary<string, string>();
  7603. dic.Add("GroupName", "-");
  7604. dic.Add("ClientUnit", "-");
  7605. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7606. //string missionLeaderJob = "";//负责人job
  7607. //int groupNumber = 0; //团人数
  7608. dic.Add("MissionLeader", "-"); //团负责人
  7609. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7610. dic.Add("GroupNumber", "0"); //团人数
  7611. dic.Add("Day", "0");
  7612. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7613. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7614. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7615. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7616. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7617. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7618. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7619. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7620. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7621. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7622. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7623. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7624. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7625. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7626. //其他费用
  7627. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7628. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7629. //其他费用合计
  7630. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7631. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7632. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7633. //公务舱合计
  7634. //国际旅费
  7635. //string outsideJJ = "";
  7636. //string allPriceJJ = "";
  7637. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7638. {
  7639. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7640. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7641. }
  7642. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7643. {
  7644. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7645. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7646. }
  7647. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7648. {
  7649. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7650. dic.Add("AirFeeTotal", airFeeTotalStr);
  7651. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7652. dic.Add("FeeTotal", feeTotalStr);
  7653. }
  7654. foreach (var key in dic.Keys)
  7655. {
  7656. builder.MoveToBookmark(key);
  7657. builder.Write(dic[key]);
  7658. }
  7659. //模板文件名
  7660. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7661. strFileName = CommonFun.ValidFileName(strFileName);
  7662. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7663. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7664. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7665. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7666. }
  7667. }
  7668. else if (dto.ExportType == 2) //表格
  7669. {
  7670. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7671. }
  7672. else if (dto.ExportType == 3)
  7673. {
  7674. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7675. }
  7676. return Ok(JsonView(400, "只可导出明细表!", ""));
  7677. }
  7678. catch (Exception ex)
  7679. {
  7680. return Ok(JsonView(400, ex.Message, ""));
  7681. }
  7682. }
  7683. /// <summary>
  7684. /// 获取三公费用标准city
  7685. /// </summary>
  7686. /// <param name="placeData"></param>
  7687. /// <param name="nationalTravelFeeId"></param>
  7688. /// <returns></returns>
  7689. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7690. {
  7691. string _city = string.Empty;
  7692. if (!placeData.Any()) return _city;
  7693. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7694. if (data == null) return _city;
  7695. string country = data.Country;
  7696. string city = data.City;
  7697. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7698. else _city = city;
  7699. return _city;
  7700. }
  7701. /// <summary>
  7702. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7703. /// </summary>
  7704. /// <returns></returns>
  7705. [HttpPost]
  7706. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7708. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7709. {
  7710. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7711. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7712. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7713. if (_view.Code == 0)
  7714. {
  7715. return Ok(JsonView(true, "操作成功"));
  7716. }
  7717. return Ok(JsonView(false, "操作失败"));
  7718. }
  7719. /// <summary>
  7720. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7721. /// </summary>
  7722. /// <returns></returns>
  7723. [HttpPost]
  7724. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7726. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7727. {
  7728. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7729. if (data.Code != 0)
  7730. {
  7731. return Ok(JsonView(false, data.Msg));
  7732. }
  7733. return Ok(JsonView(true, "操作成功!", data.Data));
  7734. }
  7735. /// <summary>
  7736. /// 三公其他费用草稿 删除
  7737. /// </summary>
  7738. /// <param name="dto"></param>
  7739. /// <returns></returns>
  7740. [HttpPost]
  7741. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7742. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7743. {
  7744. var jw = JsonView(false, "删除失败!");
  7745. var data = new Grp_DayOtherPriceDraft()
  7746. {
  7747. Id = dto.Id,
  7748. IsDel = 1,
  7749. DeleteUserId = dto.DeleteUserId,
  7750. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7751. };
  7752. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7753. if (del > 0)
  7754. {
  7755. jw.Code = 200;
  7756. jw.Msg = "删除成功!";
  7757. }
  7758. return Ok(jw);
  7759. }
  7760. /// <summary>
  7761. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7762. /// </summary>
  7763. /// <returns></returns>
  7764. [HttpPost]
  7765. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7766. {
  7767. var jw = JsonView(false);
  7768. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7769. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7770. jw.Code = StatusCodes.Status200OK;
  7771. jw.Msg = "操作成功!";
  7772. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7773. return Ok(jw);
  7774. }
  7775. /// <summary>
  7776. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7777. /// </summary>
  7778. /// <param name="dto"></param>
  7779. /// <returns></returns>
  7780. [HttpPost]
  7781. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7782. {
  7783. int userId = dto.UserId,
  7784. portId = dto.PortType,
  7785. groupId = dto.GroupId,
  7786. draftId = dto.DraftId;
  7787. _portTypeData.Add(1);
  7788. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7789. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7790. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7791. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7792. _sqlSugar.BeginTran();
  7793. try
  7794. {
  7795. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7796. if (draftDatas == null)
  7797. {
  7798. _sqlSugar.RollbackTran();
  7799. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7800. }
  7801. //验证可覆盖已有数据 两边创建人需为同一人;
  7802. int draftCreateUserId = draftDatas.CreateUserId,
  7803. formalCreateUserId = 0;
  7804. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7805. if (formalData != null)
  7806. {
  7807. formalCreateUserId = formalData.CreateUserId;
  7808. if (draftCreateUserId != formalCreateUserId)
  7809. {
  7810. _sqlSugar.RollbackTran();
  7811. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7812. }
  7813. }
  7814. //默认添加查看、编辑权限(创建人、自己)
  7815. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7816. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7817. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7818. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7819. newExterData.DiId = groupId;
  7820. newExterData.CreateUserId = userId;
  7821. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7822. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7823. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7824. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7825. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7826. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7827. //数据如果存在执行删除
  7828. if (enterExitCostInfo != null)
  7829. {
  7830. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7831. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7832. .Where(x => x.Id == enterExitCostInfo.Id)
  7833. .ExecuteCommand();
  7834. _sqlSugar.Updateable<Grp_DayAndCost>()
  7835. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7836. .Where(x => x.DiId == groupId)
  7837. .ExecuteCommand();
  7838. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7839. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7840. .Where(x => x.Diid == groupId)
  7841. .ExecuteCommand();
  7842. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7843. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7844. .Where(x => x.GroupId == groupId)
  7845. .ExecuteCommand();
  7846. }
  7847. //执行insert
  7848. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7849. if (insertId < 1)
  7850. {
  7851. _sqlSugar.RollbackTran();
  7852. return Ok(JsonView(false, "草稿数据导入失败!"));
  7853. }
  7854. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7855. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7856. #region 默认添加权限
  7857. #endregion
  7858. _sqlSugar.CommitTran();
  7859. //执行操作之后
  7860. //生成默认文件pdf并且通知人员
  7861. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7862. {
  7863. DiId = groupId,
  7864. ExportType = 1,
  7865. SubTypeId = 1005
  7866. }, "pdf");
  7867. //发送通知
  7868. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7869. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7870. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7871. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7872. //汇率信息记录
  7873. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7874. return Ok(JsonView(true));
  7875. }
  7876. catch (Exception ex)
  7877. {
  7878. _sqlSugar.RollbackTran();
  7879. return Ok(JsonView(false, ex.Message));
  7880. }
  7881. }
  7882. #endregion
  7883. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7884. /// <summary>
  7885. /// 获取币种基础数据(含逻辑处理)
  7886. /// </summary>
  7887. /// <returns></returns>
  7888. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7889. {
  7890. return await GeneralMethod.EnterExitCostInitRate();
  7891. }
  7892. /// <summary>
  7893. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7894. /// </summary>
  7895. /// <returns></returns>
  7896. [HttpPost]
  7897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7898. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7899. {
  7900. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7901. //SetDataInfoView
  7902. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7903. var fileTypes = new List<EecSetDataInfoView>();
  7904. var wordTypeData = dataSource.Where(it => it.STid == 72).Select(x => new EecSetDataInfoView() {
  7905. ParentId = 1,
  7906. Id = x.Id,
  7907. Name = x.Name
  7908. }) .ToList(); //三公费用-Word明细类型
  7909. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  7910. var excelTypeData = dataSource.Where(it => it.STid == 73)
  7911. .Select(x => new EecSetDataInfoView()
  7912. {
  7913. ParentId = 2,
  7914. Id = x.Id,
  7915. Name = x.Name
  7916. }).ToList(); //三公费用-Excel明细类型
  7917. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  7918. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  7919. fileTypes.Add(groupNameList);
  7920. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  7921. //默认币种显示
  7922. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7923. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7924. return Ok(JsonView(true, "查询成功!", new
  7925. {
  7926. FileTypeData = fileTypes,
  7927. CurrencyInit = _currencyInfos,
  7928. viewPermissionData = viewPermissionData
  7929. }));
  7930. }
  7931. /// <summary>
  7932. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7933. /// </summary>
  7934. /// <returns></returns>
  7935. [HttpPost]
  7936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7937. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7938. {
  7939. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7940. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7941. RefAsync<int> total = 0;
  7942. int diId = 0;
  7943. var status = int.TryParse(dto.GroupName, out diId);
  7944. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  7945. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7946. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7947. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7948. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7949. .OrderByDescending(x => x.VisitStartDate)
  7950. .Select(x => new EnterExitCostMobileGroupView()
  7951. {
  7952. Id = x.Id,
  7953. GroupName = x.TeamName,
  7954. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  7955. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  7956. })
  7957. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7958. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  7959. {
  7960. foreach (var item in data)
  7961. {
  7962. item.IsView = true;
  7963. }
  7964. }
  7965. return Ok(JsonView(true, "查询成功!", data, total));
  7966. }
  7967. /// <summary>
  7968. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7969. /// </summary>
  7970. /// <returns></returns>
  7971. [HttpPost]
  7972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7973. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7974. {
  7975. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7976. RefAsync<int> total = 0;
  7977. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7978. .Where(x => x.IsDel == 0 && x.STid == 66)
  7979. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7980. .Select(x => new
  7981. {
  7982. id = x.Id,
  7983. name = x.Name,
  7984. remark = x.Remark,
  7985. })
  7986. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7987. return Ok(JsonView(true, "查询成功!", data, total));
  7988. }
  7989. /// <summary>
  7990. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7991. /// </summary>
  7992. /// <returns></returns>
  7993. [HttpPost]
  7994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7995. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7996. {
  7997. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7998. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7999. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  8000. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  8001. var groupOtherRateData = groupRateData.TeamRates;
  8002. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8003. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8004. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8005. groupOtherRateData = groupOtherRateData
  8006. .Select(x => new TeamRateDescAddCurrencyIdView
  8007. {
  8008. CurrencyId = x.CurrencyId,
  8009. CurrencyName = x.CurrencyName,
  8010. CurrencyCode = x.CurrencyCode,
  8011. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8012. }).ToList();
  8013. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8014. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8015. }
  8016. /// <summary>
  8017. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8018. /// </summary>
  8019. /// <returns></returns>
  8020. [HttpPost]
  8021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8022. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8023. {
  8024. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8025. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8026. var tipsData = new List<int>() { 1, 2, 3 };
  8027. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8028. if (dto.TipsType == 1)
  8029. {
  8030. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8031. }
  8032. else if (dto.TipsType == 2)
  8033. {
  8034. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8035. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8036. }
  8037. else if (dto.TipsType == 3)
  8038. {
  8039. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8040. return Ok(JsonView(true, "查询成功!", airData.Data));
  8041. }
  8042. return Ok(JsonView(false));
  8043. }
  8044. /// <summary>
  8045. /// 团组模块 - 出入境国家费用标准-移动端 List
  8046. /// </summary>
  8047. /// <returns></returns>
  8048. [HttpPost]
  8049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8050. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8051. {
  8052. Stopwatch sw = new Stopwatch();
  8053. sw.Start();
  8054. RefAsync<int> total = 0;
  8055. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8056. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8057. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8058. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8059. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8060. .Select((ntf, sd, u) => new
  8061. {
  8062. Id = ntf.Id,
  8063. Area = $"{ntf.Country}-{ntf.City}",
  8064. Currency = ntf.Currency,
  8065. CurrencyCode = sd.Name,
  8066. CurrencyName = sd.Remark,
  8067. RoomCost = ntf.RoomCost,
  8068. FoodCost = ntf.FoodCost,
  8069. PublicCost = ntf.PublicCost,
  8070. LastUpdateUserId = ntf.LastUpdateUserId,
  8071. LastUpdateUserName = u.CnName,
  8072. LastUpdateTime = ntf.LastUpdateTime,
  8073. })
  8074. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8075. sw.Stop();
  8076. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8077. }
  8078. /// <summary>
  8079. /// 团组模块 - 出入境费用-移动端 - Info
  8080. /// </summary>
  8081. /// <returns></returns>
  8082. [HttpPost]
  8083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8084. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8085. {
  8086. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8087. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8088. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8089. return Ok(data);
  8090. }
  8091. /// <summary>
  8092. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8093. /// </summary>
  8094. /// <returns></returns>
  8095. [HttpPost]
  8096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8097. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8098. {
  8099. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8100. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8101. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8102. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8103. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8104. mobileInfo.DiId = dto.DiId;
  8105. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8106. if (eecInfo == null) return Ok(mobileInfo);
  8107. //验证查看权限
  8108. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8109. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8110. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8111. mobileInfo.IsAssignPerm = isSet;
  8112. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8113. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8114. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8115. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8116. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8117. {
  8118. SubId = dac.Id,
  8119. DiId = dac.DiId,
  8120. Type = dac.Type,
  8121. Days = dac.Days,
  8122. NationalTravelFeeId = dac.NationalTravelFeeId,
  8123. Arae = $"{ntf.Country}-{ntf.City}",
  8124. Cost = dac.Cost,
  8125. Currency = dac.Currency,
  8126. CurrencyName = sd.Name,
  8127. SubTotal = dac.SubTotal,
  8128. })
  8129. .ToList();
  8130. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8131. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8132. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8133. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8134. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8135. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8136. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8137. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8138. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8139. //其他款项
  8140. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8141. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8142. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8143. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8144. .OrderBy((dop, sd1, sd2) => dop.Index)
  8145. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8146. {
  8147. SubId = dop.Id,
  8148. DiId = dop.Diid,
  8149. Index = dop.Index,
  8150. SetDataId = dop.SetDataId,
  8151. SetDataName = sd1.Name,
  8152. Cost = dop.Cost,
  8153. Currency = dop.Currency,
  8154. CurrencyName = sd2.Remark,
  8155. SubTotal = dop.SubTotal,
  8156. Remark = dop.Remark,
  8157. })
  8158. .ToArray();
  8159. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8160. return Ok(mobileInfo);
  8161. }
  8162. /// <summary>
  8163. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8164. /// </summary>
  8165. /// <returns></returns>
  8166. [HttpPost]
  8167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8168. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8169. {
  8170. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8171. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8172. //验证查看权限
  8173. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8174. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8175. var userIds = await _sqlSugar
  8176. .Queryable<Grp_EnterExitCostPermission>()
  8177. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8178. .Select(x => x.UserId)
  8179. .ToArrayAsync();
  8180. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8181. var perUsersView = new List<dynamic>();
  8182. foreach (var item in perUsers)
  8183. {
  8184. bool isView1 = false;
  8185. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8186. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8187. }
  8188. return Ok(JsonView(perUsersView));
  8189. }
  8190. /// <summary>
  8191. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8192. /// </summary>
  8193. /// <returns></returns>
  8194. [HttpPost]
  8195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8196. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8197. {
  8198. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8199. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8200. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8201. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8202. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8203. //验证查看权限
  8204. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8205. //if (!isView) return Ok(JsonView(false, msg));
  8206. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8207. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8208. var subType = dto.SubType;
  8209. if (subType == 1) //1:境内费用
  8210. {
  8211. var oneData = new ChoiceOneMobileSubInfoView()
  8212. {
  8213. Id = eecInfo.Id,
  8214. ChoiceOne = eecInfo.ChoiceOne,
  8215. ChoiceOneTotalCost = eecInfo.InsidePay,
  8216. Visa = eecInfo.Visa,
  8217. VisaRemark = eecInfo.VisaRemark,
  8218. YiMiao = eecInfo.YiMiao,
  8219. HeSuan = eecInfo.HeSuan,
  8220. Service = eecInfo.Service,
  8221. Ticket = eecInfo.Ticket,
  8222. Safe = eecInfo.Safe,
  8223. FirstItemRemark = eecInfo.FirstItemRemark
  8224. };
  8225. return Ok(JsonView(oneData));
  8226. }
  8227. else if (subType == 2) //2:国际旅费
  8228. {
  8229. var twoData = new ChoiceTwoMobileSubInfoView()
  8230. {
  8231. Id = eecInfo.Id,
  8232. ChoiceTwoJJ = eecInfo.SumJJC,
  8233. OutsideJJPay = eecInfo.OutsideJJPay,
  8234. ChoiceTwoGW = eecInfo.SumGWC,
  8235. OutsideGWPay = eecInfo.OutsideGWPay,
  8236. ChoiceTwoTD = eecInfo.SumTDC,
  8237. OutsideTDPay = eecInfo.OutsideTDPay,
  8238. AirJJ = eecInfo.AirJJ,
  8239. AirGW = eecInfo.AirGW,
  8240. AirTD = eecInfo.AirTD,
  8241. CityTranffic = eecInfo.CityTranffic,
  8242. TwoItemRemark = eecInfo.TwoItemRemark
  8243. };
  8244. return Ok(JsonView(twoData));
  8245. }
  8246. else if (subType == 3) //3:住宿费
  8247. {
  8248. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8249. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8250. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8251. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8252. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8253. {
  8254. SubId = dac.Id,
  8255. DiId = dac.DiId,
  8256. Type = dac.Type,
  8257. Days = dac.Days,
  8258. NationalTravelFeeId = dac.NationalTravelFeeId,
  8259. Arae = $"{ntf.Country}-{ntf.City}",
  8260. Cost = dac.Cost,
  8261. Currency = dac.Currency,
  8262. CurrencyName = sd.Name,
  8263. SubTotal = dac.SubTotal,
  8264. })
  8265. .ToArray();
  8266. var data = new ChoiceMobileSubInfo3To6View()
  8267. {
  8268. ParentId = eecInfo.Id,
  8269. Choice = eecInfo.ChoiceThree,
  8270. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8271. Details = dayAndCostDatas
  8272. };
  8273. return Ok(JsonView(data));
  8274. }
  8275. else if (subType == 4) //4:伙食费
  8276. {
  8277. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8278. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8279. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8280. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8281. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8282. {
  8283. SubId = dac.Id,
  8284. DiId = dac.DiId,
  8285. Type = dac.Type,
  8286. Days = dac.Days,
  8287. NationalTravelFeeId = dac.NationalTravelFeeId,
  8288. Arae = $"{ntf.Country}-{ntf.City}",
  8289. Cost = dac.Cost,
  8290. Currency = dac.Currency,
  8291. CurrencyName = sd.Name,
  8292. SubTotal = dac.SubTotal,
  8293. })
  8294. .ToArray();
  8295. var data = new ChoiceMobileSubInfo3To6View()
  8296. {
  8297. ParentId = eecInfo.Id,
  8298. Choice = eecInfo.ChoiceFour,
  8299. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8300. Details = dayAndCostDatas
  8301. };
  8302. return Ok(JsonView(data));
  8303. }
  8304. else if (subType == 5) //5:公杂费
  8305. {
  8306. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8307. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8308. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8309. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8310. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8311. {
  8312. SubId = dac.Id,
  8313. DiId = dac.DiId,
  8314. Type = dac.Type,
  8315. Days = dac.Days,
  8316. NationalTravelFeeId = dac.NationalTravelFeeId,
  8317. Arae = $"{ntf.Country}-{ntf.City}",
  8318. Cost = dac.Cost,
  8319. Currency = dac.Currency,
  8320. CurrencyName = sd.Name,
  8321. SubTotal = dac.SubTotal,
  8322. })
  8323. .ToArray();
  8324. var data = new ChoiceMobileSubInfo3To6View()
  8325. {
  8326. ParentId = eecInfo.Id,
  8327. Choice = eecInfo.ChoiceFive,
  8328. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8329. Details = dayAndCostDatas
  8330. };
  8331. return Ok(JsonView(data));
  8332. }
  8333. else if (subType == 6) //6:培训费
  8334. {
  8335. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8336. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8337. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8338. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8339. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8340. {
  8341. SubId = dac.Id,
  8342. DiId = dac.DiId,
  8343. Type = dac.Type,
  8344. Days = dac.Days,
  8345. NationalTravelFeeId = dac.NationalTravelFeeId,
  8346. Arae = $"{ntf.Country}-{ntf.City}",
  8347. Cost = dac.Cost,
  8348. Currency = dac.Currency,
  8349. CurrencyName = sd.Name,
  8350. SubTotal = dac.SubTotal,
  8351. })
  8352. .ToArray();
  8353. var data = new ChoiceMobileSubInfo3To6View()
  8354. {
  8355. ParentId = eecInfo.Id,
  8356. Choice = eecInfo.ChoiceSix,
  8357. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8358. Details = dayAndCostDatas
  8359. };
  8360. return Ok(JsonView(data));
  8361. }
  8362. else if (subType == 7) //7:其他
  8363. {
  8364. //其他款项
  8365. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8366. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8367. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8368. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8369. .OrderBy((dop, sd1, sd2) => dop.Index)
  8370. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8371. {
  8372. SubId = dop.Id,
  8373. DiId = dop.Diid,
  8374. Index = dop.Index,
  8375. SetDataId = dop.SetDataId,
  8376. SetDataName = sd1.Name,
  8377. Cost = dop.Cost,
  8378. Currency = dop.Currency,
  8379. CurrencyName = sd2.Name,
  8380. SubTotal = dop.SubTotal,
  8381. Remark = dop.Remark,
  8382. })
  8383. .ToArray();
  8384. var data = new ChoiceSevenMobileSubInfoView()
  8385. {
  8386. ParentId = eecInfo.Id,
  8387. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8388. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8389. Details = otherData
  8390. };
  8391. return Ok(JsonView(data));
  8392. }
  8393. return Ok(JsonView(false));
  8394. }
  8395. #region op
  8396. /// <summary>
  8397. /// 移动端更新费用消息通知
  8398. /// </summary>
  8399. /// <param name="diid"></param>
  8400. /// <param name="id"></param>
  8401. /// <param name="currUserId"></param>
  8402. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8403. {
  8404. try
  8405. {
  8406. ////生成默认文件pdf并且通知人员
  8407. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8408. //{
  8409. // DiId = diid,
  8410. // ExportType = 1,
  8411. // SubTypeId = 1005
  8412. //}, "pdf");
  8413. ////发送通知
  8414. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8415. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8416. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8417. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8418. ////汇率信息记录
  8419. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8420. }
  8421. catch (Exception ex)
  8422. {
  8423. //记录日志
  8424. throw;
  8425. }
  8426. }
  8427. /// <summary>
  8428. /// 验证出入境费用数据是否存在
  8429. /// 不存在添加
  8430. /// </summary>
  8431. /// <param name="diId"></param>
  8432. /// <param name="currUserId"></param>
  8433. /// <returns></returns>
  8434. /// <exception cref="CustomException"></exception>
  8435. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8436. {
  8437. var parentId = 0;
  8438. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8439. if (info != null)
  8440. {
  8441. parentId = info.Id;
  8442. }
  8443. else
  8444. {
  8445. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8446. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8447. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8448. parentId = addId;
  8449. }
  8450. return parentId;
  8451. }
  8452. /// <summary>
  8453. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8454. /// </summary>
  8455. /// <returns></returns>
  8456. [HttpPost]
  8457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8458. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8459. {
  8460. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8461. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8462. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8463. //验证编辑权限
  8464. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8465. //if (!isEdit) return Ok(JsonView(false, msg));
  8466. var permissions = new List<Grp_EnterExitCostPermission>();
  8467. foreach (var userId in dto.UserIds)
  8468. {
  8469. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8470. }
  8471. if (permissions.Any())
  8472. {
  8473. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8474. {
  8475. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8476. }
  8477. _sqlSugar.BeginTran();
  8478. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8479. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8480. if (result < 1)
  8481. {
  8482. _sqlSugar.RollbackTran();
  8483. return Ok(JsonView(false));
  8484. }
  8485. _sqlSugar.CommitTran();
  8486. return Ok(JsonView(true));
  8487. }
  8488. return Ok(JsonView(false));
  8489. }
  8490. /// <summary>
  8491. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8492. /// </summary>
  8493. /// <returns></returns>
  8494. [HttpPost]
  8495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8496. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8497. {
  8498. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8499. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8500. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8501. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8502. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8503. int id = dto.Id;
  8504. if (id <= 0) //add
  8505. {
  8506. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8507. if (add < 1) return Ok(JsonView(false));
  8508. id = add;
  8509. }
  8510. else //update
  8511. {
  8512. ////验证编辑权限
  8513. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8514. //if (!isEdit) return Ok(JsonView(false, msg));
  8515. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8516. if (upd < 1) return Ok(JsonView(false));
  8517. }
  8518. #region 汇率变更时更改币种相关费用
  8519. var opDayCosts = new List<Grp_DayAndCost>();
  8520. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8521. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8522. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8523. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8524. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8525. .Select((dac, sd) => new
  8526. {
  8527. dac.Id,
  8528. dac.DiId,
  8529. CurrencyCode = sd.Name,
  8530. dac.Cost
  8531. })
  8532. .ToList();
  8533. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8534. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8535. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8536. .Select((dop, sd) => new
  8537. {
  8538. dop.Id,
  8539. dop.Diid,
  8540. CurrencyCode = sd.Name,
  8541. dop.Cost
  8542. })
  8543. .ToList();
  8544. if (dayCosts.Count > 0)
  8545. {
  8546. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8547. foreach (var dc in new_dayCosts)
  8548. {
  8549. var thisCurrency = dc.Key.ToUpper();
  8550. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8551. if (thisRate == 0.00M) continue;
  8552. foreach (var dcSub in dc)
  8553. {
  8554. opDayCosts.Add(new Grp_DayAndCost()
  8555. {
  8556. Id = dcSub.Id,
  8557. DiId = dcSub.DiId,
  8558. Cost = dcSub.Cost,
  8559. SubTotal = dcSub.Cost * thisRate,
  8560. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8561. });
  8562. }
  8563. }
  8564. if (opDayCosts.Count > 0)
  8565. {
  8566. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8567. }
  8568. }
  8569. if (dayOtherCosts.Count > 0)
  8570. {
  8571. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8572. foreach (var dc in new_dayOtherCosts)
  8573. {
  8574. var thisCurrency = dc.Key.ToUpper();
  8575. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8576. if (thisRate == 0.00M) continue;
  8577. foreach (var dcSub in dc)
  8578. {
  8579. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8580. {
  8581. Id = dcSub.Id,
  8582. Diid = dcSub.Diid,
  8583. Cost = dcSub.Cost,
  8584. SubTotal = dcSub.Cost * thisRate,
  8585. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8586. });
  8587. }
  8588. }
  8589. if (opDayOtherCosts.Count > 0)
  8590. {
  8591. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8592. }
  8593. }
  8594. #endregion
  8595. //消息通知
  8596. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8597. //汇率信息记录
  8598. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8599. return Ok(JsonView(new { parentId = id }));
  8600. }
  8601. /// <summary>
  8602. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8603. /// </summary>
  8604. /// <returns></returns>
  8605. [HttpPost]
  8606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8607. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8608. {
  8609. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8610. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8611. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8612. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8613. int id = dto.Id;
  8614. if (id <= 0) //add
  8615. {
  8616. checkboxInfo.CreateUserId = dto.CurrUserId;
  8617. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8618. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8619. if (add < 1) return Ok(JsonView(false));
  8620. }
  8621. else //update
  8622. {
  8623. ////验证编辑权限
  8624. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8625. //if (!isEdit) return Ok(JsonView(false, msg));
  8626. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8627. .UpdateColumns(x => new
  8628. {
  8629. x.ChoiceOne,
  8630. x.ChoiceTwo,
  8631. x.SumJJC,
  8632. x.SumGWC,
  8633. x.SumTDC,
  8634. x.ChoiceThree,
  8635. x.ChoiceFour,
  8636. x.ChoiceFive,
  8637. x.ChoiceSix,
  8638. x.OtherExpenses_Checked
  8639. })
  8640. .Where(x => x.Id == id)
  8641. .ExecuteCommandAsync();
  8642. if (upd < 1) return Ok(JsonView(false));
  8643. }
  8644. return Ok(JsonView(new { parentId = id }));
  8645. }
  8646. /// <summary>
  8647. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8648. /// </summary>
  8649. /// <returns></returns>
  8650. [HttpPost]
  8651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8652. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8653. {
  8654. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8655. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8656. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8657. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8658. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8659. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8660. var checkboxInfo = new Grp_EnterExitCost()
  8661. {
  8662. Id = id,
  8663. DiId = diId,
  8664. CreateUserId = currUserId
  8665. };
  8666. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8667. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8668. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8669. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8670. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8671. if (id <= 0) //add
  8672. {
  8673. checkboxInfo.CreateUserId = dto.CurrUserId;
  8674. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8675. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8676. if (add < 1) return Ok(JsonView(false));
  8677. }
  8678. else //update
  8679. {
  8680. ////验证编辑权限
  8681. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8682. //if (!isEdit) return Ok(JsonView(false, msg));
  8683. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8684. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8685. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8686. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8687. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8688. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8689. .Where(x => x.Id == id)
  8690. .ExecuteCommandAsync();
  8691. if (upd < 1) return Ok(JsonView(false));
  8692. }
  8693. return Ok(JsonView(new { parentId = id }));
  8694. }
  8695. /// <summary>
  8696. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8697. /// </summary>
  8698. /// <returns></returns>
  8699. [HttpPost]
  8700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8701. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8702. {
  8703. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8704. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8705. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8706. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8707. info.FirstItemRemark = dto.FirstItemRemark;
  8708. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8709. int id = dto.Id;
  8710. if (id <= 0) //add
  8711. {
  8712. info.CreateUserId = dto.CurrUserId;
  8713. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8714. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8715. if (add < 1) return Ok(JsonView(false));
  8716. id = add;
  8717. }
  8718. else //update
  8719. {
  8720. ////验证编辑权限
  8721. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8722. //if (!isEdit) return Ok(JsonView(false, msg));
  8723. var upd = await _sqlSugar.Updateable(info)
  8724. .UpdateColumns(x => new
  8725. {
  8726. x.ChoiceOne,
  8727. x.InsidePay,
  8728. x.VisaRemark,
  8729. x.Visa,
  8730. x.Service,
  8731. x.Safe,
  8732. x.Ticket,
  8733. x.HeSuan,
  8734. x.YiMiao,
  8735. x.FirstItemRemark
  8736. })
  8737. .Where(x => x.Id == id)
  8738. .ExecuteCommandAsync();
  8739. if (upd < 1) return Ok(JsonView(false));
  8740. }
  8741. //消息通知
  8742. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8743. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8744. }
  8745. /// <summary>
  8746. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8747. /// </summary>
  8748. /// <returns></returns>
  8749. [HttpPost]
  8750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8751. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8752. {
  8753. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8754. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8755. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8756. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8757. info.OutsideJJPay = dto.OutsideJJPay;
  8758. info.OutsideGWPay = dto.OutsideGWPay;
  8759. info.OutsideTDPay = dto.OutsideTDPay;
  8760. info.AirJJ = dto.AirJJ;
  8761. info.AirGW = dto.AirGW;
  8762. info.AirTD = dto.AirTD;
  8763. info.CityTranffic = dto.CityTranffic;
  8764. info.TwoItemRemark = dto.TwoItemRemark;
  8765. info.SumJJC = dto.ChoiceTwoJJ;
  8766. info.SumGWC = dto.ChoiceTwoGW;
  8767. info.SumTDC = dto.ChoiceTwoTD;
  8768. int id = dto.Id;
  8769. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8770. if (id <= 0) //add
  8771. {
  8772. info.CreateUserId = dto.CurrUserId;
  8773. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8774. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8775. if (addId <= 0) return Ok(JsonView(false));
  8776. id = addId;
  8777. }
  8778. else //update
  8779. {
  8780. ////验证编辑权限
  8781. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8782. //if (!isEdit) return Ok(JsonView(false, msg));
  8783. var upd = await _sqlSugar.Updateable(info)
  8784. .UpdateColumns(x => new
  8785. {
  8786. x.SumJJC,
  8787. x.OutsideJJPay,
  8788. x.SumGWC,
  8789. x.OutsideGWPay,
  8790. x.SumTDC,
  8791. x.OutsideTDPay,
  8792. x.AirJJ,
  8793. x.AirGW,
  8794. x.AirTD,
  8795. x.CityTranffic,
  8796. x.TwoItemRemark
  8797. })
  8798. .Where(x => x.Id == id)
  8799. .ExecuteCommandAsync();
  8800. if (upd < 1) return Ok(JsonView(false));
  8801. }
  8802. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8803. gwcItemTotal = info.AirGW + info.CityTranffic;
  8804. tdcItemTotal = info.AirTD + info.CityTranffic;
  8805. //消息通知
  8806. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8807. return Ok(JsonView(new
  8808. {
  8809. parentId = id,
  8810. choiceTwoJJ = dto.ChoiceTwoJJ,
  8811. jjcItemTotal = jjcItemTotal,
  8812. choiceTwoGW = dto.ChoiceTwoGW,
  8813. gwcItemTotal = gwcItemTotal,
  8814. choiceTwoTD = dto.ChoiceTwoTD,
  8815. tdcItemTotal = tdcItemTotal
  8816. }));
  8817. }
  8818. /// <summary>
  8819. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8820. /// </summary>
  8821. /// <returns></returns>
  8822. [HttpPost]
  8823. [ApiExplorerSettings(IgnoreApi = true)]
  8824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8825. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8826. {
  8827. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8828. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8829. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8830. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8831. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8832. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8833. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8834. var infos = infos1.Select(x => new Grp_DayAndCost
  8835. {
  8836. Id = x.Id,
  8837. DiId = dto.DiId,
  8838. Type = dto.FeeType,
  8839. Days = x.Days,
  8840. NationalTravelFeeId = x.NationalTravelFeeId,
  8841. Cost = x.Cost,
  8842. Currency = x.Currency,
  8843. SubTotal = x.SubTotal,
  8844. CreateUserId = dto.CurrUserId
  8845. })
  8846. .ToList();
  8847. var adds = infos.Where(x => x.Id <= 0).ToList();
  8848. var upds = infos.Where(x => x.Id > 0).ToList();
  8849. if (adds.Count > 0)
  8850. {
  8851. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8852. if (add < 1) return Ok(JsonView(false));
  8853. }
  8854. if (upds.Count > 0)
  8855. {
  8856. var upd = await _sqlSugar.Updateable(adds)
  8857. .UpdateColumns(x => new
  8858. {
  8859. x.Days,
  8860. x.NationalTravelFeeId,
  8861. x.Cost,
  8862. x.Currency,
  8863. x.SubTotal
  8864. })
  8865. .WhereColumns(x => new { x.Id })
  8866. .ExecuteCommandAsync();
  8867. if (upd < 1) return Ok(JsonView(false));
  8868. }
  8869. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8870. //消息通知
  8871. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8872. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8873. return Ok(JsonView(new { itemTotal = itemTotal }));
  8874. }
  8875. /// <summary>
  8876. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8877. /// </summary>
  8878. /// <returns></returns>
  8879. [HttpPost]
  8880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8881. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8882. {
  8883. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8884. int subId = dto.SubId, feeType = dto.FeeType;
  8885. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8886. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8887. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8888. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8889. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8890. subInfo.Id = subId;
  8891. subInfo.DiId = dto.DiId;
  8892. if (feeType == 3) subInfo.Type = 1;
  8893. else if (feeType == 4) subInfo.Type = 2;
  8894. else if (feeType == 5) subInfo.Type = 3;
  8895. else if (feeType == 6) subInfo.Type = 4;
  8896. subInfo.CreateUserId = dto.CurrUserId;
  8897. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8898. if (parentId < 1) return Ok(JsonView(false));
  8899. //子表op
  8900. if (subId < 1)
  8901. {
  8902. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8903. if (subAdd < 1) return Ok(JsonView(false));
  8904. }
  8905. else
  8906. {
  8907. ////验证编辑权限
  8908. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8909. //if (!isEdit) return Ok(JsonView(false, msg));
  8910. var subUpd = await _sqlSugar.Updateable(subInfo)
  8911. .UpdateColumns(x => new
  8912. {
  8913. x.Days,
  8914. x.NationalTravelFeeId,
  8915. x.Cost,
  8916. x.Currency,
  8917. x.SubTotal
  8918. })
  8919. .WhereColumns(x => new { x.Id })
  8920. .ExecuteCommandAsync();
  8921. if (subUpd < 1) return Ok(JsonView(false));
  8922. }
  8923. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8924. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8925. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8926. }
  8927. /// <summary>
  8928. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8929. /// </summary>
  8930. /// <returns></returns>
  8931. [HttpPost]
  8932. [ApiExplorerSettings(IgnoreApi = true)]
  8933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8934. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8935. {
  8936. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8937. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8938. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8939. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8940. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8941. {
  8942. Id = x.Id,
  8943. Diid = dto.DiId,
  8944. SetDataId = x.SetDataId,
  8945. Index = x.Index,
  8946. Cost = x.Cost,
  8947. Currency = x.Currency,
  8948. SubTotal = x.SubTotal,
  8949. CreateUserId = dto.CurrUserId,
  8950. Remark = x.Remark
  8951. }).ToList();
  8952. var adds = infos.Where(x => x.Id <= 0).ToList();
  8953. var upds = infos.Where(x => x.Id > 0).ToList();
  8954. if (adds.Count > 0)
  8955. {
  8956. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8957. if (add < 1) return Ok(JsonView(false));
  8958. }
  8959. if (upds.Count > 0)
  8960. {
  8961. var upd = await _sqlSugar.Updateable(adds)
  8962. .UpdateColumns(x => new
  8963. {
  8964. x.Index,
  8965. x.SetDataId,
  8966. x.Cost,
  8967. x.Currency,
  8968. x.SubTotal,
  8969. x.Remark
  8970. })
  8971. .WhereColumns(x => new { x.Id })
  8972. .ExecuteCommandAsync();
  8973. if (upd < 1) return Ok(JsonView(false));
  8974. }
  8975. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8976. //消息通知
  8977. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8978. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8979. return Ok(JsonView(new { itemTotal = itemTotal }));
  8980. }
  8981. /// <summary>
  8982. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8983. /// </summary>
  8984. /// <returns></returns>
  8985. [HttpPost]
  8986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8987. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8988. {
  8989. int subId = dto.SubId;
  8990. int diId = dto.Diid;
  8991. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8992. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8993. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8994. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8995. subInfo.Id = subId;
  8996. subInfo.Diid = dto.Diid;
  8997. subInfo.CreateUserId = dto.CurrUserId;
  8998. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8999. if (parentId < 1) return Ok(JsonView(false));
  9000. #region 子表op
  9001. if (subId < 1)//add
  9002. {
  9003. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9004. if (subAdd < 1) return Ok(JsonView(false));
  9005. }
  9006. else //upd
  9007. {
  9008. ////验证编辑权限
  9009. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9010. //if (!isEdit) return Ok(JsonView(false, msg));
  9011. var subUpd = await _sqlSugar.Updateable(subInfo)
  9012. .UpdateColumns(x => new
  9013. {
  9014. x.Index,
  9015. x.SetDataId,
  9016. x.Cost,
  9017. x.Currency,
  9018. x.SubTotal,
  9019. x.Remark
  9020. })
  9021. .WhereColumns(x => new { x.Id })
  9022. .ExecuteCommandAsync();
  9023. if (subUpd < 1) return Ok(JsonView(false));
  9024. }
  9025. #endregion
  9026. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9027. //消息通知
  9028. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9029. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9030. }
  9031. /// <summary>
  9032. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9033. /// </summary>
  9034. /// <returns></returns>
  9035. [HttpPost]
  9036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9037. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9038. {
  9039. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9040. if (data.Code != 0)
  9041. {
  9042. return Ok(JsonView(false, data.Msg));
  9043. }
  9044. return Ok(JsonView(true, "操作成功!", data.Data));
  9045. }
  9046. /// <summary>
  9047. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9048. /// </summary>
  9049. /// <param name="dto"></param>
  9050. /// <returns></returns>
  9051. [HttpPost]
  9052. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9053. {
  9054. var data = new Grp_DayOtherPrice()
  9055. {
  9056. Id = dto.Id,
  9057. IsDel = 1,
  9058. DeleteUserId = dto.DeleteUserId,
  9059. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9060. };
  9061. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9062. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9063. return Ok(JsonView(false, "删除失败!"));
  9064. }
  9065. #endregion
  9066. #endregion
  9067. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9068. /// <summary>
  9069. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9070. /// </summary>
  9071. /// <returns></returns>
  9072. [HttpPost]
  9073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9074. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9075. {
  9076. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9077. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9078. RefAsync<int> total = 0;
  9079. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9080. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9081. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9082. .Select(x => new
  9083. {
  9084. Id = x.Id,
  9085. DraftName = x.DraftName,
  9086. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9087. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9088. .Any()
  9089. })
  9090. .OrderByDescending(x => x.Id)
  9091. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9092. return Ok(JsonView(true, "查询成功!", data, total));
  9093. }
  9094. /// <summary>
  9095. /// 出入境费用-草稿 移动端
  9096. /// 获取币种基础数据(含逻辑处理)
  9097. /// </summary>
  9098. /// <returns></returns>
  9099. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9100. {
  9101. return await GeneralMethod.EnterExitCostInitRate();
  9102. }
  9103. /// <summary>
  9104. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9105. /// </summary>
  9106. /// <returns></returns>
  9107. [HttpPost]
  9108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9109. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9110. {
  9111. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9112. //SetDataInfoView
  9113. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9114. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9115. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9116. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9117. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9118. //默认币种显示
  9119. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9120. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9121. return Ok(JsonView(true, "查询成功!", new
  9122. {
  9123. WordTypeData = _WordTypeData,
  9124. ExcelTypeData = _ExcelTypeData,
  9125. CurrencyInit = _currencyInfos,
  9126. viewPermissionData = viewPermissionData
  9127. }));
  9128. }
  9129. /// <summary>
  9130. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9131. /// </summary>
  9132. /// <returns></returns>
  9133. [HttpPost]
  9134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9135. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9136. {
  9137. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9138. RefAsync<int> total = 0;
  9139. int diId = 0;
  9140. var status = int.TryParse(dto.GroupName, out diId);
  9141. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9142. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9143. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9144. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9145. .OrderByDescending(x => x.VisitStartDate)
  9146. .Select(x => new
  9147. {
  9148. Id = x.Id,
  9149. GroupName = x.TeamName
  9150. })
  9151. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9152. return Ok(JsonView(true, "查询成功!", data, total));
  9153. }
  9154. /// <summary>
  9155. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9156. /// </summary>
  9157. /// <returns></returns>
  9158. [HttpPost]
  9159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9160. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9161. {
  9162. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9163. RefAsync<int> total = 0;
  9164. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9165. .Where(x => x.IsDel == 0 && x.STid == 66)
  9166. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9167. .Select(x => new
  9168. {
  9169. id = x.Id,
  9170. name = x.Name,
  9171. remark = x.Remark,
  9172. })
  9173. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9174. return Ok(JsonView(true, "查询成功!", data, total));
  9175. }
  9176. /// <summary>
  9177. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9178. /// </summary>
  9179. /// <returns></returns>
  9180. [HttpPost]
  9181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9182. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9183. {
  9184. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9185. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9186. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  9187. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9188. var groupOtherRateData = groupRateData.TeamRates;
  9189. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9190. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9191. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9192. groupOtherRateData = groupOtherRateData
  9193. .Select(x => new TeamRateDescAddCurrencyIdView
  9194. {
  9195. CurrencyId = x.CurrencyId,
  9196. CurrencyName = x.CurrencyName,
  9197. CurrencyCode = x.CurrencyCode,
  9198. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9199. }).ToList();
  9200. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9201. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9202. }
  9203. /// <summary>
  9204. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9205. /// </summary>
  9206. /// <returns></returns>
  9207. [HttpPost]
  9208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9209. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9210. {
  9211. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9212. var tipsData = new List<int>() { 1, 2, 3 };
  9213. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9214. if (dto.TipsType == 1)
  9215. {
  9216. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9217. }
  9218. else if (dto.TipsType == 2)
  9219. {
  9220. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9221. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9222. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9223. .Select(x => x.NationalTravelFeeId)
  9224. .Distinct()
  9225. .ToListAsync();
  9226. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9227. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9228. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9229. .Select(x => x.Country)
  9230. .Distinct()
  9231. .ToArrayAsync();
  9232. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9233. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9234. return Ok(JsonView(true, "查询成功!", new
  9235. {
  9236. totalAmt = totalAmt,
  9237. remark = remark
  9238. }));
  9239. }
  9240. else if (dto.TipsType == 3)
  9241. {
  9242. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9243. }
  9244. return Ok(JsonView(false));
  9245. }
  9246. /// <summary>
  9247. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9248. /// </summary>
  9249. /// <returns></returns>
  9250. [HttpPost]
  9251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9252. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9253. {
  9254. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9255. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9256. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9257. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9258. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9259. var info = new Grp_EnterExitCostDraft() {
  9260. DraftName = dto.DraftName,
  9261. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9262. CreateUserId = dto.CurrUserId
  9263. };
  9264. _sqlSugar.BeginTran();
  9265. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9266. if (draftId < 1) {
  9267. _sqlSugar.RollbackTran();
  9268. return Ok(JsonView(false, "草稿创建失败!"));
  9269. }
  9270. //添加默认权限
  9271. await _enterExitCostDraftRep.InitPerm(draftId,dto.CurrUserId);
  9272. _sqlSugar.CommitTran();
  9273. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9274. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9275. mobileInfo.Id = draftId;
  9276. mobileInfo.DraftName = dto.DraftName;
  9277. mobileInfo.Currencys = rateInfos;
  9278. mobileInfo.IsAssignPerm = assignPerm;
  9279. return Ok(JsonView(mobileInfo));
  9280. }
  9281. /// <summary>
  9282. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9283. /// </summary>
  9284. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9285. /// <summary>
  9286. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9287. /// </summary>
  9288. /// <returns></returns>
  9289. [HttpPost]
  9290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9291. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9292. {
  9293. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9294. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9295. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9296. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9297. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9298. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9299. //验证查看编辑权限
  9300. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9301. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9302. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9303. mobileInfo.IsAssignPerm = assignPerm;
  9304. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9305. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9306. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9307. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9308. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9309. {
  9310. ParentId = dac.ParentId,
  9311. SubId = dac.Id,
  9312. Type = dac.Type,
  9313. Days = dac.Days,
  9314. NationalTravelFeeId = dac.NationalTravelFeeId,
  9315. Arae = $"{ntf.Country}-{ntf.City}",
  9316. Cost = dac.Cost,
  9317. Currency = dac.Currency,
  9318. CurrencyName = sd.Name,
  9319. SubTotal = dac.SubTotal,
  9320. })
  9321. .ToList();
  9322. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9323. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9324. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9325. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9326. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9327. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9328. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9329. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9330. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9331. //其他款项
  9332. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9333. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9334. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9335. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9336. .OrderBy((dop, sd1, sd2) => dop.Index)
  9337. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9338. {
  9339. ParentId = dop.ParentId,
  9340. SubId = dop.Id,
  9341. Index = dop.Index,
  9342. SetDataId = dop.SetDataId,
  9343. SetDataName = sd1.Name,
  9344. Cost = dop.Cost,
  9345. Currency = dop.Currency,
  9346. CurrencyName = sd2.Remark,
  9347. SubTotal = dop.SubTotal,
  9348. Remark = dop.Remark,
  9349. })
  9350. .ToArray();
  9351. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9352. return Ok(mobileInfo);
  9353. }
  9354. /// <summary>
  9355. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9356. /// </summary>
  9357. /// <returns></returns>
  9358. [HttpPost]
  9359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9360. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9361. {
  9362. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9363. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9364. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9365. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9366. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9367. //验证查看编辑权限
  9368. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9369. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9370. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9371. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9372. var subType = dto.SubType;
  9373. if (subType == 1) //1:境内费用
  9374. {
  9375. var oneData = new ChoiceOneMobileSubInfoView()
  9376. {
  9377. Id = eecInfo.Id,
  9378. ChoiceOne = eecInfo.ChoiceOne,
  9379. ChoiceOneTotalCost = eecInfo.InsidePay,
  9380. Visa = eecInfo.Visa,
  9381. VisaRemark = eecInfo.VisaRemark,
  9382. YiMiao = eecInfo.YiMiao,
  9383. HeSuan = eecInfo.HeSuan,
  9384. Service = eecInfo.Service,
  9385. Ticket = eecInfo.Ticket,
  9386. Safe = eecInfo.Safe,
  9387. FirstItemRemark = eecInfo.FirstItemRemark
  9388. };
  9389. return Ok(JsonView(oneData));
  9390. }
  9391. else if (subType == 2) //2:国际旅费
  9392. {
  9393. var twoData = new ChoiceTwoMobileSubInfoView()
  9394. {
  9395. Id = eecInfo.Id,
  9396. ChoiceTwoJJ = eecInfo.SumJJC,
  9397. OutsideJJPay = eecInfo.OutsideJJPay,
  9398. ChoiceTwoGW = eecInfo.SumGWC,
  9399. OutsideGWPay = eecInfo.OutsideGWPay,
  9400. ChoiceTwoTD = eecInfo.SumTDC,
  9401. OutsideTDPay = eecInfo.OutsideTDPay,
  9402. AirJJ = eecInfo.AirJJ,
  9403. AirGW = eecInfo.AirGW,
  9404. AirTD = eecInfo.AirTD,
  9405. CityTranffic = eecInfo.CityTranffic,
  9406. TwoItemRemark = eecInfo.TwoItemRemark
  9407. };
  9408. return Ok(JsonView(twoData));
  9409. }
  9410. else if (subType == 3) //3:住宿费
  9411. {
  9412. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9413. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9414. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9415. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9416. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9417. {
  9418. ParentId = dac.ParentId,
  9419. SubId = dac.Id,
  9420. Type = dac.Type,
  9421. Days = dac.Days,
  9422. NationalTravelFeeId = dac.NationalTravelFeeId,
  9423. Arae = $"{ntf.Country}-{ntf.City}",
  9424. Cost = dac.Cost,
  9425. Currency = dac.Currency,
  9426. CurrencyName = sd.Name,
  9427. SubTotal = dac.SubTotal,
  9428. })
  9429. .ToArray();
  9430. var data = new ChoiceDraftMobileSubInfo3To6View()
  9431. {
  9432. ParentId = eecInfo.Id,
  9433. Choice = eecInfo.ChoiceThree,
  9434. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9435. Details = dayAndCostDatas
  9436. };
  9437. return Ok(JsonView(data));
  9438. }
  9439. else if (subType == 4) //4:伙食费
  9440. {
  9441. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9442. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9443. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9444. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9445. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9446. {
  9447. ParentId = dac.ParentId,
  9448. SubId = dac.Id,
  9449. Type = dac.Type,
  9450. Days = dac.Days,
  9451. NationalTravelFeeId = dac.NationalTravelFeeId,
  9452. Arae = $"{ntf.Country}-{ntf.City}",
  9453. Cost = dac.Cost,
  9454. Currency = dac.Currency,
  9455. CurrencyName = sd.Name,
  9456. SubTotal = dac.SubTotal,
  9457. })
  9458. .ToArray();
  9459. var data = new ChoiceDraftMobileSubInfo3To6View()
  9460. {
  9461. ParentId = eecInfo.Id,
  9462. Choice = eecInfo.ChoiceFour,
  9463. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9464. Details = dayAndCostDatas
  9465. };
  9466. return Ok(JsonView(data));
  9467. }
  9468. else if (subType == 5) //5:公杂费
  9469. {
  9470. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9471. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9472. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9473. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9474. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9475. {
  9476. ParentId = dac.ParentId,
  9477. SubId = dac.Id,
  9478. Type = dac.Type,
  9479. Days = dac.Days,
  9480. NationalTravelFeeId = dac.NationalTravelFeeId,
  9481. Arae = $"{ntf.Country}-{ntf.City}",
  9482. Cost = dac.Cost,
  9483. Currency = dac.Currency,
  9484. CurrencyName = sd.Name,
  9485. SubTotal = dac.SubTotal,
  9486. })
  9487. .ToArray();
  9488. var data = new ChoiceDraftMobileSubInfo3To6View()
  9489. {
  9490. ParentId = eecInfo.Id,
  9491. Choice = eecInfo.ChoiceFive,
  9492. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9493. Details = dayAndCostDatas
  9494. };
  9495. return Ok(JsonView(data));
  9496. }
  9497. else if (subType == 6) //6:培训费
  9498. {
  9499. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9500. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9501. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9502. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9503. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9504. {
  9505. ParentId = dac.ParentId,
  9506. SubId = dac.Id,
  9507. Type = dac.Type,
  9508. Days = dac.Days,
  9509. NationalTravelFeeId = dac.NationalTravelFeeId,
  9510. Arae = $"{ntf.Country}-{ntf.City}",
  9511. Cost = dac.Cost,
  9512. Currency = dac.Currency,
  9513. CurrencyName = sd.Name,
  9514. SubTotal = dac.SubTotal,
  9515. })
  9516. .ToArray();
  9517. var data = new ChoiceDraftMobileSubInfo3To6View()
  9518. {
  9519. ParentId = eecInfo.Id,
  9520. Choice = eecInfo.ChoiceSix,
  9521. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9522. Details = dayAndCostDatas
  9523. };
  9524. return Ok(JsonView(data));
  9525. }
  9526. else if (subType == 7) //7:其他
  9527. {
  9528. //其他款项
  9529. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9530. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9531. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9532. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9533. .OrderBy((dop, sd1, sd2) => dop.Index)
  9534. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9535. {
  9536. ParentId = dop.ParentId,
  9537. SubId = dop.Id,
  9538. Index = dop.Index,
  9539. SetDataId = dop.SetDataId,
  9540. SetDataName = sd1.Name,
  9541. Cost = dop.Cost,
  9542. Currency = dop.Currency,
  9543. CurrencyName = sd2.Name,
  9544. SubTotal = dop.SubTotal,
  9545. Remark = dop.Remark,
  9546. })
  9547. .ToArray();
  9548. var data = new ChoiceSevenDraftMobileSubInfoView()
  9549. {
  9550. ParentId = eecInfo.Id,
  9551. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9552. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9553. Details = otherData
  9554. };
  9555. return Ok(JsonView(data));
  9556. }
  9557. return Ok(JsonView(false));
  9558. }
  9559. #region op
  9560. /// <summary>
  9561. /// 移动端更新费用消息通知
  9562. /// </summary>
  9563. /// <param name="draftId"></param>
  9564. /// <param name="id"></param>
  9565. /// <param name="currUserId"></param>
  9566. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9567. {
  9568. try
  9569. {
  9570. ////生成默认文件pdf并且通知人员
  9571. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9572. //{
  9573. // DiId = draftId,
  9574. // ExportType = 1,
  9575. // SubTypeId = 1005
  9576. //}, "pdf");
  9577. ////发送通知
  9578. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9579. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9580. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9581. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9582. ////汇率信息记录
  9583. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9584. }
  9585. catch (Exception ex)
  9586. {
  9587. //记录日志
  9588. throw;
  9589. }
  9590. }
  9591. /// <summary>
  9592. /// 验证出入境费用数据是否存在
  9593. /// 不存在添加
  9594. /// </summary>
  9595. /// <param name="draftId"></param>
  9596. /// <param name="currUserId"></param>
  9597. /// <returns></returns>
  9598. /// <exception cref="CustomException"></exception>
  9599. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9600. {
  9601. var parentId = 0;
  9602. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9603. if (info != null) parentId = info.Id;
  9604. else
  9605. {
  9606. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9607. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9608. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9609. parentId = addId;
  9610. }
  9611. return parentId;
  9612. }
  9613. /// <summary>
  9614. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  9615. /// </summary>
  9616. /// <returns></returns>
  9617. [HttpPost]
  9618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9619. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  9620. {
  9621. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9622. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9623. //验证查看权限
  9624. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9625. if (!isView) return Ok(JsonView(false, _viewPermStr));
  9626. var userIds = await _sqlSugar
  9627. .Queryable<Grp_EnterExitCostDraftPermission>()
  9628. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  9629. .Select(x => x.UserId)
  9630. .ToArrayAsync();
  9631. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9632. var perUsersView = new List<dynamic>();
  9633. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  9634. var viewPermissionData = new List<PermissionViewUserview>();
  9635. if (feeBasePerm.Any())
  9636. {
  9637. foreach (var item in feeBasePerm)
  9638. {
  9639. if (item.Users.Any())
  9640. {
  9641. viewPermissionData.AddRange(item.Users);
  9642. }
  9643. }
  9644. }
  9645. foreach (var item in perUsers)
  9646. {
  9647. bool isView1 = false;
  9648. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9649. else if (viewPermissionData.Any(x => x.Id ==dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  9650. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9651. }
  9652. return Ok(JsonView(perUsersView));
  9653. }
  9654. /// <summary>
  9655. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9656. /// </summary>
  9657. /// <returns></returns>
  9658. [HttpPost]
  9659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9660. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9661. {
  9662. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9663. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9664. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9665. //验证查看编辑权限
  9666. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9667. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9668. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  9669. foreach (var userId in dto.UserIds)
  9670. {
  9671. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9672. }
  9673. if (permissions.Any())
  9674. {
  9675. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9676. {
  9677. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9678. }
  9679. _sqlSugar.BeginTran();
  9680. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9681. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9682. if (result < 1)
  9683. {
  9684. _sqlSugar.RollbackTran();
  9685. return Ok(JsonView(false));
  9686. }
  9687. _sqlSugar.CommitTran();
  9688. return Ok(JsonView(true));
  9689. }
  9690. return Ok(JsonView(false));
  9691. }
  9692. /// <summary>
  9693. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9694. /// </summary>
  9695. /// <returns></returns>
  9696. [HttpPost]
  9697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9698. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9699. {
  9700. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9701. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9702. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9703. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9704. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9705. int id = dto.DraftId;
  9706. if (id <= 0) //add
  9707. {
  9708. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9709. if (add < 1) return Ok(JsonView(false));
  9710. id = add;
  9711. }
  9712. else //update
  9713. {
  9714. //验证查看编辑权限
  9715. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9716. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9717. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9718. if (upd < 1) return Ok(JsonView(false));
  9719. }
  9720. #region 汇率变更时更改币种相关费用
  9721. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9722. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9723. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9724. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9725. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9726. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9727. .Select((dac, sd) => new
  9728. {
  9729. dac.Id,
  9730. dac.ParentId,
  9731. CurrencyCode = sd.Name,
  9732. dac.Cost
  9733. })
  9734. .ToList();
  9735. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9736. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9737. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9738. .Select((dop, sd) => new
  9739. {
  9740. dop.Id,
  9741. dop.ParentId,
  9742. CurrencyCode = sd.Name,
  9743. dop.Cost
  9744. })
  9745. .ToList();
  9746. if (dayCosts.Count > 0)
  9747. {
  9748. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9749. foreach (var dc in new_dayCosts)
  9750. {
  9751. var thisCurrency = dc.Key.ToUpper();
  9752. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9753. if (thisRate == 0.00M) continue;
  9754. foreach (var dcSub in dc)
  9755. {
  9756. opDayCosts.Add(new Grp_DayAndCostDraft()
  9757. {
  9758. Id = dcSub.Id,
  9759. ParentId = dcSub.ParentId,
  9760. Cost = dcSub.Cost,
  9761. SubTotal = dcSub.Cost * thisRate,
  9762. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9763. });
  9764. }
  9765. }
  9766. if (opDayCosts.Count > 0)
  9767. {
  9768. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9769. }
  9770. }
  9771. if (dayOtherCosts.Count > 0)
  9772. {
  9773. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9774. foreach (var dc in new_dayOtherCosts)
  9775. {
  9776. var thisCurrency = dc.Key.ToUpper();
  9777. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9778. if (thisRate == 0.00M) continue;
  9779. foreach (var dcSub in dc)
  9780. {
  9781. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9782. {
  9783. Id = dcSub.Id,
  9784. ParentId = dcSub.ParentId,
  9785. Cost = dcSub.Cost,
  9786. SubTotal = dcSub.Cost * thisRate,
  9787. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9788. });
  9789. }
  9790. }
  9791. if (opDayOtherCosts.Count > 0)
  9792. {
  9793. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9794. }
  9795. }
  9796. #endregion
  9797. ////消息通知
  9798. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9799. ////汇率信息记录
  9800. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9801. return Ok(JsonView(new { parentId = id }));
  9802. }
  9803. /// <summary>
  9804. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9805. /// </summary>
  9806. /// <returns></returns>
  9807. [HttpPost]
  9808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9809. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9810. {
  9811. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9812. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9813. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9814. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9815. int id = dto.DraftId;
  9816. if (id <= 0) //add
  9817. {
  9818. checkboxInfo.CreateUserId = dto.CurrUserId;
  9819. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9820. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9821. if (add < 1) return Ok(JsonView(false));
  9822. }
  9823. else //update
  9824. {
  9825. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9826. .UpdateColumns(x => new
  9827. {
  9828. x.ChoiceOne,
  9829. x.ChoiceTwo,
  9830. x.SumJJC,
  9831. x.SumGWC,
  9832. x.SumTDC,
  9833. x.ChoiceThree,
  9834. x.ChoiceFour,
  9835. x.ChoiceFive,
  9836. x.ChoiceSix,
  9837. x.OtherExpenses_Checked
  9838. })
  9839. .Where(x => x.Id == id)
  9840. .ExecuteCommandAsync();
  9841. if (upd < 1) return Ok(JsonView(false));
  9842. }
  9843. return Ok(JsonView(new { parentId = id }));
  9844. }
  9845. /// <summary>
  9846. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9847. /// </summary>
  9848. /// <returns></returns>
  9849. [HttpPost]
  9850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9851. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9852. {
  9853. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9854. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9855. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9856. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9857. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9858. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9859. var checkboxInfo = new Grp_EnterExitCostDraft()
  9860. {
  9861. Id = draftId,
  9862. CreateUserId = currUserId
  9863. };
  9864. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9865. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9866. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9867. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9868. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9869. if (draftId <= 0) //add
  9870. {
  9871. checkboxInfo.CreateUserId = dto.CurrUserId;
  9872. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9873. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9874. if (add < 1) return Ok(JsonView(false));
  9875. }
  9876. else //update
  9877. {
  9878. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9879. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9880. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9881. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9882. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9883. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9884. .Where(x => x.Id == draftId)
  9885. .ExecuteCommandAsync();
  9886. if (upd < 1) return Ok(JsonView(false));
  9887. }
  9888. return Ok(JsonView(new { parentId = draftId }));
  9889. }
  9890. /// <summary>
  9891. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9892. /// </summary>
  9893. /// <returns></returns>
  9894. [HttpPost]
  9895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9896. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9897. {
  9898. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9899. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9900. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9901. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9902. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9903. info.FirstItemRemark = dto.FirstItemRemark;
  9904. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9905. if (id <= 0) //add
  9906. {
  9907. info.CreateUserId = dto.CurrUserId;
  9908. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9909. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9910. if (add < 1) return Ok(JsonView(false));
  9911. id = add;
  9912. }
  9913. else //update
  9914. {
  9915. var upd = await _sqlSugar.Updateable(info)
  9916. .UpdateColumns(x => new
  9917. {
  9918. x.ChoiceOne,
  9919. x.InsidePay,
  9920. x.VisaRemark,
  9921. x.Visa,
  9922. x.Service,
  9923. x.Safe,
  9924. x.Ticket,
  9925. x.HeSuan,
  9926. x.YiMiao,
  9927. x.FirstItemRemark
  9928. })
  9929. .Where(x => x.Id == id)
  9930. .ExecuteCommandAsync();
  9931. if (upd < 1) return Ok(JsonView(false));
  9932. }
  9933. ////消息通知
  9934. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9935. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9936. }
  9937. /// <summary>
  9938. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9939. /// </summary>
  9940. /// <returns></returns>
  9941. [HttpPost]
  9942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9943. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9944. {
  9945. int id = dto.DraftId;
  9946. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9947. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9948. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9949. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9950. info.OutsideJJPay = dto.OutsideJJPay;
  9951. info.OutsideGWPay = dto.OutsideGWPay;
  9952. info.OutsideTDPay = dto.OutsideTDPay;
  9953. info.AirJJ = dto.AirJJ;
  9954. info.AirGW = dto.AirGW;
  9955. info.AirTD = dto.AirTD;
  9956. info.CityTranffic = dto.CityTranffic;
  9957. info.TwoItemRemark = dto.TwoItemRemark;
  9958. info.SumJJC = dto.ChoiceTwoJJ;
  9959. info.SumGWC = dto.ChoiceTwoGW;
  9960. info.SumTDC = dto.ChoiceTwoTD;
  9961. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9962. if (id <= 0) //add
  9963. {
  9964. info.CreateUserId = dto.CurrUserId;
  9965. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9966. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9967. if (addId <= 0) return Ok(JsonView(false));
  9968. id = addId;
  9969. }
  9970. else //update
  9971. {
  9972. var upd = await _sqlSugar.Updateable(info)
  9973. .UpdateColumns(x => new
  9974. {
  9975. x.SumJJC,
  9976. x.OutsideJJPay,
  9977. x.SumGWC,
  9978. x.OutsideGWPay,
  9979. x.SumTDC,
  9980. x.OutsideTDPay,
  9981. x.AirJJ,
  9982. x.AirGW,
  9983. x.AirTD,
  9984. x.CityTranffic,
  9985. x.TwoItemRemark
  9986. })
  9987. .Where(x => x.Id == id)
  9988. .ExecuteCommandAsync();
  9989. if (upd < 1) return Ok(JsonView(false));
  9990. }
  9991. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9992. gwcItemTotal = info.AirGW + info.CityTranffic;
  9993. tdcItemTotal = info.AirTD + info.CityTranffic;
  9994. ////消息通知
  9995. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9996. return Ok(JsonView(new
  9997. {
  9998. parentId = id,
  9999. choiceTwoJJ = dto.ChoiceTwoJJ,
  10000. jjcItemTotal = jjcItemTotal,
  10001. choiceTwoGW = dto.ChoiceTwoGW,
  10002. gwcItemTotal = gwcItemTotal,
  10003. choiceTwoTD = dto.ChoiceTwoTD,
  10004. tdcItemTotal = tdcItemTotal
  10005. }));
  10006. }
  10007. /// <summary>
  10008. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10009. /// </summary>
  10010. /// <returns></returns>
  10011. [HttpPost]
  10012. [ApiExplorerSettings(IgnoreApi = true)]
  10013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10014. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10015. {
  10016. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10017. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10018. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10019. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10020. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10021. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10022. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10023. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10024. {
  10025. Id = x.Id,
  10026. ParentId = dto.DraftId,
  10027. Type = dto.FeeType,
  10028. Days = x.Days,
  10029. NationalTravelFeeId = x.NationalTravelFeeId,
  10030. Cost = x.Cost,
  10031. Currency = x.Currency,
  10032. SubTotal = x.SubTotal,
  10033. CreateUserId = dto.CurrUserId
  10034. })
  10035. .ToList();
  10036. var adds = infos.Where(x => x.Id <= 0).ToList();
  10037. var upds = infos.Where(x => x.Id > 0).ToList();
  10038. if (adds.Count > 0)
  10039. {
  10040. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10041. if (add < 1) return Ok(JsonView(false));
  10042. }
  10043. if (upds.Count > 0)
  10044. {
  10045. var upd = await _sqlSugar.Updateable(adds)
  10046. .UpdateColumns(x => new
  10047. {
  10048. x.Days,
  10049. x.NationalTravelFeeId,
  10050. x.Cost,
  10051. x.Currency,
  10052. x.SubTotal
  10053. })
  10054. .WhereColumns(x => new { x.Id })
  10055. .ExecuteCommandAsync();
  10056. if (upd < 1) return Ok(JsonView(false));
  10057. }
  10058. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10059. ////消息通知
  10060. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10061. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10062. return Ok(JsonView(new { itemTotal = itemTotal }));
  10063. }
  10064. /// <summary>
  10065. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10066. /// </summary>
  10067. /// <returns></returns>
  10068. [HttpPost]
  10069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10070. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10071. {
  10072. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10073. int subId = dto.SubId, feeType = dto.FeeType;
  10074. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10075. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10076. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10077. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10078. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10079. subInfo.Id = subId;
  10080. subInfo.ParentId = dto.DraftId;
  10081. if (feeType == 3) subInfo.Type = 1;
  10082. else if (feeType == 4) subInfo.Type = 2;
  10083. else if (feeType == 5) subInfo.Type = 3;
  10084. else if (feeType == 6) subInfo.Type = 4;
  10085. subInfo.CreateUserId = dto.CurrUserId;
  10086. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10087. if (parentId < 1) return Ok(JsonView(false));
  10088. //子表op
  10089. if (subId < 1)
  10090. {
  10091. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10092. if (subAdd < 1) return Ok(JsonView(false));
  10093. }
  10094. else
  10095. {
  10096. var subUpd = await _sqlSugar.Updateable(subInfo)
  10097. .UpdateColumns(x => new
  10098. {
  10099. x.Days,
  10100. x.NationalTravelFeeId,
  10101. x.Cost,
  10102. x.Currency,
  10103. x.SubTotal
  10104. })
  10105. .WhereColumns(x => new { x.Id })
  10106. .ExecuteCommandAsync();
  10107. if (subUpd < 1) return Ok(JsonView(false));
  10108. }
  10109. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10110. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10111. }
  10112. /// <summary>
  10113. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10114. /// </summary>
  10115. /// <returns></returns>
  10116. [HttpPost]
  10117. [ApiExplorerSettings(IgnoreApi = true)]
  10118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10119. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10120. {
  10121. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10122. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10123. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10124. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10125. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10126. {
  10127. Id = x.Id,
  10128. ParentId = dto.DraftId,
  10129. SetDataId = x.SetDataId,
  10130. Index = x.Index,
  10131. Cost = x.Cost,
  10132. Currency = x.Currency,
  10133. SubTotal = x.SubTotal,
  10134. CreateUserId = dto.CurrUserId,
  10135. Remark = x.Remark
  10136. }).ToList();
  10137. var adds = infos.Where(x => x.Id <= 0).ToList();
  10138. var upds = infos.Where(x => x.Id > 0).ToList();
  10139. if (adds.Count > 0)
  10140. {
  10141. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10142. if (add < 1) return Ok(JsonView(false));
  10143. }
  10144. if (upds.Count > 0)
  10145. {
  10146. var upd = await _sqlSugar.Updateable(adds)
  10147. .UpdateColumns(x => new
  10148. {
  10149. x.Index,
  10150. x.SetDataId,
  10151. x.Cost,
  10152. x.Currency,
  10153. x.SubTotal,
  10154. x.Remark
  10155. })
  10156. .WhereColumns(x => new { x.Id })
  10157. .ExecuteCommandAsync();
  10158. if (upd < 1) return Ok(JsonView(false));
  10159. }
  10160. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10161. //消息通知
  10162. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10163. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10164. return Ok(JsonView(new { itemTotal = itemTotal }));
  10165. }
  10166. /// <summary>
  10167. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10168. /// </summary>
  10169. /// <returns></returns>
  10170. [HttpPost]
  10171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10172. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10173. {
  10174. int subId = dto.SubId, id = dto.DraftId;
  10175. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10176. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10177. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10178. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10179. subInfo.Id = subId;
  10180. subInfo.ParentId = id;
  10181. subInfo.CreateUserId = dto.CurrUserId;
  10182. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10183. if (parentId < 1) return Ok(JsonView(false));
  10184. #region 子表op
  10185. if (subId < 1)//add
  10186. {
  10187. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10188. if (subAdd < 1) return Ok(JsonView(false));
  10189. }
  10190. else //upd
  10191. {
  10192. var subUpd = await _sqlSugar.Updateable(subInfo)
  10193. .UpdateColumns(x => new
  10194. {
  10195. x.Index,
  10196. x.SetDataId,
  10197. x.Cost,
  10198. x.Currency,
  10199. x.SubTotal,
  10200. x.Remark
  10201. })
  10202. .WhereColumns(x => new { x.Id })
  10203. .ExecuteCommandAsync();
  10204. if (subUpd < 1) return Ok(JsonView(false));
  10205. }
  10206. #endregion
  10207. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10208. ////消息通知
  10209. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10210. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10211. }
  10212. /// <summary>
  10213. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10214. /// </summary>
  10215. /// <returns></returns>
  10216. [HttpPost]
  10217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10218. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10219. {
  10220. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10221. if (data.Code != 0)
  10222. {
  10223. return Ok(JsonView(false, data.Msg));
  10224. }
  10225. return Ok(JsonView(true, "操作成功!", data.Data));
  10226. }
  10227. /// <summary>
  10228. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10229. /// </summary>
  10230. /// <param name="dto"></param>
  10231. /// <returns></returns>
  10232. [HttpPost]
  10233. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10234. {
  10235. var data = new Grp_DayOtherPriceDraft()
  10236. {
  10237. Id = dto.Id,
  10238. IsDel = 1,
  10239. DeleteUserId = dto.DeleteUserId,
  10240. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10241. };
  10242. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10243. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10244. return Ok(JsonView(false, "删除失败!"));
  10245. }
  10246. #endregion
  10247. #endregion
  10248. #region 团组经理模块 出入境费用报价表
  10249. /// <summary>
  10250. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10251. /// </summary>
  10252. /// <returns></returns>
  10253. [HttpPost]
  10254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10255. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10256. {
  10257. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10258. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10259. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10260. initRates.Insert(0, cnyInfo);
  10261. liveRates.Insert(0, cnyInfo);
  10262. return Ok(JsonView(true, "查询成功!", new
  10263. {
  10264. InitRates = initRates,
  10265. LiveRates = liveRates
  10266. }));
  10267. }
  10268. /// <summary>
  10269. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10270. /// </summary>
  10271. /// <returns></returns>
  10272. [HttpPost]
  10273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10274. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10275. {
  10276. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10277. }
  10278. /// <summary>
  10279. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10280. /// </summary>
  10281. /// <returns></returns>
  10282. [HttpPost]
  10283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10284. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10285. {
  10286. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10287. }
  10288. /// <summary>
  10289. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10290. /// </summary>
  10291. /// <returns></returns>
  10292. [HttpPost]
  10293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10294. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10295. {
  10296. int groupId = dto.DiId,
  10297. currUserId = dto.CurrUserId;
  10298. if (groupId < 1) return Ok(JsonView(false,"请传入有效的GroupId;"));
  10299. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10300. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10301. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10302. var infoView = info.Data as EnterExitCostInfoView;
  10303. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10304. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10305. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10306. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10307. var eecRates = infoView.Currencys;
  10308. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10309. int pplNum = 1;
  10310. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10311. var views = new List<QuoteSubItemInfo>();
  10312. #region 数据填充
  10313. var intTravelCosts = new List<QuoteSubItemInfo>();
  10314. #region 机票费用 1354
  10315. int intTravelIndex = 1;
  10316. if (infoView.SumJJC == 1)
  10317. {
  10318. intTravelCosts.Add(new QuoteSubItemInfo
  10319. {
  10320. ItemId = 1354,
  10321. Index = intTravelIndex,
  10322. FeeName = "经济舱",
  10323. UnitPrice = infoView.AirJJ,
  10324. Currency = "CNY",
  10325. Quantity = 1,
  10326. PplNum = 1,
  10327. TotalAmt = infoView.AirJJ,
  10328. Remark = "",
  10329. });
  10330. intTravelIndex++;
  10331. }
  10332. if (infoView.SumGWC == 1)
  10333. {
  10334. intTravelCosts.Add(new QuoteSubItemInfo
  10335. {
  10336. ItemId = 1354,
  10337. Index = intTravelIndex,
  10338. FeeName = "公务舱",
  10339. UnitPrice = infoView.AirGW,
  10340. Currency = "CNY",
  10341. Quantity = 1,
  10342. PplNum = 1,
  10343. TotalAmt = infoView.AirGW,
  10344. Remark = "",
  10345. });
  10346. intTravelIndex++;
  10347. }
  10348. if (infoView.SumTDC == 1)
  10349. {
  10350. intTravelCosts.Add(new QuoteSubItemInfo
  10351. {
  10352. ItemId = 1354,
  10353. Index = intTravelIndex,
  10354. FeeName = "头等舱",
  10355. UnitPrice = infoView.AirTD,
  10356. Currency = "CNY",
  10357. Quantity = 1,
  10358. PplNum = 1,
  10359. TotalAmt = infoView.AirTD,
  10360. Remark = "",
  10361. });
  10362. intTravelIndex++;
  10363. }
  10364. intTravelCosts.Add(new QuoteSubItemInfo
  10365. {
  10366. ItemId = 1354,
  10367. Index = intTravelIndex,
  10368. FeeName = "城市间交通费用",
  10369. UnitPrice = infoView.CityTranffic,
  10370. Currency = "CNY",
  10371. Quantity = 1,
  10372. PplNum = pplNum,
  10373. TotalAmt = infoView.CityTranffic * pplNum,
  10374. Remark = "",
  10375. });
  10376. views.AddRange(intTravelCosts);
  10377. #endregion
  10378. var accomCosts = new List<QuoteSubItemInfo>();
  10379. #region 住宿费 1355
  10380. if (infoView.QuarterageData.Any())
  10381. {
  10382. int accomIndex = 1;
  10383. int accomItemTypeId = 1355;
  10384. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10385. foreach (var item in groupData)
  10386. {
  10387. string feeName = string.Empty;
  10388. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10389. if (countryInfo != null)
  10390. {
  10391. feeName = countryInfo.Country;
  10392. var city = countryInfo.City;
  10393. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10394. {
  10395. feeName += $"-{city}";
  10396. }
  10397. }
  10398. var hotelInfo = item.FirstOrDefault();
  10399. if (hotelInfo == null) continue;
  10400. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10401. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10402. int quantity = item.ToList().Count;
  10403. accomCosts.Add(new QuoteSubItemInfo
  10404. {
  10405. ItemId = accomItemTypeId,
  10406. Index = accomIndex,
  10407. FeeName = feeName,
  10408. UnitPrice = hotelInfo.Cost,
  10409. Currency = thisCurrency,
  10410. Quantity = quantity,
  10411. PplNum = pplNum,
  10412. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10413. Remark = "",
  10414. });
  10415. accomIndex++;
  10416. }
  10417. views.AddRange(accomCosts);
  10418. }
  10419. #endregion
  10420. var mealCosts = new List<QuoteSubItemInfo>();
  10421. #region 餐饮费 1356
  10422. if (infoView.BoardWagesData.Any())
  10423. {
  10424. var mealIndex = 1;
  10425. int mealItemTypeId = 1356;
  10426. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10427. foreach (var item in groupData)
  10428. {
  10429. string feeName = string.Empty;
  10430. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10431. if (countryInfo != null)
  10432. {
  10433. feeName = countryInfo.Country;
  10434. var city = countryInfo.City;
  10435. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10436. {
  10437. feeName += $"-{city}";
  10438. }
  10439. }
  10440. var mealInfo = item.FirstOrDefault();
  10441. if (mealInfo == null) continue;
  10442. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10443. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10444. int quantity = item.ToList().Count;
  10445. mealCosts.Add(new QuoteSubItemInfo
  10446. {
  10447. ItemId = mealItemTypeId,
  10448. Index = mealIndex,
  10449. FeeName = feeName,
  10450. UnitPrice = mealInfo.Cost,
  10451. Currency = thisCurrency,
  10452. Quantity = quantity,
  10453. PplNum = pplNum,
  10454. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10455. Remark = "",
  10456. });
  10457. mealIndex++;
  10458. }
  10459. views.AddRange(mealCosts);
  10460. }
  10461. #endregion
  10462. var miscCosts = new List<QuoteSubItemInfo>();
  10463. #region 公杂费 1364
  10464. if (infoView.MiscellaneousFeeData.Any())
  10465. {
  10466. var miscIndex = 1;
  10467. int miscItemTypeId = 1364;
  10468. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10469. foreach (var item in groupData)
  10470. {
  10471. string feeName = string.Empty;
  10472. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10473. if (countryInfo != null)
  10474. {
  10475. feeName = countryInfo.Country;
  10476. var city = countryInfo.City;
  10477. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10478. {
  10479. feeName += $"-{city}";
  10480. }
  10481. }
  10482. var miscInfo = item.FirstOrDefault();
  10483. if (miscInfo == null) continue;
  10484. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10485. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10486. int quantity = item.ToList().Count;
  10487. mealCosts.Add(new QuoteSubItemInfo
  10488. {
  10489. ItemId = miscItemTypeId,
  10490. Index = miscIndex,
  10491. FeeName = feeName,
  10492. UnitPrice = miscInfo.Cost,
  10493. Currency = thisCurrency,
  10494. Quantity = quantity,
  10495. PplNum = pplNum,
  10496. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10497. Remark = "",
  10498. });
  10499. miscIndex++;
  10500. }
  10501. views.AddRange(mealCosts);
  10502. }
  10503. #endregion
  10504. #region 签证+保险 1362
  10505. int visaInsIndex = 1;
  10506. int visaInsItemTypeId = 1362;
  10507. if (infoView.Visa > 0)
  10508. {
  10509. views.Add(new QuoteSubItemInfo() {
  10510. ItemId = visaInsItemTypeId,
  10511. Index = visaInsIndex,
  10512. FeeName = $"签证",
  10513. UnitPrice = infoView.Visa,
  10514. Currency = $"CNY",
  10515. Quantity = 1,
  10516. PplNum = pplNum,
  10517. TotalAmt = infoView.Visa * pplNum,
  10518. Remark = "",
  10519. });
  10520. visaInsIndex++;
  10521. }
  10522. if (infoView.Safe > 0)
  10523. {
  10524. views.Add(new QuoteSubItemInfo()
  10525. {
  10526. ItemId = visaInsItemTypeId,
  10527. Index = visaInsIndex,
  10528. FeeName = $"保险",
  10529. UnitPrice = infoView.Safe,
  10530. Currency = $"CNY",
  10531. Quantity = 1,
  10532. PplNum = pplNum,
  10533. TotalAmt = infoView.Safe * pplNum,
  10534. Remark = "",
  10535. });
  10536. }
  10537. #endregion
  10538. #region 服务费 1363
  10539. int serviceFeeIndex = 1;
  10540. int serviceFeeItemTypeId = 1363;
  10541. if (infoView.Service > 0)
  10542. {
  10543. views.Add(new QuoteSubItemInfo()
  10544. {
  10545. ItemId = serviceFeeItemTypeId,
  10546. Index = serviceFeeIndex,
  10547. FeeName = $"服务费",
  10548. UnitPrice = infoView.Service,
  10549. Currency = $"CNY",
  10550. Quantity = 1,
  10551. PplNum = pplNum,
  10552. TotalAmt = infoView.Service * pplNum,
  10553. Remark = "",
  10554. });
  10555. }
  10556. #endregion
  10557. #endregion
  10558. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10559. result.Rates = eecRates.ToArray();
  10560. if (result.FeeItems.Any())
  10561. {
  10562. result.FeeItems.Select(x =>
  10563. {
  10564. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10565. if (feeInfos.Any()) x.Infos = feeInfos;
  10566. return x;
  10567. }
  10568. )
  10569. .OrderBy(x => x.Index)
  10570. .ToList();
  10571. }
  10572. return Ok(JsonView(result));
  10573. }
  10574. /// <summary>
  10575. /// 团组模块 - 出入境费用报价表 - Info
  10576. /// </summary>
  10577. /// <returns></returns>
  10578. [HttpPost]
  10579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10580. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10581. {
  10582. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10583. if (!info.Rates.Any())
  10584. {
  10585. var rates = await GeneralMethod.EnterExitCostInitRate();
  10586. info.Rates = rates.ToArray();
  10587. }
  10588. return Ok(JsonView(info));
  10589. }
  10590. /// <summary>
  10591. /// 团组模块 - 出入境费用报价表 - OP
  10592. /// </summary>
  10593. /// <returns></returns>
  10594. [HttpPost]
  10595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10596. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10597. {
  10598. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10599. }
  10600. /// <summary>
  10601. /// 团组模块 - 出入境费用报价表 - 删除 项
  10602. /// </summary>
  10603. /// <returns></returns>
  10604. [HttpPost]
  10605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10606. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10607. {
  10608. if (dto.Id < 1) return Ok(JsonView(false,MsgTips.Id));
  10609. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10610. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10611. }
  10612. /// <summary>
  10613. /// 团组模块 - 出入境费用报价表 - 导出
  10614. /// </summary>
  10615. /// <returns></returns>
  10616. [HttpPost]
  10617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10618. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10619. {
  10620. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10621. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10622. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id= dto.Id });
  10623. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10624. var rates = info.Rates;
  10625. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10626. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10627. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10628. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10629. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10630. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10631. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10632. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10633. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10634. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10635. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10636. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10637. //获取模板
  10638. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10639. var designer = new WorkbookDesigner();
  10640. designer.Workbook = new Workbook(tempPath);
  10641. designer.SetDataSource("QuoteName", info.Name);
  10642. designer.SetDataSource("CompanyTitle", "公司名称");
  10643. designer.SetDataSource("CompanyLabel", "");
  10644. #region 国际旅费
  10645. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10646. if (intTravelCosts.Infos.Any())
  10647. {
  10648. var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
  10649. string label = string.Empty;
  10650. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10651. if (infos.Any())
  10652. {
  10653. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10654. }
  10655. foreach (var item in intTravelCosts.Infos)
  10656. {
  10657. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10658. }
  10659. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10660. designer.SetDataSource("IntTravelLabel", label);
  10661. }
  10662. #endregion
  10663. #region 住宿费
  10664. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10665. if (accomCosts.Infos.Any())
  10666. {
  10667. string currencyName = string.Empty;
  10668. decimal rate = 1.0000M;
  10669. string label = "全程五星酒店,每人1间房\r\n";
  10670. foreach (var item in accomCosts.Infos)
  10671. {
  10672. string hotelName = string.Empty;
  10673. if (item.FeeName.Contains("-"))
  10674. {
  10675. var feeName = item.FeeName.Split('-');
  10676. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10677. }
  10678. else hotelName = $"\r\n{item.FeeName}:";
  10679. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10680. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10681. rate = rateInfo?.Rate ?? 1.0000M;
  10682. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10683. }
  10684. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10685. designer.SetDataSource("AccomLabel", label);
  10686. }
  10687. #endregion
  10688. #region 餐饮费
  10689. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  10690. if (mealCosts.Infos.Any())
  10691. {
  10692. string currencyName = string.Empty;
  10693. decimal rate = 1.0000M;
  10694. string label = "全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n";
  10695. foreach (var item in mealCosts.Infos)
  10696. {
  10697. string name = string.Empty;
  10698. if (item.FeeName.Contains("-"))
  10699. {
  10700. var feeName = item.FeeName.Split('-');
  10701. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10702. }
  10703. else name = $"\r\n{item.FeeName}:";
  10704. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10705. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10706. rate = rateInfo?.Rate ?? 1.0000M;
  10707. label += $"{name}{item.UnitPrice.TruncDecimals(2)}{currencyName}/天*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10708. }
  10709. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元\r\n({currencyName}汇率:{rate.TruncDecimals(4)})";
  10710. designer.SetDataSource("MealLabel", label);
  10711. }
  10712. #endregion
  10713. #region 车辆安排
  10714. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  10715. if (vehArranges.Infos.Any())
  10716. {
  10717. string currencyName = string.Empty;
  10718. decimal rate = 1.0000M;
  10719. string label = $"";
  10720. foreach (var item in vehArranges.Infos)
  10721. {
  10722. label += $"{item.Remark}\r\n\r\n{item.FeeName}\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元";
  10723. }
  10724. designer.SetDataSource("VehArrangeLabel", label);
  10725. }
  10726. #endregion
  10727. #region 邀请函发放对象
  10728. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  10729. #endregion
  10730. designer.Process();
  10731. //文件名
  10732. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10733. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10734. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10735. return Ok(JsonView(true, "成功", url));
  10736. }
  10737. #endregion
  10738. #region 签证费用录入
  10739. /// <summary>
  10740. /// 根据diid查询签证费用列表
  10741. /// </summary>
  10742. /// <param name="dto"></param>
  10743. /// <returns></returns>
  10744. [HttpPost]
  10745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10746. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10747. {
  10748. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10749. if (groupData.Code != 0)
  10750. {
  10751. return Ok(JsonView(false, groupData.Msg));
  10752. }
  10753. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10754. }
  10755. /// <summary>
  10756. /// 根据签证费用Id查询单条数据及c表数据
  10757. /// </summary>
  10758. /// <param name="dto"></param>
  10759. /// <returns></returns>
  10760. [HttpPost]
  10761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10762. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10763. {
  10764. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10765. if (groupData.Code != 0)
  10766. {
  10767. return Ok(JsonView(false, groupData.Msg));
  10768. }
  10769. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10770. }
  10771. /// <summary>
  10772. /// 签证费用删除
  10773. /// </summary>
  10774. /// <param name="dto"></param>
  10775. /// <returns></returns>
  10776. [HttpPost]
  10777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10778. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10779. {
  10780. _sqlSugar.BeginTran();
  10781. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10782. if (!res)
  10783. {
  10784. _sqlSugar.RollbackTran();
  10785. return Ok(JsonView(false, "删除失败"));
  10786. }
  10787. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10788. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10789. .SetColumns(a => new Grp_CreditCardPayment()
  10790. {
  10791. IsDel = 1,
  10792. DeleteUserId = dto.DeleteUserId,
  10793. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10794. })
  10795. .ExecuteCommand();
  10796. if (resSub < 1)
  10797. {
  10798. _sqlSugar.RollbackTran();
  10799. return Ok(JsonView(false, "删除失败"));
  10800. }
  10801. _sqlSugar.CommitTran();
  10802. return Ok(JsonView(true, "删除成功!"));
  10803. }
  10804. /// <summary>
  10805. /// 签证费用录入下拉框初始化
  10806. /// </summary>
  10807. /// <returns></returns>
  10808. [HttpPost]
  10809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10810. public async Task<IActionResult> VisaPriceAddSelect()
  10811. {
  10812. //支付方式
  10813. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10814. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10815. //币种
  10816. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10817. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10818. //乘客类型
  10819. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10820. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10821. //卡类型
  10822. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10823. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10824. //代办费类型
  10825. var agencyFeeTypeData = new List<dynamic>() {
  10826. new { id = 0 , Text = "未选择" },
  10827. new { id = 1 , Text = "小公务" },
  10828. new { id = 2 , Text = "大公务" },
  10829. };
  10830. //签证费用标准国家Data
  10831. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10832. var data = new
  10833. {
  10834. Payment = _Payment,
  10835. CurrencyList = _CurrencyList,
  10836. PassengerType = _PassengerType,
  10837. BankCard = _BankCard,
  10838. AgencyFeeType = agencyFeeTypeData,
  10839. CountryFeeData = visaCountryFeeData
  10840. };
  10841. return Ok(JsonView(true, "查询成功!", data));
  10842. }
  10843. /// <summary>
  10844. /// 签证费用录入操作(Status:1.新增,2.修改)
  10845. /// </summary>
  10846. /// <param name="dto"></param>
  10847. /// <returns></returns>
  10848. [HttpPost]
  10849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10850. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10851. {
  10852. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10853. if (groupData.Code != 0)
  10854. {
  10855. return Ok(JsonView(false, groupData.Msg));
  10856. }
  10857. #region 应用推送
  10858. try
  10859. {
  10860. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10861. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10862. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10863. //2024-10-21 新增LZ UID
  10864. var userIds = new List<int>() { 21 };
  10865. string title = $"系统通知";
  10866. string content = "";
  10867. var diId = dto.DiId;
  10868. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10869. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10870. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10871. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10872. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10873. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10874. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10875. }
  10876. catch (Exception ex)
  10877. {
  10878. }
  10879. #endregion
  10880. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10881. }
  10882. #endregion
  10883. #region 签证提成录入
  10884. /// <summary>
  10885. /// 签证提成录入
  10886. /// 基础数据
  10887. /// </summary>
  10888. /// <returns></returns>
  10889. [HttpGet]
  10890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10891. public async Task<IActionResult> VisaCommissionInit()
  10892. {
  10893. return Ok(await _visaCommissionRep.Init());
  10894. }
  10895. /// <summary>
  10896. /// 签证提成录入
  10897. /// Item
  10898. /// </summary>
  10899. /// <param name="_dto"></param>
  10900. /// <returns></returns>
  10901. [HttpPost]
  10902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10903. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10904. {
  10905. var validator = new VisaCommissionItemDtoValidator();
  10906. var validatorRes = await validator.ValidateAsync(_dto);
  10907. if (!validatorRes.IsValid)
  10908. {
  10909. StringBuilder sb = new StringBuilder();
  10910. foreach (var item in validatorRes.Errors)
  10911. {
  10912. sb.AppendLine(item.ErrorMessage);
  10913. }
  10914. return Ok(JsonView(false, sb.ToString()));
  10915. }
  10916. return Ok(await _visaCommissionRep.Item(_dto));
  10917. }
  10918. /// <summary>
  10919. /// 签证提成录入
  10920. /// Save
  10921. /// </summary>
  10922. /// <param name="_dto"></param>
  10923. /// <returns></returns>
  10924. [HttpPost]
  10925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10926. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10927. {
  10928. //参数验证
  10929. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10930. foreach (var item in _dto.Items)
  10931. {
  10932. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10933. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10934. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10935. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10936. }
  10937. return Ok(await _visaCommissionRep.Save(_dto));
  10938. }
  10939. /// <summary>
  10940. /// 签证提成录入
  10941. /// Create
  10942. /// </summary>
  10943. /// <param name="_dto"></param>
  10944. /// <returns></returns>
  10945. [HttpPost]
  10946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10947. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10948. {
  10949. var validator = new VisaCommissionCreateDtoValidator();
  10950. var validatorRes = await validator.ValidateAsync(_dto);
  10951. if (!validatorRes.IsValid)
  10952. {
  10953. StringBuilder sb = new StringBuilder();
  10954. foreach (var item in validatorRes.Errors)
  10955. {
  10956. sb.AppendLine(item.ErrorMessage);
  10957. }
  10958. return Ok(JsonView(false, sb.ToString()));
  10959. }
  10960. return Ok(await _visaCommissionRep.Create(_dto));
  10961. }
  10962. /// <summary>
  10963. /// 签证提成录入
  10964. /// Put(编辑)
  10965. /// </summary>
  10966. /// <param name="id"></param>
  10967. /// <param name="_dto"></param>
  10968. /// <returns></returns>
  10969. [HttpPut]
  10970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10971. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10972. {
  10973. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10974. var validator = new VisaCommissionCreateDtoValidator();
  10975. var validatorRes = await validator.ValidateAsync(_dto);
  10976. if (!validatorRes.IsValid)
  10977. {
  10978. StringBuilder sb = new StringBuilder();
  10979. foreach (var item in validatorRes.Errors)
  10980. {
  10981. sb.AppendLine(item.ErrorMessage);
  10982. }
  10983. return Ok(JsonView(false, sb.ToString()));
  10984. }
  10985. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10986. }
  10987. /// <summary>
  10988. /// 签证提成录入
  10989. /// Del
  10990. /// </summary>
  10991. /// <param name="id"></param>
  10992. /// <param name="currUserId"></param>
  10993. /// <returns></returns>
  10994. [HttpPost]
  10995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10996. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10997. {
  10998. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10999. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  11000. return Ok(await _visaCommissionRep.Del(id, currUserId));
  11001. }
  11002. #endregion
  11003. #region op费用录入
  11004. /// <summary>
  11005. /// 根据diid查询op费用列表
  11006. /// </summary>
  11007. /// <param name="dto"></param>
  11008. /// <returns></returns>
  11009. [HttpPost]
  11010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11011. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  11012. {
  11013. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  11014. if (groupData.Code != 0)
  11015. {
  11016. return Ok(JsonView(false, groupData.Msg));
  11017. }
  11018. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11019. }
  11020. /// <summary>
  11021. /// 根据op费用Id查询单条数据及c表数据
  11022. /// </summary>
  11023. /// <param name="dto"></param>
  11024. /// <returns></returns>
  11025. [HttpPost]
  11026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11027. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11028. {
  11029. try
  11030. {
  11031. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11032. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11033. var data = new
  11034. {
  11035. CarTouristGuideGround = _groupData,
  11036. CreditCardPayment = _creditCardPayment
  11037. };
  11038. return Ok(JsonView(true, "查询成功!", data));
  11039. }
  11040. catch (Exception ex)
  11041. {
  11042. return Ok(JsonView(false, "程序错误!"));
  11043. }
  11044. }
  11045. /// <summary>
  11046. /// op费用删除
  11047. /// </summary>
  11048. /// <param name="dto"></param>
  11049. /// <returns></returns>
  11050. [HttpPost]
  11051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11052. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11053. {
  11054. try
  11055. {
  11056. _sqlSugar.BeginTran();
  11057. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11058. if (!res)
  11059. {
  11060. return Ok(JsonView(false, "删除失败"));
  11061. }
  11062. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11063. {
  11064. IsDel = 1,
  11065. DeleteUserId = dto.DeleteUserId,
  11066. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11067. }).ExecuteCommandAsync();
  11068. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11069. {
  11070. IsDel = 1,
  11071. DeleteUserId = dto.DeleteUserId,
  11072. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11073. }).ExecuteCommandAsync();
  11074. #region 删除超支相关数据
  11075. //删除导入的超支数据
  11076. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11077. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11078. {
  11079. IsDel = 1,
  11080. DeleteUserId = dto.DeleteUserId,
  11081. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11082. }).ExecuteCommand();
  11083. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11084. {
  11085. IsDel = 1,
  11086. DeleteUserId = dto.DeleteUserId,
  11087. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11088. }).ExecuteCommand();
  11089. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11090. {
  11091. IsDel = 1,
  11092. DeleteUserId = dto.DeleteUserId,
  11093. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11094. }).ExecuteCommand();
  11095. #endregion
  11096. _sqlSugar.CommitTran();
  11097. return Ok(JsonView(true, "删除成功!"));
  11098. }
  11099. catch (Exception ex)
  11100. {
  11101. _sqlSugar.RollbackTran();
  11102. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11103. }
  11104. }
  11105. /// <summary>
  11106. /// op费用录入操作(Status:1.新增,2.修改)
  11107. /// </summary>
  11108. /// <param name="dto"></param>
  11109. /// <returns></returns>
  11110. [HttpPost]
  11111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11112. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11113. {
  11114. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11115. if (groupData.Code != 0)
  11116. {
  11117. return Ok(JsonView(false, groupData.Msg));
  11118. }
  11119. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11120. }
  11121. /// <summary>
  11122. /// 填写费用详细页面初始化绑定
  11123. /// </summary>
  11124. /// <param name="dto"></param>
  11125. /// <returns></returns>
  11126. [HttpPost]
  11127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11128. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11129. {
  11130. try
  11131. {
  11132. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11133. if (groupData.Code != 0)
  11134. {
  11135. return Ok(JsonView(false, groupData.Msg));
  11136. }
  11137. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11138. }
  11139. catch (Exception ex)
  11140. {
  11141. return Ok(JsonView(false, ex.Message));
  11142. }
  11143. }
  11144. /// <summary>
  11145. /// 根据op费用Id查询详细数据
  11146. /// </summary>
  11147. /// <param name="dto"></param>
  11148. /// <returns></returns>
  11149. [HttpPost]
  11150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11151. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11152. {
  11153. try
  11154. {
  11155. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11156. if (groupData.Code != 0)
  11157. {
  11158. return Ok(JsonView(false, groupData.Msg));
  11159. }
  11160. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11161. }
  11162. catch (Exception ex)
  11163. {
  11164. return Ok(JsonView(false, ex.Message));
  11165. }
  11166. }
  11167. /// <summary>
  11168. /// OP费用录入填写详情
  11169. /// </summary>
  11170. /// <param name="dto"></param>
  11171. /// <returns></returns>
  11172. [HttpPost]
  11173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11174. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11175. {
  11176. try
  11177. {
  11178. #region 参数校验
  11179. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11180. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11181. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11182. #endregion
  11183. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11184. if (groupData.Code != 0)
  11185. {
  11186. return Ok(JsonView(false, groupData.Msg));
  11187. }
  11188. //自动审核
  11189. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11190. #region 应用推送
  11191. try
  11192. {
  11193. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11194. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11195. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11196. //2024-10-21 新增LZ UID
  11197. var userIds = new List<int>() { 21 };
  11198. string title = $"系统通知";
  11199. var diId = dto.DiId;
  11200. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11201. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11202. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11203. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11204. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11205. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11206. }
  11207. catch (Exception ex)
  11208. {
  11209. }
  11210. #endregion
  11211. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11212. }
  11213. catch (Exception ex)
  11214. {
  11215. return Ok(JsonView(false, ex.Message));
  11216. }
  11217. }
  11218. /// <summary>
  11219. /// 获取三公详细所有城市
  11220. /// </summary>
  11221. /// <returns></returns>
  11222. [HttpGet]
  11223. public IActionResult OpCarCityResult()
  11224. {
  11225. var jw = JsonView(false);
  11226. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11227. {
  11228. x.Id,
  11229. x.Country,
  11230. x.City,
  11231. }).ToList();
  11232. if (data.Count > 0)
  11233. {
  11234. jw = JsonView(true, "获取成功!", data);
  11235. }
  11236. else
  11237. {
  11238. jw.Msg = "城市数据为空!";
  11239. jw.Data = new string[0];
  11240. }
  11241. return Ok(jw);
  11242. }
  11243. /// <summary>
  11244. /// 导出地接费用明细
  11245. /// </summary>
  11246. /// <param name="dto"></param>
  11247. /// <returns></returns>
  11248. [HttpPost]
  11249. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11250. {
  11251. var jw = JsonView(false);
  11252. if (dto.Diid < 1)
  11253. {
  11254. jw.Msg = "请输入正确的diid!";
  11255. return Ok(jw);
  11256. }
  11257. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11258. if (group == null)
  11259. {
  11260. jw.Msg = "未找到团组信息!";
  11261. return Ok(jw);
  11262. }
  11263. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11264. if (localGuideArr.Count == 0)
  11265. {
  11266. jw.Msg = "该团组暂无地接信息!";
  11267. return Ok(jw);
  11268. }
  11269. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11270. var overspendSoure = new Dictionary<int, int>
  11271. {
  11272. { 91, 982 }, //车
  11273. { 92 , 1059} ,//导游
  11274. { 994 , 1073}, //翻译
  11275. { 988 , 1074 }, //早餐
  11276. { 93 , 1075 }, //午餐
  11277. { 989 , 1076 }, //晚餐
  11278. };
  11279. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11280. foreach (var groupArr in localGroup)
  11281. {
  11282. var keyValue = groupArr.Key;
  11283. if (int.TryParse(keyValue, out int cityid))
  11284. {
  11285. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11286. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11287. }
  11288. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11289. foreach (var item in groupArr)
  11290. {
  11291. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11292. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11293. new Grp_CarTouristGuideGroundReservationsContentExtend
  11294. {
  11295. Count = a.Count,
  11296. CreateTime = a.CreateTime,
  11297. CreateUserId = a.CreateUserId,
  11298. CTGGRId = a.CTGGRId,
  11299. Currency = a.Currency,
  11300. DatePrice = a.DatePrice,
  11301. DeleteTime = a.DeleteTime,
  11302. DeleteUserId = a.DeleteUserId,
  11303. DiId = a.DiId,
  11304. Id = a.Id,
  11305. IsDel = a.IsDel,
  11306. Price = a.Price,
  11307. PriceContent = a.PriceContent,
  11308. Remark = a.Remark,
  11309. SId = a.SId,
  11310. SidName = b.Name,
  11311. Units = a.Units,
  11312. }
  11313. ).ToList();
  11314. if (content.Count > 0)
  11315. {
  11316. contentArr.Add(content);
  11317. }
  11318. }
  11319. //open excel
  11320. //set excel
  11321. //save excel
  11322. try
  11323. {
  11324. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11325. IWorkbook workbook;
  11326. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11327. {
  11328. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11329. }
  11330. else
  11331. {
  11332. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11333. }
  11334. ISheet sheet = workbook.GetSheetAt(0);
  11335. var rowStartIndex = 2;
  11336. var clounmCount = 10;
  11337. var initStyleRow = sheet.GetRow(2);
  11338. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11339. //var overspendArrDetail =
  11340. var existsId = new List<CarCompare>();
  11341. var lastElem = arr.Last();
  11342. var thisSid = -1;
  11343. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11344. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11345. {
  11346. Name = "未知币种!",
  11347. Remark = "未知币种!",
  11348. };
  11349. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11350. Action cloneRowFn = () =>
  11351. {
  11352. rowStartIndex++;
  11353. var cloneRow = sheet.CreateRow(rowStartIndex);
  11354. // 复制样式
  11355. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11356. {
  11357. ICell sourceCell = initStyleRow.GetCell(i);
  11358. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11359. // 确保单元格存在样式
  11360. if (sourceCell.CellStyle != null)
  11361. {
  11362. targetCell.CellStyle = sourceCell.CellStyle;
  11363. }
  11364. }
  11365. };
  11366. var mergeRow = () =>
  11367. {
  11368. for (int i = 2; i < sheet.LastRowNum; i++)
  11369. {
  11370. var row = sheet.GetRow(i);
  11371. var cellFirst = row.GetCell(0);
  11372. var thisIndex = i + 1;
  11373. while (thisIndex < sheet.LastRowNum)
  11374. {
  11375. var nextRow = sheet.GetRow(thisIndex);
  11376. var nextCellFirst = nextRow.GetCell(0);
  11377. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11378. {
  11379. thisIndex++;
  11380. }
  11381. else
  11382. {
  11383. break;
  11384. }
  11385. }
  11386. thisIndex--;
  11387. if (thisIndex != i)
  11388. {
  11389. //合并row
  11390. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11391. i, // 起始行索引(0-based)
  11392. thisIndex, // 结束行索引(0-based)
  11393. 0, // 起始列索引(0-based)
  11394. 0 // 结束列索引(0-based)
  11395. );
  11396. sheet.AddMergedRegion(cellRangeAddress);
  11397. i = thisIndex;
  11398. }
  11399. }
  11400. };
  11401. var chaoshiNumber = 0;
  11402. var totalNumber = 0.00M;
  11403. string lastStr = "";
  11404. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11405. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11406. {
  11407. b.IsAuditGM,
  11408. x.Id,
  11409. x.Area,
  11410. b.PayPercentage,
  11411. b.PayMoney,
  11412. }).ToList();
  11413. string yesPayment = "", noPayment = "";
  11414. foreach (var item in queryCarArrByCityAndDiid)
  11415. {
  11416. if (item.IsAuditGM == 1)
  11417. {
  11418. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11419. }
  11420. else
  11421. {
  11422. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11423. }
  11424. }
  11425. lastStr = yesPayment + noPayment;
  11426. foreach (var item in arr)
  11427. {
  11428. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11429. {
  11430. if (thisSid != item.SId)
  11431. {
  11432. if (thisSid == -1)
  11433. {
  11434. thisSid = item.SId;
  11435. }
  11436. else
  11437. {
  11438. //合并小计行
  11439. //创建合并区域的实例
  11440. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11441. rowStartIndex, // 起始行索引(0-based)
  11442. rowStartIndex, // 结束行索引(0-based)
  11443. 0, // 起始列索引(0-based)
  11444. 3 // 结束列索引(0-based)
  11445. );
  11446. sheet.AddMergedRegion(cellRangeAddress);
  11447. var CellStyle = workbook.CreateCellStyle();
  11448. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11449. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11450. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11451. for (int i = 0; i <= clounmCount; i++)
  11452. {
  11453. if (i > 6)
  11454. {
  11455. var CellStyle1 = workbook.CreateCellStyle();
  11456. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11457. IFont Font = workbook.CreateFont(); // 创建字体
  11458. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11459. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11460. CellStyle1.SetFont(Font);
  11461. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11462. }
  11463. else
  11464. {
  11465. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11466. }
  11467. }
  11468. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11469. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11470. //超时合计
  11471. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11472. //超时数
  11473. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11474. //超时合计费用
  11475. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11476. thisSid = item.SId;
  11477. cloneRowFn();
  11478. chaoshiNumber = 0;
  11479. totalNumber = 0;
  11480. }
  11481. }
  11482. IRow row = sheet.GetRow(rowStartIndex);
  11483. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11484. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11485. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11486. if (isOpenOverspendSoure)
  11487. {
  11488. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11489. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11490. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11491. }
  11492. for (int i = 0; i <= clounmCount; i++)
  11493. {
  11494. var cell = row.GetCell(i);
  11495. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11496. if (cell == null)
  11497. {
  11498. cell = row.CreateCell(i);
  11499. }
  11500. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11501. fontRed.CloneStyleFrom(cell.CellStyle);
  11502. IFont Font = workbook.CreateFont(); // 创建字体
  11503. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11504. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11505. fontRed.SetFont(Font);
  11506. byte[] rgb = new byte[3] { 255, 242, 204 };
  11507. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11508. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11509. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11510. if (workbook is XSSFWorkbook)
  11511. {
  11512. BackgroundColor255_242_204.FillForegroundColor = 0;
  11513. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11514. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11515. }
  11516. else
  11517. {
  11518. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11519. }
  11520. if (i == 1 || i > 6)
  11521. {
  11522. if (i > 6)
  11523. {
  11524. fontRed.FillForegroundColor = 0;
  11525. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11526. fontRed.FillPattern = FillPattern.SolidForeground;
  11527. }
  11528. cell.CellStyle = fontRed;
  11529. }
  11530. if (i > 2 && i < 7)
  11531. {
  11532. cell.CellStyle = BackgroundColor255_242_204;
  11533. }
  11534. cell.SetCellValue(setCellValue); //写入单元格
  11535. }
  11536. if (overspendSoure.ContainsKey(thisSid))
  11537. {
  11538. var overspendId = overspendSoure[thisSid];
  11539. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11540. }
  11541. cloneRowFn();
  11542. existsId.Add(new CarCompare
  11543. {
  11544. DataPrice = item.DatePrice.ObjToDate(),
  11545. Sid = item.SId
  11546. });
  11547. }
  11548. if (item.Equals(lastElem))
  11549. {
  11550. //合并小计行
  11551. //创建合并区域的实例
  11552. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11553. rowStartIndex, // 起始行索引(0-based)
  11554. rowStartIndex, // 结束行索引(0-based)
  11555. 0, // 起始列索引(0-based)
  11556. 3 // 结束列索引(0-based)
  11557. );
  11558. sheet.AddMergedRegion(cellRangeAddress);
  11559. var CellStyle = workbook.CreateCellStyle();
  11560. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11561. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11562. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11563. for (int i = 0; i <= clounmCount; i++)
  11564. {
  11565. if (i > 6)
  11566. {
  11567. var CellStyle1 = workbook.CreateCellStyle();
  11568. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11569. IFont Font = workbook.CreateFont(); // 创建字体
  11570. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11571. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11572. CellStyle1.SetFont(Font);
  11573. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11574. }
  11575. else
  11576. {
  11577. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11578. }
  11579. }
  11580. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11581. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11582. //超时合计
  11583. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11584. //超时数
  11585. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11586. //超时合计费用
  11587. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11588. cloneRowFn();
  11589. // 创建合并区域的实例
  11590. cellRangeAddress = new CellRangeAddress(
  11591. rowStartIndex, // 起始行索引(0-based)
  11592. rowStartIndex, // 结束行索引(0-based)
  11593. 0, // 起始列索引(0-based)
  11594. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11595. );
  11596. // 添加合并区域
  11597. sheet.AddMergedRegion(cellRangeAddress);
  11598. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11599. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11600. }
  11601. }
  11602. mergeRow();
  11603. // 保存修改后的Excel文件到新文件
  11604. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11605. // new FileStream(newFilePath, FileMode.CreateNew)
  11606. using (var stream = new MemoryStream())
  11607. {
  11608. workbook.Write(stream, true);
  11609. stream.Flush();
  11610. stream.Seek(0, SeekOrigin.Begin);
  11611. MemoryStream memoryStream = new MemoryStream();
  11612. stream.CopyTo(memoryStream);
  11613. memoryStream.Seek(0, SeekOrigin.Begin);
  11614. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11615. }
  11616. workbook.Close();
  11617. workbook.Dispose();
  11618. }
  11619. catch (Exception ex)
  11620. {
  11621. jw.Msg = "出现异常!" + ex.Message;
  11622. return Ok(jw);
  11623. }
  11624. }
  11625. if (Zips.Count > 0)
  11626. {
  11627. IOOperatorHelper io = new IOOperatorHelper();
  11628. var byts = io.ConvertZipStream(Zips);
  11629. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11630. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11631. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11632. }
  11633. else
  11634. {
  11635. jw.Msg = "暂无生成文件!";
  11636. }
  11637. return Ok(jw);
  11638. }
  11639. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11640. {
  11641. string outStr = string.Empty;
  11642. switch (i)
  11643. {
  11644. case 0:
  11645. outStr = arr[0].SidName;
  11646. break;
  11647. case 1:
  11648. outStr = arr[0].DataPriceStr;
  11649. break;
  11650. case 2:
  11651. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11652. break;
  11653. case 4:
  11654. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11655. break;
  11656. case 7:
  11657. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11658. {
  11659. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11660. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11661. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11662. }
  11663. break;
  11664. case 8:
  11665. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11666. {
  11667. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11668. }
  11669. break;
  11670. case 9:
  11671. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11672. {
  11673. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11674. }
  11675. break;
  11676. case 10:
  11677. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11678. {
  11679. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11680. }
  11681. break;
  11682. }
  11683. return outStr;
  11684. }
  11685. #region OP行程单
  11686. /// <summary>
  11687. /// OP行程单初始化
  11688. /// </summary>
  11689. /// <param name="dto"></param>
  11690. /// <returns></returns>
  11691. [HttpPost]
  11692. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11693. {
  11694. var jw = JsonView(false);
  11695. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11696. var group = groupList.First();
  11697. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11698. if (group == null)
  11699. {
  11700. jw.Msg = "暂无团组!";
  11701. return Ok(jw);
  11702. }
  11703. group = groupList.Find(x => x.Id == diid);
  11704. if (group == null)
  11705. {
  11706. jw.Msg = "请输入正确的团组ID!";
  11707. return Ok(jw);
  11708. }
  11709. string city = string.Empty;
  11710. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11711. if (blackCode.Count > 0)
  11712. {
  11713. var black = blackCode.First();
  11714. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11715. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11716. if (blackSp.Length > 0)
  11717. {
  11718. try
  11719. {
  11720. var cityArrCode = new List<string>(20);
  11721. foreach (var item in blackSp)
  11722. {
  11723. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11724. var IndexSelect = itemSp[2];
  11725. var cityArrCodeLength = cityArrCode.Count - 1;
  11726. var startCity = IndexSelect.Substring(0, 3);
  11727. if (cityArrCodeLength > 0)
  11728. {
  11729. var arrEndCity = cityArrCode[cityArrCodeLength];
  11730. if (arrEndCity != startCity)
  11731. {
  11732. cityArrCode.Add(startCity.ToUpper());
  11733. }
  11734. }
  11735. else
  11736. {
  11737. cityArrCode.Add(startCity.ToUpper());
  11738. }
  11739. var endCity = IndexSelect.Substring(3, 3);
  11740. cityArrCode.Add(endCity.ToUpper());
  11741. }
  11742. var cityThree = string.Empty;
  11743. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11744. cityThree = cityThree.TrimEnd(',');
  11745. if (string.IsNullOrWhiteSpace(cityThree))
  11746. {
  11747. throw new
  11748. Exception("error");
  11749. }
  11750. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11751. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11752. foreach (var item in cityArrCode)
  11753. {
  11754. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11755. if (find != null)
  11756. {
  11757. city += find.City + "/";
  11758. }
  11759. else
  11760. {
  11761. city += item + "三字码未收入/";
  11762. }
  11763. }
  11764. city = city.TrimEnd('/');
  11765. }
  11766. catch (Exception e)
  11767. {
  11768. city = "黑屏代码格式不正确!";
  11769. }
  11770. }
  11771. }
  11772. else
  11773. {
  11774. city = "未录入黑屏代码";
  11775. }
  11776. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11777. {
  11778. Date = x.Date,
  11779. Days = x.Days,
  11780. Diffgroup = x.Diffgroup,
  11781. Diid = x.Diid,
  11782. Traffic_First = x.Traffic_First,
  11783. Traffic_Second = x.Traffic_Second,
  11784. Trip = x.Trip,
  11785. WeekDay = x.WeekDay,
  11786. Id = x.Id
  11787. }).ToList();
  11788. jw.Data = new
  11789. {
  11790. groupList = groupList.Select(x => new
  11791. {
  11792. x.Id,
  11793. x.TeamName,
  11794. x.TourCode
  11795. }).ToList(),
  11796. groupInfo = new
  11797. {
  11798. group.VisitDays,
  11799. group.TourCode,
  11800. group.VisitPNumber,
  11801. group.TeamName,
  11802. city
  11803. },
  11804. OpTravelList
  11805. };
  11806. jw.Code = 200;
  11807. jw.Msg = "操作成功!";
  11808. return Ok(jw);
  11809. }
  11810. /// <summary>
  11811. /// 删除团组行程单
  11812. /// </summary>
  11813. /// <returns></returns>
  11814. [HttpPost]
  11815. public IActionResult DelTravel(DelOpTravelDto dto)
  11816. {
  11817. var jw = JsonView(false);
  11818. if (dto.UserId <= 0 || dto.Diid <= 0)
  11819. {
  11820. jw.Msg = "请输入正确的参数!";
  11821. return Ok(jw);
  11822. }
  11823. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11824. .SetColumns(x => new Grp_TravelList
  11825. {
  11826. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11827. DeleteUserId = dto.UserId,
  11828. IsDel = 1,
  11829. }).ExecuteCommand();
  11830. jw = JsonView(true);
  11831. return Ok(jw);
  11832. }
  11833. /// <summary>
  11834. /// 行程单保存
  11835. /// </summary>
  11836. /// <returns></returns>
  11837. [HttpPost]
  11838. public IActionResult TravelSave(TravelSaveDto dto)
  11839. {
  11840. var jw = JsonView(false);
  11841. if (dto.Arr.Count > 0)
  11842. {
  11843. try
  11844. {
  11845. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11846. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11847. .ToList();
  11848. _sqlSugar.BeginTran();
  11849. foreach (var item in dto.Arr)
  11850. {
  11851. if (item.Id == 0)
  11852. {
  11853. throw new Exception("请传入正确的Id");
  11854. }
  11855. //比较上一次的差异
  11856. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11857. if (findTravel != null)
  11858. {
  11859. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11860. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11861. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11862. }
  11863. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11864. .SetColumns(x => new Grp_TravelList
  11865. {
  11866. Trip = item.Trip
  11867. }).ExecuteCommand();
  11868. }
  11869. _sqlSugar.CommitTran();
  11870. jw = JsonView(true);
  11871. }
  11872. catch (Exception ex)
  11873. {
  11874. _sqlSugar.RollbackTran();
  11875. jw.Msg = "程序异常!" + ex.Message;
  11876. }
  11877. }
  11878. else
  11879. {
  11880. jw.Msg = "请传入正确的参数!";
  11881. }
  11882. return Ok(jw);
  11883. }
  11884. private string CheckStr(string original, string changed)
  11885. {
  11886. // 创建diff_match_patch对象
  11887. var dmp = new diff_match_patch();
  11888. // 计算差异
  11889. List<Diff> diffs = dmp.diff_main(original, changed);
  11890. // 清理和合并差异
  11891. dmp.diff_cleanupSemantic(diffs);
  11892. // 使用StringBuilder构建最终的字符串
  11893. StringBuilder finalString = new StringBuilder();
  11894. // 输出差异结果,并构建变动后的字符串
  11895. foreach (Diff diff in diffs)
  11896. {
  11897. switch (diff.operation)
  11898. {
  11899. case Operation.EQUAL:
  11900. // 相等的部分,直接添加到最终字符串
  11901. finalString.Append(diff.text);
  11902. break;
  11903. case Operation.INSERT:
  11904. // 插入的部分,添加标记并添加到最终字符串
  11905. finalString.Append("[++]" + diff.text + "[++]");
  11906. break;
  11907. case Operation.DELETE:
  11908. // 删除的部分,不添加到最终字符串
  11909. //finalString.Append("[++]" + diff.text + "[++]");
  11910. break;
  11911. }
  11912. }
  11913. // 输出变动后的字符串
  11914. return finalString.ToString();
  11915. }
  11916. private class tagContent
  11917. {
  11918. public DateTime Date { get; set; }
  11919. public string StartTag { get; set; }
  11920. public string EndTag { get; set; }
  11921. public string Content { get; set; }
  11922. public static int tagLength { get { return 3; } }
  11923. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11924. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11925. public bool IsFinally { get; set; }
  11926. }
  11927. private List<string> ExtractContentBetweenTags(string input, string tag)
  11928. {
  11929. List<string> results = new List<string>();
  11930. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11931. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11932. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11933. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11934. string[] strValueArr = new string[1];
  11935. foreach (System.Text.RegularExpressions.Match match in matches)
  11936. {
  11937. var strValue = match.Groups[1].Value;
  11938. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11939. }
  11940. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11941. return results;
  11942. }
  11943. /// <summary>
  11944. /// 导出行程单
  11945. /// </summary>
  11946. /// <param name="dto"></param>
  11947. /// <returns></returns>
  11948. [HttpPost]
  11949. public IActionResult ExportTravel(ExportTravelDto dto)
  11950. {
  11951. var jw = JsonView(false);
  11952. jw.Data = "";
  11953. int diid = 0;
  11954. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11955. if (Find == null)
  11956. {
  11957. jw.Msg = "请选择正确的团组!";
  11958. return Ok(jw);
  11959. }
  11960. else
  11961. {
  11962. diid = Find.Id;
  11963. }
  11964. //数据源
  11965. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11966. DataTable dtBlack = null;
  11967. try
  11968. {
  11969. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11970. }
  11971. catch (Exception)
  11972. {
  11973. jw.Msg = "机票黑屏代码有误!";
  11974. return Ok(jw);
  11975. }
  11976. string CityStr = string.Empty;
  11977. if (dtBlack.Rows.Count == 0)
  11978. {
  11979. jw.Msg = "机票黑屏代码有误!";
  11980. return Ok(jw);
  11981. }
  11982. else
  11983. {
  11984. foreach (DataRow row in dtBlack.Rows)
  11985. {
  11986. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11987. {
  11988. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11989. return Ok(jw);
  11990. }
  11991. }
  11992. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11993. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11994. }
  11995. // 指定的文字
  11996. var targetTextDic = new Dictionary<string, List<string>>();
  11997. //创建数据源Table
  11998. DataTable dtSource = new DataTable();
  11999. dtSource.Columns.Add("Days", typeof(string));
  12000. dtSource.Columns.Add("Date", typeof(string));
  12001. dtSource.Columns.Add("Week", typeof(string));
  12002. dtSource.Columns.Add("Traffic", typeof(string));
  12003. dtSource.Columns.Add("Trip", typeof(string));
  12004. //获取数据,放到datatable
  12005. foreach (var item in _travelList)
  12006. {
  12007. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  12008. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  12009. .Replace(tagContent.TagFormat.Item2, string.Empty)
  12010. .Replace("[++]", string.Empty);
  12011. DataRow dr = dtSource.NewRow();
  12012. dr["Days"] = item.Days;
  12013. dr["Date"] = item.Date;
  12014. dr["Week"] = item.WeekDay;
  12015. dr["Traffic"] = item.Traffic_First
  12016. + "\r\n"
  12017. + item.Traffic_Second;
  12018. dr["Trip"] = item.Trip;
  12019. dtSource.Rows.Add(dr);
  12020. }
  12021. Dictionary<string, string> dic = new Dictionary<string, string>();
  12022. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12023. dic.Add("City", CityStr);
  12024. dic.Add("Days", Find.VisitDays.ToString());
  12025. dic.Add("DeleCode", Find.TourCode);
  12026. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12027. //模板路径
  12028. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12029. //载入模板
  12030. Document doc = null;
  12031. DocumentBuilder builder = null;
  12032. try
  12033. {
  12034. //载入模板
  12035. doc = new Document(tempPath);
  12036. builder = new DocumentBuilder(doc);
  12037. }
  12038. catch (Exception)
  12039. {
  12040. jw.Msg = "模板位置不存在!";
  12041. return Ok(jw);
  12042. }
  12043. foreach (var key in dic.Keys)
  12044. {
  12045. Bookmark bookmark = doc.Range.Bookmarks[key];
  12046. if (bookmark != null)
  12047. {
  12048. builder.MoveToBookmark(key);
  12049. builder.Write(dic[key]);
  12050. }
  12051. }
  12052. //获取word里所有表格
  12053. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12054. //获取所填表格的序数
  12055. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12056. try
  12057. {
  12058. //循环赋值
  12059. for (int i = 0; i < dtSource.Rows.Count; i++)
  12060. {
  12061. builder.MoveToCell(0, i + 1, 0, 0);
  12062. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12063. builder.MoveToCell(0, i + 1, 1, 0);
  12064. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12065. builder.MoveToCell(0, i + 1, 2, 0);
  12066. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12067. var trip = dtSource.Rows[i]["Trip"].ToString();
  12068. builder.MoveToCell(0, i + 1, 3, 0);
  12069. builder.Write(trip);
  12070. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12071. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12072. // 获取特定索引的段落
  12073. Paragraph paragraph = (Paragraph)paragraphs[0];
  12074. Run run = paragraph.Runs[0];
  12075. Aspose.Words.Font font = run.Font;
  12076. font.Name = "黑体";
  12077. //设置双休红色
  12078. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12079. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12080. paragraph = (Paragraph)paragraphs[1];
  12081. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12082. {
  12083. run = paragraph.Runs[0];
  12084. font = run.Font;
  12085. font.Color = Color.Red;
  12086. }
  12087. }
  12088. }
  12089. catch (Exception ex)
  12090. {
  12091. }
  12092. //删除多余行
  12093. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12094. {
  12095. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12096. }
  12097. var targetTextList = new List<string>();
  12098. // 遍历文档中的表格
  12099. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12100. {
  12101. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12102. {
  12103. var cellIndex = 0;
  12104. foreach (Cell cell in row.Cells)
  12105. {
  12106. if (cellIndex == 1 && row.Cells.Count == 4)
  12107. {
  12108. foreach (var target in targetTextDic.Keys)
  12109. {
  12110. if (cell.GetText().Contains(target))
  12111. {
  12112. targetTextList = targetTextDic[target];
  12113. break;
  12114. }
  12115. }
  12116. }
  12117. // 遍历单元格中的所有段落
  12118. foreach (Paragraph paragraph in cell.Paragraphs)
  12119. {
  12120. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12121. List<Run> runs = new List<Run>();
  12122. foreach (Run run in paragraph.Runs)
  12123. {
  12124. runs.Add(run);
  12125. }
  12126. foreach (Run run in runs)
  12127. {
  12128. foreach (var targetText in targetTextList)
  12129. {
  12130. // 检查文字是否包含指定文字
  12131. if (run.Text.Contains(targetText))
  12132. {
  12133. // 将包含的部分设置为红色
  12134. HighlightText(run, targetText, Color.Red);
  12135. }
  12136. }
  12137. }
  12138. }
  12139. cellIndex++;
  12140. }
  12141. }
  12142. }
  12143. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12144. if (!Directory.Exists(savePath))
  12145. {
  12146. try
  12147. {
  12148. Directory.CreateDirectory(savePath);
  12149. }
  12150. catch
  12151. {
  12152. }
  12153. }
  12154. string path = savePath + Find.TeamName + "出访日程";
  12155. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12156. try
  12157. {
  12158. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12159. string postfix = ".docx";
  12160. if (dto.IsPDF == 1)
  12161. {
  12162. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12163. postfix = ".pdf";
  12164. }
  12165. doc.Save(path + postfix, saveFormat);
  12166. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12167. }
  12168. catch (Exception)
  12169. {
  12170. jw = JsonView(false);
  12171. }
  12172. return Ok(jw);
  12173. }
  12174. /// <summary>
  12175. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12176. /// </summary>
  12177. /// <param name="num"></param>
  12178. /// <returns></returns>
  12179. string GetNum(string num)
  12180. {
  12181. string str = "";
  12182. switch (num)
  12183. {
  12184. case "1":
  12185. str = "一";
  12186. break;
  12187. case "2":
  12188. str = "二";
  12189. break;
  12190. case "3":
  12191. str = "三";
  12192. break;
  12193. case "4":
  12194. str = "四";
  12195. break;
  12196. case "5":
  12197. str = "五";
  12198. break;
  12199. case "6":
  12200. str = "六";
  12201. break;
  12202. case "7":
  12203. str = "七";
  12204. break;
  12205. case "8":
  12206. str = "八";
  12207. break;
  12208. case "9":
  12209. str = "九";
  12210. break;
  12211. case "10":
  12212. str = "十";
  12213. break;
  12214. case "11":
  12215. str = "十一";
  12216. break;
  12217. case "12":
  12218. str = "十二";
  12219. break;
  12220. case "一":
  12221. str = "1";
  12222. break;
  12223. case "二":
  12224. str = "2";
  12225. break;
  12226. case "三":
  12227. str = "3";
  12228. break;
  12229. case "四":
  12230. str = "4";
  12231. break;
  12232. case "五":
  12233. str = "5";
  12234. break;
  12235. case "六":
  12236. str = "6";
  12237. break;
  12238. case "七":
  12239. str = "7";
  12240. break;
  12241. case "八":
  12242. str = "8";
  12243. break;
  12244. case "九":
  12245. str = "9";
  12246. break;
  12247. case "十":
  12248. str = "10";
  12249. break;
  12250. case "十一":
  12251. str = "11";
  12252. break;
  12253. case "十二":
  12254. str = "12";
  12255. break;
  12256. }
  12257. return str;
  12258. }
  12259. // 高亮包含指定文字的部分
  12260. void HighlightText(Run run, string targetText, Color color)
  12261. {
  12262. string text = run.Text;
  12263. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12264. if (startIndex >= 0)
  12265. {
  12266. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12267. // 前部分
  12268. if (startIndex > 0)
  12269. {
  12270. Run beforeRun = (Run)run.Clone(true);
  12271. beforeRun.Text = text.Substring(0, startIndex);
  12272. parentParagraph.InsertBefore(beforeRun, run);
  12273. }
  12274. // 匹配部分
  12275. Run matchRun = (Run)run.Clone(true);
  12276. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12277. matchRun.Font.Color = color;
  12278. parentParagraph.InsertBefore(matchRun, run);
  12279. // 后部分
  12280. if (startIndex + targetText.Length < text.Length)
  12281. {
  12282. Run afterRun = (Run)run.Clone(true);
  12283. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12284. parentParagraph.InsertBefore(afterRun, run);
  12285. }
  12286. // 删除原始Run
  12287. run.Remove();
  12288. }
  12289. }
  12290. #endregion
  12291. #endregion
  12292. #region 团组成本
  12293. /// <summary>
  12294. /// 团组成本数据初始化
  12295. /// </summary>
  12296. /// <param name="dto"></param>
  12297. /// <returns></returns>
  12298. [HttpPost]
  12299. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12300. {
  12301. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12302. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12303. WHEN COUNT(*) >= 0 THEN 'True'
  12304. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12305. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12306. ").ToList(); //团组列表
  12307. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12308. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12309. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12310. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12311. if (groupinfoValue != null)
  12312. {
  12313. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12314. var spArr = new string[1] { countryArr };
  12315. if (countryArr.Contains("|"))
  12316. {
  12317. spArr = countryArr.Split("|");
  12318. }
  12319. else if (countryArr.Contains("、"))
  12320. {
  12321. spArr = countryArr.Split("、");
  12322. }
  12323. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12324. {
  12325. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12326. if (dbQueryCountry != null)
  12327. {
  12328. visaCountryInfoArr.Add(dbQueryCountry);
  12329. }
  12330. }
  12331. }
  12332. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12333. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12334. var create = _GroupCostRepository.
  12335. CreateGroupCostByBlackCode(dto.Diid);
  12336. if (groupCost.Count == 0 && create.Code == 0)
  12337. {
  12338. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12339. }
  12340. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12341. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12342. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12343. groupCostMap = groupCostMap.Select(x =>
  12344. {
  12345. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12346. {
  12347. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12348. }
  12349. return x;
  12350. }).ToList();
  12351. //GroupCostParameter.Add(new
  12352. // Grp_GroupCostParameter());
  12353. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12354. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12355. return Ok(JsonView(new
  12356. {
  12357. groupList,
  12358. groupInfo,
  12359. groupChecks,
  12360. groupCost = groupCostMap,
  12361. hotelNumber,
  12362. GroupCostParameter = GroupCostParameterMap,
  12363. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12364. {
  12365. x.VisaCountry,
  12366. x.VisaPrice,
  12367. x.Id,
  12368. }).ToList(),
  12369. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12370. blackCodeIsTrue = create.Code == 0 ? true : false,
  12371. hotelIsTrue = hotelIsTrue,
  12372. }));
  12373. }
  12374. /// <summary>
  12375. /// 团组成本信息保存
  12376. /// </summary>
  12377. /// <param name="dto"></param>
  12378. /// <returns></returns>
  12379. [HttpPost]
  12380. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12381. {
  12382. if (dto.Diid <= 0 || dto.Userid <= 0)
  12383. {
  12384. return Ok(JsonView(false));
  12385. }
  12386. JsonView jw = null;
  12387. bool isTrue = false;
  12388. #region 复制团组成本
  12389. //if (dto.Diid == 2581)
  12390. //{
  12391. // dto.Diid = 2599;
  12392. // dto.CheckBoxs.ForEach(x =>
  12393. // {
  12394. // x.Diid = 2599;
  12395. // });
  12396. // dto.GroupCosts.ForEach(x =>
  12397. // {
  12398. // x.Diid = 2599;
  12399. // });
  12400. // dto.CostTypeHotelNumbers.ForEach(x =>
  12401. // {
  12402. // x.Diid = 2599;
  12403. // });
  12404. // dto.GroupCostParameters.ForEach(x =>
  12405. // {
  12406. // x.DiId = 2599;
  12407. // });
  12408. //}
  12409. #endregion
  12410. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12411. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12412. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12413. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12414. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12415. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12416. try
  12417. {
  12418. _sqlSugar.BeginTran();
  12419. isTrue = await _GroupCostRepository.
  12420. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12421. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12422. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12423. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12424. _sqlSugar.CommitTran();
  12425. jw = JsonView(true, "保存成功!", isTrue);
  12426. }
  12427. catch (Exception)
  12428. {
  12429. _sqlSugar.RollbackTran();
  12430. jw = JsonView(false);
  12431. }
  12432. return Ok(jw);
  12433. }
  12434. /// <summary>
  12435. /// 司兼导数据
  12436. /// </summary>
  12437. /// <param name="dto"></param>
  12438. /// <returns></returns>
  12439. [HttpPost]
  12440. public IActionResult GetCarGuides(CarGuidesDto dto)
  12441. {
  12442. JsonView jw = null;
  12443. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12444. jw = JsonView(true, "获取成功!", Data);
  12445. return Ok(jw);
  12446. }
  12447. /// <summary>
  12448. /// 导游数据
  12449. /// </summary>
  12450. /// <param name="dto"></param>
  12451. /// <returns></returns>
  12452. [HttpPost]
  12453. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12454. {
  12455. JsonView jw = null;
  12456. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12457. // 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
  12458. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12459. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12460. jw = JsonView(true, "获取成功!", Data);
  12461. return Ok(jw);
  12462. }
  12463. /// <summary>
  12464. /// 成本车数据
  12465. /// </summary>
  12466. /// <param name="dto"></param>
  12467. /// <returns></returns>
  12468. [HttpPost]
  12469. public IActionResult GetCarInfo(CarGuidesDto dto)
  12470. {
  12471. JsonView jw = null;
  12472. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12473. jw = JsonView(true, "获取成功!", Data);
  12474. return Ok(jw);
  12475. }
  12476. /// <summary>
  12477. /// 景点数据
  12478. /// </summary>
  12479. /// <param name="dto"></param>
  12480. /// <returns></returns>
  12481. [HttpPost]
  12482. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12483. {
  12484. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12485. return Ok(JsonView(true, "获取成功!", Data));
  12486. }
  12487. /// <summary>
  12488. /// 成本通知
  12489. /// </summary>
  12490. /// <param name="dto"></param>
  12491. /// <returns></returns>
  12492. [HttpPost]
  12493. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12494. {
  12495. if (dto.Diid < 0)
  12496. {
  12497. return Ok(JsonView(false));
  12498. }
  12499. JsonView jw = null;
  12500. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12501. if (GroupCostParameter != null)
  12502. {
  12503. int IsShare = 0;
  12504. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12505. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12506. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12507. string msg = string.Empty;
  12508. if (isTrue)
  12509. {
  12510. if (IsShare == 0)
  12511. {
  12512. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12513. }
  12514. else
  12515. {
  12516. #region 企微通知对应岗位用户
  12517. try
  12518. {
  12519. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12520. }
  12521. catch (Exception ex)
  12522. {
  12523. }
  12524. #endregion
  12525. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12526. }
  12527. jw = JsonView(isTrue, msg, new { IsShare });
  12528. }
  12529. else
  12530. {
  12531. msg = "修改失败!";
  12532. jw = JsonView(isTrue, msg);
  12533. }
  12534. }
  12535. else
  12536. {
  12537. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12538. }
  12539. return Ok(jw);
  12540. }
  12541. /// <summary>
  12542. /// 导出报价单
  12543. /// </summary>
  12544. /// <param name="dto"></param>
  12545. /// <returns></returns>
  12546. [HttpPost]
  12547. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12548. {
  12549. if (dto.Diid == 0)
  12550. {
  12551. return Ok(JsonView(false, "请传递团组id"));
  12552. }
  12553. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12554. if (deleInfo.Code != 0)
  12555. {
  12556. return Ok(JsonView(false, "团组信息查询失败!"));
  12557. }
  12558. var di = deleInfo.Data as DelegationInfoWebView;
  12559. if (di != null)
  12560. {
  12561. di.TeamName = di.TeamName.Replace("|", "、");
  12562. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12563. //文件名
  12564. string strFileName = di.TeamName + "-收款账单.doc";
  12565. //获取模板
  12566. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12567. //载入模板
  12568. Document doc = new Document(tmppath);
  12569. decimal TotalPrice = 0.00M;
  12570. string itemStr = string.Empty;
  12571. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12572. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12573. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12574. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12575. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12576. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12577. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12578. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12579. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12580. foreach (var cost in groupCostType)
  12581. {
  12582. var List = cost.ToList();
  12583. if (cost.Key == "A")
  12584. {
  12585. foreach (var ListItem in List)
  12586. {
  12587. if (ListItem.number > 0)
  12588. {
  12589. if (ListItem.code.Contains("TBR"))
  12590. {
  12591. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12592. }
  12593. else
  12594. {
  12595. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12596. }
  12597. TotalPrice += (ListItem.number * ListItem.price);
  12598. }
  12599. }
  12600. }
  12601. else
  12602. {
  12603. itemStr = itemStr.Insert(0, "A段\r\n");
  12604. itemStr += "B段\r\n";
  12605. foreach (var ListItem in List)
  12606. {
  12607. if (ListItem.number > 0)
  12608. {
  12609. if (ListItem.code.Contains("TBR"))
  12610. {
  12611. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12612. }
  12613. else
  12614. {
  12615. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12616. }
  12617. TotalPrice += (ListItem.number * ListItem.price);
  12618. }
  12619. }
  12620. }
  12621. }
  12622. #region 替换Word模板书签内容
  12623. Dictionary<string, string> marks = new Dictionary<string, string>();
  12624. marks.Add("To", di.ClientUnit);//付款方
  12625. marks.Add("ToTel", di.TellPhone);//付款方电话
  12626. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12627. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12628. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12629. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12630. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12631. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12632. marks.Add("PayItemContent", itemStr);//详细信息
  12633. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12634. #endregion
  12635. ////注
  12636. //if (doc.Range.Bookmarks["Attention"] != null)
  12637. //{
  12638. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12639. // mark.Text = frList[0].Attention;
  12640. //}
  12641. foreach (var item in marks.Keys)
  12642. {
  12643. if (doc.Range.Bookmarks[item] != null)
  12644. {
  12645. Bookmark mark = doc.Range.Bookmarks[item];
  12646. mark.Text = marks[item];
  12647. }
  12648. }
  12649. byte[] bytes = null;
  12650. using (MemoryStream stream = new MemoryStream())
  12651. {
  12652. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12653. bytes = stream.ToArray();
  12654. }
  12655. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12656. return Ok(JsonView(true, "", new
  12657. {
  12658. Data = bytes,
  12659. strFileName,
  12660. }));
  12661. }
  12662. else
  12663. {
  12664. return Ok(JsonView(false, "团组信息不存在!"));
  12665. }
  12666. }
  12667. /// <summary>
  12668. /// 导出团组成本
  12669. /// </summary>
  12670. /// <param name="dto"></param>
  12671. /// <returns></returns>
  12672. [HttpPost]
  12673. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12674. {
  12675. var jw = JsonView(false);
  12676. if (dto.Diid == 0)
  12677. {
  12678. return Ok(JsonView(false, "请传递团组id"));
  12679. }
  12680. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12681. if (deleInfo.Code != 0)
  12682. {
  12683. return Ok(JsonView(false, "团组信息查询失败!"));
  12684. }
  12685. var di = deleInfo.Data as DelegationInfoWebView;
  12686. if (di == null)
  12687. {
  12688. return Ok(JsonView(false, "团组信息查询失败!"));
  12689. }
  12690. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12691. WorkbookDesigner designer = new WorkbookDesigner();
  12692. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12693. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12694. for (int i = 0; i < List_GC.Count; i++)
  12695. {
  12696. GroupCost_Excel gc = new GroupCost_Excel();
  12697. gc.Id = List_GC[i].Id;
  12698. gc.Diid = List_GC[i].Diid.ToString();
  12699. gc.DAY = List_GC[i].DAY;
  12700. string week = "";
  12701. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12702. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12703. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12704. gc.ITIN = List_GC[i].ITIN;
  12705. gc.CarType = List_GC[i].CarType;
  12706. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12707. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12708. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12709. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12710. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12711. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12712. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12713. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12714. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12715. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12716. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12717. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12718. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12719. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12720. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12721. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12722. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12723. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12724. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12725. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12726. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12727. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12728. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12729. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12730. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12731. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12732. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12733. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12734. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12735. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12736. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12737. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12738. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12739. List_GC1.Add(gc);
  12740. }
  12741. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12742. dt.TableName = "TB";
  12743. //报表标题等不用dt的值
  12744. designer.SetDataSource("TeamName", dto.title.TeamName);
  12745. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12746. designer.SetDataSource("Tax", dto.title.Tax);
  12747. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12748. designer.SetDataSource("Currency", dto.title.Currency);
  12749. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12750. designer.SetDataSource("Rate", dto.title.Rate);
  12751. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12752. var Aparams = hotels.Find(x => x.Type == "Default");
  12753. if (Aparams == null)
  12754. {
  12755. return Ok(jw);
  12756. }
  12757. //酒店数量
  12758. var txtSGRNumber = Aparams.SGR.ToString();
  12759. var txtTBRNumber = Aparams.TBR.ToString();
  12760. var txtJSESNumber = Aparams.JSES.ToString();
  12761. var txtSUITENumbe = Aparams.SUITE.ToString();
  12762. if (dto.costType == "B")
  12763. {
  12764. Aparams = hotels.Find(x => x.Type == "A");
  12765. var Bparams = hotels.Find(x => x.Type == "B");
  12766. if (Aparams == null || Bparams == null)
  12767. {
  12768. return Ok(jw);
  12769. }
  12770. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12771. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12772. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12773. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12774. }
  12775. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12776. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12777. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12778. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12779. var ws = designer.Workbook.Worksheets[0];
  12780. int Row = List_GC.Count;
  12781. int startIndex = 11;
  12782. int HideRows = 0;
  12783. List<int> hideRowsList = new List<int>();
  12784. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12785. #region A段left数据
  12786. var left = dto.leftInfo.Find(x => x.Type == "A");
  12787. if (left == null)
  12788. {
  12789. return Ok(jw);
  12790. }
  12791. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12792. if (leftBindData != null)
  12793. {
  12794. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12795. designer.SetDataSource("VisaRS", leftBindData.rs);
  12796. designer.SetDataSource("VisaXS", leftBindData.xs);
  12797. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12798. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12799. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12800. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12801. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12802. }
  12803. else
  12804. {
  12805. hideRowsList.Add(Row + startIndex + HideRows);
  12806. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12807. }
  12808. HideRows += 2;
  12809. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12810. if (leftBindData != null)
  12811. {
  12812. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12813. designer.SetDataSource("BXRS", leftBindData.rs);
  12814. designer.SetDataSource("BXXS", leftBindData.xs);
  12815. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12816. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12817. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12818. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12819. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12820. }
  12821. else
  12822. {
  12823. hideRowsList.Add(Row + startIndex + HideRows);
  12824. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12825. }
  12826. HideRows += 2;
  12827. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12828. if (leftBindData != null)
  12829. {
  12830. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12831. designer.SetDataSource("HSRS", leftBindData.rs);
  12832. designer.SetDataSource("HSXS", leftBindData.xs);
  12833. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12834. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12835. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12836. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12837. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12838. }
  12839. else
  12840. {
  12841. hideRowsList.Add(Row + startIndex + HideRows);
  12842. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12843. }
  12844. HideRows += 2;
  12845. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12846. if (leftBindData != null)
  12847. {
  12848. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12849. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12850. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12851. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12852. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12853. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12854. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12855. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12856. }
  12857. else
  12858. {
  12859. hideRowsList.Add(Row + startIndex + HideRows);
  12860. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12861. }
  12862. HideRows += 2;
  12863. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12864. if (leftBindData != null)
  12865. {
  12866. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12867. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12868. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12869. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12870. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12871. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12872. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12873. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12874. }
  12875. else
  12876. {
  12877. hideRowsList.Add(Row + startIndex + HideRows);
  12878. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12879. }
  12880. HideRows += 2;
  12881. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12882. if (leftBindData != null)
  12883. {
  12884. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12885. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12886. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12887. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12888. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12889. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12890. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12891. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12892. }
  12893. else
  12894. {
  12895. hideRowsList.Add(Row + startIndex + HideRows);
  12896. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12897. }
  12898. HideRows += 2;
  12899. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12900. if (leftBindData != null)
  12901. {
  12902. ////TBR
  12903. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12904. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12905. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12906. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12907. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12908. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12909. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12910. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12911. }
  12912. else
  12913. {
  12914. hideRowsList.Add(Row + startIndex + HideRows);
  12915. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12916. }
  12917. HideRows += 2;
  12918. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12919. if (leftBindData != null)
  12920. {
  12921. ////SGR
  12922. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12923. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12924. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12925. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12926. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12927. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12928. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12929. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12930. }
  12931. else
  12932. {
  12933. hideRowsList.Add(Row + startIndex + HideRows);
  12934. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12935. }
  12936. HideRows += 2;
  12937. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12938. if (leftBindData != null)
  12939. {
  12940. ////JS/ES
  12941. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12942. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12943. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12944. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12945. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12946. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12947. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12948. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12949. }
  12950. else
  12951. {
  12952. hideRowsList.Add(Row + startIndex + HideRows);
  12953. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12954. }
  12955. HideRows += 2;
  12956. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12957. if (leftBindData != null)
  12958. {
  12959. ////SUITE
  12960. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12961. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12962. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12963. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12964. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12965. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12966. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12967. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12968. }
  12969. else
  12970. {
  12971. hideRowsList.Add(Row + startIndex + HideRows);
  12972. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12973. }
  12974. HideRows += 2;
  12975. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12976. if (leftBindData != null)
  12977. {
  12978. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12979. designer.SetDataSource("DJRS", leftBindData.rs);
  12980. designer.SetDataSource("DJXS", leftBindData.xs);
  12981. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12982. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12983. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12984. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12985. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12986. }
  12987. else
  12988. {
  12989. hideRowsList.Add(Row + startIndex + HideRows);
  12990. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12991. }
  12992. HideRows += 2;
  12993. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12994. if (leftBindData != null)
  12995. {
  12996. designer.SetDataSource("HCPCB", leftBindData.cb);
  12997. designer.SetDataSource("HCPRS", leftBindData.rs);
  12998. designer.SetDataSource("HCPXS", leftBindData.xs);
  12999. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13000. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13001. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13002. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13003. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13004. }
  13005. else
  13006. {
  13007. hideRowsList.Add(Row + startIndex + HideRows);
  13008. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13009. }
  13010. HideRows += 2;
  13011. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13012. if (leftBindData != null)
  13013. {
  13014. designer.SetDataSource("CPCB", leftBindData.cb);
  13015. designer.SetDataSource("CPRS", leftBindData.rs);
  13016. designer.SetDataSource("CPXS", leftBindData.xs);
  13017. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13018. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13019. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13020. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13021. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13022. }
  13023. else
  13024. {
  13025. hideRowsList.Add(Row + startIndex + HideRows);
  13026. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13027. }
  13028. HideRows += 2;
  13029. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13030. if (leftBindData != null)
  13031. {
  13032. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13033. designer.SetDataSource("GWRS", leftBindData.rs);
  13034. designer.SetDataSource("GWXS", leftBindData.xs);
  13035. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13036. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13037. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13038. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13039. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13040. }
  13041. else
  13042. {
  13043. hideRowsList.Add(Row + startIndex + HideRows);
  13044. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13045. }
  13046. HideRows += 2;
  13047. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13048. if (leftBindData != null)
  13049. {
  13050. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13051. designer.SetDataSource("LYJRS", leftBindData.rs);
  13052. designer.SetDataSource("LYJXS", leftBindData.xs);
  13053. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13054. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13055. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13056. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13057. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13058. }
  13059. else
  13060. {
  13061. hideRowsList.Add(Row + startIndex + HideRows);
  13062. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13063. }
  13064. #endregion
  13065. #region A段Right信息
  13066. var right = dto.rightInfo.Find(x => x.Type == "A");
  13067. if (right == null)
  13068. {
  13069. return Ok(jw);
  13070. }
  13071. HideRows += 4;
  13072. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13073. if (rightBindData != null)
  13074. {
  13075. //经济舱 + 双人间 TBR
  13076. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13077. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13078. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13079. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13080. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13081. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13082. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13083. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13084. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13085. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13086. }
  13087. else
  13088. {
  13089. hideRowsList.Add(Row + startIndex + HideRows);
  13090. }
  13091. HideRows += 2;
  13092. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13093. if (rightBindData != null)
  13094. {
  13095. //经济舱 + 单人间 SGR
  13096. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13097. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13098. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13099. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13100. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13101. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13102. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13103. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13104. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13105. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13106. }
  13107. else
  13108. {
  13109. hideRowsList.Add(Row + startIndex + HideRows);
  13110. }
  13111. HideRows += 2;
  13112. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13113. if (rightBindData != null)
  13114. {
  13115. //公务舱 + 单人间 SGR
  13116. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13117. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13118. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13119. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13120. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13121. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13122. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13123. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13124. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13125. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13126. }
  13127. else
  13128. {
  13129. hideRowsList.Add(Row + startIndex + HideRows);
  13130. }
  13131. HideRows += 2;
  13132. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13133. if (rightBindData != null)
  13134. {
  13135. //公务舱 + 小套房 JSES
  13136. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13137. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13138. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13139. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13140. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13141. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13142. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13143. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13144. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13145. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13146. }
  13147. else
  13148. {
  13149. hideRowsList.Add(Row + startIndex + HideRows);
  13150. }
  13151. HideRows += 2;
  13152. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13153. if (rightBindData != null)
  13154. {
  13155. //公务舱 + 小套房 JSES
  13156. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13157. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13158. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13159. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13160. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13161. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13162. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13163. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13164. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13165. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13166. }
  13167. else
  13168. {
  13169. hideRowsList.Add(Row + startIndex + HideRows);
  13170. }
  13171. HideRows += 2;
  13172. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13173. if (rightBindData != null)
  13174. {
  13175. //经济舱 + 大套房
  13176. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13177. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13178. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13179. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13180. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13181. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13182. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13183. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13184. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13185. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13186. }
  13187. else
  13188. {
  13189. hideRowsList.Add(Row + startIndex + HideRows);
  13190. }
  13191. HideRows += 2;
  13192. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13193. if (rightBindData != null)
  13194. {
  13195. //头等舱 + 小套房 JSES
  13196. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13197. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13198. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13199. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13200. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13201. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13202. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13203. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13204. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13205. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13206. }
  13207. else
  13208. {
  13209. hideRowsList.Add(Row + startIndex + HideRows);
  13210. }
  13211. HideRows += 2;
  13212. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13213. if (rightBindData != null)
  13214. {
  13215. //头等舱 + 大套房
  13216. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13217. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13218. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13219. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13220. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13221. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13222. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13223. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13224. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13225. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13226. }
  13227. else
  13228. {
  13229. hideRowsList.Add(Row + startIndex + HideRows);
  13230. }
  13231. #endregion
  13232. #region B段标题清空
  13233. designer.SetDataSource("CostBDRCB", "");
  13234. designer.SetDataSource("CostBRS", "");
  13235. designer.SetDataSource("CostBXS", "");
  13236. designer.SetDataSource("CostBZCB", "");
  13237. designer.SetDataSource("CostBDRBJ", "");
  13238. designer.SetDataSource("CostBZBJ", "");
  13239. designer.SetDataSource("CostBDRLR", "");
  13240. designer.SetDataSource("CostBZLR", "");
  13241. designer.SetDataSource("CostBDRCBOM", "");
  13242. designer.SetDataSource("CostBRSOM", "");
  13243. designer.SetDataSource("CostBZCBOM", "");
  13244. designer.SetDataSource("CostBDRBJOM", "");
  13245. designer.SetDataSource("CostBZBJOM", "");
  13246. designer.SetDataSource("CostBDRLROM", "");
  13247. designer.SetDataSource("CostBZLROM", "");
  13248. #endregion
  13249. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13250. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13251. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13252. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13253. designer.SetDataSource("DJName", "地接(CNY)");
  13254. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13255. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13256. designer.SetDataSource("GWName", "公务(CNY)");
  13257. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13258. designer.SetDataSource("LYJName", "零用金(CNY)");
  13259. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13260. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13261. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13262. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13263. designer.SetDataSource("BXName", "保险(CNY)");
  13264. designer.SetDataSource("VisaName", "签证(CNY)");
  13265. #region B段基本数据
  13266. if (dto.costType == "B")
  13267. {
  13268. left = dto.leftInfo.Find(x => x.Type == "B");
  13269. if (left == null)
  13270. {
  13271. return Ok(jw);
  13272. }
  13273. #region B段left数据
  13274. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13275. if (leftBindData != null)
  13276. {
  13277. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13278. designer.SetDataSource("BHSRS", leftBindData.rs);
  13279. designer.SetDataSource("BHSXS", leftBindData.xs);
  13280. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13281. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13282. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13283. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13284. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13285. }
  13286. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13287. if (leftBindData != null)
  13288. {
  13289. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13290. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13291. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13292. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13293. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13294. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13295. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13296. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13297. }
  13298. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13299. if (leftBindData != null)
  13300. {
  13301. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13302. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13303. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13304. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13305. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13306. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13307. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13308. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13309. }
  13310. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13311. if (leftBindData != null)
  13312. {
  13313. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13314. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13315. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13316. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13317. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13318. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13319. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13320. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13321. }
  13322. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13323. if (leftBindData != null)
  13324. {
  13325. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13326. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13327. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13328. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13329. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13330. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13331. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13332. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13333. }
  13334. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13335. if (leftBindData != null)
  13336. {
  13337. designer.SetDataSource("BCPCB", leftBindData.cb);
  13338. designer.SetDataSource("BCPRS", leftBindData.rs);
  13339. designer.SetDataSource("BCPXS", leftBindData.xs);
  13340. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13341. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13342. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13343. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13344. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13345. }
  13346. //TBR
  13347. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13348. if (leftBindData != null)
  13349. {
  13350. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13351. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13352. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13353. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13354. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13355. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13356. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13357. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13358. }
  13359. //SGR
  13360. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13361. if (leftBindData != null)
  13362. {
  13363. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13364. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13365. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13366. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13367. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13368. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13369. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13370. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13371. }
  13372. //JS/ES
  13373. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13374. if (leftBindData != null)
  13375. {
  13376. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13377. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13378. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13379. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13380. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13381. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13382. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13383. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13384. }
  13385. //SUITE
  13386. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13387. if (leftBindData != null)
  13388. {
  13389. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13390. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13391. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13392. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13393. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13394. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13395. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13396. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13397. }
  13398. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13399. if (leftBindData != null)
  13400. {
  13401. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13402. designer.SetDataSource("BDJRS", leftBindData.rs);
  13403. designer.SetDataSource("BDJXS", leftBindData.xs);
  13404. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13405. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13406. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13407. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13408. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13409. }
  13410. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13411. if (leftBindData != null)
  13412. {
  13413. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13414. designer.SetDataSource("BGWRS", leftBindData.rs);
  13415. designer.SetDataSource("BGWXS", leftBindData.xs);
  13416. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13417. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13418. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13419. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13420. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13421. }
  13422. #region 优化方案
  13423. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13424. //excelBind.Add("零用金", new {
  13425. //cb="",
  13426. //rs="",
  13427. //xs ="",
  13428. //zcb = "",
  13429. //});
  13430. #endregion
  13431. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13432. if (leftBindData != null)
  13433. {
  13434. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13435. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13436. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13437. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13438. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13439. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13440. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13441. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13442. }
  13443. #endregion
  13444. #region B段Right信息
  13445. right = dto.rightInfo.Find(x => x.Type == "B");
  13446. if (right == null)
  13447. {
  13448. return Ok(jw);
  13449. }
  13450. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13451. if (rightBindData != null)
  13452. {
  13453. //经济舱 + 双人间 TBR
  13454. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13455. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13456. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13457. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13458. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13459. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13460. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13461. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13462. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13463. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13464. }
  13465. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13466. if (rightBindData != null)
  13467. {
  13468. //经济舱 + 单人间 SGR
  13469. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13470. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13471. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13472. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13473. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13474. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13475. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13476. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13477. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13478. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13479. }
  13480. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13481. if (rightBindData != null)
  13482. {
  13483. //公务舱 + 单人间 SGR
  13484. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13485. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13486. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13487. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13488. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13489. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13490. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13491. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13492. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13493. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13494. }
  13495. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13496. if (rightBindData != null)
  13497. {
  13498. //公务舱 + 小套房 JSES
  13499. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13500. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13501. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13502. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13503. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13504. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13505. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13506. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13507. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13508. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13509. }
  13510. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13511. if (rightBindData != null)
  13512. {
  13513. //公务舱 + 小套房 JSES
  13514. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13515. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13516. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13517. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13518. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13519. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13520. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13521. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13522. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13523. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13524. }
  13525. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13526. if (rightBindData != null)
  13527. {
  13528. //经济舱 + 大套房
  13529. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13530. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13531. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13532. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13533. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13534. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13535. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13536. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13537. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13538. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13539. }
  13540. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13541. if (rightBindData != null)
  13542. {
  13543. //头等舱 + 小套房 JSES
  13544. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13545. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13546. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13547. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13548. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13549. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13550. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13551. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13552. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13553. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13554. }
  13555. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13556. if (rightBindData != null)
  13557. {
  13558. //头等舱 + 大套房
  13559. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13560. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13561. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13562. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13563. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13564. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13565. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13566. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13567. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13568. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13569. }
  13570. #endregion
  13571. #region 标题
  13572. designer.SetDataSource("CostBDRCB", "单人成本");
  13573. designer.SetDataSource("CostBRS", "人数");
  13574. designer.SetDataSource("CostBXS", "系数");
  13575. designer.SetDataSource("CostBZCB", "总成本");
  13576. designer.SetDataSource("CostBDRBJ", "单人报价");
  13577. designer.SetDataSource("CostBZBJ", "总报价");
  13578. designer.SetDataSource("CostBDRLR", "单人利润");
  13579. designer.SetDataSource("CostBZLR", "总利润");
  13580. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13581. designer.SetDataSource("CostBRSOM", "人数");
  13582. designer.SetDataSource("CostBZCBOM", "总成本");
  13583. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13584. designer.SetDataSource("CostBZBJOM", "总报价");
  13585. designer.SetDataSource("CostBDRLROM", "单人利润");
  13586. designer.SetDataSource("CostBZLROM", "总利润");
  13587. #endregion
  13588. }
  13589. #endregion
  13590. designer.SetDataSource("TzZCB2", TzZCB2);
  13591. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13592. designer.SetDataSource("TzZLR2", TzZLR2);
  13593. string[] dataSourceKeys = new string[]
  13594. {
  13595. "VF",
  13596. "TGS",
  13597. "TGOF",
  13598. "TGM",
  13599. "TGA",
  13600. "TGTF",
  13601. "TGEF",
  13602. "CFM",
  13603. "CFOF",
  13604. "B",
  13605. "L",
  13606. "D",
  13607. "TBR",
  13608. "SGR",
  13609. "JSES",
  13610. "Suite",
  13611. "TV",
  13612. "1L",
  13613. "IF",
  13614. "EF",
  13615. "BRF",
  13616. "TE",
  13617. "TGT",
  13618. "DRVT",
  13619. "PC",
  13620. "TLF",
  13621. "ECT"
  13622. };
  13623. foreach (var item in dataSourceKeys)
  13624. {
  13625. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13626. if (find != null)
  13627. {
  13628. designer.SetDataSource(item, find.text);
  13629. }
  13630. else
  13631. {
  13632. designer.SetDataSource(item, 0);
  13633. }
  13634. }
  13635. designer.SetDataSource(dt);
  13636. //根据数据源处理生成报表内容
  13637. designer.Process();
  13638. designer.Workbook.Worksheets[0].Name = "清单";
  13639. Worksheet sheet = designer.Workbook.Worksheets[0];
  13640. foreach (var Rowindex in hideRowsList)
  13641. {
  13642. ws.Cells.HideRows(Rowindex, 2);
  13643. }
  13644. byte[] bytes = null;
  13645. string strFileName = di.TeamName + "-团组-成本.xls";
  13646. using (MemoryStream stream = new MemoryStream())
  13647. {
  13648. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13649. bytes = stream.ToArray();
  13650. }
  13651. return Ok(JsonView(true, "", new
  13652. {
  13653. Data = bytes,
  13654. strFileName,
  13655. }));
  13656. }
  13657. /// <summary>
  13658. /// 导出客户报表
  13659. /// </summary>
  13660. /// <returns></returns>
  13661. [HttpPost]
  13662. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13663. {
  13664. var jw = JsonView(false);
  13665. if (dto.Diid == 0)
  13666. {
  13667. return Ok(JsonView(false, "请传递团组id"));
  13668. }
  13669. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13670. if (deleInfo.Code != 0)
  13671. {
  13672. return Ok(JsonView(false, "团组信息查询失败!"));
  13673. }
  13674. var di = deleInfo.Data as DelegationInfoWebView;
  13675. if (di == null)
  13676. {
  13677. return Ok(JsonView(false, "团组信息查询失败!"));
  13678. }
  13679. //文件名
  13680. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13681. //获取模板
  13682. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13683. //载入模板
  13684. Document doc = new Document(tmppath);
  13685. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13686. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13687. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13688. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13689. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13690. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13691. if (AParameter == null)
  13692. {
  13693. return Ok(JsonView(false, "系数不存在!"));
  13694. }
  13695. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13696. , TzAirDesc, TzZCost;
  13697. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13698. = TzAirDesc = TzZCost = string.Empty;
  13699. TzNumber = AParameter.CostTypenumber.ToString();
  13700. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13701. CarGuides1 = dto.CarGuides1;
  13702. Meal = dto.Meal;
  13703. SubsidizedMeals = dto.SubsidizedMeals;
  13704. NightRepair = dto.NightRepair;
  13705. AttractionsTickets = dto.AttractionsTickets;
  13706. MiscellaneousFees = dto.MiscellaneousFees;
  13707. ATip = dto.ATip;
  13708. TzHotelDesc = "";
  13709. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13710. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13711. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13712. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13713. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13714. TzAirDesc = "";
  13715. TzZCost = dto.TzZCost;
  13716. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13717. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13718. var index = 1;
  13719. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13720. foreach (var item in TzHotelDescArr)
  13721. {
  13722. if (AinfoArr != null)
  13723. {
  13724. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13725. if (Ainfo != null)
  13726. {
  13727. if (int.Parse(Ainfo.rs) <= 0)
  13728. {
  13729. continue;
  13730. }
  13731. var hotelText = string.Empty;
  13732. switch (item)
  13733. {
  13734. case "SGR":
  13735. hotelText = "单人间";
  13736. break;
  13737. case "JSES":
  13738. hotelText = "小套房";
  13739. break;
  13740. case "SUITE":
  13741. hotelText = "套房";
  13742. break;
  13743. case "TBR":
  13744. hotelText = "双人间";
  13745. break;
  13746. }
  13747. if (item != "TBR")
  13748. {
  13749. 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";
  13750. }
  13751. else
  13752. {
  13753. 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";
  13754. }
  13755. index++;
  13756. }
  13757. }
  13758. }
  13759. index = 1;
  13760. foreach (var item in TzAirDescArr)
  13761. {
  13762. if (AinfoArr != null)
  13763. {
  13764. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13765. if (Ainfo != null)
  13766. {
  13767. if (int.Parse(Ainfo.rs) <= 0)
  13768. {
  13769. continue;
  13770. }
  13771. 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";
  13772. index++;
  13773. }
  13774. }
  13775. }
  13776. if (dto.costType == "B")
  13777. {
  13778. if (BParameter == null)
  13779. {
  13780. return Ok(JsonView(false, "B段系数不存在!"));
  13781. }
  13782. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13783. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13784. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13785. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13786. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13787. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13788. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13789. foreach (var item in TzHotelDescArr)
  13790. {
  13791. if (AinfoArr != null)
  13792. {
  13793. TzHotelDesc += "B段信息 \r\n";
  13794. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13795. if (Ainfo != null)
  13796. {
  13797. if (int.Parse(Ainfo.rs) <= 0)
  13798. {
  13799. continue;
  13800. }
  13801. var hotelText = string.Empty;
  13802. switch (item)
  13803. {
  13804. case "SGR":
  13805. hotelText = "单人间";
  13806. break;
  13807. case "JSES":
  13808. hotelText = "小套房";
  13809. break;
  13810. case "SUITE":
  13811. hotelText = "套房";
  13812. break;
  13813. case "TBR":
  13814. hotelText = "双人间";
  13815. break;
  13816. }
  13817. if (item != "TBR")
  13818. {
  13819. 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";
  13820. }
  13821. else
  13822. {
  13823. 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";
  13824. }
  13825. index++;
  13826. }
  13827. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13828. }
  13829. }
  13830. index = 1;
  13831. foreach (var item in TzAirDescArr)
  13832. {
  13833. if (AinfoArr != null)
  13834. {
  13835. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13836. if (Ainfo != null)
  13837. {
  13838. if (int.Parse(Ainfo.rs) <= 0)
  13839. {
  13840. continue;
  13841. }
  13842. 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";
  13843. index++;
  13844. }
  13845. }
  13846. }
  13847. }
  13848. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13849. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13850. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13851. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13852. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13853. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13854. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13855. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13856. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13857. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13858. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13859. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13860. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13861. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13862. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13863. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13864. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13865. DickeyValue.Add("TzZCost", TzZCost);
  13866. foreach (var key in DickeyValue.Keys)
  13867. {
  13868. if (doc.Range.Bookmarks[key] != null)
  13869. {
  13870. Bookmark mark = doc.Range.Bookmarks[key];
  13871. mark.Text = DickeyValue[key];
  13872. }
  13873. }
  13874. byte[] bytes = null;
  13875. string strFileName = di.TeamName + "-客户报价.doc";
  13876. using (MemoryStream stream = new MemoryStream())
  13877. {
  13878. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13879. bytes = stream.ToArray();
  13880. }
  13881. return Ok(JsonView(true, "", new
  13882. {
  13883. Data = bytes,
  13884. strFileName,
  13885. }));
  13886. }
  13887. /// <summary>
  13888. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13889. /// </summary>
  13890. /// <param name="dto"></param>
  13891. /// <returns></returns>
  13892. [HttpPost]
  13893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13894. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13895. {
  13896. try
  13897. {
  13898. #region 参数验证
  13899. if (dto.DiId < 0)
  13900. {
  13901. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13902. }
  13903. List<int> cTableIds = new List<int>() {
  13904. 76 ,//酒店预订
  13905. 77 ,//行程
  13906. 79 ,//车/导游地接
  13907. 80 ,//签证
  13908. 81 ,//邀请/公务活
  13909. 82 ,//团组客户保险
  13910. 85 ,//机票预订
  13911. 98 ,//其他款项
  13912. 285 ,//收款退还
  13913. 751 ,//酒店早餐
  13914. 1015 // 超支费用
  13915. };
  13916. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13917. {
  13918. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13919. }
  13920. #endregion
  13921. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13922. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13923. if (_GroupCostParameters.Count <= 0)
  13924. {
  13925. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13926. }
  13927. if (_GroupCostParameters[0].IsShare == 0)
  13928. {
  13929. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13930. }
  13931. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13932. //处理date为空问题
  13933. if (_GroupCosts.Count > 0)
  13934. {
  13935. for (int i = 0; i < _GroupCosts.Count; i++)
  13936. {
  13937. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13938. {
  13939. if (i > 0)
  13940. {
  13941. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13942. }
  13943. }
  13944. }
  13945. }
  13946. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13947. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13948. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13949. string currCode = "";
  13950. #region currCode 验证
  13951. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13952. if (isInt)
  13953. {
  13954. var currData = currDatas.Find(it => it.Id == intCurrency);
  13955. if (currData != null)
  13956. {
  13957. currCode = currData.Name;
  13958. }
  13959. }
  13960. else
  13961. {
  13962. currCode = _GroupCostParameters[0].Currency.Trim();
  13963. }
  13964. #endregion
  13965. //op,酒店单段模式存储
  13966. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13967. {
  13968. CurrencyCode = currCode,
  13969. Rate = _GroupCostParameters[0].Rate,
  13970. CostType = _GroupCostParameters[0].CostType,
  13971. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13972. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13973. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13974. };
  13975. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13976. if (_GroupCostParameters.Count == 2)
  13977. {
  13978. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13979. }
  13980. foreach (var item in _GroupCostParameters)
  13981. {
  13982. decimal _rate = 1;
  13983. decimal _rate1 = item.Rate;
  13984. decimal _scale = 1;
  13985. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13986. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13987. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13988. //if (userInfo != null)
  13989. //{
  13990. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13991. // {
  13992. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13993. // {
  13994. // _scale = 1.00M;
  13995. // }
  13996. // }
  13997. //}
  13998. #endregion
  13999. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  14000. {
  14001. CurrencyCode = currCode,
  14002. Rate = _rate1,
  14003. CostType = item.CostType,
  14004. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  14005. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  14006. CostTypeNumber = item.CostTypenumber
  14007. };
  14008. if (_GroupCostParameters.Count > 1)
  14009. {
  14010. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  14011. }
  14012. else
  14013. {
  14014. modulePromptInfo.CostTypeNumber = item.LYJRS;
  14015. }
  14016. if (dto.CTable == 79)//
  14017. {
  14018. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14019. modulePromptInfo.TotalCost = item.DJCB;
  14020. }
  14021. List<string> costTypes = new List<string>() { "A", "B" };
  14022. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14023. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14024. if (_GroupCostsDuplicates.Count() == 1)
  14025. {
  14026. _GroupCostsTypeData = _GroupCosts;
  14027. }
  14028. else
  14029. {
  14030. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14031. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14032. }
  14033. /*
  14034. * 76 酒店预订
  14035. * 77 行程
  14036. * 79 车/导游地接
  14037. * 80 签证
  14038. * 81 邀请/公务活动
  14039. * 82 团组客户保险
  14040. * 85 机票预订
  14041. * 98 其他款项
  14042. * 285 收款退还
  14043. * 751 酒店早餐
  14044. * 1015 超支费用
  14045. */
  14046. switch (dto.CTable)
  14047. {
  14048. case 76: // 酒店预订
  14049. _ModuleSubPromptInfo.AddRange(
  14050. _GroupCostsTypeData.Select(it => new
  14051. {
  14052. it.DAY,
  14053. it.Date,
  14054. it.ACCON,
  14055. it.ITIN,
  14056. it.SGR,
  14057. it.TBR,
  14058. it.JS_ES,
  14059. it.Suite
  14060. })
  14061. );
  14062. break;
  14063. case 79: // 车/导游地接
  14064. _ModuleSubPromptInfo.AddRange(
  14065. _GroupCostsTypeData.Select(it => new
  14066. {
  14067. Date = it.Date, //日期
  14068. CarFee = it.CarCost * _rate * _scale, //车费用
  14069. CarType = it.CarType, //车型
  14070. DriverFee = it.CFS * _rate * _scale, //司机工资
  14071. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14072. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14073. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14074. GuideFee = it.TGS * _rate * _scale, //导游费用
  14075. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14076. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14077. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14078. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14079. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14080. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14081. Breakfast = it.B * _rate * _scale, //早餐费
  14082. Lunch = it.L * _rate * _scale, //午餐费
  14083. Dinner = it.D * _rate * _scale, //晚餐费
  14084. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14085. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14086. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14087. TicketFee = it.EF * _rate * _scale, //门票费
  14088. TicketRemark = it.EFR, //门票费描述
  14089. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14090. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14091. SpentCash = it.PC * _rate * _scale, //零用金
  14092. LeadersFee = it.TLF * _rate * _scale, //领队费
  14093. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14094. })
  14095. );
  14096. break;
  14097. case 85: // 机票
  14098. List<dynamic> datas = new List<dynamic>();
  14099. datas.Add(
  14100. new
  14101. {
  14102. AirType = "经济舱",
  14103. AirNum = item.JJCRS,
  14104. AirDRCB = item.JJCCB,
  14105. AirZCB = (item.JJCRS * item.JJCCB)
  14106. }
  14107. );
  14108. datas.Add(
  14109. new
  14110. {
  14111. AirType = "公务舱",
  14112. AirNum = item.GWCRS,
  14113. AirDRCB = item.GWCCB,
  14114. AirZCB = (item.GWCRS * item.GWCCB)
  14115. }
  14116. );
  14117. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14118. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14119. modulePromptInfo.Data = new
  14120. {
  14121. airFeeData = datas,
  14122. airInitData = initDatas
  14123. };
  14124. _ModulePromptInfos.Add(modulePromptInfo);
  14125. break;
  14126. default:
  14127. break;
  14128. }
  14129. }
  14130. if (dto.CTable != 85)
  14131. {
  14132. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14133. _ModulePromptInfos.Add(_ModulePromptInfo);
  14134. }
  14135. _view.ModulePromptInfos = _ModulePromptInfos;
  14136. return Ok(JsonView(true, "操作成功!", _view));
  14137. }
  14138. catch (Exception ex)
  14139. {
  14140. return Ok(JsonView(false, ex.Message));
  14141. }
  14142. }
  14143. /// <summary>
  14144. /// 根据黑屏代码重新生成行程
  14145. /// </summary>
  14146. /// <param name="dto"></param>
  14147. /// <returns></returns>
  14148. [HttpPost]
  14149. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14150. {
  14151. var jw = JsonView(false);
  14152. var Create = _GroupCostRepository.
  14153. CreateGroupCostByBlackCode(dto.Diid);
  14154. jw.Msg = Create.Msg;
  14155. if (Create.Code == 0)
  14156. {
  14157. jw.Code = 200;
  14158. jw.Data = new
  14159. {
  14160. groupCost = Create.Data,
  14161. blackCodeIsTrue = true
  14162. };
  14163. }
  14164. else
  14165. {
  14166. jw.Code = 400;
  14167. jw.Data = new
  14168. {
  14169. groupCost = Create.Data,
  14170. blackCodeIsTrue = false,
  14171. };
  14172. }
  14173. return Ok(jw);
  14174. }
  14175. /// <summary>
  14176. /// 成本获取OP历史车费用
  14177. /// </summary>
  14178. /// <param name="dto"></param>
  14179. /// <returns></returns>
  14180. [HttpPost]
  14181. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14182. {
  14183. var jw = JsonView(false);
  14184. try
  14185. {
  14186. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14187. //获取现有所有车的数据
  14188. if (!dto.Param.IsNullOrWhiteSpace())
  14189. {
  14190. string sql = $@"
  14191. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14192. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14193. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14194. 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
  14195. AND gctggr.ServiceEndTime is not NULL
  14196. ORDER by gctggrc.id DESC
  14197. ";
  14198. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14199. var numeberResult = await Task.Run(() =>
  14200. {
  14201. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14202. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14203. return numberArr;
  14204. });
  14205. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14206. foreach (var item in numeberResult)
  14207. {
  14208. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14209. {
  14210. Country = "数据异常!",
  14211. City = string.Empty,
  14212. };
  14213. item.Area = find.Country + " " + find.City;
  14214. }
  14215. dbResult.AddRange(numeberResult);
  14216. if (dto.Param.Contains("、"))
  14217. {
  14218. var sp = dto.Param.Split("、");
  14219. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14220. .Where(x =>
  14221. {
  14222. return System.Array.Exists(sp, e =>
  14223. {
  14224. bool where = false;
  14225. if (x.Area != null)
  14226. {
  14227. where = x.Area.Contains(e);
  14228. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14229. {
  14230. return false;
  14231. }
  14232. }
  14233. if (x.PriceName != null && !where)
  14234. {
  14235. where = x.PriceName.Contains(e);
  14236. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14237. {
  14238. return false;
  14239. }
  14240. }
  14241. return where;
  14242. });
  14243. }).ToList();
  14244. }
  14245. else
  14246. {
  14247. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14248. .Where(x =>
  14249. {
  14250. bool where = false;
  14251. if (x.Area != null)
  14252. {
  14253. where = x.Area.Contains(dto.Param);
  14254. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14255. {
  14256. return false;
  14257. }
  14258. }
  14259. if (x.PriceName != null && !where)
  14260. {
  14261. where = x.PriceName.Contains(dto.Param);
  14262. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14263. {
  14264. return false;
  14265. }
  14266. }
  14267. return where;
  14268. }
  14269. )
  14270. .ToList();
  14271. }
  14272. }
  14273. var view = dbResult.Select(x =>
  14274. {
  14275. decimal dp = 0.00M;
  14276. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14277. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14278. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14279. {
  14280. if (startB && endB)
  14281. {
  14282. var timesp = endD.Subtract(startD);
  14283. if ((timesp.Days + 1) != 0)
  14284. {
  14285. dp = x.Price / (timesp.Days + 1);
  14286. }
  14287. }
  14288. }
  14289. else
  14290. {
  14291. dp = x.Price;
  14292. }
  14293. return new
  14294. {
  14295. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14296. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14297. x.Area,
  14298. x.id,
  14299. price = x.Price.ToString("F2"),
  14300. x.PriceName,
  14301. x.PriceContent,
  14302. x.TeamName,
  14303. x.DatePrice,
  14304. dayPrice = dp.ToString("F2"),
  14305. };
  14306. }).OrderByDescending(x => x.id).ToList();
  14307. jw = JsonView(true, "获取成功!", view);
  14308. }
  14309. catch (Exception e)
  14310. {
  14311. jw = JsonView(false, e.Message);
  14312. }
  14313. return Ok(jw);
  14314. }
  14315. #endregion
  14316. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14317. /// <summary>
  14318. /// 酒店预订
  14319. /// 酒店费用列表 根据团组Id查询
  14320. /// </summary>
  14321. /// <param name="_dto"></param>
  14322. /// <returns></returns>
  14323. [HttpPost]
  14324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14325. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14326. {
  14327. #region 参数验证
  14328. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14329. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14330. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14331. #region 团组操作权限验证 76 酒店预定模块
  14332. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14333. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14334. #endregion
  14335. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14336. #region 页面操作权限验证
  14337. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14338. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14339. #endregion
  14340. #endregion
  14341. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14342. }
  14343. /// <summary>
  14344. /// 酒店预订
  14345. /// 基础数据
  14346. /// </summary>
  14347. /// <param name="_dto"></param>
  14348. /// <returns></returns>
  14349. [HttpPost]
  14350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14351. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14352. {
  14353. #region 参数验证
  14354. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14355. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14356. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14357. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14358. #region 页面操作权限验证
  14359. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14360. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14361. #endregion
  14362. #region 团组操作权限验证 76 酒店预定模块
  14363. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14364. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14365. #endregion
  14366. #endregion
  14367. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14368. }
  14369. /// <summary>
  14370. /// 酒店预订
  14371. /// 创建 入住卷号码
  14372. /// </summary>
  14373. /// <param name="_dto"></param>
  14374. /// <returns></returns>
  14375. [HttpPost]
  14376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14377. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14378. {
  14379. #region 参数验证
  14380. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14381. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14382. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14383. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14384. #region 页面操作权限验证
  14385. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14386. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14387. #endregion
  14388. #region 团组操作权限验证 76 酒店预定模块
  14389. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14390. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14391. #endregion
  14392. #endregion
  14393. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14394. if (data.Code != 0)
  14395. {
  14396. return Ok(JsonView(false, data.Msg));
  14397. }
  14398. return Ok(JsonView(true, data.Msg, data.Data));
  14399. }
  14400. /// <summary>
  14401. /// 酒店预订
  14402. /// 详情
  14403. /// </summary>
  14404. /// <param name="_dto"></param>
  14405. /// <returns></returns>
  14406. [HttpPost]
  14407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14408. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14409. {
  14410. #region 参数验证
  14411. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14412. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14413. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14414. #region 团组操作权限验证 76 酒店预定模块
  14415. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14416. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14417. #endregion
  14418. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14419. #region 页面操作权限验证
  14420. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14421. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14422. #endregion
  14423. #endregion
  14424. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14425. }
  14426. /// <summary>
  14427. /// 酒店预订
  14428. /// Add Or Edit
  14429. /// </summary>
  14430. /// <param name="_dto"></param>
  14431. /// <returns></returns>
  14432. [HttpPost]
  14433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14434. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14435. {
  14436. #region 参数验证
  14437. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14438. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14439. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14440. #region 团组操作权限验证 76 酒店预定模块
  14441. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14442. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14443. #endregion
  14444. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14445. #region 页面操作权限验证
  14446. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14447. if (_dto.Id == 0) // Add
  14448. {
  14449. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14450. }
  14451. else if (_dto.Id > 1) // Edit
  14452. {
  14453. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14454. }
  14455. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14456. #endregion
  14457. #endregion
  14458. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14459. if (_view.Code != 200)
  14460. {
  14461. return Ok(_view);
  14462. }
  14463. #region 成本无酒店价格数据进入超支
  14464. _sqlSugar.BeginTran();
  14465. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14466. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14467. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14468. for (int i = 0; i < groupCost.Count; i++)
  14469. {
  14470. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14471. {
  14472. groupCost[i].Date = groupCost[i - 1].Date;
  14473. }
  14474. }
  14475. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14476. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14477. List<Fin_GroupExtraCostDto_OP>();
  14478. if (start_Bool && end_Bool)
  14479. {
  14480. while (start_Time < end_Time)
  14481. {
  14482. foreach (var item in groupCost_Grp)
  14483. {
  14484. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14485. {
  14486. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14487. {
  14488. extraCostList.Add(new
  14489. Fin_GroupExtraCostDto_OP
  14490. {
  14491. Area = _dto.AreaId,
  14492. coefficient = 1.5M,
  14493. createUser = _dto.UserId,
  14494. currency = _dto.CardPriceCurrency,
  14495. diId = _dto.DiId,
  14496. ManagerConfirm = 0,
  14497. SupervisorConfirm = 0,
  14498. SYsupervisorConfirm = 0,
  14499. editType = 1,
  14500. PortType = 1,
  14501. price = _dto.CardPrice,
  14502. PriceCount = 1,
  14503. priceType = 1027,
  14504. priceDetailType = 1044,
  14505. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14506. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14507. });
  14508. }
  14509. }
  14510. }
  14511. start_Time = start_Time.AddDays(1);
  14512. }
  14513. }
  14514. if (extraCostList.Any())
  14515. {
  14516. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14517. }
  14518. _sqlSugar.CommitTran();
  14519. #endregion
  14520. #region 应用推送
  14521. try
  14522. {
  14523. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14524. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14525. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14526. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14527. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14528. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14529. var diId = _dto.DiId;
  14530. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14531. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14532. #region 操作记录
  14533. var opInfo = new Crm_TableOperationRecord()
  14534. {
  14535. TableName = "Grp_HotelReservations",
  14536. PortType = _dto.PortType,
  14537. DataId = hotelId,
  14538. CreateUserId = _dto.UserId
  14539. };
  14540. //var opStatus = OperationEnum.NoOperation;
  14541. if (_dto.Id < 1) //添加操作
  14542. {
  14543. opInfo.OperationItem = OperationEnum.Add;
  14544. }
  14545. else if (_dto.Id > 0)
  14546. {
  14547. opInfo.OperationItem = OperationEnum.Edit;
  14548. }
  14549. string opRemark = string.Empty;
  14550. if (ccpInfo != null)
  14551. {
  14552. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14553. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14554. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14555. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14556. }
  14557. opInfo.Remark = opRemark;
  14558. await _tableorRep.AddAsync(opInfo);
  14559. #endregion
  14560. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14561. //2024-10-21 新增LZ UID
  14562. var userIds = new List<int>() { 21 };
  14563. string title = $"费用审核";
  14564. string content = "";
  14565. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14566. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14567. try
  14568. {
  14569. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14570. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14571. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14572. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14573. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14574. }
  14575. catch (Exception ex)
  14576. {
  14577. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14578. }
  14579. }
  14580. catch (Exception ex)
  14581. {
  14582. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14583. }
  14584. try
  14585. {
  14586. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14587. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14588. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14589. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14590. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14591. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14592. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14593. //自动审核
  14594. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14595. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14596. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14597. //2024-10-21 新增LZ UID
  14598. var userIds = new List<int>() { 21 };
  14599. string title = $"系统通知";
  14600. var diId = _dto.DiId;
  14601. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14602. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14603. string content = "";
  14604. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14605. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14606. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14607. }
  14608. catch (Exception ex)
  14609. {
  14610. }
  14611. #endregion
  14612. return Ok(_view);
  14613. }
  14614. /// <summary>
  14615. /// 酒店自动审核测试
  14616. /// Add Or Edit
  14617. /// </summary>
  14618. /// <param name="diid"></param>
  14619. /// <param name="dataId"></param>
  14620. /// <returns></returns>
  14621. [HttpPost]
  14622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14623. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14624. {
  14625. #region 应用推送
  14626. try
  14627. {
  14628. //自动审核
  14629. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14630. }
  14631. catch (Exception ex)
  14632. {
  14633. return Ok(JsonView(false, "操作失败"));
  14634. }
  14635. #endregion
  14636. return Ok(JsonView(false, "操作成功"));
  14637. }
  14638. /// <summary>
  14639. /// 酒店预订
  14640. /// Del
  14641. /// </summary>
  14642. /// <param name="_dto"></param>
  14643. /// <returns></returns>
  14644. [HttpPost]
  14645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14646. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14647. {
  14648. #region 参数验证
  14649. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14650. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14651. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14652. #region 团组操作权限验证 76 酒店预定模块
  14653. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14654. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14655. #endregion
  14656. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14657. #region 页面操作权限验证
  14658. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14659. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14660. #endregion
  14661. #endregion
  14662. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14663. #region 操作记录
  14664. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14665. {
  14666. TableName = "Grp_HotelReservations",
  14667. PortType = _dto.PortType,
  14668. OperationItem = OperationEnum.Del,
  14669. DataId = _dto.Id,
  14670. CreateUserId = _dto.UserId
  14671. });
  14672. #endregion
  14673. return Ok(data);
  14674. }
  14675. /// <summary>
  14676. /// 酒店预订
  14677. /// 生成VOUCHER
  14678. /// 2024.05.06 之前版本
  14679. /// </summary>
  14680. /// <param name="_dto"></param>
  14681. /// <returns></returns>
  14682. [HttpPost]
  14683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14684. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14685. {
  14686. try
  14687. {
  14688. #region 参数验证
  14689. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14690. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14691. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14692. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14693. #region 团组操作权限验证 76 酒店预定模块
  14694. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14695. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14696. #endregion
  14697. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14698. #region 页面操作权限验证
  14699. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14700. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14701. #endregion
  14702. #endregion
  14703. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14704. //判断数据是否完整
  14705. if (hr != null)
  14706. {
  14707. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14708. {
  14709. string strFileName = "HotelStatement/";
  14710. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14711. if (dele != null)
  14712. strFileName += dele.TourCode;
  14713. //载入模板
  14714. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14715. Document doc = new Document(sss);
  14716. DocumentBuilder builder = new DocumentBuilder(doc);
  14717. #region 替换Word模板书签内容
  14718. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14719. //入住卷预定号码
  14720. if (doc.Range.Bookmarks["VNO"] != null)
  14721. {
  14722. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14723. mark.Text = hr.CheckNumber;
  14724. }
  14725. //酒店时间
  14726. if (doc.Range.Bookmarks["Date"] != null)
  14727. {
  14728. Bookmark mark = doc.Range.Bookmarks["Date"];
  14729. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14730. }
  14731. //团号
  14732. if (doc.Range.Bookmarks["TNo"] != null)
  14733. {
  14734. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14735. mark.Text = dele.TourCode;
  14736. }
  14737. //预定号码
  14738. if (doc.Range.Bookmarks["BookingId"] != null)
  14739. {
  14740. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14741. mark.Text = hr.ReservationsNo;
  14742. }
  14743. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14744. {
  14745. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14746. mark.Text = hr.DetermineNo;
  14747. }
  14748. //酒店城市
  14749. if (doc.Range.Bookmarks["City"] != null)
  14750. {
  14751. Bookmark mark = doc.Range.Bookmarks["City"];
  14752. mark.Text = hr.City;
  14753. }
  14754. //酒店名称
  14755. if (doc.Range.Bookmarks["HName"] != null)
  14756. {
  14757. Bookmark mark = doc.Range.Bookmarks["HName"];
  14758. mark.Text = hr.HotelName;
  14759. }
  14760. //酒店地址
  14761. if (doc.Range.Bookmarks["Address"] != null)
  14762. {
  14763. Bookmark mark = doc.Range.Bookmarks["Address"];
  14764. mark.Text = hr.HotelAddress;
  14765. }
  14766. //酒店电话
  14767. if (doc.Range.Bookmarks["Tel"] != null)
  14768. {
  14769. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14770. mark.Text = hr.HotelTel;
  14771. }
  14772. //酒店传真
  14773. if (doc.Range.Bookmarks["Fax"] != null)
  14774. {
  14775. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14776. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14777. {
  14778. mark.Text = hr.HotelFax;
  14779. }
  14780. }
  14781. //入住时间
  14782. if (doc.Range.Bookmarks["CIn"] != null)
  14783. {
  14784. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14785. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14786. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14787. }
  14788. //退房时间
  14789. if (doc.Range.Bookmarks["COut"] != null)
  14790. {
  14791. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14792. Bookmark mark = doc.Range.Bookmarks["COut"];
  14793. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14794. }
  14795. //客户名称
  14796. if (doc.Range.Bookmarks["GName"] != null)
  14797. {
  14798. string guestName = "";
  14799. string[] clients = new string[] { };
  14800. if (hr.GuestName.Contains(","))
  14801. {
  14802. clients = hr.GuestName.Split(",");
  14803. }
  14804. else
  14805. {
  14806. clients = new string[] { hr.GuestName };
  14807. }
  14808. List<int> clientIds_int = new List<int>();
  14809. if (clients.Length > 0)
  14810. {
  14811. foreach (var item in clients)
  14812. {
  14813. if (item.IsNumeric())
  14814. {
  14815. clientIds_int.Add(int.Parse(item));
  14816. }
  14817. }
  14818. }
  14819. if (clientIds_int.Count > 0)
  14820. {
  14821. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14822. foreach (var client in _clientDatas)
  14823. {
  14824. //男
  14825. if (client.Sex == 0) guestName += $"Mr.";
  14826. //女
  14827. else if (client.Sex == 1) guestName += $"Ms.";
  14828. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14829. {
  14830. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14831. }
  14832. //guestName += $"{client.Pinyin},";
  14833. }
  14834. if (guestName.Length > 0)
  14835. {
  14836. guestName = guestName.Substring(0, guestName.Length - 1);
  14837. }
  14838. }
  14839. else
  14840. {
  14841. guestName = hr.GuestName;
  14842. }
  14843. Bookmark mark = doc.Range.Bookmarks["GName"];
  14844. mark.Text = guestName;
  14845. }
  14846. //房间介绍
  14847. if (doc.Range.Bookmarks["ROOM"] != null)
  14848. {
  14849. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14850. mark.Text = hr.RoomExplanation;
  14851. }
  14852. //报价描述
  14853. if (doc.Range.Bookmarks["NOTE"] != null)
  14854. {
  14855. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14856. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14857. if (ss != null)
  14858. mark.Text = ss.Name;
  14859. }
  14860. //入住时间
  14861. if (doc.Range.Bookmarks["CheckIn"] != null)
  14862. {
  14863. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14864. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14865. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14866. }
  14867. //退房时间
  14868. if (doc.Range.Bookmarks["CheckOut"] != null)
  14869. {
  14870. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14871. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14872. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14873. }
  14874. //日期
  14875. if (doc.Range.Bookmarks["DT"] != null)
  14876. {
  14877. Bookmark mark = doc.Range.Bookmarks["DT"];
  14878. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14879. }
  14880. //名称
  14881. if (doc.Range.Bookmarks["VName"] != null)
  14882. {
  14883. Bookmark mark = doc.Range.Bookmarks["VName"];
  14884. mark.Text = hr.HotelName;
  14885. }
  14886. //号码
  14887. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14888. {
  14889. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14890. mark.Text = hr.CheckNumber;
  14891. }
  14892. #endregion
  14893. strFileName += "VOUCHER.doc";
  14894. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14895. doc.Save(fileDir);
  14896. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14897. return Ok(JsonView(true, "操作成功!", Url));
  14898. }
  14899. else
  14900. {
  14901. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14902. }
  14903. }
  14904. else
  14905. {
  14906. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14907. }
  14908. }
  14909. catch (Exception ex)
  14910. {
  14911. return Ok(JsonView(false, ex.Message));
  14912. }
  14913. }
  14914. /// <summary>
  14915. /// 酒店预订
  14916. /// 生成VOUCHER
  14917. /// 2024.05.06 之后版本
  14918. /// </summary>
  14919. /// <param name="_dto"></param>
  14920. /// <returns></returns>
  14921. [HttpPost]
  14922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14923. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14924. {
  14925. #region 参数验证
  14926. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14927. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14928. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14929. #region 团组操作权限验证 76 酒店预定模块
  14930. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14931. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14932. #endregion
  14933. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14934. #region 页面操作权限验证
  14935. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14936. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14937. #endregion
  14938. #endregion
  14939. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14940. //判断数据是否完整
  14941. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14942. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14943. string strFileName = "HotelStatement/";
  14944. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14945. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14946. #region 数据处理
  14947. List<int> guestIds = new List<int>();
  14948. //int index = 0;
  14949. foreach (var item in hrDtas)
  14950. {
  14951. if (item.GuestName.Contains(","))
  14952. {
  14953. string[] guestIdArr = item.GuestName.Split(',');
  14954. foreach (var guestIdStr in guestIdArr)
  14955. {
  14956. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14957. if (guestBool)
  14958. {
  14959. guestIds.Add(guestId);
  14960. }
  14961. }
  14962. }
  14963. else guestNames += item.GuestName;
  14964. var voucherInfo = new HotelVoucherInfoView()
  14965. {
  14966. HotelName = item.HotelName,
  14967. CheckInDate = item.CheckInDate,
  14968. CheckOutDate = item.CheckOutDate,
  14969. ConfirmationNumber = item.DetermineNo.Trim(),
  14970. RoomType = item.RoomExplanation
  14971. };
  14972. vouchers.Add(voucherInfo);
  14973. }
  14974. if (guestIds.Count > 0)
  14975. {
  14976. guestIds = guestIds.Distinct().ToList();
  14977. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14978. if (guestDatas.Count > 0)
  14979. {
  14980. guestNames = "";
  14981. foreach (var guest in guestDatas)
  14982. {
  14983. string guestName = "";
  14984. if (guest.Sex == 0) guestName += @"MR.";
  14985. else if (guest.Sex == 1) guestName += @"MS.";
  14986. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14987. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14988. guestNames += @$"{guestName.Trim()}、";
  14989. }
  14990. if (guestNames.Length > 0)
  14991. {
  14992. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14993. }
  14994. }
  14995. }
  14996. #endregion
  14997. //载入模板
  14998. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14999. Document doc = new Document(sss);
  15000. DocumentBuilder builder = new DocumentBuilder(doc);
  15001. if (doc.Range.Bookmarks["GuestName"] != null)
  15002. {
  15003. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  15004. mark.Text = guestNames;
  15005. }
  15006. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15007. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  15008. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  15009. for (int i = 1; i <= vouchers.Count; i++)
  15010. {
  15011. HotelVoucherInfoView hviv = vouchers[i - 1];
  15012. builder.MoveToCell(0, i, 0, 0);
  15013. builder.Write(hviv.HotelName);
  15014. builder.MoveToCell(0, i, 1, 0);
  15015. builder.Write(hviv.CheckInDate);
  15016. builder.MoveToCell(0, i, 2, 0);
  15017. builder.Write(hviv.CheckOutDate);
  15018. builder.MoveToCell(0, i, 3, 0);
  15019. builder.Write(hviv.RoomType);
  15020. builder.MoveToCell(0, i, 4, 0);
  15021. builder.Write(hviv.ConfirmationNumber);
  15022. }
  15023. //删除多余行
  15024. int currRowIndex = vouchers.Count + 1;
  15025. int delRows = 21 - currRowIndex;
  15026. if (delRows > 0)
  15027. {
  15028. for (int i = 0; i < delRows; i++)
  15029. {
  15030. table.Rows.RemoveAt(currRowIndex);
  15031. //cultivateRowIndex++;
  15032. }
  15033. }
  15034. strFileName += "VOUCHER.docx";
  15035. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15036. doc.Save(fileDir);
  15037. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15038. return Ok(JsonView(true, "操作成功!", Url));
  15039. }
  15040. /// <summary>
  15041. /// 酒店预订
  15042. /// 生成VOUCHER 批量生成
  15043. /// New
  15044. /// </summary>
  15045. /// <param name="_dto"></param>
  15046. /// <returns></returns>
  15047. [HttpPost]
  15048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15049. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15050. {
  15051. #region 参数验证
  15052. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15053. if (_dto.PageId < 1) _dto.PageId = 28;
  15054. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15055. #region 团组操作权限验证 76 酒店预定模块
  15056. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15057. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15058. #endregion
  15059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15060. #region 页面操作权限验证
  15061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15062. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15063. #endregion
  15064. #endregion
  15065. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15066. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15067. .OrderBy(x => x.CheckInDate)
  15068. .ToListAsync();
  15069. //判断数据是否完整
  15070. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15071. string strFileName = "HotelStatement/";
  15072. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15073. if (dele != null)
  15074. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15075. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15076. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15077. .Where(it => it.IsDel == 0)
  15078. .ToListAsync();
  15079. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15080. for (int i = 0; i < hrDtas.Count; i++)
  15081. {
  15082. string guestNames = string.Empty;
  15083. List<int> guestIds = new List<int>();
  15084. var item = hrDtas[i];
  15085. //处理客户姓名
  15086. if (item.GuestName.Contains(","))
  15087. {
  15088. string[] guestIdArr = item.GuestName.Split(',');
  15089. foreach (var guestIdStr in guestIdArr)
  15090. if (int.TryParse(guestIdStr, out int guestId))
  15091. guestIds.Add(guestId);
  15092. }
  15093. else
  15094. {
  15095. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15096. if (guestIdBool)
  15097. {
  15098. guestIds.Add(guestId);
  15099. }
  15100. //NaN
  15101. if (item.GuestName.Contains("NaN"))
  15102. {
  15103. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15104. }
  15105. }
  15106. if (guestIds.Count > 0)
  15107. {
  15108. guestIds = guestIds.Distinct().ToList();
  15109. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15110. if (guestDatas1.Count > 0)
  15111. {
  15112. guestNames = "";
  15113. foreach (var guest in guestDatas1)
  15114. {
  15115. string guestName = "";
  15116. if (guest.Sex == 0) guestName += @"MR.";
  15117. else if (guest.Sex == 1) guestName += @"MS.";
  15118. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15119. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15120. guestNames += @$"{guestName.Trim()}、";
  15121. }
  15122. if (guestNames.Length > 0)
  15123. {
  15124. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15125. }
  15126. }
  15127. }
  15128. //if (!string.IsNullOrEmpty(guestNames))
  15129. //{
  15130. hrDtas[i].GuestName = guestNames;
  15131. //}
  15132. }
  15133. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15134. Document doc = new Document();
  15135. DocumentBuilder builder = new DocumentBuilder(doc);
  15136. try
  15137. {
  15138. builder.MoveToDocumentStart();
  15139. foreach (var item in hrDtas)
  15140. {
  15141. //标题
  15142. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15143. builder.ParagraphFormat.LineSpacing = 1;
  15144. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15145. builder.ParagraphFormat.Style.Font.Size = 9;
  15146. builder.ParagraphFormat.Style.Font.Bold = true;
  15147. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15148. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15149. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15150. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15151. builder.ParagraphFormat.LineSpacing = 1;
  15152. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15153. builder.ParagraphFormat.Style.Font.Size = 9;
  15154. builder.ParagraphFormat.Style.Font.Bold = true;
  15155. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15156. builder.StartTable();
  15157. // 设置边框颜色
  15158. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15159. //设置边框样式
  15160. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15161. //表格
  15162. #region 第一行
  15163. builder.InsertCell();
  15164. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15165. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15166. //builder.CellFormat.AllowAutoFit = false;
  15167. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15168. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15169. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15170. builder.CellFormat.WrapText = true; //自动换行
  15171. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15172. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15173. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15174. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15175. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15176. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15177. builder.Write("TOUR NO:");
  15178. builder.InsertCell();
  15179. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15180. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15181. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15182. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15183. builder.ParagraphFormat.Style.Font.Bold = false;
  15184. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15185. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15186. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15187. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15188. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15189. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15190. builder.Write($"{dele?.TourCode ?? "-"}");
  15191. builder.InsertCell();
  15192. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15193. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15194. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15195. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15196. builder.ParagraphFormat.Style.Font.Bold = false;
  15197. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15198. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15199. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15200. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15201. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15202. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15203. builder.Write($"CITY:");
  15204. builder.InsertCell();
  15205. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15206. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15207. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15208. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15209. builder.ParagraphFormat.Style.Font.Bold = false;
  15210. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15211. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15212. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15213. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15214. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15215. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15216. builder.Write($"{item.City}");
  15217. builder.EndRow();
  15218. #endregion
  15219. #region 第二行
  15220. builder.InsertCell();
  15221. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15222. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15223. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15224. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15225. builder.ParagraphFormat.Style.Font.Bold = false;
  15226. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15227. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15228. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15229. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15230. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15231. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15232. builder.Write("CONFIRMATION NO:");
  15233. builder.InsertCell();
  15234. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15235. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15236. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15237. builder.ParagraphFormat.Style.Font.Bold = false;
  15238. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15239. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15240. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15241. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15242. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15243. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15244. builder.CellFormat.VerticalMerge = CellMerge.None;
  15245. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15246. builder.Write($"{item.DetermineNo}");
  15247. builder.InsertCell();
  15248. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15249. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15250. builder.InsertCell();
  15251. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15252. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15253. builder.EndRow();
  15254. #endregion
  15255. #region 第三行
  15256. builder.InsertCell();
  15257. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15258. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15259. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15260. builder.ParagraphFormat.Style.Font.Bold = false;
  15261. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15262. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15263. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15264. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15265. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15266. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15267. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15268. builder.Write($"HOTEL NAME:");
  15269. builder.InsertCell();
  15270. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15271. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15272. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15273. builder.ParagraphFormat.Style.Font.Bold = false;
  15274. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15275. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15276. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15277. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15278. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15279. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15280. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15281. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15282. builder.Write($"{item.HotelName}");
  15283. builder.InsertCell();
  15284. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15285. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15286. builder.InsertCell();
  15287. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15288. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15289. builder.EndRow();
  15290. #endregion
  15291. #region 第四行
  15292. builder.InsertCell();
  15293. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15294. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15295. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15296. builder.ParagraphFormat.Style.Font.Bold = false;
  15297. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15298. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15299. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15300. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15301. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15302. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15303. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15304. builder.Write($"HOTEL ADDRESS:");
  15305. builder.InsertCell();
  15306. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15307. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15308. builder.ParagraphFormat.Style.Font.Size = 8;
  15309. builder.ParagraphFormat.Style.Font.Bold = false;
  15310. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15311. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15312. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15313. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15314. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15315. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15316. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15317. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15318. builder.Write($"{item.HotelAddress}");
  15319. builder.InsertCell();
  15320. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15321. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15322. builder.InsertCell();
  15323. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15324. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15325. builder.EndRow();
  15326. #endregion
  15327. #region 第五行
  15328. builder.InsertCell();
  15329. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15330. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15331. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15332. builder.ParagraphFormat.Style.Font.Bold = false;
  15333. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15334. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15335. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15336. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15337. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15338. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15339. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15340. builder.Write("TEL:");
  15341. builder.InsertCell();
  15342. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15343. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15344. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15345. builder.ParagraphFormat.Style.Font.Bold = false;
  15346. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15347. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15348. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15349. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15350. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15351. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15352. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15353. builder.Write($"{item.HotelTel}");
  15354. builder.InsertCell();
  15355. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15356. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15357. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15358. builder.ParagraphFormat.Style.Font.Bold = false;
  15359. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15360. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15361. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15362. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15363. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15364. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15365. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15366. builder.Write($"FAX:");
  15367. builder.InsertCell();
  15368. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15369. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15370. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15371. builder.ParagraphFormat.Style.Font.Bold = false;
  15372. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15373. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15374. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15375. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15376. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15377. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15378. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15379. builder.Write($"{item.HotelFax}");
  15380. builder.EndRow();
  15381. #endregion
  15382. #region 第六行
  15383. builder.InsertCell();
  15384. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15385. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15386. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15387. builder.ParagraphFormat.Style.Font.Bold = false;
  15388. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15389. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15390. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15391. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15392. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15393. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15394. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15395. builder.Write("CHECK IN:");
  15396. builder.InsertCell();
  15397. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15398. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15399. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15400. builder.ParagraphFormat.Style.Font.Bold = false;
  15401. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15402. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15403. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15404. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15405. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15406. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15407. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15408. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15409. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15410. builder.Write($"{checkInStr}");
  15411. builder.InsertCell();
  15412. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15413. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15414. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15415. builder.ParagraphFormat.Style.Font.Bold = false;
  15416. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15417. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15418. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15419. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15420. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15421. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15422. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15423. builder.Write($"CHECK OUT:");
  15424. builder.InsertCell();
  15425. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15426. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15427. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15428. builder.ParagraphFormat.Style.Font.Bold = false;
  15429. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15430. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15431. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15432. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15433. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15434. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15435. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15436. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15437. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15438. builder.Write($"{checkOutStr}");
  15439. builder.EndRow();
  15440. #endregion
  15441. #region 第七行
  15442. builder.InsertCell();
  15443. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15444. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15445. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15446. builder.ParagraphFormat.Style.Font.Bold = false;
  15447. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15448. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15449. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15450. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15451. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15452. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15453. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15454. builder.Write($"GUEST NAME:");
  15455. builder.InsertCell();
  15456. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15457. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15458. builder.ParagraphFormat.Style.Font.Size = 8;
  15459. builder.ParagraphFormat.Style.Font.Bold = false;
  15460. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15461. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15462. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15463. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15464. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15465. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15466. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15467. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15468. builder.Write($"{item.GuestName}");
  15469. builder.InsertCell();
  15470. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15471. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15472. builder.InsertCell();
  15473. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15474. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15475. builder.EndRow();
  15476. #endregion
  15477. #region 第八行
  15478. builder.InsertCell();
  15479. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15480. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15481. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15482. builder.ParagraphFormat.Style.Font.Bold = false;
  15483. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15484. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15485. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15486. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15487. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15488. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15489. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15490. builder.Write($"ROOM TYPE:");
  15491. builder.InsertCell();
  15492. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15493. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15494. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15495. builder.ParagraphFormat.Style.Font.Bold = false;
  15496. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15497. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15498. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15499. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15500. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15501. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15502. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15503. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15504. builder.Write($"{item.RoomExplanation}");
  15505. builder.InsertCell();
  15506. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15507. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15508. builder.InsertCell();
  15509. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15510. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15511. builder.EndRow();
  15512. #endregion
  15513. #region 第九行
  15514. builder.InsertCell();
  15515. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15516. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15517. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15518. builder.ParagraphFormat.Style.Font.Bold = false;
  15519. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15520. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15521. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15522. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15523. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15524. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15525. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15526. builder.Write($"NOTE:");
  15527. builder.InsertCell();
  15528. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15529. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15530. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15531. builder.ParagraphFormat.Style.Font.Bold = false;
  15532. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15533. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15534. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15535. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15536. 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.");
  15537. builder.InsertCell();
  15538. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15539. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15540. builder.InsertCell();
  15541. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15542. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15543. builder.EndRow();
  15544. #endregion
  15545. builder.EndTable();
  15546. //换行
  15547. builder.Writeln("");
  15548. builder.Writeln("");
  15549. }
  15550. #region 获取文档中的所有表格 设置文字自适应
  15551. // 获取文档中的所有表格。
  15552. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15553. {
  15554. // 遍历表格中的所有行。
  15555. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15556. {
  15557. foreach (Cell cell in row.Cells)
  15558. {
  15559. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15560. cellFormat.Width = 0;
  15561. }
  15562. }
  15563. }
  15564. #endregion
  15565. #region 设置页眉
  15566. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15567. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15568. if (System.IO.File.Exists(voucherHeaderPath))
  15569. {
  15570. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15571. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15572. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15573. Shape shape = builder.InsertImage(imageBytes);
  15574. // 调整图片位置
  15575. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15576. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15577. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15578. shape.Left = 0; // 将图片距离页面左边缘的距离
  15579. shape.Width = 81; // 设置图片宽度
  15580. shape.Height = 36; // 设置图片高度
  15581. }
  15582. //靠右
  15583. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15584. //// 设置页脚上下边距
  15585. //builder.PageSetup.HeaderDistance = 42;
  15586. // 添加页眉线
  15587. Aspose.Words.Border borderHeader = null;
  15588. try
  15589. {
  15590. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15591. }
  15592. catch (Exception e)
  15593. {
  15594. // TODO Auto-generated catch block
  15595. //e.printStackTrace();
  15596. }
  15597. borderHeader.Shadow = true;
  15598. borderHeader.DistanceFromText = 2;
  15599. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15600. #endregion
  15601. }
  15602. catch (Exception ex)
  15603. {
  15604. }
  15605. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15606. doc.Save(fileDir);
  15607. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15608. return Ok(JsonView(true, "操作成功!", Url));
  15609. }
  15610. /// <summary>
  15611. /// 酒店预订
  15612. /// 生成 预定成本 Excel
  15613. /// </summary>
  15614. /// <param name="_dto"></param>
  15615. /// <returns></returns>
  15616. [HttpPost]
  15617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15618. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15619. {
  15620. #region 参数验证
  15621. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15622. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15623. if (!vadalitorRes.IsValid)
  15624. {
  15625. var errors = new StringBuilder();
  15626. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15627. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15628. }
  15629. #region 团组操作权限验证 76 酒店预定模块
  15630. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15631. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15632. #endregion
  15633. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15634. #region 页面操作权限验证
  15635. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15636. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15637. #endregion
  15638. #endregion
  15639. decimal _rate = 1.00M;
  15640. string _currency = string.Empty;
  15641. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15642. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15643. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15644. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15645. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15646. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15647. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15648. if (_GroupCostParameter == null)
  15649. {
  15650. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15651. bool isIntType = int.TryParse(_currency, out int currId);
  15652. if (isIntType)
  15653. {
  15654. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15655. }
  15656. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15657. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15658. if (currInfo == null)
  15659. {
  15660. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15661. }
  15662. else _rate = currInfo.Rate;
  15663. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15664. {
  15665. _rate = _GroupCostParameter.Rate;
  15666. }
  15667. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15668. //string strFileName = "HotelStatement/";
  15669. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15670. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15671. var rateDatas = new List<dynamic>();
  15672. #region 数据处理
  15673. foreach (var item in hrDtas)
  15674. {
  15675. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15676. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15677. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15678. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15679. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15680. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15681. {
  15682. continue;
  15683. }
  15684. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15685. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15686. string singleRoomFeeStr = string.Empty,
  15687. doubleRoomFeeStr = string.Empty,
  15688. suiteRoomFeeStr = string.Empty,
  15689. otherRoomFeeStr = string.Empty,
  15690. payMoneyStr = string.Empty,
  15691. cardPriceStr = string.Empty;
  15692. if (roomCurr.Equals("CNY"))
  15693. {
  15694. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15695. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15696. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15697. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15698. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15699. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15700. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15701. }
  15702. else
  15703. {
  15704. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15705. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15706. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15707. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15708. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15709. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15710. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15711. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15712. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15713. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15714. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15715. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15716. if (ccpPaymentCurrency.Equals("CNY"))
  15717. {
  15718. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15719. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15720. }
  15721. else
  15722. {
  15723. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15724. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15725. }
  15726. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15727. if (hotelcardPriceCurrency.Equals("CNY"))
  15728. {
  15729. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15730. }
  15731. else
  15732. {
  15733. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15734. }
  15735. }
  15736. string breakfastPriceStr = string.Empty,
  15737. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15738. governmentRentStr = string.Empty,
  15739. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15740. cityTaxStr = string.Empty,
  15741. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15742. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15743. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15744. {
  15745. if (breakfastCurrency1.Equals("CNY"))
  15746. {
  15747. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15748. }
  15749. else
  15750. {
  15751. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15752. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15753. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15754. }
  15755. }
  15756. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15757. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15758. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15759. {
  15760. if (governmentRentCurrency.Equals("CNY"))
  15761. {
  15762. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15763. }
  15764. else
  15765. {
  15766. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15767. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15768. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15769. }
  15770. }
  15771. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15772. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15773. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15774. {
  15775. if (cityTaxStrCurrency1.Equals("CNY"))
  15776. {
  15777. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15778. }
  15779. else
  15780. {
  15781. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15782. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15783. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15784. }
  15785. }
  15786. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15787. int payDId = roomInfo?.PayDId ?? 0;
  15788. pcfds.Add(new HotelReservations_PCFD_View()
  15789. {
  15790. City = item.City,
  15791. HotelName = item.HotelName,
  15792. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15793. // SingleRoomCount = item.SingleRoomCount,
  15794. SingleRoomPrice = singleRoomFeeStr,
  15795. // DoubleRoomCount = item.DoubleRoomCount,
  15796. DoubleRoomPrice = doubleRoomFeeStr,
  15797. //SuiteRoomCount = item.SuiteRoomCount,
  15798. SuiteRoomPrice = suiteRoomFeeStr,
  15799. OtherRoomPrice = otherRoomFeeStr,
  15800. //OtherRoomCount = item.OtherRoomCount,
  15801. BreakfastPrice = breakfastPriceStr,
  15802. GovernmentRent = governmentRentStr,
  15803. CityTax = cityTaxStr,
  15804. RoomExplanation = item.RoomExplanation,
  15805. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15806. PayTime = roomInfo?.ConsumptionDate,
  15807. BankNo = roomInfo?.BankNo,
  15808. PayMoney = payMoneyStr,
  15809. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15810. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15811. CardPrice = cardPriceStr,
  15812. Remark = ccpInfo.Remark
  15813. });
  15814. }
  15815. #endregion
  15816. //载入模板
  15817. WorkbookDesigner designer = new WorkbookDesigner();
  15818. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15819. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15820. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15821. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15822. var rateDatas1 = rateDatas.Distinct();
  15823. var rateStr = string.Empty;
  15824. foreach (var item in rateDatas1)
  15825. {
  15826. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15827. }
  15828. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15829. designer.SetDataSource("Opertor", userInfo.CnName);
  15830. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15831. dt.TableName = "ViewMyHotelReservations";
  15832. designer.SetDataSource(dt);
  15833. designer.Process();
  15834. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15835. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15836. designer.Workbook.Save(serverPath);
  15837. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15838. #region 删除指定行
  15839. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15840. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15841. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15842. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15843. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15844. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15845. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15846. cssIndex = dt.Columns["CityTax"].Ordinal,
  15847. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15848. remarkIndex = dt.Columns["Remark"].Ordinal;
  15849. //删除指定列
  15850. foreach (DataRow item in dt.Rows)
  15851. {
  15852. string singleStr = item["SingleRoomPrice"].ToString();
  15853. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15854. if (containsDigitButNotZero1) singleDel = false;
  15855. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15856. string doubleStr = item["DoubleRoomPrice"].ToString();
  15857. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15858. if (containsDigitButNotZero2) doubleDel = false;
  15859. string suiteStr = item["SuiteRoomPrice"].ToString();
  15860. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15861. if (containsDigitButNotZero3) suiteDel = false;
  15862. string otherStr = item["OtherRoomPrice"].ToString();
  15863. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15864. if (containsDigitButNotZero4) otherDel = false;
  15865. string zcStr = item["BreakfastPrice"].ToString();
  15866. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15867. if (containsDigitButNotZero5) zcDel = false;
  15868. string dsStr = item["GovernmentRent"].ToString();
  15869. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15870. if (containsDigitButNotZero6) dsDel = false;
  15871. string cssStr = item["CityTax"].ToString();
  15872. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15873. if (containsDigitButNotZero7) cssDel = false;
  15874. string cpStr = item["ConsumptionPatterns"].ToString();
  15875. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15876. string remarkStr = item["Remark"].ToString();
  15877. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15878. }
  15879. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15880. DeleteColumn(serverPath, cpIndex, cpDel);
  15881. DeleteColumn(serverPath, dsIndex, dsDel);
  15882. DeleteColumn(serverPath, cssIndex, cssDel);
  15883. DeleteColumn(serverPath, zcIndex, zcDel);
  15884. DeleteColumn(serverPath, otherIndex, otherDel);
  15885. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15886. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15887. DeleteColumn(serverPath, singleIndex, singleDel);
  15888. #endregion
  15889. //只保留第一个表格
  15890. DeleteSheet(serverPath);
  15891. return Ok(JsonView(true, "操作成功", url = rst));
  15892. }
  15893. else
  15894. {
  15895. _currency = _GroupCostParameter.Currency;
  15896. bool isIntType = int.TryParse(_currency, out int currId);
  15897. if (isIntType)
  15898. {
  15899. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15900. }
  15901. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15902. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15903. if (currInfo == null)
  15904. {
  15905. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15906. }
  15907. if (!_currency.ToUpper().Equals("CNY"))
  15908. {
  15909. _rate = _GroupCostParameter.Rate;
  15910. }
  15911. _rate = currInfo.Rate;
  15912. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15913. //string strFileName = "HotelStatement/";
  15914. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15915. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15916. #region 数据处理
  15917. foreach (var item in hrDtas)
  15918. {
  15919. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15920. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15921. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15922. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15923. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15924. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15925. string singleRoomFeeStr = string.Empty,
  15926. doubleRoomFeeStr = string.Empty,
  15927. suiteRoomFeeStr = string.Empty,
  15928. otherRoomFeeStr = string.Empty,
  15929. payMoneyStr = string.Empty,
  15930. cardPriceStr = string.Empty;
  15931. if (roomCurr.Equals(_currency))
  15932. {
  15933. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15934. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15935. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15936. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15937. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15938. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15939. }
  15940. else
  15941. {
  15942. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15943. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15944. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15945. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15946. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15947. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15948. }
  15949. string breakfastPriceStr = string.Empty,
  15950. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15951. governmentRentStr = string.Empty,
  15952. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15953. cityTaxStrStr = string.Empty,
  15954. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15955. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15956. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15957. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15958. int payDId = roomInfo?.PayDId ?? 0;
  15959. pcfds.Add(new HotelReservations_PCFD_View()
  15960. {
  15961. City = item.City,
  15962. HotelName = item.HotelName,
  15963. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15964. // SingleRoomCount = item.SingleRoomCount,
  15965. SingleRoomPrice = singleRoomFeeStr,
  15966. // DoubleRoomCount = item.DoubleRoomCount,
  15967. DoubleRoomPrice = doubleRoomFeeStr,
  15968. //SuiteRoomCount = item.SuiteRoomCount,
  15969. SuiteRoomPrice = suiteRoomFeeStr,
  15970. OtherRoomPrice = otherRoomFeeStr,
  15971. //OtherRoomCount = item.OtherRoomCount,
  15972. BreakfastPrice = breakfastPriceStr,
  15973. GovernmentRent = governmentRentStr,
  15974. CityTax = cityTaxStrStr,
  15975. RoomExplanation = item.RoomExplanation,
  15976. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15977. PayTime = roomInfo?.ConsumptionDate,
  15978. BankNo = roomInfo?.BankNo,
  15979. PayMoney = payMoneyStr,
  15980. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15981. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15982. CardPrice = cardPriceStr,
  15983. Remark = ccpInfo.Remark
  15984. });
  15985. }
  15986. #endregion
  15987. //载入模板
  15988. WorkbookDesigner designer = new WorkbookDesigner();
  15989. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15990. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15991. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15992. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15993. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15994. designer.SetDataSource("Opertor", userInfo.CnName);
  15995. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15996. dt.TableName = "ViewMyHotelReservations";
  15997. designer.SetDataSource(dt);
  15998. designer.Process();
  15999. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16000. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16001. designer.Workbook.Save(serverPath);
  16002. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16003. #region 删除指定行
  16004. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16005. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16006. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16007. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16008. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16009. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16010. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16011. cssIndex = dt.Columns["CityTax"].Ordinal,
  16012. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16013. remarkIndex = dt.Columns["Remark"].Ordinal;
  16014. //删除指定列
  16015. foreach (DataRow item in dt.Rows)
  16016. {
  16017. string singleStr = item["SingleRoomPrice"].ToString();
  16018. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16019. if (containsDigitButNotZero1) singleDel = false;
  16020. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16021. string doubleStr = item["DoubleRoomPrice"].ToString();
  16022. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16023. if (containsDigitButNotZero2) doubleDel = false;
  16024. string suiteStr = item["SuiteRoomPrice"].ToString();
  16025. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16026. if (containsDigitButNotZero3) suiteDel = false;
  16027. string otherStr = item["OtherRoomPrice"].ToString();
  16028. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16029. if (containsDigitButNotZero4) otherDel = false;
  16030. string zcStr = item["BreakfastPrice"].ToString();
  16031. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16032. if (containsDigitButNotZero5) zcDel = false;
  16033. string dsStr = item["GovernmentRent"].ToString();
  16034. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16035. if (containsDigitButNotZero6) dsDel = false;
  16036. string cssStr = item["CityTax"].ToString();
  16037. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16038. if (containsDigitButNotZero7) cssDel = false;
  16039. string cpStr = item["ConsumptionPatterns"].ToString();
  16040. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16041. string remarkStr = item["Remark"].ToString();
  16042. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16043. }
  16044. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16045. DeleteColumn(serverPath, cpIndex, cpDel);
  16046. DeleteColumn(serverPath, dsIndex, dsDel);
  16047. DeleteColumn(serverPath, cssIndex, cssDel);
  16048. DeleteColumn(serverPath, zcIndex, zcDel);
  16049. DeleteColumn(serverPath, otherIndex, otherDel);
  16050. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16051. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16052. DeleteColumn(serverPath, singleIndex, singleDel);
  16053. #endregion
  16054. //只保留第一个表格
  16055. DeleteSheet(serverPath);
  16056. return Ok(JsonView(true, "操作成功", url = rst));
  16057. }
  16058. //return Ok(JsonView(false));
  16059. }
  16060. /// <summary>
  16061. /// 删除指定列
  16062. /// </summary>
  16063. /// <param name="file"></param>
  16064. /// <param name="columnIndex"></param>
  16065. /// <param name="isDel"></param>
  16066. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16067. {
  16068. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16069. //wb.Save(file);
  16070. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16071. if (sheet1 != null)
  16072. {
  16073. if (isDel)
  16074. {
  16075. Cells cells = sheet1.Cells;
  16076. cells.DeleteColumn(columnIndex);
  16077. }
  16078. }
  16079. wb.Save(file);
  16080. }
  16081. /// <summary>
  16082. /// 删除sheet
  16083. /// </summary>
  16084. /// <param name="file"></param>
  16085. /// <param name="sheetName"></param>
  16086. private void DeleteSheet(string file, string sheetName = "")
  16087. {
  16088. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16089. //wb.Save(file);
  16090. List<string> sheets = new List<string>();
  16091. foreach (var item in wb.Worksheets)
  16092. {
  16093. sheets.Add(item.Name);
  16094. }
  16095. if (sheets.Count > 0)
  16096. {
  16097. sheets.RemoveAt(0);//不删除第一个sheet
  16098. foreach (var item in sheets)
  16099. {
  16100. wb.Worksheets.RemoveAt(item);
  16101. }
  16102. }
  16103. wb.Save(file);
  16104. }
  16105. /// <summary>
  16106. /// 酒店预订
  16107. /// 确认单
  16108. /// </summary>
  16109. /// <param name="_dto"></param>
  16110. /// <returns></returns>
  16111. [HttpPost]
  16112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16113. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16114. {
  16115. try
  16116. {
  16117. #region 参数验证
  16118. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16119. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16120. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16121. #region 团组操作权限验证 76 酒店预定模块
  16122. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16123. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16124. #endregion
  16125. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16126. #region 页面操作权限验证
  16127. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16128. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16129. #endregion
  16130. #endregion
  16131. //团组信息
  16132. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16133. //酒店数据
  16134. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16135. if (listhoteldata.Count < 0)
  16136. {
  16137. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16138. }
  16139. //利datatable存储
  16140. DataTable dt = new DataTable();
  16141. dt.Columns.Add("CheckInDate", typeof(string));
  16142. dt.Columns.Add("City", typeof(string));
  16143. dt.Columns.Add("Hotel", typeof(string));
  16144. dt.Columns.Add("Room", typeof(string));
  16145. for (int i = 0; i < listhoteldata.Count; i++)
  16146. {
  16147. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16148. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16149. while (dayStart < dayEnd)
  16150. {
  16151. string temp = "";
  16152. DataRow row = dt.NewRow();
  16153. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16154. row["City"] = listhoteldata[i].City;
  16155. row["Hotel"] = listhoteldata[i].HotelName;
  16156. if (listhoteldata[i].SingleRoomCount > 0)
  16157. {
  16158. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16159. }
  16160. if (listhoteldata[i].DoubleRoomCount > 0)
  16161. {
  16162. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16163. }
  16164. if (listhoteldata[i].SuiteRoomCount > 0)
  16165. {
  16166. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16167. }
  16168. if (listhoteldata[i].OtherRoomCount > 0)
  16169. {
  16170. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16171. }
  16172. row["Room"] = temp;
  16173. dt.Rows.Add(row);
  16174. dayStart = dayStart.AddDays(1);
  16175. }
  16176. }
  16177. Dictionary<string, string> dic = new Dictionary<string, string>();
  16178. dic.Add("Dele", di.TeamName);
  16179. dic.Add("City", di.VisitCountry);
  16180. //模板路径
  16181. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16182. //载入模板
  16183. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16184. DocumentBuilder builder = new DocumentBuilder(doc);
  16185. foreach (var key in dic.Keys)
  16186. {
  16187. builder.MoveToBookmark(key);
  16188. builder.Write(dic[key]);
  16189. }
  16190. //获取word里所有表格
  16191. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16192. //获取所填表格的序数
  16193. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16194. var rowStart = tableOne.Rows[0]; //获取第1行
  16195. //循环赋值
  16196. for (int i = 0; i < dt.Rows.Count; i++)
  16197. {
  16198. builder.MoveToCell(0, i + 1, 0, 0);
  16199. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16200. builder.MoveToCell(0, i + 1, 1, 0);
  16201. builder.Write(dt.Rows[i]["City"].ToString());
  16202. builder.MoveToCell(0, i + 1, 2, 0);
  16203. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16204. builder.MoveToCell(0, i + 1, 3, 0);
  16205. builder.Write(dt.Rows[i]["Room"].ToString());
  16206. }
  16207. //删除多余行
  16208. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16209. {
  16210. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16211. }
  16212. string strFileName = di.TeamName + "酒店确认单.doc";
  16213. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16214. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16215. return Ok(JsonView(true, "成功", url));
  16216. }
  16217. catch (Exception ex)
  16218. {
  16219. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16220. }
  16221. }
  16222. #endregion
  16223. #region 团组状态
  16224. /// <summary>
  16225. /// 团组状态列表 Page
  16226. /// </summary>
  16227. /// <param name="dto">团组列表请求dto</param>
  16228. /// <returns></returns>
  16229. [HttpPost]
  16230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16231. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16232. {
  16233. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16234. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16235. {
  16236. string sqlWhere = string.Empty;
  16237. if (dto.IsSure == 0) //未完成
  16238. {
  16239. sqlWhere += string.Format(@" And IsSure = 0");
  16240. }
  16241. else if (dto.IsSure == 1) //已完成
  16242. {
  16243. sqlWhere += string.Format(@" And IsSure = 1");
  16244. }
  16245. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16246. {
  16247. string tj = dto.SearchCriteria;
  16248. 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}%')",
  16249. tj, tj, tj, tj, tj);
  16250. }
  16251. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16252. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16253. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16254. From (
  16255. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16256. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16257. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16258. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16259. From Grp_DelegationInfo gdi
  16260. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16261. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16262. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16263. Where gdi.IsDel = 0 {0}
  16264. ) temp ", sqlWhere);
  16265. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16266. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16267. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16268. }
  16269. else
  16270. {
  16271. return Ok(JsonView(false, "查询失败"));
  16272. }
  16273. }
  16274. /// <summary>
  16275. /// 团组状态
  16276. /// 设置操作完成
  16277. /// </summary>
  16278. /// <param name="dto">团组列表请求dto</param>
  16279. /// <returns></returns>
  16280. [HttpPost]
  16281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16282. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16283. {
  16284. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16285. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16286. {
  16287. Id = dto.Id,
  16288. IsSure = 1
  16289. };
  16290. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16291. .UpdateColumns(it => new { it.IsSure })
  16292. .WhereColumns(it => new { it.Id })
  16293. .ExecuteCommandAsync();
  16294. if (result > 0)
  16295. {
  16296. return Ok(JsonView(true, "操作完成!"));
  16297. }
  16298. return Ok(JsonView(false, "操作失败!"));
  16299. }
  16300. #endregion
  16301. #region 保险费用录入
  16302. /// <summary>
  16303. /// 根据团组Id查询保险费用列表
  16304. /// </summary>
  16305. /// <param name="dto"></param>
  16306. /// <returns></returns>
  16307. [HttpPost]
  16308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16309. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16310. {
  16311. Result groupData = await _customersRep.CustomersByDiId(dto);
  16312. if (groupData.Code != 0)
  16313. {
  16314. return Ok(JsonView(false, groupData.Msg));
  16315. }
  16316. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16317. }
  16318. /// <summary>
  16319. /// 根据保险费用Id查询保险费用详细
  16320. /// </summary>
  16321. /// <param name="dto"></param>
  16322. /// <returns></returns>
  16323. [HttpPost]
  16324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16325. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16326. {
  16327. try
  16328. {
  16329. Result groupData = await _customersRep.CustomersById(dto);
  16330. if (groupData.Code != 0)
  16331. {
  16332. return Ok(JsonView(false, groupData.Msg));
  16333. }
  16334. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16335. }
  16336. catch (Exception ex)
  16337. {
  16338. return Ok(JsonView(false, ex.Message));
  16339. }
  16340. }
  16341. /// <summary>
  16342. /// 保险费用录入页面初始化绑定
  16343. /// </summary>
  16344. /// <param name="dto"></param>
  16345. /// <returns></returns>
  16346. [HttpPost]
  16347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16348. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16349. {
  16350. try
  16351. {
  16352. Result groupData = await _customersRep.CustomersInitialize(dto);
  16353. if (groupData.Code != 0)
  16354. {
  16355. return Ok(JsonView(false, groupData.Msg));
  16356. }
  16357. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16358. }
  16359. catch (Exception ex)
  16360. {
  16361. return Ok(JsonView(false, ex.Message));
  16362. }
  16363. }
  16364. /// <summary>
  16365. /// 保险费用操作(Status:1.新增,2.修改)
  16366. /// </summary>
  16367. /// <param name="dto"></param>
  16368. /// <returns></returns>
  16369. [HttpPost]
  16370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16371. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16372. {
  16373. Result groupData = await _customersRep.OpCustomers(dto);
  16374. if (groupData.Code != 0)
  16375. {
  16376. return Ok(JsonView(false, groupData.Msg));
  16377. }
  16378. #region 应用推送
  16379. try
  16380. {
  16381. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16382. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16383. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16384. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16385. //自动审核
  16386. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16387. //2024-10-21 新增LZ UID
  16388. var userIds = new List<int>() { 21 };
  16389. string title = $"系统通知";
  16390. var diId = dto.DiId;
  16391. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16392. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16393. string content = "";
  16394. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16395. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16396. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16397. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16398. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16399. }
  16400. catch (Exception ex)
  16401. {
  16402. }
  16403. #endregion
  16404. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16405. }
  16406. /// <summary>
  16407. /// 保险文件上传
  16408. /// </summary>
  16409. /// <param name="file"></param>
  16410. /// <returns></returns>
  16411. [HttpPost]
  16412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16413. public async Task<IActionResult> UploadCus(IFormFile file)
  16414. {
  16415. try
  16416. {
  16417. if (file != null)
  16418. {
  16419. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16420. //文件名称
  16421. string projectFileName = file.FileName;
  16422. //上传的文件的路径
  16423. string filePath = "";
  16424. if (!Directory.Exists(fileDir))
  16425. {
  16426. Directory.CreateDirectory(fileDir);
  16427. }
  16428. //上传的文件的路径
  16429. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16430. using (FileStream fs = System.IO.File.Create(filePath))
  16431. {
  16432. file.CopyTo(fs);
  16433. fs.Flush();
  16434. }
  16435. return Ok(JsonView(true, "上传成功!", projectFileName));
  16436. }
  16437. else
  16438. {
  16439. return Ok(JsonView(false, "上传失败!"));
  16440. }
  16441. }
  16442. catch (Exception ex)
  16443. {
  16444. return Ok(JsonView(false, "程序错误!"));
  16445. throw;
  16446. }
  16447. }
  16448. /// <summary>
  16449. /// 保险删除指定文件
  16450. /// </summary>
  16451. /// <param name="dto"></param>
  16452. /// <returns></returns>
  16453. [HttpPost]
  16454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16455. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16456. {
  16457. try
  16458. {
  16459. string filePath = "";
  16460. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16461. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16462. //int id = 0;
  16463. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16464. // 删除该文件
  16465. try
  16466. {
  16467. System.IO.File.Delete(filePath);
  16468. 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()
  16469. {
  16470. Attachment = "",
  16471. }).ExecuteCommandAsync();
  16472. if (result != 0)
  16473. {
  16474. return Ok(JsonView(true, "成功!"));
  16475. }
  16476. else
  16477. {
  16478. return Ok(JsonView(false, "失败!"));
  16479. }
  16480. }
  16481. catch (Exception)
  16482. {
  16483. 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()
  16484. {
  16485. Attachment = "",
  16486. }).ExecuteCommandAsync();
  16487. if (result != 0)
  16488. {
  16489. return Ok(JsonView(true, "成功!"));
  16490. }
  16491. else
  16492. {
  16493. return Ok(JsonView(false, "失败!"));
  16494. }
  16495. }
  16496. }
  16497. catch (Exception ex)
  16498. {
  16499. return Ok(JsonView(false, "程序错误!"));
  16500. throw;
  16501. }
  16502. }
  16503. /// <summary>
  16504. /// 保险费用操作(删除)
  16505. /// </summary>
  16506. /// <param name="dto"></param>
  16507. /// <returns></returns>
  16508. [HttpPost]
  16509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16510. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16511. {
  16512. try
  16513. {
  16514. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16515. if (!res)
  16516. {
  16517. return Ok(JsonView(false, "删除失败"));
  16518. }
  16519. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16520. {
  16521. IsDel = 1,
  16522. DeleteUserId = dto.DeleteUserId,
  16523. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16524. }).ExecuteCommandAsync();
  16525. return Ok(JsonView(true, "删除成功!"));
  16526. }
  16527. catch (Exception ex)
  16528. {
  16529. return Ok(JsonView(false, "程序错误!"));
  16530. throw;
  16531. }
  16532. }
  16533. #endregion
  16534. #region 接团客户名单 PageId 104
  16535. /// <summary>
  16536. /// 接团客户名单
  16537. /// 迁移数据(慎用!)
  16538. /// </summary>
  16539. /// <returns></returns>
  16540. [HttpPost]
  16541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16542. public async Task<IActionResult> PostTourClientListChange()
  16543. {
  16544. try
  16545. {
  16546. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16547. //var groupClinetData1
  16548. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16549. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16550. int updateCount = 0;
  16551. if (oldOAClientList.Count > 0)
  16552. {
  16553. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16554. _sqlSugar.BeginTran();
  16555. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16556. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16557. foreach (var item in oldOAClientList)
  16558. {
  16559. int comId = 0;
  16560. string format = "yyyy-MM-dd HH:mm:ss";
  16561. string data11 = "1990-01-01 00:00";
  16562. var data1 = IsValidDate(item.OPdate, format);
  16563. if (data1) data11 = item.OPdate;
  16564. //客户公司验证
  16565. if (!string.IsNullOrEmpty(item.Company))
  16566. {
  16567. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16568. if (clientComInfo == null) // add
  16569. {
  16570. var addInfo = new Crm_CustomerCompany()
  16571. {
  16572. CompanyAbbreviation = "",
  16573. CompanyFullName = item.Company,
  16574. Address = "",
  16575. PostCodes = "",
  16576. LastedOpUserId = item.OPer,
  16577. LastedOpDt = Convert.ToDateTime(data11),
  16578. CreateUserId = item.OPer,
  16579. CreateTime = Convert.ToDateTime(data11),
  16580. IsDel = 0
  16581. };
  16582. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16583. if (comId1 > 0) comId = comId1;
  16584. }
  16585. else comId = clientComInfo.Id;
  16586. }
  16587. //客户人员验证
  16588. int clientId = 0;
  16589. string name = item.LastName + item.Name;
  16590. if (!string.IsNullOrEmpty(name))
  16591. {
  16592. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16593. if (clientInfo == null)
  16594. {
  16595. DateTime? dateTime = null;
  16596. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16597. if (isDt) dateTime = birthDayDt;
  16598. var addInfo1 = new Crm_DeleClient()
  16599. {
  16600. CrmCompanyId = comId,
  16601. DiId = -1,
  16602. LastName = item.LastName,
  16603. FirstName = item.Name,
  16604. OldName = "",
  16605. Pinyin = item.Pinyin,
  16606. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16607. Marriage = 0,
  16608. Phone = item.Phone,
  16609. Job = item.Job,
  16610. BirthDay = dateTime
  16611. };
  16612. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16613. if (clientId1 > 0) clientId = clientId1;
  16614. }
  16615. else clientId = clientInfo.Id;
  16616. }
  16617. if (clientId < 1)
  16618. {
  16619. continue;
  16620. }
  16621. int airType = 0;
  16622. if (item.AirType == "超经舱") airType = 459;
  16623. else if (item.AirType == "公务舱") airType = 458;
  16624. else if (item.AirType == "经济舱") airType = 460;
  16625. else if (item.AirType == "其他") airType = 565;
  16626. else if (item.AirType == "头等舱") airType = 457;
  16627. var _TourClientListEntity = new Grp_TourClientList()
  16628. {
  16629. DiId = item.Diid,
  16630. ClientId = clientId,
  16631. CreateUserId = item.OPer,
  16632. CreateTime = Convert.ToDateTime(data11),
  16633. Remark = item.Remark,
  16634. IsDel = item.Isdel,
  16635. ShippingSpaceTypeId = airType,
  16636. ShippingSpaceSpecialNeeds = item.AirRemark,
  16637. HotelSpecialNeeds = item.RoomType
  16638. };
  16639. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16640. if (_TourClientList > 0)
  16641. {
  16642. updateCount++;
  16643. }
  16644. }
  16645. _sqlSugar.CommitTran();
  16646. }
  16647. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16648. }
  16649. catch (Exception ex)
  16650. {
  16651. _sqlSugar.RollbackTran();
  16652. return Ok(JsonView(false, ex.Message));
  16653. }
  16654. //return Ok(JsonView(true));
  16655. }
  16656. private bool IsValidDate(string dateString, string format)
  16657. {
  16658. DateTime dateValue;
  16659. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16660. return valid;
  16661. }
  16662. /// <summary>
  16663. /// 接团客户名单
  16664. /// 根据团组Id查询List
  16665. /// </summary>
  16666. /// <param name="_dto"></param>
  16667. /// <returns></returns>
  16668. [HttpPost]
  16669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16670. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16671. {
  16672. #region 参数验证
  16673. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16674. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16675. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16676. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16677. #region 页面操作权限验证
  16678. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16679. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16680. #endregion
  16681. #endregion
  16682. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16683. if (viewData.Code != 0)
  16684. {
  16685. return Ok(JsonView(false, viewData.Msg));
  16686. }
  16687. return Ok(JsonView(viewData.Data));
  16688. }
  16689. /// <summary>
  16690. /// 接团客户名单
  16691. /// 基础数据 Init
  16692. /// </summary>
  16693. /// <param name="_dto"></param>
  16694. /// <returns></returns>
  16695. [HttpPost]
  16696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16697. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16698. {
  16699. #region 参数验证
  16700. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16701. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16702. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16703. #region 页面操作权限验证
  16704. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16705. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16706. #endregion
  16707. #endregion
  16708. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16709. }
  16710. /// <summary>
  16711. /// 接团客户名单
  16712. /// 根据 Id查询 Details
  16713. /// </summary>
  16714. /// <param name="_dto"></param>
  16715. /// <returns></returns>
  16716. [HttpPost]
  16717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16718. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16719. {
  16720. #region 参数验证
  16721. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16722. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16723. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16724. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16725. #region 页面操作权限验证
  16726. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16727. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16728. #endregion
  16729. #endregion
  16730. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16731. if (viewData.Code != 0)
  16732. {
  16733. return Ok(JsonView(false, viewData.Msg));
  16734. }
  16735. return Ok(JsonView(viewData.Data));
  16736. }
  16737. /// <summary>
  16738. /// 接团客户名单
  16739. /// Add Or Edit
  16740. /// </summary>
  16741. /// <param name="_dto"></param>
  16742. /// <returns></returns>
  16743. [HttpPost]
  16744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16745. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16746. {
  16747. #region 参数验证
  16748. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16749. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16750. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16751. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16752. #region 页面操作权限验证
  16753. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16754. if (_dto.Id == 0) //添加
  16755. {
  16756. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16757. }
  16758. else if (_dto.Id >= 0) //修改
  16759. {
  16760. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16761. }
  16762. #endregion
  16763. #endregion
  16764. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16765. if (viewData.Code != 0)
  16766. {
  16767. return Ok(JsonView(false, viewData.Msg));
  16768. }
  16769. return Ok(JsonView(true));
  16770. }
  16771. /// <summary>
  16772. /// 接团客户名单
  16773. /// json字符串 AddMultiple(添加多个)
  16774. /// </summary>
  16775. /// <param name="_dto"></param>
  16776. /// <returns></returns>
  16777. [HttpPost]
  16778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16779. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16780. {
  16781. #region 参数验证
  16782. string jsonLabel = _dto.JsonLabel;
  16783. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16784. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16785. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16786. #region 页面操作权限验证
  16787. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16788. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16789. #endregion
  16790. #endregion
  16791. var request = new TourClientListAddMultipleDto();
  16792. request.DiId = _dto.DiId;
  16793. request.UserId = _dto.UserId;
  16794. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16795. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16796. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16797. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16798. var infos = new List<TourClientListInfo>();
  16799. foreach (var data in datas)
  16800. {
  16801. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16802. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16803. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16804. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16805. {
  16806. continue;
  16807. }
  16808. infos.Add(new TourClientListInfo()
  16809. {
  16810. IsAccompany = 1,
  16811. LastName = lastName,
  16812. FirstName = firstName,
  16813. Pinyin = lastNameEn + @"/" + firstNameEn,
  16814. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16815. CompanyFullName = data.CompanyFullName,
  16816. Job = data.Job
  16817. });
  16818. }
  16819. if (infos.Any())
  16820. {
  16821. var viewData = await _tourClientListRep._AddMultiple(request);
  16822. if (viewData.Code != 0)
  16823. {
  16824. return Ok(JsonView(false, viewData.Msg));
  16825. }
  16826. return Ok(JsonView(true));
  16827. }
  16828. return Ok(JsonView(false));
  16829. }
  16830. /// <summary>
  16831. /// 接团客户名单
  16832. /// AddMultiple(添加多个)
  16833. /// </summary>
  16834. /// <param name="_dto"></param>
  16835. /// <returns></returns>
  16836. [HttpPost]
  16837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16838. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16839. {
  16840. #region 参数验证
  16841. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16842. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16843. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16844. #region 页面操作权限验证
  16845. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16846. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16847. #endregion
  16848. #endregion
  16849. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16850. if (viewData.Code != 0)
  16851. {
  16852. return Ok(JsonView(false, viewData.Msg));
  16853. }
  16854. return Ok(JsonView(true));
  16855. }
  16856. /// <summary>
  16857. /// 接团客户名单
  16858. /// Del
  16859. /// </summary>
  16860. /// <param name="_dto"></param>
  16861. /// <returns></returns>
  16862. [HttpPost]
  16863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16864. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16865. {
  16866. #region 参数验证
  16867. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16868. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16869. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16870. #region 页面操作权限验证
  16871. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16872. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16873. #endregion
  16874. #endregion
  16875. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16876. if (viewData.Code != 0)
  16877. {
  16878. return Ok(JsonView(false, viewData.Msg));
  16879. }
  16880. return Ok(JsonView(true));
  16881. }
  16882. /// <summary>
  16883. /// 接团客户名单
  16884. /// 文件下载 客户名单
  16885. /// </summary>
  16886. /// <param name="_dto"></param>
  16887. /// <returns></returns>
  16888. [HttpPost]
  16889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16890. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16891. {
  16892. #region 参数验证
  16893. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16894. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16895. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16896. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16897. #region 页面操作权限验证
  16898. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16899. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16900. #endregion
  16901. #endregion
  16902. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16903. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16904. From Grp_TourClientList tcl
  16905. Left Join
  16906. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16907. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16908. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16909. From Crm_DeleClient dc
  16910. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16911. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16912. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16913. Where dc.IsDel = 0) temp
  16914. On temp.DcId =tcl.ClientId
  16915. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16916. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16917. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16918. //载入模板
  16919. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16920. if (_dto.Language == 1)
  16921. {
  16922. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16923. }
  16924. //载入模板
  16925. var doc = new Document(tempPath);
  16926. DocumentBuilder builder = new DocumentBuilder(doc);
  16927. //获取word里所有表格
  16928. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16929. //获取所填表格的序数
  16930. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16931. var rowStart = tableOne.Rows[0]; //获取第1行
  16932. if (_dto.Language == 0)
  16933. {
  16934. //循环赋值
  16935. for (int i = 0; i < DcList.Count; i++)
  16936. {
  16937. EncryptionProcessor.DecryptProperties(DcList[i]);
  16938. builder.MoveToCell(0, i + 1, 0, 0);
  16939. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16940. builder.MoveToCell(0, i + 1, 1, 0);
  16941. int sex = DcList[i].Sex;
  16942. string sexStr = string.Empty;
  16943. if (sex == 0) sexStr = "男";
  16944. else if (sex == 1) sexStr = "女";
  16945. else sexStr = "未设置";
  16946. builder.Write(sexStr);
  16947. builder.MoveToCell(0, i + 1, 2, 0);
  16948. string birthDay = DcList[i].BirthDay;
  16949. string birthDayStr = string.Empty;
  16950. if (!string.IsNullOrEmpty(birthDay))
  16951. {
  16952. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16953. }
  16954. builder.Write(birthDayStr);
  16955. builder.MoveToCell(0, i + 1, 3, 0);
  16956. string company = "";
  16957. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16958. {
  16959. company = DcList[i].CompanyFullName.ToString();
  16960. }
  16961. builder.Write(company);
  16962. builder.MoveToCell(0, i + 1, 4, 0);
  16963. builder.Write(DcList[i].Job);
  16964. }
  16965. }
  16966. else if (_dto.Language == 1)
  16967. {
  16968. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16969. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16970. List<string> transArrayStr = new List<string>();
  16971. string transStrRes1 = "";
  16972. for (int i = 0; i < DcList.Count; i++)
  16973. {
  16974. var dc = DcList[i];
  16975. EncryptionProcessor.DecryptProperties(dc);
  16976. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16977. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16978. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16979. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16980. else transStrRes1 += $"{str1}|";
  16981. }
  16982. //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";
  16983. string transStrRes = "";
  16984. if (transStrRes1.Length > 0)
  16985. {
  16986. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16987. }
  16988. //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
  16989. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16990. //List<string> transArray = new List<string> { };
  16991. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16992. if (transStrRes.Contains("|"))
  16993. {
  16994. string[] transArray1 = transStrRes.Split('|');
  16995. if (transArray1.Length > 0)
  16996. {
  16997. foreach (var item in transArray1)
  16998. {
  16999. if (item.Contains("&"))
  17000. {
  17001. string[] transArray2 = item.Split('&');
  17002. int index = 0;
  17003. string companyName = "", job = "";
  17004. if (transArray2.Length > 0)
  17005. {
  17006. bool success = int.TryParse(transArray2[0].Trim(), out index);
  17007. if (1 < transArray2.Length) companyName = transArray2[1];
  17008. if (2 < transArray2.Length) job = transArray2[2];
  17009. }
  17010. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  17011. }
  17012. }
  17013. }
  17014. }
  17015. //循环赋值
  17016. for (int i = 0; i < DcList.Count; i++)
  17017. {
  17018. string PYName = "";
  17019. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17020. {
  17021. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17022. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17023. PYName = PY_First + " " + PY_Last;
  17024. }
  17025. else
  17026. {
  17027. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17028. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17029. PYName = PY_First + " " + PY_Last;
  17030. }
  17031. builder.MoveToCell(0, i + 1, 0, 0);
  17032. builder.Write(PYName);
  17033. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17034. builder.MoveToCell(0, i + 1, 1, 0);
  17035. builder.Write(sex);
  17036. DateTime birthDt;
  17037. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17038. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17039. builder.MoveToCell(0, i + 1, 2, 0);
  17040. builder.Write(birthday);
  17041. string company = string.Empty, job = string.Empty;
  17042. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17043. if (dcTransInfo != null)
  17044. {
  17045. company = dcTransInfo.CompanyName;
  17046. job = dcTransInfo.Job;
  17047. }
  17048. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17049. {
  17050. //查询对照表
  17051. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17052. if (tempCec != null)
  17053. {
  17054. company = tempCec.enName;
  17055. }
  17056. //翻译
  17057. else
  17058. {
  17059. }
  17060. }
  17061. builder.MoveToCell(0, i + 1, 3, 0);
  17062. builder.Write(company);
  17063. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17064. {
  17065. //查询对照表
  17066. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17067. if (tempPec != null)
  17068. {
  17069. job = tempPec.enName;
  17070. }
  17071. //翻译
  17072. else
  17073. {
  17074. }
  17075. }
  17076. builder.MoveToCell(0, i + 1, 4, 0);
  17077. builder.Write(job);
  17078. }
  17079. }
  17080. //删除多余行
  17081. while (tableOne.Rows.Count > DcList.Count + 1)
  17082. {
  17083. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17084. }
  17085. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17086. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17087. doc.Save(fileDir);
  17088. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17089. return Ok(JsonView(true, "操作成功!", Url));
  17090. }
  17091. private class TranslateInfo
  17092. {
  17093. public int Index { get; set; }
  17094. public string CompanyName { get; set; }
  17095. public string Job { get; set; }
  17096. }
  17097. #endregion
  17098. #region 团组倒推表
  17099. /// <summary>
  17100. /// 倒推表基础数据
  17101. /// Init
  17102. /// </summary>
  17103. /// <returns></returns>
  17104. [HttpPost]
  17105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17106. public async Task<IActionResult> PostInvertedListInit()
  17107. {
  17108. var viewData = await _invertedListRep._Init();
  17109. if (viewData.Code != 0)
  17110. {
  17111. return Ok(JsonView(false, viewData.Msg));
  17112. }
  17113. return Ok(JsonView(viewData.Data));
  17114. }
  17115. /// <summary>
  17116. /// 倒推表
  17117. /// Info
  17118. /// </summary>
  17119. /// <param name="dto"></param>
  17120. /// <returns></returns>
  17121. [HttpPost]
  17122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17123. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17124. {
  17125. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17126. if (viewData.Code != 0)
  17127. {
  17128. return Ok(JsonView(false, viewData.Msg));
  17129. }
  17130. return Ok(JsonView(viewData.Data));
  17131. }
  17132. /// <summary>
  17133. /// 倒推表
  17134. /// Create
  17135. /// </summary>
  17136. /// <param name="dto"></param>
  17137. /// <returns></returns>
  17138. [HttpPost]
  17139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17140. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17141. {
  17142. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17143. if (viewData.Code != 0)
  17144. {
  17145. return Ok(JsonView(false, viewData.Msg));
  17146. }
  17147. return Ok(JsonView(viewData.Data));
  17148. }
  17149. /// <summary>
  17150. /// 倒推表
  17151. /// Update
  17152. /// </summary>
  17153. /// <param name="dto"></param>
  17154. /// <returns></returns>
  17155. [HttpPost]
  17156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17157. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17158. {
  17159. var viewData = await _invertedListRep._Update(dto);
  17160. if (viewData.Code != 0)
  17161. {
  17162. return Ok(JsonView(false, viewData.Msg));
  17163. }
  17164. return Ok(JsonView(viewData.Data));
  17165. }
  17166. /// <summary>
  17167. /// 倒推表
  17168. /// File Download
  17169. /// </summary>
  17170. /// <param name="dto"></param>
  17171. /// <returns></returns>
  17172. [HttpPost]
  17173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17174. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17175. {
  17176. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17177. if (info2.Code != 0)
  17178. {
  17179. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17180. }
  17181. var info1 = info2.Data as InvertedListInfoView;
  17182. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17183. string teamName = "";
  17184. if (info != null) teamName = info.TeamName;
  17185. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17186. var doc = new Document();
  17187. var builder = new DocumentBuilder(doc);
  17188. #region old insert
  17189. ////载入模板
  17190. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17191. //Document doc = new Document(tempPath);
  17192. //DocumentBuilder builder = new DocumentBuilder(doc);
  17193. //利用键值对存放数据
  17194. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17195. //dic.Add("TeamName", teamName);
  17196. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17197. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17198. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17199. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17200. //dic.Add("SQRemark", info1.ApprovalRemark);
  17201. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17202. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17203. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17204. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17205. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17206. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17207. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17208. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17209. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17210. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17211. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17212. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17213. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17214. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17215. //#region 填充word模板书签内容
  17216. //foreach (var key in dic.Keys)
  17217. //{
  17218. // builder.MoveToBookmark(key);
  17219. // builder.Write(dic[key]);
  17220. //}
  17221. //#endregion
  17222. #endregion
  17223. #region New Insert
  17224. string titleFont = $"仿宋",
  17225. contentFont = $"仿宋";
  17226. var fontColor = Color.FromArgb(64, 64, 64);
  17227. //设置标题 团组名称
  17228. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17229. builder.Font.Name = titleFont;
  17230. builder.Font.Color = fontColor;
  17231. builder.Font.Size = 12;
  17232. builder.Font.Bold = true;
  17233. builder.Writeln(teamName);
  17234. //设置副标题 团组出访时间
  17235. builder.Font.Size = 12;
  17236. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17237. builder.Writeln();
  17238. var backgroundColor = Color.FromArgb(199, 199, 199);
  17239. var table = builder.StartTable();
  17240. builder.InsertCell();
  17241. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17242. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17243. builder.CellFormat.Borders.LineWidth = 1;
  17244. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17245. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17246. builder.RowFormat.Height = 40;
  17247. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17248. builder.Font.Name = contentFont;
  17249. builder.Font.Size = 12;
  17250. builder.Font.Bold = true;
  17251. builder.Font.Color = fontColor;
  17252. builder.Write("时间");
  17253. builder.InsertCell();
  17254. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17255. builder.Write("流程");
  17256. builder.InsertCell();
  17257. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17258. builder.Write("说明");
  17259. builder.EndRow();
  17260. //报批资料准备
  17261. if (info1.IsSelectedAirportd)
  17262. {
  17263. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17264. }
  17265. //报批/提供送签资料
  17266. if (info1.IsSelectedApprovalData)
  17267. {
  17268. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17269. }
  17270. //出批件护照办理
  17271. if (info1.IsSelectedIssueApproval)
  17272. {
  17273. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17274. }
  17275. //签证资料准备
  17276. if (info1.IsSelectedVisaInfo)
  17277. {
  17278. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17279. }
  17280. //送签
  17281. if (info1.IsSelectedSendVisa)
  17282. {
  17283. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17284. }
  17285. //出签
  17286. if (info1.IsSelectedIssueVisa)
  17287. {
  17288. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17289. }
  17290. //机票
  17291. if (info1.IsSelectedAirTicket)
  17292. {
  17293. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17294. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17295. }
  17296. //酒店
  17297. if (info1.IsSelectedHotel)
  17298. {
  17299. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17300. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17301. }
  17302. //开行前会
  17303. if (info1.IsSelectedPreTripMeeting)
  17304. {
  17305. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17306. }
  17307. //送机
  17308. if (info1.IsSelectedAirportdDropOff)
  17309. {
  17310. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17311. }
  17312. builder.EndTable();
  17313. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17314. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17315. for (int i = 0; i < table.Rows.Count; i++)
  17316. {
  17317. var row = table.Rows[i];
  17318. //设置宽度
  17319. row.Cells[0].CellFormat.Width = 20.00;
  17320. row.Cells[1].CellFormat.Width = 30.00;
  17321. row.Cells[2].CellFormat.Width = 50.00;
  17322. if (i != 0)
  17323. {
  17324. //边框设置
  17325. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17326. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17327. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17328. }
  17329. }
  17330. #region 页脚插入图片
  17331. // 创建页脚
  17332. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17333. doc.FirstSection.HeadersFooters.Add(footer);
  17334. Paragraph para = new Paragraph(doc);
  17335. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17336. footer.AppendChild(para);
  17337. builder.MoveTo(para);
  17338. string imagePath = "./Images/FMGJ_Log.png";
  17339. builder.InsertImage(imagePath);
  17340. #endregion
  17341. #endregion
  17342. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17343. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17344. string filePath = fileDir + $@"InvertedList/{fileName}";
  17345. doc.Save(filePath);
  17346. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17347. return Ok(JsonView(true, "操作成功!", Url));
  17348. }
  17349. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  17350. {
  17351. var fontColor = Color.FromArgb(64, 64, 64);
  17352. builder.InsertCell();
  17353. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17354. builder.RowFormat.Height = 40;
  17355. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17356. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17357. builder.Font.Name = fontName;
  17358. builder.Font.Size = 8;
  17359. builder.Font.Bold = true;
  17360. builder.Font.Color = fontColor;
  17361. builder.Write(dateTime);
  17362. builder.InsertCell();
  17363. builder.Font.Size = 9;
  17364. builder.Font.Bold = true;
  17365. builder.Font.Color = fontColor;
  17366. builder.Write(content);
  17367. builder.InsertCell();
  17368. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17369. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17370. builder.Font.Size = 9;
  17371. builder.Font.Bold = false;
  17372. builder.Font.Color = fontColor;
  17373. builder.Write(reamrk);
  17374. builder.EndRow();
  17375. }
  17376. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  17377. {
  17378. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17379. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17380. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17381. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17382. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17383. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17384. }
  17385. #endregion
  17386. #region 会务倒推表
  17387. /// <summary>
  17388. /// 会务倒推表
  17389. /// Init
  17390. /// </summary>
  17391. /// <returns></returns>
  17392. [HttpPost]
  17393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17394. public async Task<IActionResult> InforRetrogressTableInit()
  17395. {
  17396. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17397. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17398. return Ok(JsonView(false, groupData.Msg));
  17399. }
  17400. /// <summary>
  17401. /// 会务倒推表
  17402. /// ExcelDownload
  17403. /// </summary>
  17404. /// <param name="dto"></param>
  17405. /// <returns></returns>
  17406. [HttpPost]
  17407. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17409. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17410. {
  17411. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17412. var validatorRes = await validator.ValidateAsync(dto);
  17413. if (!validatorRes.IsValid)
  17414. {
  17415. StringBuilder sb = new StringBuilder();
  17416. foreach (var item in validatorRes.Errors)
  17417. {
  17418. sb.AppendLine(item.ErrorMessage);
  17419. }
  17420. return Ok(JsonView(false, sb.ToString()));
  17421. }
  17422. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17423. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17424. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17425. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17426. #region Excel
  17427. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17428. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17429. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17430. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17431. var fileNamePrefix = string.Empty;
  17432. if (days >= 30)
  17433. {
  17434. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17435. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17436. }
  17437. else if (days < 30 && days > 7)
  17438. {
  17439. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17440. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17441. }
  17442. else if (days <= 7)
  17443. {
  17444. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17445. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17446. }
  17447. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17448. fileName = CommonFun.ValidFileName(fileName);
  17449. //载入模板
  17450. WorkbookDesigner designer = new WorkbookDesigner();
  17451. designer.Workbook = new Workbook(tempPath);
  17452. designer.Process();
  17453. if (!Directory.Exists(savePath))
  17454. {
  17455. Directory.CreateDirectory(savePath);
  17456. }
  17457. string serverPath = $"{savePath}{fileName}";
  17458. designer.Workbook.Save(serverPath);
  17459. string rst = $"{servicePath}{ftpPath}{fileName}";
  17460. #endregion
  17461. return Ok(JsonView(new { url = rst }));
  17462. }
  17463. #endregion
  17464. #region 三公签证费用(签证费、代办费)
  17465. /// <summary>
  17466. /// 三公签证费用(签证费、代办费)
  17467. /// List
  17468. /// </summary>
  17469. /// <returns></returns>
  17470. [HttpPost]
  17471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17472. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17473. {
  17474. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17475. if (_view.Code != 0)
  17476. {
  17477. return Ok(JsonView(false, _view.Msg));
  17478. }
  17479. return Ok(JsonView(true, "操作成功!", _view.Data));
  17480. }
  17481. /// <summary>
  17482. /// 三公签证费用(签证费、代办费)
  17483. /// Add Or Update
  17484. /// </summary>
  17485. /// <returns></returns>
  17486. [HttpPost]
  17487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17488. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17489. {
  17490. var _view = await _visaFeeInfoRep._Update(_dto);
  17491. if (_view.Code != 0)
  17492. {
  17493. return Ok(JsonView(false, _view.Msg));
  17494. }
  17495. return Ok(JsonView(true, _view.Msg));
  17496. }
  17497. #endregion
  17498. #region 酒店询价
  17499. /// <summary>
  17500. /// 酒店询价
  17501. /// Init
  17502. /// </summary>
  17503. /// <returns></returns>
  17504. [HttpPost]
  17505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17506. public async Task<IActionResult> PostHotelInquiryInit()
  17507. {
  17508. var res = await _hotelInquiryRep._Init();
  17509. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17510. return Ok(JsonView(true, res.Msg, res.Data));
  17511. }
  17512. /// <summary>
  17513. /// 酒店询价
  17514. /// page Item
  17515. /// </summary>
  17516. /// <param name="_dto"></param>
  17517. /// <returns></returns>
  17518. [HttpPost]
  17519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17520. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17521. {
  17522. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17523. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17524. var view = res.Data as PageDataViewBase;
  17525. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17526. }
  17527. /// <summary>
  17528. /// 酒店询价
  17529. /// info
  17530. /// </summary>
  17531. /// <param name="_dto"></param>
  17532. /// <returns></returns>
  17533. [HttpPost]
  17534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17535. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17536. {
  17537. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17538. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17539. return Ok(JsonView(true, res.Msg, res.Data));
  17540. }
  17541. /// <summary>
  17542. /// 酒店询价
  17543. /// Add Or Edit
  17544. /// </summary>
  17545. /// <param name="_dto"></param>
  17546. /// <returns></returns>
  17547. [HttpPost]
  17548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17549. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17550. {
  17551. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17552. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17553. return Ok(JsonView(true, res.Msg, res.Data));
  17554. }
  17555. /// <summary>
  17556. /// 酒店询价
  17557. /// Del
  17558. /// </summary>
  17559. /// <param name="_dto"></param>
  17560. /// <returns></returns>
  17561. [HttpPost]
  17562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17563. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17564. {
  17565. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17566. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17567. return Ok(JsonView(true, res.Msg, res.Data));
  17568. }
  17569. #endregion
  17570. #region 下载匹配op行程单
  17571. /// <summary>
  17572. /// 匹配op行程单
  17573. /// Init
  17574. /// </summary>
  17575. /// <param name="dto">团组列表请求dto</param>
  17576. /// <returns></returns>
  17577. [HttpPost]
  17578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17579. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17580. {
  17581. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17582. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17583. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17584. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17585. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17586. .Where(it => it.IsDel == 0)
  17587. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17588. .OrderByDescending(it => it.VisitStartDate)
  17589. .ToList();
  17590. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17591. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17592. var diids = groupInfos.Select(it => it.Id).ToList();
  17593. List<string> countrys = new List<string>();
  17594. foreach (var item in country)
  17595. {
  17596. var data = _groupRepository.FormartTeamName(item);
  17597. var dataArray = _groupRepository.GroupSplitCountry(data);
  17598. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17599. }
  17600. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17601. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17602. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17603. foreach (var item in areaItem)
  17604. {
  17605. string areaStr = item.Value;
  17606. if (!string.IsNullOrEmpty(areaStr))
  17607. {
  17608. string[] str1 = areaStr.Split("-");
  17609. if (str1.Length > 0)
  17610. {
  17611. areaArray.AddRange(str1);
  17612. }
  17613. }
  17614. }
  17615. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17616. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17617. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17618. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17619. .ToList();
  17620. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17621. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17622. .Where(it => countriesIds.Contains(it.Id))
  17623. .Select(it => new { it.Id, Name = it.Name_CN })
  17624. .ToList();
  17625. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17626. .Select(it => it.TeamName).ToList();
  17627. stopwatch.Stop();
  17628. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17629. }
  17630. ///// <summary>
  17631. ///// 匹配op行程单
  17632. ///// Init 查询区域数据
  17633. ///// </summary>
  17634. ///// <param name="dto">团组列表请求dto</param>
  17635. ///// <returns></returns>
  17636. //[HttpPost]
  17637. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17638. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17639. //{
  17640. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17641. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17642. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17643. // if (string.IsNullOrEmpty(countriesDataStr))
  17644. // {
  17645. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17646. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17647. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17648. // }
  17649. // else
  17650. // {
  17651. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17652. // }
  17653. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17654. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17655. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17656. // List<dynamic> childList = new List<dynamic>();
  17657. // int parentId = dto.CountriesId;
  17658. // if (provinceData.Count > 1)
  17659. // {
  17660. // foreach (var item1 in provinceData)
  17661. // {
  17662. // List<dynamic> childList1 = new List<dynamic>();
  17663. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17664. // foreach (var item2 in citiesData1)
  17665. // {
  17666. // List<dynamic> childList2 = new List<dynamic>();
  17667. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17668. // foreach (var item3 in countiesData1)
  17669. // {
  17670. // childList2.Add(new
  17671. // {
  17672. // id = item3.Id,
  17673. // parentId = item2.Id,
  17674. // level = "district",
  17675. // name = item3.Name_CN,
  17676. // });
  17677. // }
  17678. // childList1.Add(new
  17679. // {
  17680. // id = item2.Id,
  17681. // parentId = item1.Id,
  17682. // level = "city",
  17683. // name = item2.Name_CN,
  17684. // childList = childList2
  17685. // });
  17686. // }
  17687. // childList.Add(new
  17688. // {
  17689. // id = item1.Id,
  17690. // parentId = parentId,
  17691. // level = "province",
  17692. // name = item1.Name_CN,
  17693. // childList = childList1
  17694. // });
  17695. // }
  17696. // //城市
  17697. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17698. // foreach (var item2 in citiesData2)
  17699. // {
  17700. // List<dynamic> childList22 = new List<dynamic>();
  17701. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17702. // foreach (var item3 in countiesData1)
  17703. // {
  17704. // childList22.Add(new
  17705. // {
  17706. // id = item3.Id,
  17707. // parentId = item2.Id,
  17708. // level = "district",
  17709. // name = item3.Name_CN,
  17710. // });
  17711. // }
  17712. // childList.Add(new
  17713. // {
  17714. // id = item2.Id,
  17715. // parentId = parentId,
  17716. // level = "city",
  17717. // name = item2.Name_CN,
  17718. // childList = childList22
  17719. // });
  17720. // }
  17721. // }
  17722. // else
  17723. // {
  17724. // foreach (var item2 in citiesData)
  17725. // {
  17726. // string cname = item2.Name_CN;
  17727. // List<dynamic> childList1 = new List<dynamic>();
  17728. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17729. // foreach (var item3 in countiesData1)
  17730. // {
  17731. // childList1.Add(new
  17732. // {
  17733. // Id = item3.Id,
  17734. // parentId = item2.Id,
  17735. // level = "district",
  17736. // name = item3.Name_CN
  17737. // });
  17738. // }
  17739. // childList.Add(new
  17740. // {
  17741. // id = item2.Id,
  17742. // parentId = parentId,
  17743. // level = "city",
  17744. // name = item2.Name_CN,
  17745. // childList = childList1
  17746. // });
  17747. // }
  17748. // }
  17749. // stopwatch.Stop();
  17750. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17751. //}
  17752. /// <summary>
  17753. /// 匹配op行程单
  17754. /// 接团信息列表 Page
  17755. /// </summary>
  17756. /// <param name="dto">团组列表请求dto</param>
  17757. /// <returns></returns>
  17758. [HttpPost]
  17759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17760. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17761. {
  17762. var swatch = new Stopwatch();
  17763. swatch.Start();
  17764. #region 参数验证
  17765. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17766. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17767. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17768. #region 页面操作权限验证
  17769. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17770. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17771. #endregion
  17772. #endregion
  17773. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17774. {
  17775. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17776. //string sqlWhere = "";
  17777. if (!string.IsNullOrEmpty(dto.Country))
  17778. {
  17779. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17780. }
  17781. if (!string.IsNullOrEmpty(dto.Area))
  17782. {
  17783. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17784. }
  17785. if (!string.IsNullOrEmpty(dto.TeamName))
  17786. {
  17787. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17788. }
  17789. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17790. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17791. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17792. swatch.Stop();
  17793. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17794. }
  17795. else
  17796. {
  17797. return Ok(JsonView(false, "查询失败"));
  17798. }
  17799. }
  17800. /// <summary>
  17801. /// 匹配op行程单
  17802. /// 行程单下载
  17803. /// </summary>
  17804. /// <param name="dto">团组列表请求dto</param>
  17805. /// <returns></returns>
  17806. [HttpPost]
  17807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17808. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17809. {
  17810. #region 参数验证
  17811. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17812. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17813. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17814. #region 页面操作权限验证
  17815. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17816. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17817. #endregion
  17818. #endregion
  17819. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17820. {
  17821. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17822. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17823. }
  17824. else
  17825. {
  17826. return Ok(JsonView(false, "下载失败!"));
  17827. }
  17828. }
  17829. #endregion
  17830. #region 国家信息 数据 注释
  17831. //[HttpPost]
  17832. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17833. //{
  17834. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17835. // foreach (var item in dto)
  17836. // {
  17837. // infos.Add(new Grp_GroupsTaskAssignment()
  17838. // {
  17839. // DIId = item,
  17840. // CTId = 82,
  17841. // UId = 248,
  17842. // IsEnable = 1,
  17843. // CreateUserId = 233,
  17844. // CreateTime = DateTime.Now,
  17845. // IsDel = 0
  17846. // });
  17847. // infos.Add(new Grp_GroupsTaskAssignment()
  17848. // {
  17849. // DIId = item,
  17850. // CTId = 82,
  17851. // UId = 286,
  17852. // IsEnable = 1,
  17853. // CreateUserId = 233,
  17854. // CreateTime = DateTime.Now,
  17855. // IsDel = 0
  17856. // });
  17857. // }
  17858. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17859. // return Ok("操作成功");
  17860. //}
  17861. //public class paramJsonDto
  17862. //{
  17863. // public List<CountriesInfo> str { get; set; }
  17864. //}
  17865. //[HttpPost]
  17866. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17867. //{
  17868. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17869. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17870. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17871. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17872. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17873. // _sqlSugar.BeginTran();
  17874. // int countitiesIndex = 0;
  17875. // foreach (var item in dto.str)
  17876. // {
  17877. // dynamic data = item.c;
  17878. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17879. // if (data != null)
  17880. // {
  17881. // countitiesIndex++;
  17882. // foreach (var item1 in data)
  17883. // {
  17884. // string cnname = item1.cn;
  17885. // string enname = item1.en;
  17886. // Sys_Cities provinceInfo = new Sys_Cities()
  17887. // {
  17888. // CountriesId = countriesId,
  17889. // Name_CN = cnname,
  17890. // Name_EN = enname,
  17891. // ParentId = 0,
  17892. // IsCapital = 1,
  17893. // CreateUserId = 208,
  17894. // CreateTime = DateTime.Now,
  17895. // IsDel = 0
  17896. // };
  17897. // if (item1.lv == "province") //省份
  17898. // {
  17899. // provinceInfo.Level = 1;
  17900. // int provinceId = 0;
  17901. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17902. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17903. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17904. // var data1 = item1.c;
  17905. // foreach (var item2 in data1)
  17906. // {
  17907. // if (item2.lv == "city")
  17908. // {
  17909. // string citycnname = item2.cn;
  17910. // string cityenname = item2.en;
  17911. // Sys_Cities cityInfo = new Sys_Cities()
  17912. // {
  17913. // CountriesId = countriesId,
  17914. // ParentId = provinceId,
  17915. // Level = 2,
  17916. // Name_CN = citycnname,
  17917. // Name_EN = cityenname,
  17918. // IsCapital = 1,
  17919. // CreateUserId = 208,
  17920. // CreateTime = DateTime.Now,
  17921. // IsDel = 0
  17922. // };
  17923. // if (item2.c != null)
  17924. // {
  17925. // int cityId = 0;
  17926. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17927. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17928. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17929. // foreach (var item3 in item2.c)
  17930. // {
  17931. // if (item3.lv == "district")
  17932. // {
  17933. // var districtInfo = new Sys_Cities()
  17934. // {
  17935. // CountriesId = countriesId,
  17936. // Name_CN = item3.cn,
  17937. // Name_EN = item3.en,
  17938. // Level = 3,
  17939. // ParentId = cityId,
  17940. // IsCapital = 1,
  17941. // CreateUserId = 208,
  17942. // CreateTime = DateTime.Now,
  17943. // IsDel = 0
  17944. // };
  17945. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17946. // //{
  17947. // districts.Add(districtInfo);
  17948. // //}
  17949. // }
  17950. // }
  17951. // }
  17952. // else
  17953. // {
  17954. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17955. // //{
  17956. // cities.Add(cityInfo);
  17957. // //}
  17958. // }
  17959. // }
  17960. // }
  17961. // }
  17962. // else if (item1.lv == "city")//城市
  17963. // {
  17964. // provinceInfo.Level = 2;
  17965. // if (item1.c != null)
  17966. // {
  17967. // int cityId = 0;
  17968. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17969. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17970. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17971. // foreach (var item3 in item1.c)
  17972. // {
  17973. // if (item3.lv == "district")
  17974. // {
  17975. // var districtInfo = new Sys_Cities()
  17976. // {
  17977. // CountriesId = countriesId,
  17978. // Name_CN = item3.cn,
  17979. // Name_EN = item3.en,
  17980. // Level = 3,
  17981. // ParentId = cityId,
  17982. // IsCapital = 1,
  17983. // CreateUserId = 208,
  17984. // CreateTime = DateTime.Now,
  17985. // IsDel = 0
  17986. // };
  17987. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17988. // //{
  17989. // districts.Add(districtInfo);
  17990. // //}
  17991. // }
  17992. // }
  17993. // }
  17994. // else
  17995. // {
  17996. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17997. // //{
  17998. // cities.Add(provinceInfo);
  17999. // //}
  18000. // }
  18001. // }
  18002. // }
  18003. // }
  18004. // }
  18005. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  18006. // cities = cities.Distinct().ToList();
  18007. // districts = districts.Distinct().ToList();
  18008. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  18009. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  18010. // cities.AddRange(districts);
  18011. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  18012. // //_sqlSugar.RollbackTran();
  18013. // _sqlSugar.CommitTran();
  18014. // return Ok(JsonView(false, "操作成功!"));
  18015. //}
  18016. //[HttpPost]
  18017. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18018. //{
  18019. // List<CountitiesInfo> infos = dto.MyProperty;
  18020. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18021. // _sqlSugar.BeginTran();
  18022. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18023. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18024. // foreach (var item in infos)
  18025. // {
  18026. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18027. // if (countryInfo != null)
  18028. // {
  18029. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18030. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18031. // if (cityInfo1 != null)
  18032. // {
  18033. // cityInfo1.IsCapital = 0;
  18034. // cityInfos.Add(cityInfo1);
  18035. // }
  18036. // }
  18037. // }
  18038. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18039. // .UpdateColumns(it => it.IsCapital)
  18040. // .WhereColumns(it => it.Id)
  18041. // .ExecuteCommand();
  18042. // //_sqlSugar.RollbackTran();
  18043. // _sqlSugar.CommitTran();
  18044. // return Ok(JsonView(false, "操作成功!"));
  18045. //}
  18046. //public class CounrtiesDto
  18047. //{
  18048. // public List<CountitiesInfo> MyProperty { get; set; }
  18049. //}
  18050. //public class CountitiesInfo
  18051. //{
  18052. // /// <summary>
  18053. // /// 圣约翰
  18054. // /// </summary>
  18055. // public string capital_name_chinese { get; set; }
  18056. // /// <summary>
  18057. // ///
  18058. // /// </summary>
  18059. // public string capital_name { get; set; }
  18060. // /// <summary>
  18061. // ///
  18062. // /// </summary>
  18063. // public string country_type { get; set; }
  18064. // /// <summary>
  18065. // /// 安提瓜和巴布达
  18066. // /// </summary>
  18067. // public string country_name_chinese { get; set; }
  18068. // /// <summary>
  18069. // /// 安提瓜和巴布达
  18070. // /// </summary>
  18071. // public string country_name_chinese_short { get; set; }
  18072. // /// <summary>
  18073. // /// 安提瓜和巴布达
  18074. // /// </summary>
  18075. // public string country_name_chinese_UN { get; set; }
  18076. // /// <summary>
  18077. // ///
  18078. // /// </summary>
  18079. // public string country_name_english_abbreviation { get; set; }
  18080. // /// <summary>
  18081. // ///
  18082. // /// </summary>
  18083. // public string country_name_english_formal { get; set; }
  18084. // /// <summary>
  18085. // ///
  18086. // /// </summary>
  18087. // public string country_name_english_UN { get; set; }
  18088. // /// <summary>
  18089. // ///
  18090. // /// </summary>
  18091. // public string continent_name { get; set; }
  18092. // /// <summary>
  18093. // ///
  18094. // /// </summary>
  18095. // public string subregion_name { get; set; }
  18096. // /// <summary>
  18097. // ///
  18098. // /// </summary>
  18099. // public string country_code2 { get; set; }
  18100. // /// <summary>
  18101. // ///
  18102. // /// </summary>
  18103. // public string country_code3 { get; set; }
  18104. // /// <summary>
  18105. // ///
  18106. // /// </summary>
  18107. // public string phone_code { get; set; }
  18108. //}
  18109. //public class CountriesInfo : BasicInfo
  18110. //{
  18111. // public List<CitiesInfo> c { get; set; }
  18112. //}
  18113. //public class CitiesInfo : BasicInfo
  18114. //{
  18115. // public List<AreaInfo> c { get; set; }
  18116. //}
  18117. //public class AreaInfo : BasicInfo
  18118. //{
  18119. // public List<AreaInfo> c { get; set; }
  18120. //}
  18121. //public class BasicInfo
  18122. //{
  18123. // public string code { get; set; }
  18124. // public string cn { get; set; }
  18125. // public string lv { get; set; }
  18126. // public string en { get; set; }
  18127. //}
  18128. #endregion
  18129. #region 查看邀请方
  18130. /// <summary>
  18131. /// 查看邀请方
  18132. /// 邀请方信息 Init
  18133. /// </summary>
  18134. /// <param name="dto"></param>
  18135. /// <returns></returns>
  18136. [HttpPost]
  18137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18138. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18139. {
  18140. string sqlWhere = string.Empty;
  18141. if (!string.IsNullOrEmpty(dto.Search))
  18142. {
  18143. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18144. }
  18145. string sql = string.Format($@"Select
  18146. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18147. Id,
  18148. UnitName
  18149. From Res_InvitationOfficialActivityData
  18150. Where IsDel = 0
  18151. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18152. RefAsync<int> total = 0;
  18153. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18154. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18155. }
  18156. /// <summary>
  18157. /// 查看邀请方
  18158. /// 国家信息 Init
  18159. /// </summary>
  18160. /// <param name="dto"></param>
  18161. /// <returns></returns>
  18162. [HttpPost]
  18163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18164. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18165. {
  18166. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18167. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18168. var diids = groupInfos.Select(it => it.Id).ToList();
  18169. List<string> countrys = new List<string>();
  18170. foreach (var item in country)
  18171. {
  18172. var data = _groupRepository.FormartTeamName(item);
  18173. var dataArray = _groupRepository.GroupSplitCountry(data);
  18174. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18175. }
  18176. countrys = countrys.Distinct().ToList();
  18177. for (int i = 0; i < countrys.Count; i++)
  18178. {
  18179. string item = countrys[i];
  18180. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18181. {
  18182. countrys.Remove(item);
  18183. i--;
  18184. }
  18185. }
  18186. RefAsync<int> total = 0;
  18187. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18188. .Where(it => countrys.Contains(it.Name_CN))
  18189. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18190. .Select(it => new { id = it.Id, name = it.Name_CN })
  18191. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18192. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18193. }
  18194. /// <summary>
  18195. /// 查看邀请方
  18196. /// 城市信息 Init
  18197. /// </summary>
  18198. /// <param name="dto"></param>
  18199. /// <returns></returns>
  18200. [HttpPost]
  18201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18202. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18203. {
  18204. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18205. RefAsync<int> total = 0;
  18206. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18207. .Where(it => it.CountriesId == dto.CountiesId)
  18208. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18209. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18210. .Select(it => new { id = it.Id, name = it.Name_CN })
  18211. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18212. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18213. }
  18214. /// <summary>
  18215. /// 查看邀请方
  18216. /// 团组名称 Init
  18217. /// </summary>
  18218. /// <param name="dto"></param>
  18219. /// <returns></returns>
  18220. [HttpPost]
  18221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18222. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18223. {
  18224. var watch = new Stopwatch();
  18225. watch.Start();
  18226. RefAsync<int> total = 0;
  18227. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18228. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18229. .Where((oa, di) => oa.IsDel == 0)
  18230. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18231. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18232. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18233. .Distinct()
  18234. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18235. watch.Stop();
  18236. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18237. }
  18238. /// <summary>
  18239. /// 查看邀请方
  18240. /// 团组 & 邀请方信息
  18241. /// </summary>
  18242. /// <param name="dto"></param>
  18243. /// <returns></returns>
  18244. [HttpPost]
  18245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18246. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18247. {
  18248. var watch = new Stopwatch();
  18249. watch.Start();
  18250. RefAsync<int> total = 0;
  18251. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18252. .AS("Grp_DelegationInfo")
  18253. .Includes(x => x.InvitingInfos)
  18254. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18255. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18256. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18257. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18258. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18259. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18260. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18261. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18262. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18263. infos.ForEach(x =>
  18264. {
  18265. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18266. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18267. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18268. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18269. });
  18270. watch.Stop();
  18271. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18272. }
  18273. #endregion
  18274. #region 报批行程
  18275. /// <summary>
  18276. /// 报批行程初始化
  18277. /// </summary>
  18278. /// <param name="dto"></param>
  18279. /// <returns></returns>
  18280. [HttpPost]
  18281. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18282. {
  18283. const int chiNumber = 5;
  18284. var jw = JsonView(false);
  18285. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18286. var group = groupList.First();
  18287. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18288. group = groupList.First(x => x.Id == diid);
  18289. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18290. .Where(x => x.DiId == diid && x.IsDel == 0)
  18291. .ToArray();
  18292. var count = 1;
  18293. foreach (var item in blackCodeList)
  18294. {
  18295. if (string.IsNullOrWhiteSpace(item.Title))
  18296. {
  18297. item.Title = "未设置名称数据" + count;
  18298. }
  18299. count++;
  18300. };
  18301. if (group == null)
  18302. {
  18303. jw.Msg = "暂无团组!";
  18304. return Ok(jw);
  18305. }
  18306. var data = new
  18307. {
  18308. groupList = groupList.Select(x => new
  18309. {
  18310. x.TeamName,
  18311. x.Id
  18312. }),
  18313. content = new ArrayList(),
  18314. groupInfo = new
  18315. {
  18316. group.VisitDays,
  18317. group.TourCode,
  18318. group.VisitPNumber,
  18319. group.TeamName,
  18320. group.Id,
  18321. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18322. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18323. },
  18324. blackCodeList = blackCodeList.Select(x => new
  18325. {
  18326. x.Title,
  18327. x.Id
  18328. }),
  18329. FileTempList = new ArrayList()
  18330. {
  18331. new { Index = 1,FileName = "旧模板" },
  18332. new { Index = 2,FileName = "省外办" },
  18333. new { Index = 3,FileName = "市外办" },
  18334. }
  18335. };
  18336. var resultArr = new ArrayList();
  18337. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18338. #region 默认不生成行程
  18339. //if (content.Count == 0)
  18340. //{
  18341. // var stay = "-";
  18342. // var cityPath = "-";
  18343. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18344. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18345. // .ToList();
  18346. // //添加城市路径以及住宿地
  18347. // //黑屏代码数据
  18348. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18349. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18350. // {
  18351. // jw = JsonView(true, "黑屏代码有误!", data);
  18352. // return Ok(jw);
  18353. // }
  18354. // data = data with
  18355. // {
  18356. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18357. // {
  18358. // x.Title,
  18359. // x.Id,
  18360. // }).ToArray())
  18361. // };
  18362. // foreach (DataRow row in dtBlack.Rows)
  18363. // {
  18364. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18365. // {
  18366. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18367. // return Ok(jw);
  18368. // }
  18369. // }
  18370. // //黑屏代码获取时间区间
  18371. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18372. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18373. // _sqlSugar.BeginTran();
  18374. // for (int i = 0; i < timeArr.Count; i++)
  18375. // {
  18376. // stay = "-";
  18377. // cityPath = "-";
  18378. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18379. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18380. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18381. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18382. // if (tbSelect.Length > 0)
  18383. // {
  18384. // List<string> threeCodeStr = new List<string>();
  18385. // foreach (var item in tbSelect)
  18386. // {
  18387. // var threeCode = item["Three"].ToString() ?? "";
  18388. // if (threeCode.Length == 6)
  18389. // {
  18390. // var start = threeCode.Substring(0, 3);
  18391. // var end = threeCode.Substring(3, 3);
  18392. // if (threeCodeStr.Count == 0)
  18393. // {
  18394. // threeCodeStr.Add(start);
  18395. // threeCodeStr.Add(end);
  18396. // }
  18397. // else
  18398. // {
  18399. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18400. // {
  18401. // threeCodeStr.Add(end);
  18402. // }
  18403. // else
  18404. // {
  18405. // threeCodeStr.Add(start);
  18406. // threeCodeStr.Add(end);
  18407. // }
  18408. // }
  18409. // }
  18410. // }
  18411. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18412. // var last = threeCodeStr.Last();
  18413. // foreach (var item in threeCodeStr)
  18414. // {
  18415. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18416. // if (item.Equals(last))
  18417. // {
  18418. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18419. // }
  18420. // }
  18421. // cityPath = cityPath.Trim('-');
  18422. // }
  18423. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18424. // appro.Diid = diid ?? -1;
  18425. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18426. // appro.Id = thisId;
  18427. // appro.CreateUserId = dto.UserId;
  18428. // appro.CreateTime = DateTime.Now;
  18429. // content.Add(appro);
  18430. // }
  18431. // _sqlSugar.CommitTran();
  18432. //}
  18433. #endregion
  18434. foreach (var x in content)
  18435. {
  18436. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18437. if (chiList.Count < chiNumber)
  18438. {
  18439. for (int i = chiList.Count; i < chiNumber; i++)
  18440. {
  18441. chiList.Add(new Grp_ApprovalTravelDetails());
  18442. }
  18443. }
  18444. resultArr.Add(new
  18445. {
  18446. x.Id,
  18447. x.Date,
  18448. x.Diid,
  18449. chiList = chiList.Select(x1 => new
  18450. {
  18451. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18452. x1.Details,
  18453. x1.ParentId,
  18454. x1.Id
  18455. })
  18456. });
  18457. }
  18458. data = data with
  18459. {
  18460. content = resultArr,
  18461. };
  18462. jw = JsonView(true, "获取成功!", data);
  18463. return Ok(jw);
  18464. }
  18465. /// <summary>
  18466. /// 报批行程删除
  18467. /// </summary>
  18468. /// <param name="dto"></param>
  18469. /// <returns></returns>
  18470. [HttpPost]
  18471. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18472. {
  18473. var jw = JsonView(false);
  18474. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18475. if (group == null)
  18476. {
  18477. jw.Msg = "团组参数有误!";
  18478. return Ok(jw);
  18479. }
  18480. try
  18481. {
  18482. _sqlSugar.BeginTran();
  18483. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18484. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18485. {
  18486. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18487. DeleteUserId = dto.uesrId,
  18488. IsDel = 1
  18489. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18490. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18491. {
  18492. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18493. DeleteUserId = dto.uesrId,
  18494. IsDel = 1
  18495. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18496. _sqlSugar.CommitTran();
  18497. jw = JsonView(true, "删除成功");
  18498. }
  18499. catch (Exception ex)
  18500. {
  18501. jw = JsonView(false, ex.Message);
  18502. }
  18503. return Ok(jw);
  18504. }
  18505. /// <summary>
  18506. /// 报批行程保存
  18507. /// </summary>
  18508. /// <param name="dto"></param>
  18509. /// <returns></returns>
  18510. [HttpPost]
  18511. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18512. {
  18513. var jw = JsonView(false);
  18514. var Find = dto.Arr.Find(x => x.id == 0);
  18515. if (Find != null)
  18516. {
  18517. jw.Msg = "生成的ID为0!";
  18518. return Ok(jw);
  18519. }
  18520. foreach (var item in dto.Arr)
  18521. {
  18522. foreach (var chi in item.chiList)
  18523. {
  18524. if (chi.parentId == 0)
  18525. {
  18526. chi.parentId = item.id;
  18527. }
  18528. }
  18529. }
  18530. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18531. _sqlSugar.BeginTran();
  18532. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18533. {
  18534. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18535. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18536. {
  18537. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18538. DeleteUserId = dto.UserId,
  18539. IsDel = 1
  18540. }).ExecuteCommand();
  18541. }
  18542. try
  18543. {
  18544. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18545. {
  18546. CreateTime = DateTime.Now,
  18547. CreateUserId = dto.UserId,
  18548. Details = x.details,
  18549. ParentId = x.parentId,
  18550. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18551. Remark = "",
  18552. IsDel = 0
  18553. }).ToList()).ExecuteCommand();
  18554. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18555. {
  18556. Id = x.id,
  18557. Details = x.details,
  18558. ParentId = x.parentId,
  18559. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18560. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18561. {
  18562. Details = x.Details,
  18563. ParentId = x.ParentId,
  18564. Time = x.Time
  18565. }).ExecuteCommand();
  18566. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18567. {
  18568. Id = x.id,
  18569. Date = x.date,
  18570. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18571. {
  18572. Date = x.Date
  18573. }).ExecuteCommand();
  18574. _sqlSugar.CommitTran();
  18575. jw = JsonView(true, "保存成功!");
  18576. }
  18577. catch (Exception ex)
  18578. {
  18579. _sqlSugar.RollbackTran();
  18580. jw = JsonView(false, "保存失败!" + ex.Message);
  18581. }
  18582. return Ok(jw);
  18583. }
  18584. /// <summary>
  18585. /// 报批行程生成
  18586. /// </summary>
  18587. /// <param name="dto"></param>
  18588. /// <returns></returns>
  18589. [HttpPost]
  18590. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18591. {
  18592. var jw = JsonView(false);
  18593. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18594. if (group == null)
  18595. {
  18596. jw.Msg = "暂无该团组!";
  18597. return Ok(jw);
  18598. }
  18599. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18600. //黑屏代码数据
  18601. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18602. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18603. {
  18604. jw.Msg = "黑屏代码有误!";
  18605. return Ok(jw);
  18606. }
  18607. foreach (DataRow row in dtBlack.Rows)
  18608. {
  18609. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18610. {
  18611. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18612. return Ok(jw);
  18613. }
  18614. }
  18615. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18616. var resultArr = new ArrayList();
  18617. //if (officialActivitiesArr.Count == 0)
  18618. //{
  18619. // jw.Msg = "暂无公务出访信息!";
  18620. // return Ok(jw);
  18621. //}
  18622. try
  18623. {
  18624. _sqlSugar.BeginTran();
  18625. DeleteApprovalJourney(new
  18626. Domain.Dtos.Groups.DeleteApprovalJourney
  18627. {
  18628. Diid = dto.Diid,
  18629. uesrId = dto.Userid
  18630. });
  18631. var stay = "-";
  18632. var cityPath = "-";
  18633. //添加城市路径以及住宿地
  18634. //黑屏代码获取时间区间
  18635. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18636. var empty = "【未收入该三字码!请机票同事录入】";
  18637. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18638. for (int i = 0; i < timeArr.Count; i++)
  18639. {
  18640. stay = "-";
  18641. cityPath = "-";
  18642. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18643. DateTime NewData = DateTime.Parse(timeArr[i]);
  18644. //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();
  18645. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18646. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18647. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18648. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18649. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18650. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18651. if (tbSelect.Length > 0)
  18652. {
  18653. List<string> threeCodeStr = new List<string>();
  18654. bool isTrade = false;
  18655. string trip = string.Empty;
  18656. var rowLast = tbSelect.Last();
  18657. var rowFirst = tbSelect.First();
  18658. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18659. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18660. var takeOffTime = DateTime.Parse(timeArr[i]);
  18661. var fallToTime = DateTime.Parse(timeArr[i]);
  18662. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18663. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18664. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18665. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18666. foreach (var item in tbSelect)
  18667. {
  18668. var start = string.Empty;
  18669. var end = string.Empty;
  18670. var threeCode = item["Three"].ToString() ?? "";
  18671. if (threeCode.Length == 6)
  18672. {
  18673. start = threeCode.Substring(0, 3);
  18674. end = threeCode.Substring(3, 3);
  18675. if (threeCodeStr.Count == 0)
  18676. {
  18677. threeCodeStr.Add(start);
  18678. threeCodeStr.Add(end);
  18679. }
  18680. else
  18681. {
  18682. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18683. {
  18684. threeCodeStr.Add(end);
  18685. }
  18686. else
  18687. {
  18688. threeCodeStr.Add(start);
  18689. threeCodeStr.Add(end);
  18690. }
  18691. }
  18692. }
  18693. //处理机票信息
  18694. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18695. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18696. if (start_Object == null)
  18697. {
  18698. start_Object = new Res_ThreeCode()
  18699. {
  18700. AirPort = empty,
  18701. AirPort_En = empty,
  18702. City = empty,
  18703. Country = empty,
  18704. Four = empty,
  18705. Three = empty,
  18706. };
  18707. }
  18708. if (end_Object == null)
  18709. {
  18710. end_Object = new Res_ThreeCode()
  18711. {
  18712. AirPort = empty,
  18713. AirPort_En = empty,
  18714. City = empty,
  18715. Country = empty,
  18716. Four = empty,
  18717. Three = empty,
  18718. };
  18719. }
  18720. //机型判断
  18721. string airModel = item["AirModel"].ToString();
  18722. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18723. string flightTime = item["FlightTime"].ToString();
  18724. if (flightTime!.Contains(":"))
  18725. {
  18726. flightTime = flightTime.Replace(":", "小时");
  18727. flightTime += "分钟";
  18728. }
  18729. if (flightTime.Contains("H"))
  18730. {
  18731. flightTime = flightTime.Replace("H", "小时");
  18732. }
  18733. if (flightTime.Contains("M"))
  18734. {
  18735. flightTime = flightTime.Replace("M", "分钟");
  18736. }
  18737. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18738. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18739. {
  18740. flightTime = flightDataTime.Hour > 0
  18741. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18742. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18743. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18744. }
  18745. //航班号
  18746. string flightcode = item["Fliagtcode"].ToString();
  18747. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18748. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18749. if (aircompany == null)
  18750. {
  18751. aircompany = new Res_AirCompany
  18752. {
  18753. CnName = hsEmpty,
  18754. EnName = hsEmpty,
  18755. ShortCode = hsEmpty,
  18756. };
  18757. }
  18758. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18759. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18760. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18761. if (isTrade)
  18762. {
  18763. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18764. }
  18765. else
  18766. {
  18767. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18768. }
  18769. }
  18770. chiarr.Add(new Grp_ApprovalTravelDetails
  18771. {
  18772. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18773. CreateTime = DateTime.Now,
  18774. CreateUserId = dto.Userid,
  18775. ParentId = 0,
  18776. Details = trip
  18777. });
  18778. //添加乘车语句
  18779. chiarr.Add(new Grp_ApprovalTravelDetails
  18780. {
  18781. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18782. CreateTime = DateTime.Now,
  18783. CreateUserId = dto.Userid,
  18784. ParentId = 0,
  18785. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18786. });
  18787. if (i != timeArr.Count - 1)
  18788. {
  18789. fallToTime = fallToTime.AddHours(2.5);
  18790. foreach (var item in Times)
  18791. {
  18792. //排列公务时间
  18793. if (fallToTime.Hour < item.Item1)
  18794. {
  18795. chiarr.Add(new Grp_ApprovalTravelDetails
  18796. {
  18797. Time = $"{item.Item2} - {item.Item3}",
  18798. CreateTime = DateTime.Now,
  18799. CreateUserId = dto.Userid,
  18800. ParentId = 0,
  18801. Details = "公务活动"
  18802. });
  18803. }
  18804. }
  18805. }
  18806. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18807. var last = threeCodeStr.Last();
  18808. foreach (var item in threeCodeStr)
  18809. {
  18810. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18811. if (item.Equals(last))
  18812. {
  18813. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18814. }
  18815. }
  18816. cityPath = cityPath.Trim('-');
  18817. }
  18818. else
  18819. {
  18820. foreach (var item in Times)
  18821. {
  18822. chiarr.Add(new Grp_ApprovalTravelDetails
  18823. {
  18824. Time = $"{item.Item2} - {item.Item3}",
  18825. CreateTime = DateTime.Now,
  18826. CreateUserId = dto.Userid,
  18827. ParentId = 0,
  18828. Details = "公务活动"
  18829. });
  18830. }
  18831. }
  18832. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18833. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18834. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18835. appro.Diid = dto.Diid;
  18836. appro.CreateUserId = dto.Userid;
  18837. appro.CreateTime = DateTime.Now;
  18838. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18839. appro.Id = thisId;
  18840. //foreach (var item in gwinfo)
  18841. //{
  18842. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18843. // chi.Details = "拜访" + item.Client;
  18844. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18845. // {
  18846. // chi.Details += "," + item.ReqSample;
  18847. // }
  18848. // chi.ParentId = thisId;
  18849. // chi.Time = item.Time;
  18850. // chiarr.Add(chi);
  18851. //}
  18852. if (chiarr.Count < 6)
  18853. {
  18854. for (int j = chiarr.Count; j < 6; j++)
  18855. {
  18856. chiarr.Add(new
  18857. Grp_ApprovalTravelDetails());
  18858. }
  18859. }
  18860. resultArr.Add(new
  18861. {
  18862. appro.Id,
  18863. appro.Date,
  18864. appro.Diid,
  18865. chiList = chiarr.Select(x1 => new
  18866. {
  18867. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18868. x1.Details,
  18869. x1.ParentId,
  18870. x1.Id
  18871. })
  18872. });
  18873. }
  18874. _sqlSugar.CommitTran();
  18875. jw = JsonView(true, "生成成功!", resultArr);
  18876. }
  18877. catch (Exception ex)
  18878. {
  18879. jw.Code = 400;
  18880. jw.Msg = "生成失败!" + ex.Message;
  18881. }
  18882. return Ok(jw);
  18883. }
  18884. /// <summary>
  18885. /// 报批行程word导出
  18886. /// </summary>
  18887. /// <param name="dto"></param>
  18888. /// <returns></returns>
  18889. [HttpPost]
  18890. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18891. {
  18892. var jw = JsonView(false);
  18893. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18894. if (group == null)
  18895. {
  18896. jw.Msg = "暂无该团组!";
  18897. return Ok(jw);
  18898. }
  18899. //模板路径
  18900. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18901. var fileName = string.Empty;
  18902. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18903. bool bold = false;
  18904. if (dto.FileIndex == 1)
  18905. {
  18906. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18907. }
  18908. else if (dto.FileIndex == 2)
  18909. {
  18910. fileName = "省外办-报批.docx";
  18911. bold = false;
  18912. titleFont = "方正黑体简体";
  18913. timeFont = "Times New Roman";
  18914. contentFont = "方正仿宋_GBK";
  18915. }
  18916. else if (dto.FileIndex == 3)
  18917. {
  18918. fileName = "市外办-报批.docx";
  18919. titleFont = "方正黑体简体";
  18920. timeFont = "Times New Roman";
  18921. contentFont = "方正仿宋简体";
  18922. }
  18923. tempPath = tempPath + fileName;
  18924. //载入模板
  18925. Document doc = new Document(tempPath);
  18926. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18927. //获取所填表格的序数
  18928. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18929. Aspose.Words.Tables.Row titleRowClone = null;
  18930. Aspose.Words.Tables.Row CenterRowClone = null;
  18931. int index = 0;
  18932. int indexChi = 0;
  18933. int SetIndex = 0;
  18934. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18935. //获取数据,放到datatable
  18936. foreach (var item in ApprovalTravelArr)
  18937. {
  18938. if (index > 0)
  18939. {
  18940. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18941. tableOne.AppendChild(titleRowClone);
  18942. }
  18943. var textTime = item.Date;
  18944. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18945. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18946. SetIndex++;
  18947. if (ChiRep.Count > 0)
  18948. {
  18949. foreach (var itemChi in ChiRep)
  18950. {
  18951. var txtTime = itemChi.Time;
  18952. var txtDetail = itemChi.Details;
  18953. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18954. {
  18955. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  18956. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18957. //indexChi++;
  18958. //SetIndex++;
  18959. break;
  18960. }
  18961. if (indexChi > 0)
  18962. {
  18963. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18964. tableOne.AppendChild(CenterRowClone);
  18965. }
  18966. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  18967. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  18968. indexChi++;
  18969. SetIndex++;
  18970. }
  18971. }
  18972. //else
  18973. //{
  18974. // if (indexChi > 0)
  18975. // {
  18976. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18977. // tableOne.AppendChild(CenterRowClone);
  18978. // }
  18979. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  18980. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18981. // indexChi++;
  18982. // SetIndex++;
  18983. //}
  18984. index++;
  18985. }
  18986. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  18987. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18988. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18989. jw.Code = 200;
  18990. jw.Msg = "";
  18991. return Ok(jw);
  18992. }
  18993. private string intToString(int numberVal)
  18994. {
  18995. string numberval = numberVal.ToString();
  18996. Dictionary<char, string> Number = new Dictionary<char, string>();
  18997. Number.Add('1', "一");
  18998. Number.Add('2', "二");
  18999. Number.Add('3', "三");
  19000. Number.Add('4', "四");
  19001. Number.Add('5', "五");
  19002. Number.Add('6', "六");
  19003. Number.Add('7', "七");
  19004. Number.Add('8', "八");
  19005. Number.Add('9', "九");
  19006. string stringNumberVal = string.Empty;
  19007. for (int i = 0; i < numberval.Length; i++)
  19008. {
  19009. if (i == 0)
  19010. {
  19011. stringNumberVal += Number[numberval[i]];
  19012. }
  19013. else if (i >= 1)
  19014. {
  19015. if (numberval[i] == '0')
  19016. {
  19017. stringNumberVal = "十";
  19018. }
  19019. else
  19020. {
  19021. stringNumberVal += "十" + Number[numberval[i]];
  19022. }
  19023. }
  19024. }
  19025. return stringNumberVal;
  19026. }
  19027. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  19028. {
  19029. //获取table中的某个单元格,从0开始
  19030. Cell lshCell = table.Rows[rows].Cells[cells];
  19031. //将单元格中段落移除
  19032. foreach (Paragraph item in lshCell.Paragraphs)
  19033. {
  19034. lshCell.Paragraphs.Remove(item);
  19035. }
  19036. if (val.Contains("\r\n"))
  19037. {
  19038. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19039. foreach (var item in spArr)
  19040. {
  19041. //新建一个段落
  19042. Paragraph p = new Paragraph(doc);
  19043. var r = new Run(doc, item);
  19044. //设置字体
  19045. if (!string.IsNullOrEmpty(font))
  19046. {
  19047. r.Font.Name = font;
  19048. }
  19049. r.Font.Bold = bold;
  19050. //把设置的值赋给之前新建的段落
  19051. p.AppendChild(r);
  19052. //将此段落加到单元格内
  19053. lshCell.AppendChild(p);
  19054. }
  19055. }
  19056. else
  19057. {
  19058. //新建一个段落
  19059. Paragraph p = new Paragraph(doc);
  19060. var r = new Run(doc, val);
  19061. //设置字体
  19062. if (!string.IsNullOrEmpty(font))
  19063. {
  19064. r.Font.Name = font;
  19065. }
  19066. r.Font.Bold = bold;
  19067. //把设置的值赋给之前新建的段落
  19068. p.AppendChild(r);
  19069. //将此段落加到单元格内
  19070. lshCell.AppendChild(p);
  19071. }
  19072. }
  19073. [HttpPost]
  19074. public async Task<IActionResult> ServerHttp(string paramStr)
  19075. {
  19076. paramStr = paramStr.TrimEnd('\'');
  19077. paramStr = paramStr.TrimStart('\'');
  19078. JsonView jw = JsonView(false);
  19079. JObject param = JObject.Parse(paramStr);
  19080. if (!param.ContainsKey("url"))
  19081. {
  19082. jw.Msg = "url null";
  19083. return Ok(jw);
  19084. }
  19085. string url = param["url"]!.ToString();
  19086. var methon = "get";
  19087. Dictionary<string, string> headValues = null;
  19088. string bodyStr = string.Empty;
  19089. if (param.ContainsKey("methon"))
  19090. {
  19091. methon = param["methon"]!.ToString().ToLower();
  19092. }
  19093. if (param.ContainsKey("header"))
  19094. {
  19095. var header = param["header"]!.ToString();
  19096. JObject headerJobject = JObject.Parse(header);
  19097. headValues = new Dictionary<string, string>();
  19098. foreach (JProperty item in headerJobject.Properties())
  19099. {
  19100. var value = item.Value.ToString();
  19101. var head = item.Path;
  19102. headValues.Add(head, value);
  19103. }
  19104. }
  19105. HttpClient client = new HttpClient();
  19106. string responseString = string.Empty;
  19107. StringContent content = null;
  19108. if (headValues != null)
  19109. {
  19110. foreach (var item in headValues.Keys)
  19111. {
  19112. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19113. {
  19114. if (param.ContainsKey("body"))
  19115. {
  19116. bodyStr = param["body"]!.ToString();
  19117. }
  19118. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19119. }
  19120. else
  19121. {
  19122. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19123. }
  19124. }
  19125. }
  19126. try
  19127. {
  19128. if (methon == "get")
  19129. {
  19130. responseString = await client.GetStringAsync(url);
  19131. }
  19132. else if (methon == "post")
  19133. {
  19134. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19135. {
  19136. Content = content
  19137. };
  19138. var response = await client.SendAsync(request);
  19139. try
  19140. {
  19141. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19142. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19143. {
  19144. using (StreamReader reader = new StreamReader(gzipStream))
  19145. {
  19146. responseString = await reader.ReadToEndAsync();
  19147. }
  19148. }
  19149. }
  19150. catch (Exception)
  19151. {
  19152. responseString = await response.Content.ReadAsStringAsync();
  19153. }
  19154. }
  19155. else
  19156. {
  19157. responseString = "methon error";
  19158. }
  19159. jw = JsonView(true, "success", responseString);
  19160. }
  19161. catch (Exception ex)
  19162. {
  19163. jw.Msg = "error " + ex.Message;
  19164. jw.Data = ex.StackTrace;
  19165. }
  19166. finally
  19167. {
  19168. client.Dispose();
  19169. }
  19170. return Ok(jw);
  19171. }
  19172. #endregion
  19173. #region 团组接待意见调查
  19174. /// <summary>
  19175. /// 团组接待意见调查 - 信息管理
  19176. /// 基础数据(团组)
  19177. /// </summary>
  19178. /// <returns></returns>
  19179. [HttpGet]
  19180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19181. public async Task<IActionResult> OpinionaireInit()
  19182. {
  19183. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19184. .Select(x => new
  19185. {
  19186. x.Id,
  19187. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19188. })
  19189. .OrderByDescending(x => x.Id)
  19190. .ToListAsync();
  19191. return Ok(JsonView(groupData, groupData.Count));
  19192. }
  19193. /// <summary>
  19194. /// 团组接待意见调查 - 信息管理
  19195. /// 列表
  19196. /// </summary>
  19197. /// <param name="groupId"></param>
  19198. /// <returns></returns>
  19199. [HttpGet("{groupId}")]
  19200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19201. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19202. {
  19203. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19204. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19205. .Select(x => new
  19206. {
  19207. x.Id,
  19208. x.TourGuideName,
  19209. x.CityName,
  19210. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19211. x.CreateTime
  19212. })
  19213. .OrderBy(x => x.Id)
  19214. .ToListAsync();
  19215. return Ok(JsonView(data));
  19216. }
  19217. /// <summary>
  19218. /// 团组接待意见调查 - 信息管理
  19219. /// 保存
  19220. /// </summary>
  19221. /// <param name="dto"></param>
  19222. /// <returns></returns>
  19223. [HttpPost]
  19224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19225. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19226. {
  19227. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19228. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19229. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19230. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19231. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19232. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19233. _opinionaireRep.BeginTran();
  19234. if (addData != null && addData.Count > 0)
  19235. {
  19236. foreach (var item in addData)
  19237. {
  19238. item.CreateUserId = currUserInfo.UserId;
  19239. item.DiId = dto.DiId;
  19240. }
  19241. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19242. }
  19243. if (updData != null && updData.Count > 0)
  19244. {
  19245. var upd = await _opinionaireRep._sqlSugar
  19246. .Updateable(updData)
  19247. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19248. .WhereColumns(x => new { x.Id })
  19249. .ExecuteCommandAsync();
  19250. }
  19251. _opinionaireRep.CommitTran();
  19252. return Ok(JsonView("操作成功!"));
  19253. }
  19254. /// <summary>
  19255. /// 团组接待意见调查 - 信息管理
  19256. /// 删除
  19257. /// </summary>
  19258. /// <param name="id"></param>
  19259. /// <returns></returns>
  19260. [HttpDelete("{id}")]
  19261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19262. public async Task<IActionResult> OpinionaireManageDel(int id)
  19263. {
  19264. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19265. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19266. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19267. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19268. if (!del) return Ok(JsonView("操作失败!"));
  19269. return Ok(JsonView("操作成功!"));
  19270. }
  19271. /// <summary>
  19272. /// 团组接待意见调查 - 用户
  19273. /// 列表
  19274. /// </summary>
  19275. /// <param name="diId"></param>
  19276. /// <returns></returns>
  19277. [HttpGet("{diId}")]
  19278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19279. public async Task<IActionResult> OpinionaireUserList(int diId)
  19280. {
  19281. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19282. var sql = string.Format(@"
  19283. SELECT
  19284. o.Id,
  19285. o.DiId,
  19286. di.TeamName AS 'GroupName',
  19287. di.VisitPNumber AS 'PeopleNumber',
  19288. di.ClientName AS 'LeadGroup',
  19289. di.VisitCountry AS 'Travel',
  19290. di.VisitDays AS 'Days',
  19291. o.CityName,
  19292. o.TourGuideName,
  19293. o.Catering,
  19294. o.CateringReason,
  19295. o.Stay,
  19296. o.StayReason,
  19297. o.[Route],
  19298. o.RouteReason,
  19299. o.OfficialActivity,
  19300. o.OfficialActivityReason,
  19301. o.TourGuide,
  19302. o.TourGuideReason,
  19303. o.[Translate],
  19304. o.TranslateReason,
  19305. o.Trip,
  19306. o.TripReason,
  19307. o.ESFileName,
  19308. o.SignatureDate,
  19309. o.Remark
  19310. FROM
  19311. Grp_Opinionaire o
  19312. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19313. WHERE
  19314. o.IsDel = 0
  19315. AND o.DiId = {0}
  19316. ORDER BY
  19317. o.Id ASC", diId);
  19318. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19319. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19320. return Ok(JsonView(data));
  19321. }
  19322. /// <summary>
  19323. /// 团组接待意见调查 - 用户
  19324. /// 保存
  19325. /// </summary>
  19326. /// <param name="dto"></param>
  19327. /// <returns></returns>
  19328. [HttpPost]
  19329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19330. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19331. {
  19332. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19333. foreach (var item in dto)
  19334. {
  19335. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19336. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19337. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19338. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19339. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19340. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19341. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19342. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19343. }
  19344. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19345. if (!Directory.Exists(filePathBase))
  19346. {
  19347. Directory.CreateDirectory(filePathBase);
  19348. }
  19349. #region 上传文件
  19350. var filePaths = new List<string>();
  19351. foreach (var item in dto)
  19352. {
  19353. var file = item.File;
  19354. // 将文件保存到指定位置
  19355. var filePath = Path.Combine(filePathBase, file.FileName);
  19356. using (var stream = new FileStream(filePath, FileMode.Create))
  19357. {
  19358. await file.CopyToAsync(stream);
  19359. }
  19360. //验证文件是否上传成功
  19361. if (!System.IO.File.Exists(filePath))
  19362. {
  19363. foreach (var filePathStr in filePaths)
  19364. {
  19365. System.IO.File.Delete(filePathStr);
  19366. }
  19367. return Ok(JsonView(false, "文件上传失败!"));
  19368. }
  19369. item.ESFileName = file.FileName;
  19370. }
  19371. #endregion
  19372. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19373. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19374. .UpdateColumns(x => new
  19375. {
  19376. x.Catering,
  19377. x.CateringReason,
  19378. x.Stay,
  19379. x.StayReason,
  19380. x.Route,
  19381. x.RouteReason,
  19382. x.OfficialActivity,
  19383. x.OfficialActivityReason,
  19384. x.TourGuide,
  19385. x.TourGuideReason,
  19386. x.Translate,
  19387. x.TranslateReason,
  19388. x.Trip,
  19389. x.TripReason,
  19390. x.ESFileName,
  19391. x.SignatureDate,
  19392. x.Remark
  19393. })
  19394. .WhereColumns(x => new { x.Id })
  19395. .ExecuteCommandAsync();
  19396. if (upd < 1)
  19397. {
  19398. foreach (var filePathStr in filePaths)
  19399. {
  19400. System.IO.File.Delete(filePathStr);
  19401. }
  19402. return Ok(JsonView(false));
  19403. }
  19404. return Ok(JsonView(true));
  19405. }
  19406. #endregion
  19407. #region 团组餐厅相关信息
  19408. /// <summary>
  19409. /// 团组相关餐厅信息
  19410. /// 基础数据(团组)
  19411. /// </summary>
  19412. /// <returns></returns>
  19413. [HttpGet]
  19414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19415. public async Task<IActionResult> RestaurantInit()
  19416. {
  19417. return Ok(await _restaurantRep.InitAsync());
  19418. }
  19419. /// <summary>
  19420. /// 团组相关餐厅信息
  19421. /// Item
  19422. /// </summary>
  19423. /// <param name="dto"></param>
  19424. /// <returns></returns>
  19425. [HttpPost]
  19426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19427. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19428. {
  19429. int portType = dto.PortType,
  19430. groupId = dto.GroupId;
  19431. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19432. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19433. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19434. }
  19435. /// <summary>
  19436. /// 团组相关餐厅信息
  19437. /// List
  19438. /// </summary>
  19439. /// <param name="dto"></param>
  19440. /// <returns></returns>
  19441. [HttpPost]
  19442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19443. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19444. {
  19445. int portType = dto.PortType,
  19446. groupId = dto.GroupId;
  19447. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19448. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19449. var sql = string.Format(@" SELECT
  19450. ri.Id,
  19451. ri.GroupId,
  19452. ri.Date,
  19453. ri.StartTime,
  19454. ri.EndTime,
  19455. CASE WHEN ri.Type = 1 THEN '早餐'
  19456. WHEN ri.Type = 2 THEN '午餐'
  19457. WHEN ri.Type = 3 THEN '晚餐'
  19458. ELSE '其他'
  19459. END AS 'Type',
  19460. ri.Name,
  19461. ri.Address,
  19462. ri.Tel,
  19463. ri.Remark,
  19464. ri.CreateTime,
  19465. u.CnName AS CreateUserName
  19466. FROM
  19467. Grp_RestaurantInfo ri
  19468. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19469. WHERE
  19470. ri.IsDel = 0
  19471. AND ri.GroupId = {0}
  19472. ORDER BY
  19473. ri.Date ASC
  19474. ", groupId);
  19475. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19476. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19477. return Ok(JsonView(infos));
  19478. }
  19479. /// <summary>
  19480. /// 团组相关餐厅信息
  19481. /// Info
  19482. /// </summary>
  19483. /// <param name="dto"></param>
  19484. /// <returns></returns>
  19485. [HttpPost]
  19486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19487. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19488. {
  19489. int portType = dto.PortType,
  19490. id = dto.Id;
  19491. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19492. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19493. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19494. }
  19495. /// <summary>
  19496. /// 团组相关餐厅信息
  19497. /// Op
  19498. /// </summary>
  19499. /// <param name="dto"></param>
  19500. /// <returns></returns>
  19501. [HttpPost]
  19502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19503. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19504. {
  19505. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19506. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19507. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19508. return Ok(await _restaurantRep.OpAsync(dto));
  19509. }
  19510. /// <summary>
  19511. /// 团组相关餐厅信息
  19512. /// Del
  19513. /// </summary>
  19514. /// <param name="dto"></param>
  19515. /// <returns></returns>
  19516. [HttpPost]
  19517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19518. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19519. {
  19520. int userId = dto.DeleteUserId;
  19521. var id = dto.Id;
  19522. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19523. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19524. return Ok(await _restaurantRep.DelAsync(dto));
  19525. }
  19526. #endregion
  19527. // /// <summary>
  19528. // ///
  19529. // /// </summary>
  19530. // /// <param name="_dto"></param>
  19531. // /// <returns></returns>
  19532. // [HttpPost]
  19533. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19534. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19535. // {
  19536. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19537. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19538. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19539. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19540. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19541. // dic_psg.Add("客人", 974);
  19542. // dic_psg.Add("司机", 975);
  19543. // dic_psg.Add("导游", 976);
  19544. // dic_psg.Add("公司内部人员", 977);
  19545. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19546. // foreach (var item in list_visa)
  19547. // {
  19548. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19549. // temp.Id = item.Id;
  19550. // temp.DIId = item.DIId;
  19551. // temp.VisaClient = item.VisaClient;
  19552. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19553. // temp.VisaCurrency = item.VisaCurrency;
  19554. // temp.IsThird = item.IsThird;
  19555. // if (dic_psg.ContainsKey(item.PassengerType))
  19556. // {
  19557. // temp.PassengerType = dic_psg[item.PassengerType];
  19558. // }
  19559. // else {
  19560. // temp.PassengerType = -1;
  19561. // }
  19562. // temp.VisaNumber = item.VisaNumber;
  19563. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19564. // temp.CreateUserId = item.Operators;
  19565. // DateTime dt_ct;
  19566. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19567. // if (b_ct)
  19568. // {
  19569. // temp.CreateTime = dt_ct;
  19570. // }
  19571. // else
  19572. // {
  19573. // temp.CreateTime = DateTime.Now;
  19574. // }
  19575. // temp.DeleteTime = "";
  19576. // temp.DeleteUserId = 0;
  19577. // temp.Remark = item.Remark;
  19578. // if (string.IsNullOrEmpty(temp.Remark)) {
  19579. // temp.Remark = "";
  19580. // }
  19581. // temp.IsDel = item.IsDel;
  19582. // temp.VisaDescription = item.VisaAttachment;
  19583. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19584. //([Id]
  19585. // ,[DIId]
  19586. // ,[VisaClient]
  19587. // ,[VisaPrice]
  19588. // ,[VisaCurrency]
  19589. // ,[IsThird]
  19590. // ,[PassengerType]
  19591. // ,[VisaNumber]
  19592. // ,[VisaFreeNumber]
  19593. // ,[CreateUserId]
  19594. // ,[CreateTime]
  19595. // ,[DeleteTime]
  19596. // ,[DeleteUserId]
  19597. // ,[Remark]
  19598. // ,[IsDel]
  19599. // ,[visaDescription])
  19600. // VALUES
  19601. // ({0},{1},'{2}',{3},{4}
  19602. //,{5},{6},{7},{8},{9}
  19603. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19604. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19605. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19606. //);
  19607. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19608. // }
  19609. // return Ok(JsonView(true, "操作成功!"));
  19610. // }
  19611. /// <summary>
  19612. /// 123132123
  19613. /// </summary>
  19614. /// <param name="_dto"></param>
  19615. /// <returns></returns>
  19616. [HttpPost]
  19617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19618. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19619. {
  19620. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19621. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19622. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19623. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19624. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19625. dicDetail.Add(789, 1034);
  19626. dicDetail.Add(790, 1035);
  19627. dicDetail.Add(791, 1036);
  19628. dicDetail.Add(792, 1037);
  19629. dicDetail.Add(793, 1038);
  19630. dicDetail.Add(794, 1039);
  19631. dicDetail.Add(795, 1040);
  19632. dicDetail.Add(796, 1041);
  19633. dicDetail.Add(797, 1042);
  19634. dicDetail.Add(798, 1043);
  19635. dicDetail.Add(801, 1044);
  19636. dicDetail.Add(802, 1045);
  19637. dicDetail.Add(803, 1046);
  19638. Dictionary<int, int> dic = new Dictionary<int, int>();
  19639. dic.Add(806, 1027);
  19640. dic.Add(807, 1028);
  19641. dic.Add(808, 1029);
  19642. dic.Add(809, 1030);
  19643. dic.Add(810, 1031);
  19644. dic.Add(811, 1032);
  19645. dic.Add(812, 1033);
  19646. foreach (var item in list_visa)
  19647. {
  19648. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19649. temp.Coefficient = item.coefficient;
  19650. DateTime dtCrt;
  19651. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19652. if (b1)
  19653. {
  19654. temp.CreateTime = dtCrt;
  19655. }
  19656. else
  19657. {
  19658. temp.CreateTime = DateTime.Now;
  19659. }
  19660. temp.CreateUserId = item.Operators;
  19661. temp.DeleteTime = "";
  19662. temp.DeleteUserId = 0;
  19663. temp.DiId = int.Parse(item.DIID);
  19664. temp.FilePath = item.FilePath;
  19665. temp.IsDel = item.IsDel;
  19666. temp.Price = item.Price;
  19667. temp.PriceCount = 1;
  19668. temp.PriceCurrency = item.Currency;
  19669. int detailId = 0;
  19670. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19671. {
  19672. detailId = dicDetail[item.PriceTypeDetail];
  19673. }
  19674. temp.PriceDetailType = detailId;
  19675. temp.PriceDt = DateTime.Now;
  19676. temp.PriceName = item.PriceName;
  19677. temp.PriceSum = item.Price;
  19678. int tid = 0;
  19679. if (dic.ContainsKey(item.PriceType))
  19680. {
  19681. tid = dic[item.PriceType];
  19682. }
  19683. temp.PriceType = tid;
  19684. temp.Remark = item.Remark;
  19685. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19686. }
  19687. return Ok(JsonView(true, "操作成功!"));
  19688. }
  19689. [HttpPost]
  19690. public IActionResult TimeTest()
  19691. {
  19692. var jw = JsonView(false, "error");
  19693. _sqlSugar.BeginTran();
  19694. try
  19695. {
  19696. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19697. .Select(x => new Crm_NewClientData
  19698. {
  19699. Id = x.Id,
  19700. Client = x.Client,
  19701. Contact = x.Contact,
  19702. Location = x.Location,
  19703. })
  19704. .ToList();
  19705. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19706. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19707. Stopwatch stopwatch = new Stopwatch();
  19708. // 开始计时
  19709. stopwatch.Start();
  19710. foreach (var item in clientList)
  19711. {
  19712. EncryptionProcessor.DecryptProperties(item);
  19713. }
  19714. stopwatch.Stop();
  19715. jw.Code = 200;
  19716. jw.Data = stopwatch.ElapsedMilliseconds;
  19717. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19718. }
  19719. catch (Exception ex)
  19720. {
  19721. jw.Code = 400;
  19722. jw.Msg = ex.Message;
  19723. }
  19724. return Ok(jw);
  19725. }
  19726. }
  19727. }