GroupsController.cs 1.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962
  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. /// 团组前期信息 Init
  379. /// </summary>
  380. /// <returns></returns>
  381. [HttpGet]
  382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  383. public async Task<IActionResult> GroupOrderPreInfo()
  384. {
  385. return Ok(await _grpOrderPreInfoRep.DataInit());
  386. }
  387. /// <summary>
  388. /// 国家数据源
  389. /// </summary>
  390. /// <returns></returns>
  391. [HttpGet]
  392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  393. public async Task<IActionResult> CountryInit()
  394. {
  395. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  396. return Ok(JsonView(countrys));
  397. }
  398. /// <summary>
  399. /// 城市数据源
  400. /// </summary>
  401. /// <returns></returns>
  402. [HttpGet("{countryLabel}")]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> CityByCountry(string countryLabel)
  405. {
  406. countryLabel = HttpUtility.UrlDecode(countryLabel);
  407. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  408. var citys = Array.Empty<string?>();
  409. if (countryList.Any())
  410. {
  411. var cityDatas = await _sqlSugar
  412. .Queryable<Grp_NationalTravelFee>()
  413. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  414. .ToArrayAsync();
  415. foreach (var item in cityDatas)
  416. {
  417. if (item.City.Contains("城市"))
  418. {
  419. item.City = item.Country + "-所有城市";
  420. }
  421. }
  422. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  423. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  424. }
  425. return Ok(JsonView(citys));
  426. }
  427. /// <summary>
  428. /// 团组前期信息 Info
  429. /// </summary>
  430. /// <param name="id">Id</param>
  431. /// <param name="tempId">Id</param>
  432. /// <returns></returns>
  433. [HttpGet("{id}/{tempId}")]
  434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  435. public async Task<IActionResult> GroupOrderPreInfo(int id, int tempId = 1404)
  436. {
  437. return Ok(await _grpOrderPreInfoRep.InfoAsync(id, tempId));
  438. }
  439. /// <summary>
  440. /// 团组前期信息 Save
  441. /// </summary>
  442. /// <param name="dto">Id</param>
  443. /// <returns></returns>
  444. [HttpPost]
  445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  446. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  447. {
  448. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  449. }
  450. /// <summary>
  451. /// 团组前期信息 文件下载
  452. /// </summary>
  453. /// <param name="id">Id</param>
  454. /// <param name="tempId">Id</param>
  455. /// <returns></returns>
  456. [HttpGet("{id}/{tempId}")]
  457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  458. public async Task<IActionResult> GroupOrderPreInfoFileDownload(int id, int tempId = 1404)
  459. {
  460. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  461. var data = view.Data as GrpOrderPreInfoView;
  462. #region Excel
  463. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  464. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  465. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  466. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  467. var fileNamePrefix = string.Empty;
  468. if (tempId == 1405)
  469. {
  470. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  471. fileNamePrefix = $"{data.Name}_无商邀版";
  472. }
  473. else if (tempId == 1406)
  474. {
  475. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  476. fileNamePrefix = $"{data.Name}_有商邀版";
  477. }
  478. else
  479. {
  480. //tempId == 1404 默认下载
  481. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  482. fileNamePrefix = $"{data.Name}_单接送机";
  483. }
  484. foreach (var item in data.Items)
  485. {
  486. var obj = item.NewValue;
  487. if (obj == null) item.OriginVal = "";
  488. else if (obj.Equals("有") || obj.Equals("无"))
  489. {
  490. item.OriginVal = obj.ToString();
  491. }
  492. else if (obj is object[] objArray)
  493. {
  494. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  495. item.OriginVal = string.Join("、", stringArray);
  496. }
  497. else if (obj is string[] stringArray)
  498. {
  499. item.OriginVal = string.Join("、", stringArray);
  500. }
  501. else if (obj.Equals("-"))
  502. {
  503. item.OriginVal = "";
  504. }
  505. }
  506. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  507. fileName = CommonFun.ValidFileName(fileName);
  508. //载入模板
  509. WorkbookDesigner designer = new WorkbookDesigner();
  510. designer.Workbook = new Workbook(tempPath);
  511. if (tempId == 1406)
  512. {
  513. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  514. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  515. for (int i = 1; i <= view2.Length; i++)
  516. {
  517. view2[i - 1].Index = i;
  518. }
  519. designer.SetDataSource("View1", view1);
  520. designer.SetDataSource("View2", view2);
  521. }
  522. else
  523. {
  524. designer.SetDataSource("View", data.Items);
  525. }
  526. designer.Process();
  527. if (!Directory.Exists(savePath))
  528. {
  529. Directory.CreateDirectory(savePath);
  530. }
  531. string serverPath = $"{savePath}{fileName}";
  532. designer.Workbook.Save(serverPath);
  533. string rst = $"{servicePath}{ftpPath}{fileName}";
  534. #endregion
  535. return Ok(JsonView(new { url = rst }));
  536. }
  537. #endregion
  538. #region 团组基本信息
  539. /// <summary>
  540. /// 接团信息列表
  541. /// </summary>
  542. /// <param name="dto">团组列表请求dto</param>
  543. /// <returns></returns>
  544. [HttpPost]
  545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  546. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  547. {
  548. var groupData = await _groupRepository.GetGroupList(dto);
  549. if (groupData.Code != 0)
  550. {
  551. return Ok(JsonView(false, groupData.Msg));
  552. }
  553. return Ok(JsonView(groupData.Data));
  554. }
  555. /// <summary>
  556. /// 分页查询团组列表
  557. /// </summary>
  558. /// <param name="dto"></param>
  559. /// <returns></returns>
  560. [HttpPost]
  561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  562. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  563. {
  564. var watch = new Stopwatch();
  565. watch.Start();
  566. RefAsync<int> total = 0;
  567. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  568. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  569. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  570. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  571. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  572. .Distinct()
  573. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  574. watch.Stop();
  575. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  576. }
  577. /// <summary>
  578. /// 接团信息列表 Page Init
  579. /// </summary>
  580. /// <returns></returns>
  581. [HttpPost]
  582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  583. public async Task<IActionResult> PostGroupPageListInit()
  584. {
  585. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  586. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  587. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  588. var _view = new
  589. {
  590. depData = depDatas,
  591. rankData = rankDatas
  592. };
  593. return Ok(JsonView(true, "查询成功!", _view));
  594. }
  595. /// <summary>
  596. /// 接团信息列表 Page
  597. /// </summary>
  598. /// <param name="dto">团组列表请求dto</param>
  599. /// <returns></returns>
  600. [HttpPost]
  601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  602. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  603. {
  604. #region 参数验证
  605. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  606. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  607. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  608. #region 页面操作权限验证
  609. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  610. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  611. #endregion
  612. #endregion
  613. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  614. {
  615. string sqlWhere = string.Empty;
  616. if (dto.IsSure == 0) //未完成
  617. {
  618. sqlWhere += string.Format(@" And IsSure = 0");
  619. }
  620. else if (dto.IsSure == 1) //已完成
  621. {
  622. sqlWhere += string.Format(@" And IsSure = 1");
  623. }
  624. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  625. {
  626. string tj = dto.SearchCriteria;
  627. 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}%')",
  628. tj, tj, tj, tj, tj);
  629. }
  630. if (int.TryParse(dto.Rank, out int rankId))
  631. {
  632. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  633. }
  634. string sqlWhere1 = string.Empty;
  635. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  636. {
  637. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  638. }
  639. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  640. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  641. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  642. JietuanOperator,IsSure,CreateTime,IsBid
  643. From (
  644. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  645. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  646. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  647. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  648. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  649. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  650. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  651. From Grp_DelegationInfo gdi
  652. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  653. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  654. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  655. Where gdi.IsDel = 0 {0}
  656. ) temp {1}", sqlWhere, sqlWhere1);
  657. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  658. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  659. var _view = new
  660. {
  661. PageFuncAuth = pageFunAuthView,
  662. Data = _DelegationList
  663. };
  664. return Ok(JsonView(true, "查询成功!", _view, total));
  665. }
  666. else
  667. {
  668. return Ok(JsonView(false, "查询失败"));
  669. }
  670. }
  671. /// <summary>
  672. /// 团组列表
  673. /// </summary>
  674. /// <returns></returns>
  675. [HttpPost]
  676. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  677. {
  678. #region 参数验证
  679. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  680. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  681. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  682. #region 页面操作权限验证
  683. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  684. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  685. #endregion
  686. #endregion
  687. if (dto.PortType != 1 && dto.PortType != 2)
  688. {
  689. return Ok(JsonView(false, "查询失败!"));
  690. }
  691. string orderbyStr = "order by gdi.CreateTime Desc";
  692. string sqlWhere = string.Empty;
  693. if (dto.IsSure == 0) //未完成
  694. {
  695. sqlWhere += string.Format(@" And IsSure = 0");
  696. }
  697. else if (dto.IsSure == 1) //已完成
  698. {
  699. sqlWhere += string.Format(@" And IsSure = 1");
  700. }
  701. //团组类型
  702. if (dto.TeamDid > 0)
  703. {
  704. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  705. }
  706. //团组名称
  707. if (!string.IsNullOrEmpty(dto.TeamName))
  708. {
  709. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  710. }
  711. //客户名称
  712. if (!string.IsNullOrEmpty(dto.ClientName))
  713. {
  714. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  715. }
  716. //客户单位
  717. if (!string.IsNullOrEmpty(dto.ClientUnit))
  718. {
  719. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  720. }
  721. //出访时间
  722. if (!string.IsNullOrEmpty(dto.visitDataTime))
  723. {
  724. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  725. orderbyStr = "order by gdi.VisitDate";
  726. }
  727. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  728. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  729. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  730. JietuanOperator,IsSure,CreateTime
  731. From (
  732. Select row_number() over({0}) as Row_Number,
  733. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  734. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  735. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  736. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  737. From Grp_DelegationInfo gdi
  738. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  739. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  740. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  741. Where gdi.IsDel = 0 {1}
  742. ) temp ", orderbyStr, sqlWhere);
  743. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  744. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  745. #region 处理所属部门
  746. /*
  747. * 1.sq 和 gyy 等显示 市场部
  748. * 2.王鸽和主管及张总还有管理员号统一国交部
  749. * 2-1. 4 管理员 ,21 张海麟
  750. */
  751. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  752. List<int> userIds1 = new List<int>() { 4, 21 };
  753. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  754. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  755. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  756. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  757. .ToList();
  758. foreach (var item in _DelegationList)
  759. {
  760. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  761. }
  762. #endregion
  763. var _view = new
  764. {
  765. PageFuncAuth = pageFunAuthView,
  766. Data = _DelegationList
  767. };
  768. return Ok(JsonView(true, "查询成功!", _view, total));
  769. }
  770. /// <summary>
  771. /// 接团信息详情
  772. /// </summary>
  773. /// <param name="dto">团组info请求dto</param>
  774. /// <returns></returns>
  775. [HttpPost]
  776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  777. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  778. {
  779. var groupData = await _groupRepository.GetGroupInfo(dto);
  780. if (groupData.Code != 0)
  781. {
  782. return Ok(JsonView(false, groupData.Msg));
  783. }
  784. return Ok(JsonView(groupData.Data));
  785. }
  786. /// <summary>
  787. /// 接团信息 编辑添加
  788. /// 基础信息数据源
  789. /// </summary>
  790. /// <param name="dto"></param>
  791. /// <returns></returns>
  792. [HttpPost]
  793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  794. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  795. {
  796. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  797. if (groupData.Code != 0)
  798. {
  799. return Ok(JsonView(false, groupData.Msg));
  800. }
  801. return Ok(JsonView(groupData.Data));
  802. }
  803. /// <summary>
  804. /// 接团信息 操作(增改)
  805. /// </summary>
  806. /// <param name="dto"></param>
  807. /// <returns></returns>
  808. [HttpPost]
  809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  810. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  811. {
  812. // 创建 Stopwatch 实例
  813. Stopwatch stopwatch = Stopwatch.StartNew();
  814. decimal ffrPrice = 0.00M;
  815. DateTime? visitDt = null;
  816. if (dto.Status == 2)
  817. {
  818. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  819. if (groupInfo != null)
  820. {
  821. ffrPrice = groupInfo.PaymentMoney;
  822. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  823. }
  824. }
  825. var groupData = await _groupRepository.GroupOperation(dto);
  826. if (groupData.Code != 0)
  827. {
  828. return Ok(JsonView(false, groupData.Msg));
  829. }
  830. int diId = 0;
  831. try
  832. {
  833. //添加时 默认加入团组汇率
  834. if (dto.Status == 1) //添加
  835. {
  836. diId = groupData.Data;
  837. //添加默认币种
  838. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  839. //默认分配权限
  840. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  841. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  842. var _managerIds = new List<int>() { 22, 32, 21 };
  843. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  844. if (userIds.Count > 0)
  845. {
  846. userIds.Add(208);
  847. //创建团组管控
  848. GroupStepForDelegation.CreateWorkStep(diId);
  849. //发送消息
  850. string groupName = dto.TeamName;
  851. string createGroupUser = string.Empty;
  852. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  853. if (userInfo != null) createGroupUser = userInfo.CnName;
  854. string title = $"系统通知";
  855. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  856. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  857. }
  858. //默认创建倒推表
  859. await _invertedListRep._Create(dto.UserId, diId);
  860. }
  861. else if (dto.Status == 2)
  862. {
  863. diId = dto.Id;
  864. }
  865. #region 签证人员团组时间通知
  866. #region 计算出访起止时间
  867. var startTime = new DateTime();
  868. var endTime = new DateTime();
  869. if (DateTime.TryParse(dto.VisitDate, out startTime))
  870. {
  871. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  872. }
  873. #endregion
  874. #endregion
  875. #region 团组操作默认添加/修改收款账单
  876. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  877. {
  878. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  879. .Where(x => x.IsDel == 0 &&
  880. x.Diid == diId &&
  881. x.Remark.Equals("预付款")
  882. )
  883. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  884. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  885. .FirstAsync();
  886. ffrInfo = new Fin_ForeignReceivables()
  887. {
  888. Diid = diId,
  889. PriceName = dto.ClientUnit,
  890. Price = dto.PaymentMoney,
  891. Count = 1,
  892. Unit = $"元",
  893. ItemSumPrice = dto.PaymentMoney,
  894. Rate = 1.0000M,
  895. Currency = 836,
  896. AddingWay = 0,
  897. CreateUserId = dto.UserId,
  898. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  899. Remark = $"预付款"
  900. };
  901. if (ffrInfo == null) //Add
  902. {
  903. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  904. }
  905. else //修改
  906. {
  907. await _sqlSugar.Updateable(ffrInfo)
  908. .UpdateColumns(x => new
  909. {
  910. x.PriceName,
  911. x.Price,
  912. x.ItemSumPrice,
  913. x.CreateTime,
  914. x.CreateUserId
  915. })
  916. .WhereColumns(x => x.Id)
  917. .ExecuteCommandAsync();
  918. }
  919. }
  920. #endregion
  921. if (diId > 0)
  922. {
  923. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  924. }
  925. // 停止计时
  926. stopwatch.Stop();
  927. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  928. }
  929. catch (Exception ex)
  930. {
  931. // 停止计时
  932. stopwatch.Stop();
  933. Logs("[response]" + JsonConvert.SerializeObject(dto));
  934. Logs(ex.Message);
  935. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  936. }
  937. // 停止计时
  938. stopwatch.Stop();
  939. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  940. }
  941. /// <summary>
  942. /// 接团流程操作(增改)
  943. /// 安卓端使用 建团时添加客户名单
  944. /// </summary>
  945. /// <param name="dto"></param>
  946. /// <returns></returns>
  947. [HttpPost]
  948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  949. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  950. {
  951. #region 参数验证
  952. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  953. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  954. #region 页面操作权限验证
  955. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  956. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  957. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  958. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  959. #endregion
  960. #endregion
  961. try
  962. {
  963. //_sqlSugar.BeginTran();
  964. decimal ffrPrice = 0.00M;
  965. DateTime? visitDt = null;
  966. if (dto.Status == 2)
  967. {
  968. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  969. if (groupInfo != null)
  970. {
  971. ffrPrice = groupInfo.PaymentMoney;
  972. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  973. }
  974. }
  975. var _dto = new GroupOperationDto();
  976. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  977. var groupData = await _groupRepository.GroupOperation(_dto);
  978. if (groupData.Code != 0)
  979. {
  980. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  981. }
  982. int diId = 0;
  983. //添加时 默认加入团组汇率
  984. if (dto.Status == 1) //添加
  985. {
  986. diId = groupData.Data;
  987. //添加默认币种
  988. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  989. //默认分配权限
  990. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  991. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  992. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  993. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  994. if (userIds.Count > 0)
  995. {
  996. userIds.Add(208);
  997. //创建团组管控
  998. GroupStepForDelegation.CreateWorkStep(diId);
  999. //发送消息
  1000. string groupName = dto.TeamName;
  1001. string createGroupUser = string.Empty;
  1002. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1003. if (userInfo != null) createGroupUser = userInfo.CnName;
  1004. string title = $"系统通知";
  1005. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1006. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1007. }
  1008. #region 应用推送
  1009. try
  1010. {
  1011. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1012. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1013. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1014. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1015. {
  1016. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1017. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1018. }
  1019. }
  1020. catch (Exception ex)
  1021. {
  1022. }
  1023. #endregion
  1024. //默认创建倒推表
  1025. await _invertedListRep._Create(dto.UserId, diId);
  1026. }
  1027. if (dto.Status == 2)
  1028. {
  1029. diId = dto.Id;
  1030. if (diId == 0)
  1031. {
  1032. //_sqlSugar.RollbackTran();
  1033. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1034. }
  1035. }
  1036. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1037. if (viewData.Code != 0)
  1038. {
  1039. //_sqlSugar.RollbackTran();
  1040. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1041. }
  1042. #region 团组操作默认添加/修改收款账单
  1043. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1044. {
  1045. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1046. .Where(x => x.IsDel == 0 &&
  1047. x.Diid == diId &&
  1048. x.Remark.Equals("预付款")
  1049. )
  1050. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1051. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1052. .FirstAsync();
  1053. ffrInfo = new Fin_ForeignReceivables()
  1054. {
  1055. Diid = diId,
  1056. PriceName = dto.ClientUnit,
  1057. Price = dto.PaymentMoney,
  1058. Count = 1,
  1059. Unit = $"元",
  1060. ItemSumPrice = dto.PaymentMoney,
  1061. Rate = 1.0000M,
  1062. Currency = 836,
  1063. AddingWay = 0,
  1064. CreateUserId = dto.UserId,
  1065. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1066. Remark = $"预付款"
  1067. };
  1068. if (ffrInfo == null) //Add
  1069. {
  1070. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1071. }
  1072. else //修改
  1073. {
  1074. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1075. .UpdateColumns(x => new
  1076. {
  1077. x.PriceName,
  1078. x.Price,
  1079. x.ItemSumPrice,
  1080. x.CreateTime,
  1081. x.CreateUserId
  1082. })
  1083. .WhereColumns(x => x.Id)
  1084. .ExecuteCommandAsync();
  1085. }
  1086. }
  1087. #endregion
  1088. #region 签证人员团组时间通知
  1089. #region 计算出访起止时间
  1090. var startTime = new DateTime();
  1091. var endTime = new DateTime();
  1092. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1093. {
  1094. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1095. }
  1096. #endregion
  1097. if (diId > 0)
  1098. {
  1099. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1100. }
  1101. #endregion
  1102. //_sqlSugar.CommitTran();
  1103. return Ok(JsonView(true, "添加成功"));
  1104. }
  1105. catch (Exception ex)
  1106. {
  1107. _sqlSugar.RollbackTran();
  1108. return Ok(JsonView(false, ex.Message));
  1109. }
  1110. }
  1111. /// <summary>
  1112. /// 接团流程操作(增改)
  1113. /// 安卓端使用 建团时添加客户名单
  1114. /// </summary>
  1115. /// <param name="dto"></param>
  1116. /// <returns></returns>
  1117. [HttpPost]
  1118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1119. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1120. {
  1121. #region 参数验证
  1122. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1123. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1124. #region 页面操作权限验证
  1125. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1126. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1127. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1128. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1129. #endregion
  1130. #endregion
  1131. _sqlSugar.BeginTran();
  1132. decimal ffrPrice = 0.00M;
  1133. DateTime? visitDt = null;
  1134. if (dto.Status == 2)
  1135. {
  1136. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1137. if (groupInfo != null)
  1138. {
  1139. ffrPrice = groupInfo.PaymentMoney;
  1140. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1141. }
  1142. }
  1143. var _dto = new GroupOperationDto();
  1144. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1145. var groupData = await _groupRepository.GroupOperation(_dto);
  1146. if (groupData.Code != 0)
  1147. {
  1148. _sqlSugar.RollbackTran();
  1149. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1150. }
  1151. try
  1152. {
  1153. int diId = 0;
  1154. //添加时 默认加入团组汇率
  1155. if (dto.Status == 1) //添加
  1156. {
  1157. diId = groupData.Data;
  1158. //添加默认币种
  1159. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1160. //默认分配权限
  1161. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1162. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1163. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1164. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1165. if (userIds.Count > 0)
  1166. {
  1167. userIds.Add(208);
  1168. //创建团组管控
  1169. GroupStepForDelegation.CreateWorkStep(diId);
  1170. //发送消息
  1171. string groupName = dto.TeamName;
  1172. string createGroupUser = string.Empty;
  1173. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1174. if (userInfo != null) createGroupUser = userInfo.CnName;
  1175. string title = $"系统通知";
  1176. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1177. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1178. }
  1179. #region 应用推送
  1180. try
  1181. {
  1182. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1183. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1184. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1185. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1186. {
  1187. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1188. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1189. }
  1190. }
  1191. catch (Exception ex)
  1192. {
  1193. _sqlSugar.CommitTran();
  1194. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1195. }
  1196. #endregion
  1197. //默认创建倒推表
  1198. await _invertedListRep._Create(dto.UserId, diId);
  1199. }
  1200. else if (dto.Status == 2)
  1201. {
  1202. diId = dto.Id;
  1203. if (diId == 0)
  1204. {
  1205. _sqlSugar.RollbackTran();
  1206. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1207. }
  1208. }
  1209. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1210. if (viewData.Code != 0)
  1211. {
  1212. _sqlSugar.RollbackTran();
  1213. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1214. }
  1215. #region 团组操作默认添加/修改收款账单
  1216. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1217. {
  1218. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1219. .Where(x => x.IsDel == 0 &&
  1220. x.Diid == diId &&
  1221. x.Remark.Equals("预付款")
  1222. )
  1223. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1224. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1225. .FirstAsync();
  1226. ffrInfo = new Fin_ForeignReceivables()
  1227. {
  1228. Diid = diId,
  1229. PriceName = dto.ClientUnit,
  1230. Price = dto.PaymentMoney,
  1231. Count = 1,
  1232. Unit = $"元",
  1233. ItemSumPrice = dto.PaymentMoney,
  1234. Rate = 1.0000M,
  1235. Currency = 836,
  1236. AddingWay = 0,
  1237. CreateUserId = dto.UserId,
  1238. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1239. Remark = $"预付款"
  1240. };
  1241. if (ffrInfo == null) //Add
  1242. {
  1243. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1244. }
  1245. else //修改
  1246. {
  1247. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1248. .UpdateColumns(x => new
  1249. {
  1250. x.PriceName,
  1251. x.Price,
  1252. x.ItemSumPrice,
  1253. x.CreateTime,
  1254. x.CreateUserId
  1255. })
  1256. .WhereColumns(x => x.Id)
  1257. .ExecuteCommandAsync();
  1258. }
  1259. }
  1260. #endregion
  1261. #region 签证人员团组时间通知
  1262. #region 计算出访起止时间
  1263. var startTime = new DateTime();
  1264. var endTime = new DateTime();
  1265. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1266. {
  1267. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1268. }
  1269. #endregion
  1270. if (diId > 0)
  1271. {
  1272. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1273. }
  1274. #endregion
  1275. _sqlSugar.CommitTran();
  1276. return Ok(JsonView(true));
  1277. }
  1278. catch (Exception ex)
  1279. {
  1280. _sqlSugar.RollbackTran();
  1281. return Ok(JsonView(false, ex.Message));
  1282. }
  1283. }
  1284. /// <summary>
  1285. /// 接团信息 操作(删除)
  1286. /// </summary>
  1287. /// <param name="dto"></param>
  1288. /// <returns></returns>
  1289. [HttpPost]
  1290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1291. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1292. {
  1293. var diId = dto.Id;
  1294. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1295. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1296. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1297. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1298. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1299. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1300. #endregion
  1301. var groupData = await _groupRepository.GroupDel(dto);
  1302. if (groupData.Code != 0)
  1303. {
  1304. return Ok(JsonView(false, groupData.Msg));
  1305. }
  1306. return Ok(JsonView(true));
  1307. }
  1308. /// <summary>
  1309. /// 获取团组销售报价号
  1310. /// 团组添加时 使用
  1311. /// </summary>
  1312. /// <returns></returns>
  1313. [HttpPost]
  1314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1315. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1316. {
  1317. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1318. if (groupData.Code != 0)
  1319. {
  1320. return Ok(JsonView(false, groupData.Msg));
  1321. }
  1322. object salesQuoteNo = new
  1323. {
  1324. SalesQuoteNo = groupData.Data
  1325. };
  1326. return Ok(JsonView(salesQuoteNo));
  1327. }
  1328. /// <summary>
  1329. /// 设置确认出团
  1330. /// </summary>
  1331. /// <param name="dto"></param>
  1332. /// <returns></returns>
  1333. [HttpPost]
  1334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1335. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1336. {
  1337. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1338. if (groupData.Code != 0)
  1339. {
  1340. return Ok(JsonView(false, groupData.Msg));
  1341. }
  1342. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1343. #region OA消息推送
  1344. try
  1345. {
  1346. string groupName = groupInfo.TeamName;
  1347. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1348. string title = $"系统通知";
  1349. string content = $"团组[{groupName}]已确认出团!";
  1350. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1351. }
  1352. catch (Exception ex)
  1353. {
  1354. }
  1355. #endregion
  1356. #region 应用推送
  1357. try
  1358. {
  1359. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1360. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1361. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1362. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1363. {
  1364. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1365. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1366. }
  1367. }
  1368. catch (Exception ex)
  1369. {
  1370. }
  1371. #endregion
  1372. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1373. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1374. }
  1375. /// <summary>
  1376. /// 获取团组名称data And 签证国别Data
  1377. /// </summary>
  1378. /// <param name="dto"></param>
  1379. /// <returns></returns>
  1380. [HttpPost]
  1381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1382. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1383. {
  1384. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1385. if (groupData.Code != 0)
  1386. {
  1387. return Ok(JsonView(false, groupData.Msg));
  1388. }
  1389. return Ok(JsonView(groupData.Data));
  1390. }
  1391. /// <summary>
  1392. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1393. /// </summary>
  1394. /// <returns></returns>
  1395. [HttpPost]
  1396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1397. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1398. {
  1399. try
  1400. {
  1401. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1402. if (groupData.Code != 0)
  1403. {
  1404. return Ok(JsonView(false, groupData.Msg));
  1405. }
  1406. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1407. }
  1408. catch (Exception ex)
  1409. {
  1410. return Ok(JsonView(false, "程序错误!"));
  1411. throw;
  1412. }
  1413. }
  1414. /// <summary>
  1415. /// 团组清单 Excel
  1416. /// </summary>
  1417. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1418. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1419. /// <returns></returns>
  1420. [HttpGet]
  1421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1422. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1423. {
  1424. DateTime _beginDt, _endDt;
  1425. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1426. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1427. if (!beginBool && !endBool)
  1428. {
  1429. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1430. }
  1431. string sql = string.Format(@"
  1432. SELECT
  1433. ROW_NUMBER,
  1434. Id,
  1435. SalesQuoteNo,
  1436. TourCode,
  1437. TeamTypeId,
  1438. TeamType,
  1439. TeamLevId,
  1440. TeamLev,
  1441. TeamName,
  1442. ClientName,
  1443. ClientUnit,
  1444. VisitDate,
  1445. VisitDays,
  1446. VisitPNumber,
  1447. JietuanOperatorId,
  1448. JietuanOperator,
  1449. IsSure,
  1450. CreateUserName,
  1451. IsBid
  1452. FROM
  1453. (
  1454. SELECT
  1455. ROW_NUMBER() OVER(
  1456. ORDER BY
  1457. gdi.CreateTime Desc
  1458. ) AS ROW_NUMBER,
  1459. gdi.Id,
  1460. SalesQuoteNo,
  1461. TourCode,
  1462. ssd.Id TeamTypeId,
  1463. ssd.Name TeamType,
  1464. ssd1.Id TeamLevId,
  1465. ssd1.Name TeamLev,
  1466. TeamName,
  1467. ClientName,
  1468. ClientUnit,
  1469. VisitDate,
  1470. VisitDays,
  1471. VisitPNumber,
  1472. JietuanOperator JietuanOperatorId,
  1473. su.CnName JietuanOperator,
  1474. IsSure,
  1475. gdi.CreateTime,
  1476. su1.CnName As CreateUserName,
  1477. gdi.IsBid
  1478. FROM
  1479. Grp_DelegationInfo gdi
  1480. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1481. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1482. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1483. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1484. WHERE
  1485. gdi.IsDel = 0
  1486. AND gdi.IsBid = 0
  1487. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1488. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1489. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1490. #region 处理所属部门
  1491. /*
  1492. * 1.sq 和 gyy 等显示 市场部
  1493. * 2.王鸽和主管及张总还有管理员号统一国交部
  1494. * 2-1. 4 管理员 ,21 张海麟
  1495. */
  1496. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1497. List<int> userIds1 = new List<int>() { 4, 21 };
  1498. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1499. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1500. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1501. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1502. .ToListAsync();
  1503. var droupIds = groupList.Select(it => it.Id).ToList();
  1504. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1505. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1506. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1507. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1508. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1509. {
  1510. DiId = tcl.DiId,
  1511. LastName = dc.LastName,
  1512. FirstName = dc.FirstName,
  1513. Sex = dc.Sex,
  1514. Birthday = dc.BirthDay,
  1515. Company = cc.CompanyFullName,
  1516. Job = dc.Job,
  1517. CreateTime = tcl.CreateTime,
  1518. })
  1519. .ToList();
  1520. foreach (var item in groupList)
  1521. {
  1522. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1523. string groupFirstName = "";
  1524. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1525. if (currDatas.Any())
  1526. {
  1527. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1528. }
  1529. item.GroupFirst = groupFirstName;
  1530. }
  1531. #endregion
  1532. #region Excel
  1533. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1534. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1535. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1536. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1537. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1538. //载入模板
  1539. WorkbookDesigner designer = new WorkbookDesigner();
  1540. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1541. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1542. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1543. dt.TableName = "GroupList";
  1544. designer.SetDataSource(dt);
  1545. designer.Process();
  1546. if (!Directory.Exists(savePath))
  1547. {
  1548. Directory.CreateDirectory(savePath);
  1549. }
  1550. string serverPath = $"{savePath}{fileName}";
  1551. designer.Workbook.Save(serverPath);
  1552. string rst = $"{servicePath}{ftpPath}{fileName}";
  1553. #endregion
  1554. return Ok(JsonView(true, "操作成功!", rst));
  1555. }
  1556. #endregion
  1557. #region 团组&签证
  1558. /// <summary>
  1559. /// 根据团组Id获取签证客户信息List
  1560. /// </summary>
  1561. /// <param name="dto">请求dto</param>
  1562. /// <returns></returns>
  1563. [HttpPost]
  1564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1565. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1566. {
  1567. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1568. if (groupData.Code != 0)
  1569. {
  1570. return Ok(JsonView(false, groupData.Msg));
  1571. }
  1572. return Ok(JsonView(groupData.Data));
  1573. }
  1574. /// <summary>
  1575. /// IOS获取团组签证拍照上传进度01(团组列表)
  1576. /// </summary>
  1577. /// <param name="dto">请求dto</param>
  1578. /// <returns></returns>
  1579. [HttpPost]
  1580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1581. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1582. {
  1583. if (dto == null)
  1584. {
  1585. return Ok(JsonView(false, "参数为空"));
  1586. }
  1587. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1588. return Ok(JsonView(visaList));
  1589. }
  1590. /// <summary>
  1591. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1592. /// </summary>
  1593. /// <returns></returns>
  1594. [HttpPost]
  1595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1596. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1597. {
  1598. if (dto == null)
  1599. {
  1600. return Ok(JsonView(false, "请求错误:"));
  1601. }
  1602. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1603. return Ok(JsonView(list));
  1604. }
  1605. /// <summary>
  1606. /// IOS获取团组签证拍照上传进度03(相册)
  1607. /// </summary>
  1608. /// <returns></returns>
  1609. [HttpPost]
  1610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1611. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1612. {
  1613. if (dto == null)
  1614. {
  1615. return Ok(JsonView(false, "请求错误:"));
  1616. }
  1617. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1618. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1619. list.ForEach(s => s.url = url);
  1620. return Ok(JsonView(list));
  1621. }
  1622. /// <summary>
  1623. /// IOS获取团组签证拍照上传进度04(图片上传)
  1624. /// </summary>
  1625. /// <param name="dto"></param>
  1626. /// <returns></returns>
  1627. [HttpPost]
  1628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1629. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1630. {
  1631. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1632. //if (!string.IsNullOrEmpty(result))
  1633. //{
  1634. //}
  1635. //else {
  1636. // return Ok(JsonView(false, "上传失败"));
  1637. //}
  1638. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1639. int sucNum = 0;
  1640. try
  1641. {
  1642. foreach (var item in dto.base64DataList)
  1643. {
  1644. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1645. string result = DecodeBase64ToImage(item, imageName);
  1646. if (!string.IsNullOrEmpty(result))
  1647. {
  1648. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1649. pic.CreateUserId = dto.CreateUserId;
  1650. pic.PicName = imageName;
  1651. pic.PicPath = result;
  1652. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1653. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1654. if (insertResult > 0)
  1655. {
  1656. sucNum++;
  1657. }
  1658. }
  1659. }
  1660. }
  1661. catch (Exception ex)
  1662. {
  1663. return Ok(JsonView(false, ex.Message));
  1664. }
  1665. string msg = string.Format(@"成功上传{0}张", sucNum);
  1666. return Ok(JsonView(true, msg));
  1667. }
  1668. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1669. {
  1670. string filename = "";//声明一个string类型的相对路径
  1671. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1672. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1673. try//会有异常抛出,try,catch一下
  1674. {
  1675. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1676. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1677. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1678. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1679. //文件名称
  1680. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1681. //上传的文件的路径
  1682. string filePath = "";
  1683. if (!Directory.Exists(fileDir))
  1684. {
  1685. Directory.CreateDirectory(fileDir);
  1686. }
  1687. //上传的文件的路径
  1688. filePath = fileDir + filename;
  1689. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1690. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1691. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1692. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1693. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1694. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1695. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1696. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1697. bitmap.Dispose();
  1698. }
  1699. catch (Exception e)
  1700. {
  1701. string massage = e.Message;
  1702. Logs("IOS图片上传Error:" + massage);
  1703. //filename = e.Message;
  1704. }
  1705. return filename;//返回相对路径
  1706. }
  1707. /// <summary>
  1708. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1709. /// </summary>
  1710. /// <param name="dto"></param>
  1711. /// <returns></returns>
  1712. [HttpPost]
  1713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1714. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1715. {
  1716. if (dto == null)
  1717. {
  1718. return Ok(JsonView(false, "请求错误:"));
  1719. }
  1720. string msg = "参数错误";
  1721. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1722. {
  1723. try
  1724. {
  1725. //_delegationVisaRep.BeginTran();
  1726. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1727. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1728. .Where(s => s.Id == dto.visaProgressCustomerId)
  1729. .ExecuteCommandAsync();
  1730. if (updCount > 0 && dto.publishCode == 1)
  1731. {
  1732. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1733. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1734. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1735. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1736. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1737. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1738. if (groupData == null)
  1739. {
  1740. _delegationVisaRep.RollbackTran();
  1741. }
  1742. string title = string.Format(@"[签证进度更新]");
  1743. string content = string.Format(@"测试文本");
  1744. bool rst = await _message.AddMsg(new MessageDto()
  1745. {
  1746. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1747. IssuerId = dto.publisher,
  1748. Title = title,
  1749. Content = content,
  1750. ReleaseTime = DateTime.Now,
  1751. UIdList = new List<int> {
  1752. 234
  1753. }
  1754. });
  1755. if (rst)
  1756. {
  1757. return Ok(JsonView(true, "发送通知成功"));
  1758. }
  1759. }
  1760. //_delegationVisaRep.CommitTran();
  1761. }
  1762. catch (Exception)
  1763. {
  1764. //_delegationVisaRep.RollbackTran();
  1765. }
  1766. }
  1767. return Ok(JsonView(true, msg));
  1768. }
  1769. #endregion
  1770. #region 团组任务分配
  1771. /// <summary>
  1772. /// 团组任务分配初始化
  1773. /// </summary>
  1774. /// <returns></returns>
  1775. [HttpPost]
  1776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1777. public async Task<IActionResult> GetTaskAssignmen()
  1778. {
  1779. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1780. if (groupData.Code != 0)
  1781. {
  1782. return Ok(JsonView(false, groupData.Msg));
  1783. }
  1784. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1785. }
  1786. /// <summary>
  1787. /// 团组任务分配查询
  1788. /// </summary>
  1789. /// <param name="dto"></param>
  1790. /// <returns></returns>
  1791. [HttpPost]
  1792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1793. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1794. {
  1795. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1796. if (groupData.Code != 0)
  1797. {
  1798. return Ok(JsonView(false, groupData.Msg));
  1799. }
  1800. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1801. }
  1802. /// <summary>
  1803. /// 团组任务分配操作
  1804. /// </summary>
  1805. /// <param name="dto"></param>
  1806. /// <returns></returns>
  1807. [HttpPost]
  1808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1809. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1810. {
  1811. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1812. if (groupData.Code != 0)
  1813. {
  1814. return Ok(JsonView(false, groupData.Msg));
  1815. }
  1816. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1817. }
  1818. /// <summary>
  1819. /// 团组任务分配
  1820. /// 批量分配
  1821. /// 查询团组
  1822. /// </summary>
  1823. /// <param name="dto"></param>
  1824. /// <returns></returns>
  1825. [HttpPost]
  1826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1827. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1828. {
  1829. //参数验证
  1830. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1831. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1832. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1833. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1834. }
  1835. /// <summary>
  1836. /// 团组任务分配
  1837. /// 批量分配
  1838. /// </summary>
  1839. /// <param name="dto"></param>
  1840. /// <returns></returns>
  1841. [HttpPost]
  1842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1843. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1844. {
  1845. //参数验证
  1846. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1847. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1848. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1849. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1850. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1851. }
  1852. #endregion
  1853. #region 团组费用审核
  1854. /// <summary>
  1855. /// 费用审核
  1856. /// 团组列表 Page
  1857. /// </summary>
  1858. /// <param name="_dto">团组列表请求dto</param>
  1859. /// <returns></returns>
  1860. [HttpPost]
  1861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1862. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1863. {
  1864. #region 参数验证
  1865. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1866. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1867. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1868. #region 页面操作权限验证
  1869. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1870. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1871. #endregion
  1872. #endregion
  1873. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1874. {
  1875. string sqlWhere = string.Empty;
  1876. if (_dto.IsSure == 0) //未完成
  1877. {
  1878. sqlWhere += string.Format(@" And IsSure = 0");
  1879. }
  1880. else if (_dto.IsSure == 1) //已完成
  1881. {
  1882. sqlWhere += string.Format(@" And IsSure = 1");
  1883. }
  1884. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1885. {
  1886. string tj = _dto.SearchCriteria;
  1887. 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}%')",
  1888. tj, tj, tj, tj, tj);
  1889. }
  1890. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1891. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1892. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1893. From (
  1894. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1895. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1896. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1897. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1898. From Grp_DelegationInfo gdi
  1899. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1900. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1901. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1902. Where gdi.IsDel = 0 {0}
  1903. ) temp ", sqlWhere);
  1904. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1905. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1906. var _view = new
  1907. {
  1908. PageFuncAuth = pageFunAuthView,
  1909. Data = _DelegationList
  1910. };
  1911. return Ok(JsonView(true, "查询成功!", _view, total));
  1912. }
  1913. else
  1914. {
  1915. return Ok(JsonView(false, "查询失败"));
  1916. }
  1917. }
  1918. /// <summary>
  1919. /// 获取团组费用审核
  1920. /// </summary>
  1921. /// <param name="_dto"></param>
  1922. /// <returns></returns>
  1923. [HttpPost]
  1924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1925. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1926. {
  1927. try
  1928. {
  1929. #region 参数验证
  1930. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1931. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1932. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1933. #region 页面操作权限验证
  1934. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1935. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1936. #endregion
  1937. #endregion
  1938. var _view = new Grp_CreditCardPaymentView();
  1939. var clientNameList = getSimplClientList(_dto.DiId);
  1940. #region 费用清单
  1941. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1942. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1943. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1944. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1945. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1946. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1947. /*
  1948. * 76://酒店预订
  1949. */
  1950. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1951. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1952. /*
  1953. * 79://车/导游地接
  1954. */
  1955. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1956. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1957. /*
  1958. * 80: //签证
  1959. */
  1960. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1961. /*
  1962. *81: //邀请/公务活动
  1963. */
  1964. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1965. /*
  1966. * 82: //团组客户保险
  1967. */
  1968. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1969. /*
  1970. * Lable = 85 机票预订
  1971. */
  1972. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1973. /*
  1974. * 85 机票预定
  1975. */
  1976. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1977. /*
  1978. * 98 其他款项
  1979. */
  1980. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1981. /*
  1982. * 285:收款退还
  1983. */
  1984. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1985. /*
  1986. * 1015: //超支费用
  1987. */
  1988. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1989. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1990. /*
  1991. * 币种信息
  1992. */
  1993. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1994. /*
  1995. * 车/导游地接 费用类型
  1996. */
  1997. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1998. /*
  1999. * 车/导游地接 费用类型
  2000. */
  2001. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2002. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2003. /*
  2004. * 用户信息
  2005. */
  2006. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2007. /*
  2008. * 费用模块
  2009. */
  2010. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2011. string priceModule = string.Empty;
  2012. if (sdPriceName != null)
  2013. {
  2014. priceModule = sdPriceName.Name;
  2015. }
  2016. /*
  2017. * 成本信息
  2018. */
  2019. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2020. decimal _groupRate = 0.0000M;
  2021. string _groupCurrencyCode = "-";
  2022. if (groupCost != null)
  2023. {
  2024. _groupRate = groupCost.Rate;
  2025. if (int.TryParse(groupCost.Currency, out int _currency))
  2026. {
  2027. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2028. }
  2029. else _groupCurrencyCode = groupCost.Currency;
  2030. }
  2031. string costContentSql = $"Select * From Grp_GroupCost";
  2032. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2033. //处理日期为空的天数
  2034. for (int i = 0; i < groupCostDetails.Count; i++)
  2035. if (i != 0)
  2036. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2037. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2038. /*
  2039. * 处理详情数据
  2040. */
  2041. foreach (var entity in entityList)
  2042. {
  2043. var _detail = new Grp_CreditCardPaymentDetailView();
  2044. _detail.Id = entity.Id;
  2045. _detail.PriceName = priceModule;
  2046. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2047. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2048. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2049. //处理金额
  2050. if (entity.CTable == 1015)
  2051. {
  2052. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2053. if (czInfo != null)
  2054. {
  2055. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2056. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2057. }
  2058. }
  2059. /*
  2060. * 应付款金额
  2061. */
  2062. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2063. string PaymentCurrency_WaitPay = "Unknown";
  2064. string hotelCurrncyCode = "Unknown";
  2065. string hotelCurrncyName = "Unknown";
  2066. if (sdPaymentCurrency_WaitPay != null)
  2067. {
  2068. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2069. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2070. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2071. if (hotelCurrncyCode.Equals("CNY"))
  2072. {
  2073. entity.DayRate = 1.0000M;
  2074. }
  2075. }
  2076. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2077. /*
  2078. * 此次付款金额
  2079. */
  2080. decimal CurrPayStr = 0.00M,
  2081. OriginalCurrPay = 0.00M;
  2082. if (entity.PayPercentage == 0)
  2083. {
  2084. if (entity.PayThenMoney != 0)
  2085. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2086. }
  2087. else
  2088. {
  2089. if (entity.PayMoney != 0)
  2090. {
  2091. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2092. }
  2093. }
  2094. //if (_dto.Label == 79)
  2095. //{
  2096. // string original = string.Empty;
  2097. // if (hotelCurrncyCode.Equals("CNY"))
  2098. // {
  2099. // OriginalCurrPay = CurrPayStr;
  2100. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2101. // }
  2102. // else
  2103. // {
  2104. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2105. // //760 EUR(7600.00 CNY)
  2106. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2107. // }
  2108. //}
  2109. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2110. string original = string.Empty;
  2111. if (hotelCurrncyCode.Equals("CNY"))
  2112. {
  2113. OriginalCurrPay = CurrPayStr;
  2114. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2115. }
  2116. else
  2117. {
  2118. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2119. //760 EUR(7600.00 CNY)
  2120. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2121. }
  2122. /*
  2123. * 剩余尾款
  2124. */
  2125. decimal BalanceStr = 0;
  2126. if (CurrPayStr != 0)
  2127. {
  2128. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2129. BalanceStr = 0;
  2130. else
  2131. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2132. }
  2133. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2134. /*
  2135. * Bus名称
  2136. */
  2137. _detail.BusName = "待增加";
  2138. /*
  2139. *费用所属
  2140. */
  2141. switch (entity.CTable)
  2142. {
  2143. case 76://酒店预订
  2144. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2145. if (hotelReservations != null)
  2146. {
  2147. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2148. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2149. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2150. string roomFeeStr = "", roomFeestr1 = "";
  2151. //是否比较房型价格
  2152. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2153. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2154. roomFeeStr += $"<br/>";
  2155. var roomTotal = 0.00M;
  2156. if (hotelReservations.SingleRoomPrice > 0)
  2157. {
  2158. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2159. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2160. //__isSingle = true;
  2161. roomTotal += fee;
  2162. }
  2163. if (hotelReservations.DoubleRoomPrice > 0)
  2164. {
  2165. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2166. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2167. // __isDouble = true;
  2168. roomTotal += fee;
  2169. }
  2170. if (hotelReservations.SuiteRoomPrice > 0)
  2171. {
  2172. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2173. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2174. //__isSuite = true;
  2175. roomTotal += fee;
  2176. }
  2177. if (hotelReservations.OtherRoomPrice > 0)
  2178. {
  2179. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2180. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2181. //__isOther = true;
  2182. roomTotal += fee;
  2183. }
  2184. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2185. else roomFeeStr += " 0.00 * 0";
  2186. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2187. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2188. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2189. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2190. /*
  2191. * 费用类型
  2192. * 1:房费
  2193. * 2:早餐
  2194. * 3:地税
  2195. * 4:城市税
  2196. * </summary>
  2197. */
  2198. //地税
  2199. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2200. if (governmentRentData != null)
  2201. {
  2202. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2203. governmentRentFee = governmentRentData.Price;
  2204. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2205. if (governmentRentCurrData != null)
  2206. {
  2207. governmentRentCode = governmentRentCurrData.Name;
  2208. governmentRentName = $"({governmentRentCurrData.Remark})";
  2209. }
  2210. }
  2211. //城市税
  2212. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2213. if (cityTaxData != null)
  2214. {
  2215. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2216. cityTaxFee = cityTaxData.Price;
  2217. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2218. if (cityTaxCurrData != null)
  2219. {
  2220. cityTaxCode = cityTaxCurrData.Name;
  2221. cityTaxName = $"({cityTaxCurrData.Remark})";
  2222. }
  2223. }
  2224. //酒店早餐
  2225. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2226. if (breakfastData != null)
  2227. {
  2228. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2229. breakfastFee = breakfastData.Price;
  2230. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2231. if (breakfastCurrData != null)
  2232. {
  2233. breakfastCode = breakfastCurrData.Name;
  2234. breakfastName = $"({breakfastCurrData.Remark})";
  2235. }
  2236. }
  2237. //房间费用
  2238. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2239. if (roomData != null)
  2240. {
  2241. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2242. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2243. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2244. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2245. roomFee = roomData.Price;
  2246. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2247. if (roomCurrData != null)
  2248. {
  2249. roomCode = roomCurrData.Name;
  2250. roomName = $"({roomCurrData.Remark})";
  2251. }
  2252. }
  2253. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2254. string hotelCostStr = "";
  2255. decimal hotelCsotTotal = 0.00M;
  2256. if (groupCost != null)
  2257. {
  2258. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2259. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2260. }
  2261. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2262. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2263. string hotelCost_day = "";
  2264. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2265. foreach (var item in hotelCostDetails1)
  2266. {
  2267. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2268. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2269. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2270. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2271. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2272. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2273. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2274. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2275. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2276. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2277. hotelCost_day += @$"<br/>";
  2278. }
  2279. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2280. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2281. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2282. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2283. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2284. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2285. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2286. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2287. $"房间说明: {hotelReservations.Remark} <br/>" +
  2288. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2289. $"{hotelBreakfastStr}" +
  2290. $"{hotelGovernmentRentStr}" +
  2291. $"{hotelCityTaxStr}";
  2292. _detail.PriceNameContent = hotelReservations.HotelName;
  2293. }
  2294. break;
  2295. case 79://车/导游地接
  2296. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2297. if (touristGuideGroundReservations != null)
  2298. {
  2299. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2300. {
  2301. _detail.BusName = touristGuideGroundReservations.BusName;
  2302. }
  2303. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2304. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2305. //if (isInt)
  2306. //{
  2307. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2308. // if (cityInfo != null)
  2309. // {
  2310. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2311. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2312. // if (carFeeItem != null)
  2313. // {
  2314. // nameContent += $@"({carFeeItem.Name})";
  2315. // }
  2316. // _detail.PriceNameContent = nameContent;
  2317. // }
  2318. //}
  2319. //else
  2320. //{
  2321. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2322. //}
  2323. var touristGuideGroundReservationsContents =
  2324. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2325. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2326. foreach (var item in touristGuideGroundReservationsContents)
  2327. {
  2328. string typeName = "Unknown";
  2329. string carCurrencyCode = "Unknown";
  2330. string carCurrencyName = "Unknown";
  2331. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2332. if (carTypeData != null) typeName = carTypeData.Name;
  2333. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2334. if (currencyData != null)
  2335. {
  2336. carCurrencyCode = currencyData.Name;
  2337. carCurrencyName = currencyData.Remark;
  2338. }
  2339. //op、成本 币种是否一致
  2340. bool IsCurrencyAgreement = false;
  2341. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2342. string opCostStr = string.Empty;
  2343. decimal opCostTypePrice = 0.00M;
  2344. #region 处理成本各项费用
  2345. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2346. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2347. if (opCost.Count > 0)
  2348. {
  2349. switch (item.SId)
  2350. {
  2351. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2352. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2353. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2354. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2355. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2356. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2357. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2358. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2359. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2360. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2361. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2362. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2363. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2364. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2365. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2366. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2367. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2368. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2369. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2370. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2371. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2372. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2373. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2374. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2375. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2376. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2377. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2378. }
  2379. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2380. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2381. }
  2382. #endregion
  2383. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2384. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2385. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2386. $"{opTypeStr} {opCostStr}<br/>" +
  2387. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2388. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2389. }
  2390. _detail.PriceMsgContent = priceMsg;
  2391. }
  2392. break;
  2393. case 80: //签证
  2394. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2395. if (visaInfo != null)
  2396. {
  2397. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2398. _detail.PriceNameContent = visaInfo.VisaDescription;
  2399. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2400. }
  2401. break;
  2402. case 81: //邀请/公务活动
  2403. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2404. if (_ioa != null)
  2405. {
  2406. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2407. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2408. sendCurrName = "Unknown", //快递费用币种 Name
  2409. sendCurrCode = "Unknown", //快递费用币种 Code
  2410. eventsCurrName = "Unknown", //公务活动费币种 Name
  2411. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2412. translateCurrName = "Unknown", //公务翻译费 Name
  2413. translateCurrCode = "Unknown"; //公务翻译费 Code
  2414. #region 处理费用币种
  2415. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2416. if (inviteCurrData != null)
  2417. {
  2418. inviteCurrName = inviteCurrData.Remark;
  2419. inviteCurrCode = inviteCurrData.Name;
  2420. }
  2421. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2422. if (sendCurrData != null)
  2423. {
  2424. sendCurrName = sendCurrData.Remark;
  2425. sendCurrCode = sendCurrData.Name;
  2426. }
  2427. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2428. if (eventsCurrData != null)
  2429. {
  2430. eventsCurrName = eventsCurrData.Remark;
  2431. eventsCurrCode = eventsCurrData.Name;
  2432. }
  2433. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2434. if (translateCurrData != null)
  2435. {
  2436. translateCurrName = translateCurrData.Remark;
  2437. translateCurrCode = translateCurrData.Name;
  2438. }
  2439. #endregion
  2440. _detail.PriceNameContent = _ioa.InviterArea;
  2441. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2442. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2443. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2444. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2445. $@"备注:" + _ioa.Remark + "<br/>";
  2446. }
  2447. break;
  2448. case 82: //团组客户保险
  2449. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2450. if (customers != null)
  2451. {
  2452. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2453. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2454. }
  2455. break;
  2456. case 85: //机票预订
  2457. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2458. if (jpRes != null)
  2459. {
  2460. string FlightsDescription = jpRes.FlightsDescription;
  2461. string PriceDescription = jpRes.PriceDescription;
  2462. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2463. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2464. }
  2465. break;
  2466. case 98://其他款项
  2467. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2468. if (gdpRes != null)
  2469. {
  2470. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2471. _detail.PriceNameContent = gdpRes.PriceName;
  2472. }
  2473. break;
  2474. case 285://收款退还
  2475. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2476. if (refundAndOtherMoney != null)
  2477. {
  2478. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2479. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2480. }
  2481. break;
  2482. case 751://酒店早餐
  2483. break;
  2484. case 1015://超支费用
  2485. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2486. if (groupExtraCost != null)
  2487. {
  2488. _detail.PriceNameContent = groupExtraCost.PriceName;
  2489. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2490. }
  2491. break;
  2492. default:
  2493. break;
  2494. }
  2495. /*
  2496. * 申请人
  2497. */
  2498. string operatorName = " - ";
  2499. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2500. if (_opUser != null)
  2501. {
  2502. operatorName = _opUser.CnName;
  2503. }
  2504. _detail.OperatorName = operatorName;
  2505. /*
  2506. * 审核人
  2507. */
  2508. string auditOperatorName = "Unknown";
  2509. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2510. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2511. else
  2512. {
  2513. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2514. if (_adUser != null)
  2515. {
  2516. auditOperatorName = _adUser.CnName;
  2517. }
  2518. }
  2519. _detail.AuditOperatorName = auditOperatorName;
  2520. /*
  2521. * 超预算比例
  2522. */
  2523. string overBudgetStr = "";
  2524. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2525. else if (entity.ExceedBudget == 0)
  2526. {
  2527. if (entity.CTable == 76 || entity.CTable == 79)
  2528. {
  2529. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2530. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2531. }
  2532. else
  2533. {
  2534. overBudgetStr = "未超预算";
  2535. }
  2536. }
  2537. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2538. _detail.OverBudget = overBudgetStr;
  2539. decimal auditFee = 0.00M; //已审核金额 人名币
  2540. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2541. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2542. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2543. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2544. {
  2545. auditedFeeOriginal = entity.PayMoney;
  2546. auditFee = CurrPayStr;
  2547. }
  2548. else if (entity.IsAuditGM == 0)
  2549. {
  2550. unAuditFeeCNY = CurrPayStr;
  2551. unAuditFeeOriginal = OriginalCurrPay;
  2552. OriginalCurrPay = 0.00M;
  2553. }
  2554. /*
  2555. * 费用总计
  2556. */
  2557. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2558. {
  2559. CurrencyId = entity.PaymentCurrency,
  2560. CurrencyName = PaymentCurrency_WaitPay,
  2561. AmountPayable = entity.PayMoney,
  2562. ThisPayment = OriginalCurrPay,
  2563. BalancePayment = BalanceStr,
  2564. AuditedFunds = auditFee,
  2565. AuditedFundsOriginal = auditedFeeOriginal,
  2566. UnAuditFundsCNY = unAuditFeeCNY,
  2567. UnAuditFundsOriginal = unAuditFeeOriginal
  2568. });
  2569. _detail.IsAuditGM = entity.IsAuditGM;
  2570. detailList.Add(_detail);
  2571. }
  2572. #endregion
  2573. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2574. /*
  2575. * 下方描述处理
  2576. */
  2577. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2578. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2579. if (ccpCurrencyPrice != null)
  2580. {
  2581. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2582. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2583. }
  2584. else
  2585. {
  2586. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2587. }
  2588. string amountPayableStr = string.Format(@"应付款总金额: ");
  2589. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2590. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2591. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2592. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2593. foreach (var item in nonDuplicat)
  2594. {
  2595. var currencyName = item.CurrencyName;
  2596. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2597. if (strs.Count > 0)
  2598. {
  2599. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2600. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2601. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2602. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2603. //单独处理此次付款金额
  2604. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2605. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2606. //单独处理已审核费用
  2607. //if (item.CurrencyId == 836) //人民币
  2608. //{
  2609. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2610. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2611. //}
  2612. //else
  2613. //{
  2614. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2615. //}
  2616. if (currencyName.Equals("CNY"))
  2617. {
  2618. //已审核费用
  2619. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2620. //未审核费用
  2621. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2622. }
  2623. else
  2624. {
  2625. //已审核费用
  2626. 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"));
  2627. //未审核费用
  2628. 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"));
  2629. }
  2630. }
  2631. }
  2632. _view.TotalStr1 = amountPayableStr[..^1];
  2633. _view.TotalStr2 = thisPaymentStr[..^1];
  2634. _view.TotalStr3 = balancePaymentStr[..^1];
  2635. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2636. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2637. var _view1 = new
  2638. {
  2639. PageFuncAuth = pageFunAuthView,
  2640. Data = _view
  2641. };
  2642. return Ok(JsonView(_view1));
  2643. }
  2644. catch (Exception ex)
  2645. {
  2646. return Ok(JsonView(false, ex.Message));
  2647. }
  2648. }
  2649. /// <summary>
  2650. /// 费用审核
  2651. /// 修改团组费用审核状态
  2652. /// </summary>
  2653. /// <param name="_dto">参数Json字符串</param>
  2654. /// <returns></returns>
  2655. [HttpPost]
  2656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2657. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2658. {
  2659. #region 参数验证
  2660. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2661. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2662. #endregion
  2663. #region 页面操作权限验证
  2664. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2665. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2666. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2667. #endregion
  2668. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2669. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2670. DateTime dtNow = DateTime.Now;
  2671. _groupRepository.BeginTran();
  2672. int rst = 0;
  2673. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2674. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2675. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2676. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2677. List<dynamic> msgDatas = new List<dynamic>();
  2678. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2679. foreach (var item in idList)
  2680. {
  2681. int CreditId = int.Parse(item);
  2682. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2683. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2684. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2685. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2686. .Where(s => s.Id == CreditId)
  2687. .ExecuteCommandAsync();
  2688. if (result < 1)
  2689. {
  2690. rst = -1;
  2691. _groupRepository.RollbackTran();
  2692. return Ok(JsonView(false, "操作失败并回滚!"));
  2693. }
  2694. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2695. if (creditData != null)
  2696. {
  2697. #region 应用通知配置
  2698. try
  2699. {
  2700. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2701. }
  2702. catch (Exception ex)
  2703. {
  2704. }
  2705. #endregion
  2706. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2707. string groupNameStr = string.Empty;
  2708. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2709. if (groupData != null) groupNameStr = groupData.TeamName;
  2710. string creditTypeStr = string.Empty;
  2711. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2712. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2713. string creditCurrency = string.Empty;
  2714. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2715. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2716. if (creditCurrency.Equals("CNY"))
  2717. {
  2718. creditData.DayRate = 1.0000M;
  2719. }
  2720. if (creditData.PayPercentage == 0.00M)
  2721. {
  2722. creditData.PayPercentage = 100M;
  2723. }
  2724. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2725. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2726. string msgContent = "";
  2727. if (creditCurrency.Equals("CNY"))
  2728. {
  2729. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2730. }
  2731. else
  2732. {
  2733. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2734. }
  2735. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2736. }
  2737. }
  2738. if (rst == 0)
  2739. {
  2740. _groupRepository.CommitTran();
  2741. foreach (var item in msgDatas)
  2742. {
  2743. //发送消息
  2744. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2745. }
  2746. #region 应用推送
  2747. try
  2748. {
  2749. foreach (var ccpId in dic_ccp_user.Keys)
  2750. {
  2751. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2752. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2753. }
  2754. }
  2755. catch (Exception)
  2756. {
  2757. }
  2758. #endregion
  2759. return Ok(JsonView(true, "操作成功!"));
  2760. }
  2761. return Ok(JsonView(false, "操作失败!"));
  2762. }
  2763. #endregion
  2764. #region 机票费用录入
  2765. /// <summary>
  2766. /// 机票录入当前登录人可操作团组
  2767. /// </summary>
  2768. /// <param name="dto"></param>
  2769. /// <returns></returns>
  2770. [HttpPost]
  2771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2772. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2773. {
  2774. try
  2775. {
  2776. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2777. if (groupData.Code != 0)
  2778. {
  2779. return Ok(JsonView(false, groupData.Msg));
  2780. }
  2781. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2782. }
  2783. catch (Exception ex)
  2784. {
  2785. return Ok(JsonView(false, "程序错误!"));
  2786. throw;
  2787. }
  2788. }
  2789. /// <summary>
  2790. /// 机票费用录入列表
  2791. /// </summary>
  2792. /// <param name="dto"></param>
  2793. /// <returns></returns>
  2794. [HttpPost]
  2795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2796. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2797. {
  2798. try
  2799. {
  2800. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2801. if (groupData.Code != 0)
  2802. {
  2803. return Ok(JsonView(false, groupData.Msg));
  2804. }
  2805. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2806. }
  2807. catch (Exception ex)
  2808. {
  2809. return Ok(JsonView(false, ex.Message));
  2810. throw;
  2811. }
  2812. }
  2813. /// <summary>
  2814. /// 根据id查询费用录入信息
  2815. /// </summary>
  2816. /// <param name="dto"></param>
  2817. /// <returns></returns>
  2818. [HttpPost]
  2819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2820. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2821. {
  2822. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2823. if (groupData.Code != 0)
  2824. {
  2825. return Ok(JsonView(false, groupData.Msg));
  2826. }
  2827. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2828. }
  2829. /// <summary>
  2830. /// 机票费用录入操作(Status:1.新增,2.修改)
  2831. /// </summary>
  2832. /// <param name="dto"></param>
  2833. /// <returns></returns>
  2834. [HttpPost]
  2835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2836. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2837. {
  2838. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2839. if (groupData.Code != 0)
  2840. {
  2841. return Ok(JsonView(false, groupData.Msg));
  2842. }
  2843. #region 应用推送
  2844. try
  2845. {
  2846. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2847. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2848. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2849. //2024-10-21 新增LZ UID
  2850. var userIds = new List<int>() { 21 };
  2851. string title = $"系统通知";
  2852. string content = "";
  2853. var diId = dto.AirTicketResOpData.DiId;
  2854. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2855. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2856. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2857. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2858. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2859. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2860. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2861. }
  2862. catch (Exception ex)
  2863. {
  2864. }
  2865. #endregion
  2866. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2867. }
  2868. /// <summary>
  2869. /// 根据舱位类型查询接团客户名单信息
  2870. /// </summary>
  2871. /// <param name="dto"></param>
  2872. /// <returns></returns>
  2873. [HttpPost]
  2874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2875. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2876. {
  2877. try
  2878. {
  2879. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2880. if (crm_Groups.Count != 0)
  2881. {
  2882. List<dynamic> Customer = new List<dynamic>();
  2883. foreach (var item in crm_Groups)
  2884. {
  2885. var data = new
  2886. {
  2887. Id = item.Id,
  2888. Pinyin = item.Pinyin,
  2889. Name = item.LastName + item.FirstName
  2890. };
  2891. Customer.Add(data);
  2892. }
  2893. return Ok(JsonView(true, "查询成功!", Customer));
  2894. }
  2895. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2896. }
  2897. catch (Exception ex)
  2898. {
  2899. return Ok(JsonView(false, "程序错误!"));
  2900. throw;
  2901. }
  2902. }
  2903. /// <summary>
  2904. /// 根据团号获取客户信息
  2905. /// </summary>
  2906. /// <param name="dto"></param>
  2907. /// <returns></returns>
  2908. [HttpPost]
  2909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2910. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2911. {
  2912. var jw = JsonView(false);
  2913. if (dto.DIID < 1)
  2914. {
  2915. jw.Msg += "请输入正确的diid";
  2916. return Ok(jw);
  2917. }
  2918. var arr = getSimplClientList(dto.DIID);
  2919. jw = JsonView(true, "获取成功!", arr);
  2920. return Ok(jw);
  2921. }
  2922. private List<SimplClientInfo> getSimplClientList(int diId)
  2923. {
  2924. 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);
  2925. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2926. foreach (var item in arr)
  2927. {
  2928. EncryptionProcessor.DecryptProperties(item);
  2929. }
  2930. return arr;
  2931. }
  2932. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2933. {
  2934. string result = origin;
  2935. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2936. {
  2937. string[] temparr = origin.Split(',');
  2938. string fistrStr = temparr[0];
  2939. int count = temparr.Count();
  2940. int tempId;
  2941. bool success = int.TryParse(fistrStr, out tempId);
  2942. if (success)
  2943. {
  2944. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2945. if (tempInfo != null)
  2946. {
  2947. if (count > 1)
  2948. {
  2949. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2950. }
  2951. else
  2952. {
  2953. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2954. }
  2955. }
  2956. }
  2957. }
  2958. return result;
  2959. }
  2960. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2961. {
  2962. string result = origin;
  2963. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2964. {
  2965. string[] temparr = origin.Split(',');
  2966. result = "";
  2967. foreach (var item in temparr)
  2968. {
  2969. int tempId;
  2970. bool success = int.TryParse(item, out tempId);
  2971. if (success)
  2972. {
  2973. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2974. if (tempInfo != null)
  2975. {
  2976. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2977. }
  2978. }
  2979. }
  2980. }
  2981. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2982. return result;
  2983. }
  2984. /// <summary>
  2985. /// 机票费用录入,删除
  2986. /// </summary>
  2987. /// <param name="dto"></param>
  2988. /// <returns></returns>
  2989. [HttpPost]
  2990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2991. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2992. {
  2993. try
  2994. {
  2995. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2996. if (res)
  2997. {
  2998. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2999. {
  3000. IsDel = 1,
  3001. DeleteUserId = dto.DeleteUserId,
  3002. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3003. }).ExecuteCommandAsync();
  3004. return Ok(JsonView(true, "删除成功!"));
  3005. }
  3006. return Ok(JsonView(false, "删除失败!"));
  3007. }
  3008. catch (Exception ex)
  3009. {
  3010. return Ok(JsonView(false, "程序错误!"));
  3011. throw;
  3012. }
  3013. }
  3014. /// <summary>
  3015. /// 导出机票录入报表
  3016. /// </summary>
  3017. /// <param name="dto"></param>
  3018. /// <returns></returns>
  3019. [HttpPost]
  3020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3021. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3022. {
  3023. try
  3024. {
  3025. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3026. if (groupData.Code != 0)
  3027. {
  3028. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3029. }
  3030. else
  3031. {
  3032. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3033. if (AirTicketReservations.Count != 0)
  3034. {
  3035. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3036. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3037. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3038. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3039. WorkbookDesigner designer = new WorkbookDesigner();
  3040. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3041. decimal countCost = 0;
  3042. foreach (var item in AirTicketReservations)
  3043. {
  3044. #region 处理客人姓名
  3045. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3046. item.ClientName = clientNames;
  3047. #endregion
  3048. if (item.BankType == "其他")
  3049. {
  3050. item.BankNo = "--";
  3051. }
  3052. else
  3053. {
  3054. if (!string.IsNullOrEmpty(item.BankType))
  3055. {
  3056. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3057. }
  3058. }
  3059. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3060. item.Price = System.Decimal.Round(item.Price, 2);
  3061. countCost += Convert.ToDecimal(item.Price);
  3062. }
  3063. designer.SetDataSource("Export", AirTicketReservations);
  3064. designer.SetDataSource("ExportDiCode", diCode);
  3065. designer.SetDataSource("ExportDiName", diName);
  3066. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3067. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3068. designer.Process();
  3069. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3070. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3071. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3072. return Ok(JsonView(true, "成功", url = rst));
  3073. }
  3074. else
  3075. {
  3076. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3077. }
  3078. }
  3079. }
  3080. catch (Exception ex)
  3081. {
  3082. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3083. throw;
  3084. }
  3085. }
  3086. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3087. /// <summary>
  3088. /// 行程单导出
  3089. /// </summary>
  3090. /// <param name="dto"></param>
  3091. /// <returns></returns>
  3092. [HttpPost]
  3093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3094. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3095. {
  3096. try
  3097. {
  3098. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3099. if (groupData.Code != 0)
  3100. {
  3101. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3102. }
  3103. else
  3104. {
  3105. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3106. if (dto.Language == "CN")
  3107. {
  3108. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3109. DocumentBuilder builder = new DocumentBuilder(doc);
  3110. int tableIndex = 0;//表格索引
  3111. //得到文档中的第一个表格
  3112. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3113. foreach (var item in _AirTicketReservations)
  3114. {
  3115. #region 处理固定数据
  3116. string[] FlightsCode = item.FlightsCode.Split('/');
  3117. if (FlightsCode.Length != 0)
  3118. {
  3119. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3120. if (_AirCompany != null)
  3121. {
  3122. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3123. }
  3124. else
  3125. {
  3126. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3127. }
  3128. }
  3129. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3130. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3131. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3132. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3133. string name = "";
  3134. foreach (string clientName in nameArray)
  3135. {
  3136. if (!name.Contains(clientName))
  3137. {
  3138. name += clientName + ",";
  3139. }
  3140. }
  3141. if (!string.IsNullOrWhiteSpace(name))
  3142. {
  3143. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3144. }
  3145. else
  3146. {
  3147. table.Range.Bookmarks["ClientName"].Text = "--";
  3148. }
  3149. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3150. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3151. table.Range.Bookmarks["JointTicket"].Text = "--";
  3152. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3153. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3154. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3155. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3156. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3157. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3158. #endregion
  3159. #region 循环数据处理
  3160. List<AirInfo> airs = new List<AirInfo>();
  3161. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3162. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3163. for (int i = 0; i < FlightsCode.Length; i++)
  3164. {
  3165. AirInfo air = new AirInfo();
  3166. string[] tempstr = DayArray[i]
  3167. .Replace("\r\n", string.Empty)
  3168. .Replace("\\r\\n", string.Empty)
  3169. .TrimStart().TrimEnd()
  3170. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3171. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3172. string starCity = "";
  3173. if (star_Three != null)
  3174. {
  3175. starCity = star_Three.AirPort;
  3176. }
  3177. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3178. string EndCity = "";
  3179. if (End_Three != null)
  3180. {
  3181. EndCity = End_Three.AirPort;
  3182. }
  3183. air.Destination = starCity + "/" + EndCity;
  3184. air.Flight = FlightsCode[i];
  3185. air.SeatingClass = item.CTypeName;
  3186. string dateTime = tempstr[2];
  3187. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3188. air.FlightDate = DateTemp;
  3189. air.DepartureTime = tempstr[5];
  3190. air.LandingTime = tempstr[6];
  3191. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3192. air.TicketStatus = "--";
  3193. air.Luggage = "--";
  3194. air.DepartureTerminal = "--";
  3195. air.LandingTerminal = "--";
  3196. airs.Add(air);
  3197. }
  3198. int row = 13;
  3199. for (int i = 0; i < airs.Count; i++)
  3200. {
  3201. if (airs.Count > 2)
  3202. {
  3203. for (int j = 0; j < airs.Count - 2; j++)
  3204. {
  3205. var CopyRow = table.Rows[12].Clone(true);
  3206. table.Rows.Add(CopyRow);
  3207. }
  3208. }
  3209. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3210. int index = 0;
  3211. foreach (PropertyInfo property in properties)
  3212. {
  3213. string value = property.GetValue(airs[i]).ToString();
  3214. Cell ishcel0 = table.Rows[row].Cells[index];
  3215. Paragraph p = new Paragraph(doc);
  3216. string s = value;
  3217. p.AppendChild(new Run(doc, s));
  3218. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3219. ishcel0.AppendChild(p);
  3220. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3221. index++;
  3222. }
  3223. row++;
  3224. }
  3225. #endregion
  3226. Paragraph lastParagraph = new Paragraph(doc);
  3227. //第一个表格末尾加段落
  3228. table.ParentNode.InsertAfter(lastParagraph, table);
  3229. //复制第一个表格
  3230. Table cloneTable = (Table)table.Clone(true);
  3231. //在文档末尾段落后面加入复制的表格
  3232. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3233. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3234. {
  3235. int rownewsIndex = 13;
  3236. for (int i = 0; i < 2; i++)
  3237. {
  3238. var CopyRow = table.Rows[12].Clone(true);
  3239. table.Rows.RemoveAt(13);
  3240. table.Rows.Add(CopyRow);
  3241. rownewsIndex++;
  3242. }
  3243. }
  3244. else
  3245. {
  3246. table.Rows.RemoveAt(12);
  3247. }
  3248. cloneTable.Rows.RemoveAt(12);
  3249. }
  3250. if (_AirTicketReservations.Count != 0)
  3251. {
  3252. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3253. if (FlightsCode.Length != 0)
  3254. {
  3255. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3256. if (_AirCompany != null)
  3257. {
  3258. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3259. }
  3260. else
  3261. {
  3262. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3263. }
  3264. }
  3265. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3266. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3267. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3268. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3269. string name = "";
  3270. foreach (string clientName in nameArray)
  3271. {
  3272. if (!name.Contains(clientName))
  3273. {
  3274. name += clientName + ",";
  3275. }
  3276. }
  3277. if (!string.IsNullOrWhiteSpace(name))
  3278. {
  3279. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3280. }
  3281. else
  3282. {
  3283. table.Range.Bookmarks["ClientName"].Text = "--";
  3284. }
  3285. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3286. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3287. table.Range.Bookmarks["JointTicket"].Text = "--";
  3288. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3289. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3290. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3291. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3292. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3293. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3294. }
  3295. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3296. //保存合并后的文档
  3297. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3298. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3299. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3300. return Ok(JsonView(true, "成功!", rst));
  3301. }
  3302. else
  3303. {
  3304. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3305. DocumentBuilder builder = new DocumentBuilder(doc);
  3306. int tableIndex = 0;//表格索引
  3307. //得到文档中的第一个表格
  3308. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3309. List<string> texts = new List<string>();
  3310. foreach (var item in _AirTicketReservations)
  3311. {
  3312. string[] FlightsCode = item.FlightsCode.Split('/');
  3313. if (FlightsCode.Length != 0)
  3314. {
  3315. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3316. if (_AirCompany != null)
  3317. {
  3318. if (!transDic.ContainsKey(_AirCompany.CnName))
  3319. {
  3320. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3321. }
  3322. }
  3323. else
  3324. {
  3325. if (!transDic.ContainsKey("--"))
  3326. {
  3327. transDic.Add("--", "--");
  3328. }
  3329. }
  3330. }
  3331. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3332. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3333. string name = "";
  3334. foreach (string clientName in nameArray)
  3335. {
  3336. name += clientName + ",";
  3337. }
  3338. if (!texts.Contains(name))
  3339. {
  3340. texts.Add(name);
  3341. }
  3342. List<AirInfo> airs = new List<AirInfo>();
  3343. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3344. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3345. for (int i = 0; i < FlightsCode.Length; i++)
  3346. {
  3347. AirInfo air = new AirInfo();
  3348. string[] tempstr = DayArray[i]
  3349. .Replace("\r\n", string.Empty)
  3350. .Replace("\\r\\n", string.Empty)
  3351. .TrimStart().TrimEnd()
  3352. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3353. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3354. if (star_Three != null)
  3355. {
  3356. if (!transDic.ContainsKey(star_Three.AirPort))
  3357. {
  3358. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3359. }
  3360. }
  3361. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3362. if (End_Three != null)
  3363. {
  3364. if (!transDic.ContainsKey(End_Three.AirPort))
  3365. {
  3366. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3367. }
  3368. }
  3369. if (!texts.Contains(item.CTypeName))
  3370. {
  3371. texts.Add(item.CTypeName);
  3372. }
  3373. }
  3374. }
  3375. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3376. if (transData.Count > 0)
  3377. {
  3378. foreach (TranslateResult item in transData)
  3379. {
  3380. if (!transDic.ContainsKey(item.Query))
  3381. {
  3382. transDic.Add(item.Query, item.Translation);
  3383. }
  3384. }
  3385. }
  3386. foreach (var item in _AirTicketReservations)
  3387. {
  3388. #region 处理固定数据
  3389. string[] FlightsCode = item.FlightsCode.Split('/');
  3390. if (FlightsCode.Length != 0)
  3391. {
  3392. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3393. if (_AirCompany != null)
  3394. {
  3395. string str = "--";
  3396. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3397. if (!string.IsNullOrEmpty(translateResult))
  3398. {
  3399. str = translateResult;
  3400. str = _airTicketResRep.Processing(str);
  3401. }
  3402. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3403. }
  3404. else
  3405. {
  3406. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3407. }
  3408. }
  3409. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3410. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3411. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3412. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3413. string names = "";
  3414. foreach (string clientName in nameArray)
  3415. {
  3416. names += clientName + ",";
  3417. }
  3418. if (!string.IsNullOrWhiteSpace(names))
  3419. {
  3420. string str = "--";
  3421. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3422. if (!string.IsNullOrEmpty(translateResult))
  3423. {
  3424. str = translateResult;
  3425. str = _airTicketResRep.Processing(str);
  3426. }
  3427. table.Range.Bookmarks["ClientName"].Text = str;
  3428. }
  3429. else
  3430. {
  3431. table.Range.Bookmarks["ClientName"].Text = "--";
  3432. }
  3433. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3434. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3435. table.Range.Bookmarks["JointTicket"].Text = "--";
  3436. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3437. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3438. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3439. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3440. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3441. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3442. #endregion
  3443. #region 循环数据处理
  3444. List<AirInfo> airs = new List<AirInfo>();
  3445. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3446. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3447. for (int i = 0; i < FlightsCode.Length; i++)
  3448. {
  3449. AirInfo air = new AirInfo();
  3450. string[] tempstr = DayArray[i]
  3451. .Replace("\r\n", string.Empty)
  3452. .Replace("\\r\\n", string.Empty)
  3453. .TrimStart().TrimEnd()
  3454. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3455. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3456. string starCity = "";
  3457. if (star_Three != null)
  3458. {
  3459. string str2 = "--";
  3460. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3461. if (!string.IsNullOrEmpty(translateResult2))
  3462. {
  3463. str2 = translateResult2;
  3464. str2 = _airTicketResRep.Processing(str2);
  3465. }
  3466. starCity = str2;
  3467. }
  3468. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3469. string EndCity = "";
  3470. if (End_Three != null)
  3471. {
  3472. string str1 = "--";
  3473. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3474. if (!string.IsNullOrEmpty(translateResult1))
  3475. {
  3476. str1 = translateResult1;
  3477. str1 = _airTicketResRep.Processing(str1);
  3478. }
  3479. EndCity = str1;
  3480. }
  3481. air.Destination = starCity + "/" + EndCity;
  3482. air.Flight = FlightsCode[i];
  3483. string str = "--";
  3484. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3485. if (!string.IsNullOrEmpty(translateResult))
  3486. {
  3487. str = translateResult;
  3488. str = _airTicketResRep.Processing(str);
  3489. }
  3490. air.SeatingClass = str;
  3491. string dateTime = tempstr[2];
  3492. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3493. air.FlightDate = DateTemp;
  3494. air.DepartureTime = tempstr[5];
  3495. air.LandingTime = tempstr[6];
  3496. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3497. air.TicketStatus = "--";
  3498. air.Luggage = "--";
  3499. air.DepartureTerminal = "--";
  3500. air.LandingTerminal = "--";
  3501. airs.Add(air);
  3502. }
  3503. int row = 13;
  3504. for (int i = 0; i < airs.Count; i++)
  3505. {
  3506. if (airs.Count > 2)
  3507. {
  3508. for (int j = 0; j < airs.Count - 2; j++)
  3509. {
  3510. var CopyRow = table.Rows[12].Clone(true);
  3511. table.Rows.Add(CopyRow);
  3512. }
  3513. }
  3514. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3515. int index = 0;
  3516. foreach (PropertyInfo property in properties)
  3517. {
  3518. string value = property.GetValue(airs[i]).ToString();
  3519. Cell ishcel0 = table.Rows[row].Cells[index];
  3520. Paragraph p = new Paragraph(doc);
  3521. string s = value;
  3522. p.AppendChild(new Run(doc, s));
  3523. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3524. ishcel0.AppendChild(p);
  3525. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3526. //ishcel0.CellFormat.VerticalAlignment=
  3527. index++;
  3528. }
  3529. row++;
  3530. }
  3531. #endregion
  3532. Paragraph lastParagraph = new Paragraph(doc);
  3533. //第一个表格末尾加段落
  3534. table.ParentNode.InsertAfter(lastParagraph, table);
  3535. //复制第一个表格
  3536. Table cloneTable = (Table)table.Clone(true);
  3537. //在文档末尾段落后面加入复制的表格
  3538. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3539. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3540. {
  3541. int rownewsIndex = 13;
  3542. for (int i = 0; i < 2; i++)
  3543. {
  3544. var CopyRow = table.Rows[12].Clone(true);
  3545. table.Rows.RemoveAt(13);
  3546. table.Rows.Add(CopyRow);
  3547. rownewsIndex++;
  3548. }
  3549. }
  3550. else
  3551. {
  3552. table.Rows.RemoveAt(12);
  3553. }
  3554. cloneTable.Rows.RemoveAt(12);
  3555. }
  3556. if (_AirTicketReservations.Count != 0)
  3557. {
  3558. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3559. if (FlightsCode.Length != 0)
  3560. {
  3561. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3562. if (_AirCompany != null)
  3563. {
  3564. string str = "--";
  3565. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3566. if (!string.IsNullOrEmpty(translateResult))
  3567. {
  3568. str = translateResult;
  3569. str = _airTicketResRep.Processing(str);
  3570. }
  3571. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3572. }
  3573. else
  3574. {
  3575. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3576. }
  3577. }
  3578. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3579. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3580. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3581. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3582. string names = "";
  3583. foreach (string clientName in nameArray)
  3584. {
  3585. names += clientName + ",";
  3586. }
  3587. if (!string.IsNullOrWhiteSpace(names))
  3588. {
  3589. string str = "--";
  3590. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3591. if (!string.IsNullOrEmpty(translateResult))
  3592. {
  3593. str = translateResult;
  3594. str = _airTicketResRep.Processing(str);
  3595. }
  3596. table.Range.Bookmarks["ClientName"].Text = str;
  3597. }
  3598. else
  3599. {
  3600. table.Range.Bookmarks["ClientName"].Text = "--";
  3601. }
  3602. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3603. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3604. table.Range.Bookmarks["JointTicket"].Text = "--";
  3605. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3606. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3607. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3608. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3609. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3610. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3611. }
  3612. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3613. //保存合并后的文档
  3614. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3615. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3616. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3617. return Ok(JsonView(true, "成功!", rst));
  3618. }
  3619. }
  3620. }
  3621. catch (Exception ex)
  3622. {
  3623. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3624. throw;
  3625. }
  3626. }
  3627. #endregion
  3628. #region 团组增减款项 --> 其他款项
  3629. /// <summary>
  3630. /// 团组增减款项下拉框绑定
  3631. /// </summary>
  3632. /// <param name="dto"></param>
  3633. /// <returns></returns>
  3634. [HttpPost]
  3635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3636. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3637. {
  3638. #region 参数验证
  3639. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3640. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3641. #endregion
  3642. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3643. }
  3644. /// <summary>
  3645. /// 根据团组Id查询团组增减款项
  3646. /// </summary>
  3647. /// <param name="dto"></param>
  3648. /// <returns></returns>
  3649. [HttpPost]
  3650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3651. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3652. {
  3653. #region 参数验证
  3654. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3655. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3656. #endregion
  3657. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3658. }
  3659. /// <summary>
  3660. /// 团组增减款项操作(Status:1.新增,2.修改)
  3661. /// </summary>
  3662. /// <param name="dto"></param>
  3663. /// <returns></returns>
  3664. [HttpPost]
  3665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3666. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3667. {
  3668. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3669. if (groupData.Code != 200)
  3670. {
  3671. return Ok(JsonView(false, groupData.Msg));
  3672. }
  3673. #region 应用推送
  3674. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3675. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3676. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3677. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3678. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3679. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3680. //自动审核
  3681. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3682. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3683. //2024-10-21 新增LZ UID
  3684. var userIds = new List<int>() { 21 };
  3685. string title = $"系统通知";
  3686. string content = "";
  3687. var diId = dto.DiId;
  3688. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3689. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3690. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3691. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3692. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3693. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3694. #endregion
  3695. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3696. }
  3697. /// <summary>
  3698. /// 团组增减款项操作 删除
  3699. /// </summary>
  3700. /// <param name="dto"></param>
  3701. /// <returns></returns>
  3702. [HttpPost]
  3703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3704. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3705. {
  3706. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3707. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3708. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3709. if (res.Code == 0)
  3710. {
  3711. return Ok(JsonView(true, "删除成功!"));
  3712. }
  3713. return Ok(JsonView(false, "删除失败!"));
  3714. }
  3715. /// <summary>
  3716. /// 根据团组增减款项Id查询
  3717. /// </summary>
  3718. /// <param name="dto"></param>
  3719. /// <returns></returns>
  3720. [HttpPost]
  3721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3722. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3723. {
  3724. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3725. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3726. }
  3727. /// <summary>
  3728. /// 查询供应商名称
  3729. /// </summary>
  3730. /// <param name="dto"></param>
  3731. /// <returns></returns>
  3732. [HttpPost]
  3733. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3734. {
  3735. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3736. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3737. ?? new List<Grp_DecreasePayments>();
  3738. dbResult = dbResult.Distinct(new
  3739. ProductComparer()).ToList();
  3740. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3741. {
  3742. x.Id,
  3743. x.SupplierAddress,
  3744. x.SupplierArea,
  3745. x.SupplierContact,
  3746. x.SupplierContactNumber,
  3747. x.SupplierEmail,
  3748. x.SupplierName,
  3749. x.SupplierSocialAccount,
  3750. x.SupplierTypeId,
  3751. }).ToList());
  3752. return Ok(jw);
  3753. }
  3754. /// <summary>
  3755. /// 团组增减款项 OTA匹配
  3756. /// </summary>
  3757. /// <param name="file"></param>
  3758. /// <returns></returns>
  3759. [HttpPost]
  3760. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3761. {
  3762. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3763. string fileName = file.FileName;
  3764. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3765. {
  3766. return Ok(JsonView(false, "请上传Excel文件!"));
  3767. }
  3768. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3769. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3770. if (!Directory.Exists(path))
  3771. {
  3772. Directory.CreateDirectory(path);
  3773. }
  3774. var filePath = @$"{path}/{fileName}";
  3775. //保存文件
  3776. using (FileStream fs = System.IO.File.Create(filePath))
  3777. {
  3778. file.CopyTo(fs);
  3779. fs.Flush();
  3780. }
  3781. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3782. //读取ExcelFile
  3783. DataTable dt = ConvertExcelToDataTable(filePath);
  3784. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3785. dt.TableName = "TB";
  3786. //修改table列名
  3787. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3788. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3789. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3790. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3791. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3792. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3793. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3794. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3795. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3796. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3797. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3798. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3799. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3800. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3801. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3802. var otaOrderNos = new List<string>();
  3803. foreach (DataRow item in dt.Rows)
  3804. {
  3805. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3806. }
  3807. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3808. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3809. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3810. .Select((dp, di) => new
  3811. {
  3812. dp.PriceName,
  3813. dp.OTAOrderNo,
  3814. dp.FeeTotal,
  3815. di.TeamName,
  3816. })
  3817. .ToListAsync();
  3818. foreach (DataRow item in dt.Rows)
  3819. {
  3820. var otaOrderNo = item["OTAOrderNo"].ToString();
  3821. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3822. if (oaData == null) continue;
  3823. item["GroupName"] = oaData.TeamName;
  3824. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3825. }
  3826. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3827. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3828. List<DataTable> datas = new List<DataTable>();
  3829. datas.Add(dt);
  3830. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3831. return Ok(JsonView(true, "操作成功", new { url = url }));
  3832. }
  3833. #region
  3834. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3835. {
  3836. // 创建Workbook对象
  3837. Workbook workbook = new Workbook(excelFilePath);
  3838. // 获取第一个工作表
  3839. Worksheet worksheet = workbook.Worksheets[0];
  3840. // 将工作表转换为DataTable
  3841. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3842. return dataTable;
  3843. }
  3844. #endregion
  3845. #endregion
  3846. #region 文件上传、删除
  3847. /// <summary>
  3848. /// region 文件上传 可以带参数
  3849. /// </summary>
  3850. /// <param name="file"></param>
  3851. /// <returns></returns>
  3852. [HttpPost]
  3853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3854. public async Task<IActionResult> UploadProject(IFormFile file)
  3855. {
  3856. //var TypeName = Request.Headers["TypeName"].ToString();
  3857. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3858. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3859. ////文件名称
  3860. //string projectFileName = file.FileName;
  3861. ////上传的文件的路径
  3862. //string filePath = $"{fileDir}/{projectFileName}";
  3863. //if (TypeName == "A")//A代表团组增减款项
  3864. //{
  3865. // filePath = fileDir + $@"\团组增减款项相关文件";
  3866. // if (!Directory.Exists(filePath))
  3867. // {
  3868. // Directory.CreateDirectory(filePath);
  3869. // }
  3870. // //上传的文件的路径
  3871. // filePath += $@"\{projectFileName}";
  3872. //}
  3873. //else if (TypeName == "B")//B代表商邀相关文件
  3874. //{
  3875. // //上传的文件的路径
  3876. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3877. // if (!Directory.Exists(filePath))
  3878. // {
  3879. // Directory.CreateDirectory(filePath);
  3880. // }
  3881. // //上传的文件的路径
  3882. // filePath = $@"\{projectFileName}";
  3883. //}
  3884. //try
  3885. //{
  3886. // using (FileStream fs = System.IO.File.Create(filePath))
  3887. // {
  3888. // file.CopyTo(fs);
  3889. // fs.Flush();
  3890. // }
  3891. //}
  3892. //catch (Exception ex)
  3893. //{
  3894. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3895. //}
  3896. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3897. try
  3898. {
  3899. var TypeName = Request.Headers["TypeName"].ToString();
  3900. if (file != null)
  3901. {
  3902. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3903. //文件名称
  3904. string projectFileName = file.FileName;
  3905. //上传的文件的路径
  3906. string filePath = $"{fileDir}/{projectFileName}";
  3907. if (TypeName == "A")//A代表团组增减款项
  3908. {
  3909. if (!Directory.Exists(fileDir))
  3910. {
  3911. Directory.CreateDirectory(fileDir);
  3912. }
  3913. //上传的文件的路径
  3914. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3915. }
  3916. else if (TypeName == "B")//B代表商邀相关文件
  3917. {
  3918. if (!Directory.Exists(fileDir))
  3919. {
  3920. Directory.CreateDirectory(fileDir);
  3921. }
  3922. //上传的文件的路径
  3923. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3924. }
  3925. using (FileStream fs = System.IO.File.Create(filePath))
  3926. {
  3927. file.CopyTo(fs);
  3928. fs.Flush();
  3929. }
  3930. return Ok(JsonView(true, "上传成功!", projectFileName));
  3931. }
  3932. else
  3933. {
  3934. return Ok(JsonView(false, "上传失败!"));
  3935. }
  3936. }
  3937. catch (Exception ex)
  3938. {
  3939. return Ok(JsonView(false, "程序错误!"));
  3940. }
  3941. }
  3942. /// <summary>
  3943. /// 删除指定文件
  3944. /// </summary>
  3945. /// <param name="dto"></param>
  3946. /// <returns></returns>
  3947. [HttpPost]
  3948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3949. public async Task<IActionResult> DelFile(DelFileDto dto)
  3950. {
  3951. try
  3952. {
  3953. var TypeName = Request.Headers["TypeName"].ToString();
  3954. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3955. string filePath = "";
  3956. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3957. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3958. int id = 0;
  3959. if (TypeName == "A")
  3960. {
  3961. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3962. // 删除该文件
  3963. System.IO.File.Delete(filePath);
  3964. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3965. .Where(a => a.Id == dto.Id)
  3966. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3967. .ExecuteCommandAsync();
  3968. }
  3969. else if (TypeName == "B")
  3970. {
  3971. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3972. // 删除该文件
  3973. System.IO.File.Delete(filePath);
  3974. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3975. if (info != null)
  3976. {
  3977. string[] files = new string[] { };
  3978. if (!string.IsNullOrEmpty(info.Attachment))
  3979. {
  3980. try
  3981. {
  3982. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3983. }
  3984. catch (Exception)
  3985. {
  3986. files = new List<string>() { info.Attachment }.ToArray();
  3987. }
  3988. }
  3989. if (files.Length > 0)
  3990. {
  3991. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3992. string filePath2 = string.Empty;
  3993. if (files1.Length > 0)
  3994. {
  3995. filePath2 = JsonConvert.SerializeObject(files1);
  3996. }
  3997. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3998. .Where(a => a.Id == dto.Id)
  3999. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4000. .ExecuteCommandAsync();
  4001. }
  4002. }
  4003. }
  4004. if (id != 0)
  4005. {
  4006. return Ok(JsonView(true, "成功!"));
  4007. }
  4008. else
  4009. {
  4010. return Ok(JsonView(false, "失败!"));
  4011. }
  4012. }
  4013. catch (Exception ex)
  4014. {
  4015. return Ok(JsonView(false, "程序错误!"));
  4016. throw;
  4017. }
  4018. }
  4019. /// <summary>
  4020. /// 文件上传多个文件 可以带参数
  4021. /// </summary>
  4022. /// <param name="files"></param>
  4023. /// <returns></returns>
  4024. [HttpPost]
  4025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4026. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4027. {
  4028. try
  4029. {
  4030. var TypeName = Request.Headers["TypeName"].ToString();
  4031. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4032. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4033. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4034. var filePahts = new List<string>();
  4035. foreach (var file in files)
  4036. {
  4037. //文件名称
  4038. string projectFileName = file.FileName;
  4039. //上传的文件的路径
  4040. string filePath = $"{fileDir}/{projectFileName}";
  4041. if (TypeName == "A")//A代表团组增减款项
  4042. {
  4043. if (!Directory.Exists(fileDir))
  4044. {
  4045. Directory.CreateDirectory(fileDir);
  4046. }
  4047. //上传的文件的路径
  4048. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4049. }
  4050. else if (TypeName == "B")//B代表商邀相关文件
  4051. {
  4052. if (!Directory.Exists(fileDir))
  4053. {
  4054. Directory.CreateDirectory(fileDir);
  4055. }
  4056. //上传的文件的路径
  4057. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4058. }
  4059. using (FileStream fs = System.IO.File.Create(filePath))
  4060. {
  4061. file.CopyTo(fs);
  4062. fs.Flush();
  4063. }
  4064. filePahts.Add(projectFileName);
  4065. }
  4066. return Ok(JsonView(true, "上传成功!", filePahts));
  4067. }
  4068. catch (Exception ex)
  4069. {
  4070. return Ok(JsonView(false, "程序错误!"));
  4071. }
  4072. }
  4073. #endregion
  4074. #region 商邀费用录入
  4075. /// <summary>
  4076. /// 根据团组Id查询商邀费用列表
  4077. /// </summary>
  4078. /// <param name="dto"></param>
  4079. /// <returns></returns>
  4080. [HttpPost]
  4081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4082. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4083. {
  4084. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4085. if (groupData.Code != 0)
  4086. {
  4087. return Ok(JsonView(false, groupData.Msg));
  4088. }
  4089. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4090. }
  4091. /// <summary>
  4092. /// 商邀费用列表
  4093. /// 下载文件
  4094. /// </summary>
  4095. /// <param name="id"></param>
  4096. /// <returns></returns>
  4097. [HttpGet("{id}")]
  4098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4099. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4100. {
  4101. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4102. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4103. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4104. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4105. var filePaths = new List<string>();
  4106. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4107. try
  4108. {
  4109. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4110. }
  4111. catch (Exception ex)
  4112. {
  4113. filePaths.Add(info.Attachment);
  4114. }
  4115. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4116. for (int i = 0; i < filePaths.Count; i++)
  4117. {
  4118. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4119. }
  4120. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4121. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4122. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4123. {
  4124. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4125. {
  4126. foreach (string filePath in filePaths)
  4127. {
  4128. if (System.IO.File.Exists(filePath))
  4129. {
  4130. // 获取文件名
  4131. string fileName = Path.GetFileName(filePath);
  4132. // 将文件添加到ZIP归档中
  4133. zipArchive.CreateEntryFromFile(filePath, fileName);
  4134. }
  4135. }
  4136. }
  4137. }
  4138. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4139. }
  4140. /// <summary>
  4141. /// 商邀费用 Info Page 基础数据源
  4142. /// </summary>
  4143. /// <returns></returns>
  4144. [HttpPost]
  4145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4146. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4147. {
  4148. try
  4149. {
  4150. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4151. if (groupData.Code != 0)
  4152. {
  4153. return Ok(JsonView(false, groupData.Msg));
  4154. }
  4155. return Ok(JsonView(true, "操作成功", groupData.Data));
  4156. }
  4157. catch (Exception ex)
  4158. {
  4159. return Ok(JsonView(false, ex.Message));
  4160. throw;
  4161. }
  4162. }
  4163. /// <summary>
  4164. /// 根据商邀费用ID查询C表和商邀费用数据
  4165. /// </summary>
  4166. /// <param name="dto"></param>
  4167. /// <returns></returns>
  4168. [HttpPost]
  4169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4170. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4171. {
  4172. try
  4173. {
  4174. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4175. if (groupData.Code != 0)
  4176. {
  4177. return Ok(JsonView(false, groupData.Msg));
  4178. }
  4179. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4180. }
  4181. catch (Exception ex)
  4182. {
  4183. return Ok(JsonView(false, ex.Message));
  4184. throw;
  4185. }
  4186. }
  4187. /// <summary>
  4188. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4189. /// </summary>
  4190. /// <param name="dto"></param>
  4191. /// <returns></returns>
  4192. [HttpPost]
  4193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4194. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4195. {
  4196. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4197. if (groupData.Code != 0)
  4198. {
  4199. return Ok(JsonView(false, groupData.Msg));
  4200. }
  4201. #region 应用推送
  4202. try
  4203. {
  4204. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4205. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4206. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4207. //2024-10-21 新增LZ UID
  4208. var userIds = new List<int>() { 21 };
  4209. string title = $"系统通知";
  4210. string content = "";
  4211. var diId = dto.DiId;
  4212. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4213. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4214. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4215. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4216. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4217. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4218. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4219. }
  4220. catch (Exception ex)
  4221. {
  4222. }
  4223. #endregion
  4224. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4225. }
  4226. /// <summary>
  4227. /// 商邀删除
  4228. /// </summary>
  4229. /// <param name="dto"></param>
  4230. /// <returns></returns>
  4231. [HttpPost]
  4232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4233. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4234. {
  4235. try
  4236. {
  4237. _sqlSugar.BeginTran();
  4238. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4239. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4240. {
  4241. IsDel = 1,
  4242. DeleteUserId = dto.DeleteUserId,
  4243. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4244. })
  4245. .Where(it => it.Id == dto.Id)
  4246. .ExecuteCommand();
  4247. if (res1 > 0)
  4248. {
  4249. int _diId = 0;
  4250. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4251. if (_ioaInfo != null)
  4252. {
  4253. _diId = _ioaInfo.DiId;
  4254. }
  4255. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4256. .SetColumns(a => new Grp_CreditCardPayment()
  4257. {
  4258. IsDel = 1,
  4259. DeleteUserId = dto.DeleteUserId,
  4260. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4261. })
  4262. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4263. .ExecuteCommand();
  4264. if (res2 > 0)
  4265. {
  4266. _sqlSugar.CommitTran();
  4267. return Ok(JsonView(true, "删除成功!"));
  4268. }
  4269. }
  4270. _sqlSugar.RollbackTran();
  4271. return Ok(JsonView(false, "删除失败"));
  4272. }
  4273. catch (Exception ex)
  4274. {
  4275. _sqlSugar.RollbackTran();
  4276. return Ok(JsonView(false, ex.Message));
  4277. }
  4278. }
  4279. /// <summary>
  4280. /// 团组模块文件上传
  4281. /// </summary>
  4282. /// <param name="dto"></param>
  4283. /// <returns></returns>
  4284. [HttpPost]
  4285. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4286. {
  4287. var jw = JsonView(false);
  4288. long M = 1024 * 1024;
  4289. if (dto.Files == null || dto.Files.Count == 0)
  4290. {
  4291. jw.Msg = "无文件信息!";
  4292. return Ok(jw);
  4293. }
  4294. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4295. {
  4296. jw.Msg = "文件大小超过20M!";
  4297. return Ok(jw);
  4298. }
  4299. //var nameSp = dto.File.FileName.Split(".");
  4300. //if (nameSp.Length < 2)
  4301. //{
  4302. // jw.Msg = "拓展名称有误!";
  4303. // return Ok(jw);
  4304. //}
  4305. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4306. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4307. //{
  4308. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4309. // return Ok(jw);
  4310. //}
  4311. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4312. if (Ctable == null)
  4313. {
  4314. jw.Msg = "Ctable指向有误!";
  4315. return Ok(jw);
  4316. }
  4317. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4318. if (groupInfo == null)
  4319. {
  4320. jw.Msg = "团组信息不存在!";
  4321. return Ok(jw);
  4322. }
  4323. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4324. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4325. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4326. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4327. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4328. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4329. try
  4330. {
  4331. if (!Directory.Exists(fileBase))
  4332. {
  4333. Directory.CreateDirectory(fileBase);
  4334. }
  4335. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4336. foreach (var fileStream in dto.Files)
  4337. {
  4338. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4339. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4340. {
  4341. Cid = dto.Cid,
  4342. CreateTime = DateTime.Now,
  4343. CreateUserId = dto.Userid,
  4344. Ctable = dto.Ctable,
  4345. Diid = dto.Diid,
  4346. IsDel = 0,
  4347. FilePath = saveFilePath,
  4348. FileName = fileStream.FileName
  4349. };
  4350. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4351. {
  4352. fileStream.CopyTo(fs);
  4353. fs.Flush();
  4354. }
  4355. saveArr.Add(file);
  4356. }
  4357. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4358. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4359. jw = JsonView(true, "保存成功!", new
  4360. {
  4361. count = addResult,
  4362. filesName = saveArr.Select(x => x.FileName)
  4363. });
  4364. }
  4365. catch (Exception ex)
  4366. {
  4367. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4368. {
  4369. count = 0,
  4370. filesName = new string[0],
  4371. });
  4372. }
  4373. return Ok(jw);
  4374. }
  4375. /// <summary>
  4376. /// 查询各模块已保存文件
  4377. /// </summary>
  4378. /// <param name="dto"></param>
  4379. /// <returns></returns>
  4380. [HttpPost]
  4381. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4382. {
  4383. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4384. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4385. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4386. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4387. {
  4388. expression = Expressionable.Create<Grp_GroupModelFile>()
  4389. .And(x => visaIds.Contains(x.CreateUserId));
  4390. }
  4391. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4392. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4393. .Where(expression.ToExpression())
  4394. .ToList();
  4395. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4396. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4397. {
  4398. x.FileName,
  4399. x.Id,
  4400. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4401. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4402. })));
  4403. }
  4404. /// <summary>
  4405. /// 下载该团组下的所有文件
  4406. /// </summary>
  4407. /// <param name="dto"></param>
  4408. /// <returns></returns>
  4409. [HttpPost]
  4410. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4411. {
  4412. var jw = JsonView(false);
  4413. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4414. if (groupInfo == null)
  4415. {
  4416. jw.Msg = "团组信息不存在!";
  4417. return Ok(jw);
  4418. }
  4419. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4420. var isModule = Convert.ToBoolean(dto.isModule);
  4421. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4422. IOOperatorHelper io = new IOOperatorHelper();
  4423. if (isModule)
  4424. {
  4425. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4426. foreach (var moduleArr in moduleGroup)
  4427. {
  4428. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4429. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4430. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4431. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4432. foreach (var item in moduleArr)
  4433. {
  4434. if (System.IO.File.Exists(item.FilePath))
  4435. {
  4436. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4437. {
  4438. byte[] bytes = new byte[fileStream.Length];
  4439. fileStream.Read(bytes, 0, bytes.Length);
  4440. fileStream.Close();
  4441. Stream stream = new MemoryStream(bytes);
  4442. chiZips.Add(item.FileName, stream);
  4443. }
  4444. }
  4445. }
  4446. if (chiZips.Count > 0)
  4447. {
  4448. var byts = io.ConvertZipStream(chiZips);
  4449. Stream stream = new MemoryStream(byts);
  4450. Zips.Add(key.Name + "_.zip", stream);
  4451. }
  4452. }
  4453. }
  4454. else
  4455. {
  4456. foreach (var item in dbQuery)
  4457. {
  4458. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4459. {
  4460. byte[] bytes = new byte[fileStream.Length];
  4461. fileStream.Read(bytes, 0, bytes.Length);
  4462. fileStream.Close();
  4463. Stream stream = new MemoryStream(bytes);
  4464. while (Zips.Keys.Contains(item.FileName))
  4465. {
  4466. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4467. }
  4468. Zips.Add(item.FileName, stream);
  4469. }
  4470. }
  4471. }
  4472. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4473. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4474. if (Zips.Count > 0)
  4475. {
  4476. var byts = io.ConvertZipStream(Zips);
  4477. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4478. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4479. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4480. }
  4481. else
  4482. {
  4483. jw.Msg = "暂无生成文件!";
  4484. }
  4485. return Ok(jw);
  4486. }
  4487. /// <summary>
  4488. /// 下载该团组下此模块的所有文件
  4489. /// </summary>
  4490. /// <param name="dto"></param>
  4491. /// <returns></returns>
  4492. [HttpPost]
  4493. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4494. {
  4495. var jw = JsonView(false);
  4496. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4497. if (groupInfo == null)
  4498. {
  4499. jw.Msg = "团组信息不存在!";
  4500. return Ok(jw);
  4501. }
  4502. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4503. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4504. && x.IsDel == 0);
  4505. if (key == null)
  4506. {
  4507. jw.Msg = "Ctable指向错误!";
  4508. return Ok(jw);
  4509. }
  4510. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4511. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4512. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4513. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4514. IOOperatorHelper io = new IOOperatorHelper();
  4515. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4516. foreach (var item in dbQuery)
  4517. {
  4518. if (System.IO.File.Exists(item.FilePath))
  4519. {
  4520. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4521. {
  4522. byte[] bytes = new byte[fileStream.Length];
  4523. fileStream.Read(bytes, 0, bytes.Length);
  4524. fileStream.Close();
  4525. Stream stream = new MemoryStream(bytes);
  4526. while (Zips.Keys.Contains(item.FileName))
  4527. {
  4528. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4529. }
  4530. Zips.Add(item.FileName, stream);
  4531. }
  4532. }
  4533. }
  4534. if (Zips.Count > 0)
  4535. {
  4536. var byts = io.ConvertZipStream(Zips);
  4537. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4538. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4539. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4540. }
  4541. else
  4542. {
  4543. jw.Msg = "暂无生成文件!";
  4544. }
  4545. return Ok(jw);
  4546. }
  4547. /// <summary>
  4548. /// 删除该团组下的指定文件
  4549. /// </summary>
  4550. /// <param name="dto"></param>
  4551. /// <returns></returns>
  4552. [HttpPost]
  4553. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4554. {
  4555. var jw = JsonView(false);
  4556. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4557. if (sing == null)
  4558. {
  4559. jw.Msg = "暂无";
  4560. return Ok(jw);
  4561. }
  4562. if (System.IO.File.Exists(sing.FilePath))
  4563. {
  4564. try
  4565. {
  4566. System.IO.File.Delete(sing.FilePath);
  4567. }
  4568. catch (Exception ex)
  4569. {
  4570. jw.Msg = "删除失败!" + ex.Message;
  4571. return Ok(jw);
  4572. }
  4573. }
  4574. sing.IsDel = 1;
  4575. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4576. sing.DeleteUserId = dto.UserId;
  4577. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4578. jw = JsonView(true, "删除成功!");
  4579. return Ok(jw);
  4580. }
  4581. #endregion
  4582. #region 团组英文资料
  4583. /// <summary>
  4584. /// 查询团组英文所有资料
  4585. /// </summary>
  4586. /// <param name="dto"></param>
  4587. /// <returns></returns>
  4588. [HttpPost]
  4589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4590. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4591. {
  4592. try
  4593. {
  4594. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4595. if (groupData.Code != 0)
  4596. {
  4597. return Ok(JsonView(false, groupData.Msg));
  4598. }
  4599. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4600. }
  4601. catch (Exception ex)
  4602. {
  4603. return Ok(JsonView(false, "程序错误!"));
  4604. throw;
  4605. }
  4606. }
  4607. /// <summary>
  4608. /// 团组英文资料操作(Status:1.新增,2.修改)
  4609. /// </summary>
  4610. /// <param name="dto"></param>
  4611. /// <returns></returns>
  4612. [HttpPost]
  4613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4614. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4615. {
  4616. try
  4617. {
  4618. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4619. if (groupData.Code != 0)
  4620. {
  4621. return Ok(JsonView(false, groupData.Msg));
  4622. }
  4623. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4624. }
  4625. catch (Exception ex)
  4626. {
  4627. return Ok(JsonView(false, "程序错误!"));
  4628. throw;
  4629. }
  4630. }
  4631. /// <summary>
  4632. /// 团组英文资料Id查询数据
  4633. /// </summary>
  4634. /// <param name="dto"></param>
  4635. /// <returns></returns>
  4636. [HttpPost]
  4637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4638. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4639. {
  4640. try
  4641. {
  4642. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4643. if (_DelegationEnData != null)
  4644. {
  4645. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4646. }
  4647. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4648. }
  4649. catch (Exception ex)
  4650. {
  4651. return Ok(JsonView(false, "程序错误!"));
  4652. throw;
  4653. }
  4654. }
  4655. /// <summary>
  4656. /// 团组英文资料删除
  4657. /// </summary>
  4658. /// <param name="dto"></param>
  4659. /// <returns></returns>
  4660. [HttpPost]
  4661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4662. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4663. {
  4664. try
  4665. {
  4666. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4667. if (!res)
  4668. {
  4669. return Ok(JsonView(false, "删除失败"));
  4670. }
  4671. return Ok(JsonView(true, "删除成功!"));
  4672. }
  4673. catch (Exception ex)
  4674. {
  4675. return Ok(JsonView(false, "程序错误!"));
  4676. throw;
  4677. }
  4678. }
  4679. #endregion
  4680. #region 导出邀请函
  4681. /// <summary>
  4682. /// 导出邀请函页面初始化
  4683. /// </summary>
  4684. /// <param name="dto"></param>
  4685. /// <returns></returns>
  4686. [HttpPost]
  4687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4688. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4689. {
  4690. try
  4691. {
  4692. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4693. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4694. if (dto.DiId == 0)
  4695. {
  4696. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4697. }
  4698. else
  4699. {
  4700. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4701. }
  4702. return Ok(JsonView(true, "查询成功!", new
  4703. {
  4704. deleClient = crm_Deles,
  4705. delegations = grp_Delegations
  4706. }));
  4707. }
  4708. catch (Exception ex)
  4709. {
  4710. return Ok(JsonView(false, "程序错误!"));
  4711. throw;
  4712. }
  4713. }
  4714. /// <summary>
  4715. /// 导出邀请函
  4716. /// </summary>
  4717. /// <param name="dto"></param>
  4718. /// <returns></returns>
  4719. [HttpPost]
  4720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4721. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4722. {
  4723. #region 参数验证
  4724. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4725. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4726. #endregion
  4727. try
  4728. {
  4729. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4730. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4731. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4732. From Grp_TourClientList tcl
  4733. Left Join
  4734. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4735. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4736. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4737. From Crm_DeleClient dc
  4738. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4739. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4740. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4741. Where dc.IsDel = 0) temp
  4742. On temp.DcId =tcl.ClientId
  4743. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4744. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4745. List<string> texts = new List<string>();
  4746. if (datas.Count != 0)
  4747. {
  4748. foreach (TourClientListDetailsView item in datas)
  4749. {
  4750. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4751. {
  4752. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4753. }
  4754. else
  4755. {
  4756. string name = item.LastName + item.FirstName;
  4757. texts.Add(name);
  4758. }
  4759. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4760. {
  4761. if (!transDic.ContainsKey(item.Job))
  4762. {
  4763. texts.Add(item.Job);
  4764. }
  4765. }
  4766. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4767. {
  4768. texts.Add(item.CompanyFullName);
  4769. }
  4770. }
  4771. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4772. if (transData.Count > 0)
  4773. {
  4774. foreach (TranslateResult item in transData)
  4775. {
  4776. if (!transDic.ContainsKey(item.Query))
  4777. {
  4778. transDic.Add(item.Query, item.Translation);
  4779. }
  4780. }
  4781. }
  4782. List<GuestList> list = new List<GuestList>();
  4783. foreach (TourClientListDetailsView dele in datas)
  4784. {
  4785. GuestList guestList = new GuestList();
  4786. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4787. {
  4788. guestList.Name = dele.Pinyin;
  4789. }
  4790. else
  4791. {
  4792. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4793. guestList.Name = Name;
  4794. }
  4795. if (dele.Sex == 0)
  4796. {
  4797. guestList.Sex = "Male";
  4798. }
  4799. else if (dele.Sex == 1)
  4800. {
  4801. guestList.Sex = "Female";
  4802. }
  4803. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4804. if (!string.IsNullOrEmpty(dele.Job))
  4805. {
  4806. guestList.Job = dele.Job;
  4807. }
  4808. list.Add(guestList);
  4809. }
  4810. //载入模板
  4811. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4812. DocumentBuilder builder = new DocumentBuilder(doc);
  4813. //获取word里所有表格
  4814. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4815. //获取所填表格的序数
  4816. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4817. var rowStart = tableOne.Rows[0]; //获取第1行
  4818. //循环赋值
  4819. for (int i = 0; i < list.Count; i++)
  4820. {
  4821. builder.MoveToCell(0, i + 1, 0, 0);
  4822. builder.Write(list[i].Name.ToString());
  4823. builder.MoveToCell(0, i + 1, 1, 0);
  4824. builder.Write(list[i].Sex.ToString());
  4825. builder.MoveToCell(0, i + 1, 2, 0);
  4826. builder.Write(list[i].DOB.ToString());
  4827. builder.MoveToCell(0, i + 1, 3, 0);
  4828. builder.Write(list[i].Job.ToString());
  4829. }
  4830. //删除多余行
  4831. while (tableOne.Rows.Count > list.Count + 1)
  4832. {
  4833. tableOne.Rows.RemoveAt(list.Count + 1);
  4834. }
  4835. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4836. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4837. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4838. doc.Save(filePath);
  4839. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4840. return Ok(JsonView(true, "操作成功!", Url));
  4841. }
  4842. else
  4843. {
  4844. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4845. }
  4846. }
  4847. catch (Exception ex)
  4848. {
  4849. return Ok(JsonView(false, ex.Message));
  4850. throw;
  4851. }
  4852. }
  4853. #endregion
  4854. #region 团组经理模块 出入境费用
  4855. /// <summary>
  4856. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4857. /// </summary>
  4858. /// <returns></returns>
  4859. [HttpPost]
  4860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4861. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4862. {
  4863. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4864. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4865. //SetDataInfoView
  4866. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4867. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4868. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4869. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4870. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4871. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4872. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4873. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4874. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4875. return Ok(JsonView(true, "查询成功!", new
  4876. {
  4877. GroupNameData = groupNameData.Data,
  4878. CurrencyData = _CurrencyData,
  4879. WordTypeData = _WordTypeData,
  4880. ExcelTypeData = _ExcelTypeData,
  4881. CurrencyInit = _currencyInfos,
  4882. ViewPermissionData = viewPermissionData
  4883. }));
  4884. }
  4885. /// <summary>
  4886. /// 团组模块 - 出入境费用
  4887. /// 实时汇率 tips
  4888. /// 签证费用 tips
  4889. /// 机票费用 tips
  4890. /// </summary>
  4891. /// <returns></returns>
  4892. [HttpPost]
  4893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4894. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4895. {
  4896. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4897. //默认币种显示
  4898. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4899. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4900. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4901. return Ok(JsonView(true, "查询成功!", new
  4902. {
  4903. //GroupNameData = groupNameData.Data,
  4904. visaData = visaData.Data,
  4905. airData = airData.Data,
  4906. reteInfos = reteInfos
  4907. }));
  4908. }
  4909. /// <summary>
  4910. /// 团组模块 - 出入境费用 - Info
  4911. /// </summary>
  4912. /// <returns></returns>
  4913. [HttpPost]
  4914. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4916. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4917. {
  4918. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4919. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4920. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4921. }
  4922. /// <summary>
  4923. /// 团组模块 - 出入境费用 - 设置view权限
  4924. /// </summary>
  4925. /// <returns></returns>
  4926. [HttpPost]
  4927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4928. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4929. {
  4930. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4931. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4932. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4933. var permissions = new List<Grp_EnterExitCostPermission>();
  4934. foreach (var userId in dto.UserIds)
  4935. {
  4936. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4937. }
  4938. if (permissions.Any())
  4939. {
  4940. _sqlSugar.BeginTran();
  4941. try
  4942. {
  4943. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4944. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4945. if (result < 1)
  4946. {
  4947. _sqlSugar.RollbackTran();
  4948. return Ok(JsonView(false));
  4949. }
  4950. }
  4951. catch (Exception ex)
  4952. {
  4953. _sqlSugar.RollbackTran();
  4954. return Ok(JsonView(false, ex.Message));
  4955. }
  4956. _sqlSugar.CommitTran();
  4957. return Ok(JsonView(true));
  4958. }
  4959. return Ok(JsonView(false));
  4960. }
  4961. /// <summary>
  4962. /// 团组模块 - 出入境费用 - Add And Update
  4963. /// </summary>
  4964. /// <returns></returns>
  4965. [HttpPost]
  4966. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  4967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4968. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4969. {
  4970. try
  4971. {
  4972. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4973. if (dto.DayOtherPriceData.Any())
  4974. {
  4975. var inserList = dto.DayOtherPriceData
  4976. .Where(x => x.Id == 0)
  4977. .Select(x => new Grp_DayOtherPrice
  4978. {
  4979. Cost = x.Cost,
  4980. Id = x.Id,
  4981. CreateTime = DateTime.Now,
  4982. CreateUserId = dto.UserId,
  4983. Currency = x.Currency,
  4984. Diid = x.DiId,
  4985. Index = x.Index,
  4986. IsDel = 0,
  4987. SetDataId = x.SetDataId,
  4988. SubTotal = x.SubTotal,
  4989. Remark = x.Remark
  4990. })
  4991. .ToList();
  4992. var updateList = dto.DayOtherPriceData
  4993. .Where(x => x.Id != 0)
  4994. .Select(x => new Grp_DayOtherPrice
  4995. {
  4996. Cost = x.Cost,
  4997. Id = x.Id,
  4998. CreateTime = DateTime.Now,
  4999. CreateUserId = dto.UserId,
  5000. Currency = x.Currency,
  5001. Diid = x.DiId,
  5002. Index = x.Index,
  5003. IsDel = 0,
  5004. SetDataId = x.SetDataId,
  5005. SubTotal = x.SubTotal,
  5006. Remark = x.Remark
  5007. })
  5008. .ToList();
  5009. //添加
  5010. _sqlSugar.BeginTran();
  5011. if (inserList.Any())
  5012. {
  5013. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5014. }
  5015. if (updateList.Any())
  5016. {
  5017. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5018. }
  5019. _sqlSugar.CommitTran();
  5020. }
  5021. if (data.Code != 0)
  5022. {
  5023. return Ok(JsonView(false, data.Msg));
  5024. }
  5025. //生成默认文件pdf并且通知人员
  5026. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5027. {
  5028. DiId = dto.DiId,
  5029. ExportType = 1,
  5030. SubTypeId = 1005
  5031. }, "pdf");
  5032. //发送通知
  5033. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5034. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5035. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5036. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5037. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5038. //汇率信息记录
  5039. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5040. return Ok(JsonView(true, data.Msg, data.Data));
  5041. }
  5042. catch (Exception ex)
  5043. {
  5044. return Ok(JsonView(false, ex.Message));
  5045. }
  5046. }
  5047. /// <summary>
  5048. /// 团组模块 - 出入境费用 - Confirm 费用
  5049. /// </summary>
  5050. /// <returns></returns>
  5051. [HttpPost]
  5052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5053. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5054. {
  5055. //TODO:测试完毕需把对应的用户ID更改
  5056. //1、数据表添加字段
  5057. //2、更改字段接口()
  5058. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5059. //3、确认成功 给财务发送消息
  5060. if (_view.Code == 200)
  5061. {
  5062. if (dto.Type == 1)
  5063. {
  5064. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5065. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5066. }
  5067. }
  5068. return Ok(_view);
  5069. }
  5070. /// <summary>
  5071. /// 团组模块 - 出入境费用 - File download
  5072. /// </summary>
  5073. /// <param name="dto"></param>
  5074. /// <returns></returns>
  5075. [HttpPost]
  5076. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5078. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5079. {
  5080. try
  5081. {
  5082. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5083. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5084. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5085. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5086. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5087. 3 团组成员名单 1 团组成员名单", ""));
  5088. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5089. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5090. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5091. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5092. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5093. //数据源
  5094. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5095. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5096. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5097. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5098. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5099. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5100. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5101. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5102. .Select((x, a, b) => new
  5103. {
  5104. x.Index,
  5105. itemName = a.Name,
  5106. CurrencyStr = b.Name,
  5107. x.Cost,
  5108. x.SubTotal,
  5109. x.Remark
  5110. })
  5111. .OrderBy((x) => x.Index)
  5112. .ToList(); //其他款项费用
  5113. var peiceItemCurrencys = new List<string>();
  5114. if (_DayAndCosts.Any())
  5115. {
  5116. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5117. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5118. }
  5119. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5120. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5121. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5122. {
  5123. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5124. }
  5125. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5126. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5127. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5128. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5129. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5130. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5131. .Select((tcl, dc, cc) => new ClientInfo
  5132. {
  5133. LastName = dc.LastName,
  5134. FirstName = dc.FirstName,
  5135. Sex = dc.Sex,
  5136. Birthday = dc.BirthDay,
  5137. Company = cc.CompanyFullName,
  5138. Job = dc.Job
  5139. })
  5140. .ToList();
  5141. foreach (var item in DeleClientList)
  5142. {
  5143. EncryptionProcessor.DecryptProperties(item);
  5144. }
  5145. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5146. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5147. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5148. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5149. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5150. if (dto.ExportType == 1) //明细表
  5151. {
  5152. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5153. {
  5154. //获取模板
  5155. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5156. //载入模板
  5157. Document doc = new Document(tempPath);
  5158. DocumentBuilder builder = new DocumentBuilder(doc);
  5159. //利用键值对存放数据
  5160. Dictionary<string, string> dic = new Dictionary<string, string>();
  5161. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5162. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5163. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5164. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5165. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5166. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5167. //境内费用(其他费用)
  5168. if (_EnterExitCosts.ChoiceOne == 1)
  5169. {
  5170. string row1_1 = "";
  5171. if (_EnterExitCosts.Visa > 0)
  5172. {
  5173. //insidePayTotal += _EnterExitCosts.Visa;
  5174. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5175. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5176. {
  5177. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5178. }
  5179. }
  5180. string row1_2 = "";
  5181. if (_EnterExitCosts.YiMiao > 0)
  5182. {
  5183. //insidePayTotal += _EnterExitCosts.YiMiao;
  5184. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5185. }
  5186. if (_EnterExitCosts.HeSuan > 0)
  5187. {
  5188. //insidePayTotal += _EnterExitCosts.HeSuan;
  5189. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5190. }
  5191. if (_EnterExitCosts.Service > 0)
  5192. {
  5193. //insidePayTotal += _EnterExitCosts.Service;
  5194. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5195. }
  5196. string row1_3 = "";
  5197. if (_EnterExitCosts.Safe > 0)
  5198. {
  5199. //insidePayTotal += _EnterExitCosts.Safe;
  5200. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5201. }
  5202. if (_EnterExitCosts.Ticket > 0)
  5203. {
  5204. //insidePayTotal += _EnterExitCosts.Ticket;
  5205. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5206. }
  5207. string row1 = "";
  5208. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5209. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5210. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5211. row1 += $"备注:{_EnterExitCosts.Remark}";
  5212. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5213. dic.Add("Row1Str", row1);
  5214. }
  5215. string airTotalStr = string.Empty,
  5216. airPriceStr = string.Empty;
  5217. //经济舱
  5218. if (_EnterExitCosts.SumJJC == 1)
  5219. {
  5220. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5221. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5222. }
  5223. //公务舱
  5224. if (_EnterExitCosts.SumGWC == 1)
  5225. {
  5226. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5227. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5228. }
  5229. //头等舱
  5230. if (_EnterExitCosts.SumTDC == 1)
  5231. {
  5232. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5233. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5234. }
  5235. //汇率描述
  5236. string rateStr = "";
  5237. if (peiceItemCurrencyInfos.Any())
  5238. {
  5239. rateStr = "\r\n汇率描述:";
  5240. foreach (var item in peiceItemCurrencyInfos)
  5241. {
  5242. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5243. }
  5244. }
  5245. string twoItemRemark = "备注:";
  5246. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5247. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5248. dic.Add("AirTotalStr", airTotalStr);
  5249. dic.Add("AirPriceStr", airPriceStr);
  5250. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5251. dic.Add("TwoItemRemark", twoItemRemark);
  5252. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5253. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5254. int table1Row = 0,
  5255. table2Row = 0,
  5256. table3Row = 0,
  5257. table4Row = 0,
  5258. table5Row = 0;
  5259. //住宿费
  5260. if (_EnterExitCosts.ChoiceThree == 1)
  5261. {
  5262. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5263. table1Row = dac1.Count;
  5264. #region 填充word表格内容
  5265. for (int i = 0; i < dac1.Count; i++)
  5266. {
  5267. Grp_DayAndCost dac = dac1[i];
  5268. if (dac == null) continue;
  5269. builder.MoveToCell(0, i, 0, 0);
  5270. builder.Write("第" + dac.Days.ToString() + "晚:");
  5271. builder.MoveToCell(0, i, 1, 0);
  5272. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5273. //builder.Write(dac.Place == null ? "" : dac.Place);
  5274. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5275. builder.MoveToCell(0, i, 2, 0);
  5276. builder.Write("费用标准:");
  5277. string curr = "";
  5278. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5279. if (currData != null)
  5280. {
  5281. curr = currData.Name;
  5282. }
  5283. builder.MoveToCell(0, i, 3, 0);
  5284. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5285. builder.MoveToCell(0, i, 4, 0);
  5286. builder.Write("费用小计:");
  5287. builder.MoveToCell(0, i, 5, 0);
  5288. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5289. }
  5290. #endregion
  5291. }
  5292. else dic.Add("SubZS", "0.00");
  5293. //删除多余行
  5294. while (table1.Rows.Count > table1Row)
  5295. {
  5296. table1.Rows.RemoveAt(table1Row);
  5297. }
  5298. //伙食费
  5299. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5300. if (_EnterExitCosts.ChoiceFour == 1)
  5301. {
  5302. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5303. table2Row = dac2.Count;
  5304. #region 填充word表格内容
  5305. for (int i = 0; i < dac2.Count; i++)
  5306. {
  5307. Grp_DayAndCost dac = dac2[i];
  5308. if (dac == null) continue;
  5309. builder.MoveToCell(1, i, 0, 0);
  5310. builder.Write("第" + dac.Days.ToString() + "天:");
  5311. builder.MoveToCell(1, i, 1, 0);
  5312. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5313. builder.MoveToCell(1, i, 2, 0);
  5314. builder.Write("费用标准:");
  5315. string curr = "";
  5316. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5317. if (currData != null)
  5318. {
  5319. curr = currData.Name;
  5320. }
  5321. builder.MoveToCell(1, i, 3, 0);
  5322. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5323. builder.MoveToCell(1, i, 4, 0);
  5324. builder.Write("费用小计:");
  5325. builder.MoveToCell(1, i, 5, 0);
  5326. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5327. }
  5328. #endregion
  5329. }
  5330. else dic.Add("SubHS", "0.00");
  5331. //删除多余行
  5332. while (table2.Rows.Count > table2Row)
  5333. {
  5334. table2.Rows.RemoveAt(table2Row);
  5335. }
  5336. //公杂费
  5337. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5338. if (_EnterExitCosts.ChoiceFive == 1)
  5339. {
  5340. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5341. table3Row = dac3.Count;
  5342. #region 填充word表格内容
  5343. for (int i = 0; i < dac3.Count; i++)
  5344. {
  5345. Grp_DayAndCost dac = dac3[i];
  5346. if (dac == null) continue;
  5347. builder.MoveToCell(2, i, 0, 0);
  5348. builder.Write("第" + dac.Days.ToString() + "天:");
  5349. builder.MoveToCell(2, i, 1, 0);
  5350. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5351. builder.MoveToCell(2, i, 2, 0);
  5352. builder.Write("费用标准:");
  5353. string curr = "";
  5354. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5355. if (currData != null)
  5356. {
  5357. curr = currData.Name;
  5358. }
  5359. builder.MoveToCell(2, i, 3, 0);
  5360. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5361. builder.MoveToCell(2, i, 4, 0);
  5362. builder.Write("费用小计:");
  5363. builder.MoveToCell(2, i, 5, 0);
  5364. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5365. }
  5366. //删除多余行
  5367. while (table3.Rows.Count > table3Row)
  5368. {
  5369. table3.Rows.RemoveAt(table3Row);
  5370. }
  5371. #endregion
  5372. }
  5373. else dic.Add("SubGZF", "0.00");
  5374. //删除多余行
  5375. while (table3.Rows.Count > table3Row)
  5376. {
  5377. table3.Rows.RemoveAt(table3Row);
  5378. }
  5379. //培训费
  5380. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5381. if (_EnterExitCosts.ChoiceSix == 1)
  5382. {
  5383. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5384. dic.Add("SubPX", pxStr);
  5385. table4Row = dac4.Count;
  5386. #region 填充word表格内容
  5387. for (int i = 0; i < dac4.Count; i++)
  5388. {
  5389. Grp_DayAndCost dac = dac4[i];
  5390. if (dac == null) continue;
  5391. builder.MoveToCell(3, i, 0, 0);
  5392. builder.Write("第" + dac.Days.ToString() + "天:");
  5393. builder.MoveToCell(3, i, 1, 0);
  5394. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5395. builder.MoveToCell(3, i, 2, 0);
  5396. builder.Write("费用标准:");
  5397. string curr = "";
  5398. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5399. if (currData != null)
  5400. {
  5401. curr = currData.Name;
  5402. }
  5403. builder.MoveToCell(3, i, 3, 0);
  5404. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5405. builder.MoveToCell(3, i, 4, 0);
  5406. builder.Write("费用小计:");
  5407. builder.MoveToCell(3, i, 5, 0);
  5408. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5409. }
  5410. #endregion
  5411. }
  5412. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5413. //删除多余行
  5414. while (table4.Rows.Count > table4Row)
  5415. {
  5416. table4.Rows.RemoveAt(table4Row);
  5417. }
  5418. //其他费用
  5419. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5420. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5421. {
  5422. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5423. dic.Add("titleQi", qtStr);
  5424. table5Row = dac5.Count;
  5425. #region 填充word表格内容
  5426. for (int i = 0; i < dac5.Count; i++)
  5427. {
  5428. var dac = dac5[i];
  5429. if (dac == null) continue;
  5430. builder.MoveToCell(4, i, 0, 0);
  5431. builder.Write("第" + dac.Index.ToString() + "项:");
  5432. builder.MoveToCell(4, i, 1, 0);
  5433. builder.Write(dac.itemName);
  5434. builder.MoveToCell(4, i, 2, 0);
  5435. builder.Write("费用标准:");
  5436. builder.MoveToCell(4, i, 3, 0);
  5437. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5438. builder.MoveToCell(4, i, 4, 0);
  5439. builder.Write("费用小计:");
  5440. builder.MoveToCell(4, i, 5, 0);
  5441. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5442. builder.MoveToCell(4, i, 6, 0);
  5443. builder.Write("备注:");
  5444. builder.MoveToCell(4, i, 7, 0);
  5445. builder.Write(dac.Remark);
  5446. }
  5447. #endregion
  5448. }
  5449. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5450. //删除多余行
  5451. while (table5.Rows.Count > table5Row)
  5452. {
  5453. table5.Rows.RemoveAt(table5Row);
  5454. }
  5455. //加上其他费用
  5456. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5457. decimal subJJC = 0.00M,
  5458. subGWC = 0.00M,
  5459. subTDC = 0.00M;
  5460. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5461. string totalLabel = string.Format("全部费用总计:");
  5462. //经济舱
  5463. if (_EnterExitCosts.SumJJC == 1)
  5464. {
  5465. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5466. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5467. }
  5468. //公务舱
  5469. if (_EnterExitCosts.SumGWC == 1)
  5470. {
  5471. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5472. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5473. }
  5474. //头等舱
  5475. if (_EnterExitCosts.SumTDC == 1)
  5476. {
  5477. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5478. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5479. }
  5480. //TotalLabel
  5481. dic.Add("TotalLabel", totalLabel);
  5482. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5483. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5484. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5485. #region 填充word模板书签内容
  5486. foreach (var key in dic.Keys)
  5487. {
  5488. Bookmark bookmark = doc.Range.Bookmarks[key];
  5489. if (bookmark != null)
  5490. {
  5491. builder.MoveToBookmark(key);
  5492. builder.Write(dic[key]);
  5493. }
  5494. }
  5495. #endregion
  5496. #region 设置页眉
  5497. string userLabel = string.Empty;
  5498. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5499. if (currUserInfo != null)
  5500. {
  5501. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5502. if (userInfo != null)
  5503. {
  5504. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5505. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5506. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5507. }
  5508. }
  5509. //设置页脚
  5510. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5511. #endregion
  5512. //文件名
  5513. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5514. AsposeHelper.removewatermark_v2180();
  5515. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5516. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5517. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5518. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5519. }
  5520. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5521. {
  5522. //获取模板
  5523. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5524. //载入模板
  5525. Document doc = new Document(tempPath);
  5526. DocumentBuilder builder = new DocumentBuilder(doc);
  5527. Dictionary<string, string> dic = new Dictionary<string, string>();
  5528. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5529. {
  5530. List<string> list = new List<string>();
  5531. try
  5532. {
  5533. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5534. foreach (var item in spilitArr)
  5535. {
  5536. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5537. var depCode = spDotandEmpty[2].Substring(0, 3);
  5538. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5539. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5540. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5541. list.Add(depName);
  5542. list.Add(arrName);
  5543. }
  5544. list = list.Distinct().ToList();
  5545. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5546. }
  5547. catch (Exception)
  5548. {
  5549. dic.Add("ReturnCode", "行程录入不正确!");
  5550. }
  5551. }
  5552. else
  5553. {
  5554. dic.Add("ReturnCode", "未录入行程!");
  5555. }
  5556. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5557. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5558. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5559. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5560. {
  5561. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5562. dic.Add("Day", sp.Days.ToString());
  5563. }
  5564. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5565. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5566. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5567. //dic.Add("Names", Names);
  5568. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5569. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5570. decimal dac1totalPrice = 0.00M;
  5571. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5572. foreach (var dac in dac1)
  5573. {
  5574. if (dac.SubTotal == 0.00M)
  5575. {
  5576. continue;
  5577. }
  5578. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5579. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5580. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5581. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5582. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5583. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5584. builder.Write(currency);//币种
  5585. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5586. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5587. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5588. builder.Write("");//人数
  5589. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5590. builder.Write("");//天数
  5591. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5592. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5593. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5594. decimal rate = 0.00M;
  5595. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5596. builder.Write(rate.ToString("#0.0000"));//汇率
  5597. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5598. decimal rbmPrice = dac.SubTotal;
  5599. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5600. accommodationStartIndex++;
  5601. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5602. }
  5603. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5604. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5605. {
  5606. table1.Rows.RemoveAt(i - 1);
  5607. foodandotherStartIndex--;
  5608. }
  5609. if (dac2.Count == dac3.Count)//国家 币种 金额
  5610. {
  5611. for (int i = 0; i < dac2.Count; i++)
  5612. {
  5613. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5614. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5615. }
  5616. }
  5617. decimal dac2totalPrice = 0.00M;
  5618. foreach (var dac in dac2)
  5619. {
  5620. if (dac.SubTotal == 0)
  5621. {
  5622. continue;
  5623. }
  5624. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5625. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5626. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5627. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5628. builder.Write(currency);//币种
  5629. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5630. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5631. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5632. builder.Write("");//人数
  5633. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5634. builder.Write("");//天数
  5635. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5636. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5637. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5638. decimal rate = 0.00M;
  5639. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5640. builder.Write(rate.ToString("#0.0000"));//汇率
  5641. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5642. decimal rbmPrice = dac.SubTotal;
  5643. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5644. foodandotherStartIndex++;
  5645. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5646. }
  5647. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5648. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5649. {
  5650. table1.Rows.RemoveAt(i - 1);
  5651. }
  5652. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5653. string otherFeeStr = "";
  5654. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5655. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5656. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5657. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5658. foreach (var otherInfo in dac5)
  5659. {
  5660. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5661. }
  5662. #endregion
  5663. if (otherFeeStr.Length > 0)
  5664. {
  5665. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5666. otherFeeStr = $"({otherFeeStr})";
  5667. dic.Add("OtherFeeStr", otherFeeStr);
  5668. }
  5669. //总计
  5670. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5671. //国际旅费
  5672. string outsideAir = string.Empty;
  5673. string allPriceAir = string.Empty;
  5674. if (_EnterExitCosts.SumJJC == 1)
  5675. {
  5676. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5677. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5678. }
  5679. if (_EnterExitCosts.SumGWC == 1)
  5680. {
  5681. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5682. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5683. }
  5684. if (_EnterExitCosts.SumTDC == 1)
  5685. {
  5686. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5687. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5688. }
  5689. dic.Add("InTravelPrice", $"({outsideAir})");
  5690. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5691. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5692. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5693. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5694. foreach (var key in dic.Keys)
  5695. {
  5696. builder.MoveToBookmark(key);
  5697. builder.Write(dic[key]);
  5698. }
  5699. //模板文件名
  5700. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5701. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5702. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5703. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5704. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5705. }
  5706. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5707. {
  5708. //获取模板
  5709. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5710. //载入模板
  5711. WorkbookDesigner designer = new WorkbookDesigner();
  5712. designer.Workbook = new Workbook(tempPath);
  5713. Dictionary<string, string> dic = new Dictionary<string, string>();
  5714. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5715. {
  5716. List<string> list = new List<string>();
  5717. try
  5718. {
  5719. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5720. foreach (var item in spilitArr)
  5721. {
  5722. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5723. var depCode = spDotandEmpty[2].Substring(0, 3);
  5724. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5725. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5726. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5727. list.Add(depName);
  5728. list.Add(arrName);
  5729. }
  5730. list = list.Distinct().ToList();
  5731. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5732. }
  5733. catch (Exception)
  5734. {
  5735. dic.Add("ReturnCode", "行程录入不正确!");
  5736. }
  5737. }
  5738. else
  5739. {
  5740. dic.Add("ReturnCode", "未录入行程!");
  5741. }
  5742. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5743. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5744. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5745. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5746. {
  5747. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5748. dic.Add("Day", sp.Days.ToString());
  5749. }
  5750. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5751. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5752. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5753. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5754. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5755. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5756. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5757. designer.SetDataSource("Name", Names);
  5758. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5759. designer.SetDataSource("Day", dic["Day"] + "天");
  5760. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5761. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5762. int startIndex = 10;
  5763. const int startIndexcopy = 10;
  5764. if (dac2.Count == dac3.Count)//国家 币种 金额
  5765. {
  5766. for (int i = 0; i < dac2.Count; i++)
  5767. {
  5768. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5769. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5770. }
  5771. }
  5772. DataTable dtdac1 = new DataTable();
  5773. List<string> place = new List<string>();
  5774. dtdac1.Columns.AddRange(new DataColumn[] {
  5775. new DataColumn(){ ColumnName = "city"},
  5776. new DataColumn(){ ColumnName = "curr"},
  5777. new DataColumn(){ ColumnName = "criterion"},
  5778. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5779. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5780. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5781. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5782. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5783. });
  5784. DataTable dtdac2 = new DataTable();
  5785. dtdac2.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. dtdac1.TableName = "tb1";
  5796. dtdac2.TableName = "tb2";
  5797. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5798. foreach (var item in dac1)
  5799. {
  5800. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5801. if (place.Contains(item.Place))
  5802. {
  5803. continue;
  5804. }
  5805. DataRow row = dtdac1.NewRow();
  5806. row["city"] = item.Place;
  5807. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5808. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5809. row["curr"] = currency;
  5810. row["rate"] = rate.ToString("#0.0000");
  5811. row["criterion"] = item.Cost.ToString("#0.00");
  5812. row["number"] = 1;
  5813. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5814. //row["costRMB"] = rbmPrice;
  5815. dtdac1.Rows.Add(row);
  5816. place.Add(item.Place);
  5817. }
  5818. place = new List<string>();
  5819. foreach (var item in dac2)
  5820. {
  5821. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5822. if (place.Contains(item.Place))
  5823. {
  5824. continue;
  5825. }
  5826. DataRow row = dtdac2.NewRow();
  5827. row["city"] = item.Place;
  5828. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5829. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5830. row["curr"] = currency;
  5831. row["rate"] = rate.ToString("#0.0000");
  5832. row["criterion"] = item.Cost.ToString("#0.00");
  5833. row["number"] = 1;
  5834. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5835. //row["cost"] = item.SubTotal;
  5836. //row["costRMB"] = rbmPrice;
  5837. dtdac2.Rows.Add(row);
  5838. place.Add(item.Place);
  5839. //dac2totalPrice += rbmPrice;
  5840. }
  5841. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5842. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5843. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5844. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5845. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5846. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5847. string cell4Str1 = string.Empty;
  5848. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5849. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5850. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5851. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5852. string cellStr = $" 5.其他费用(";
  5853. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5854. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5855. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5856. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5857. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5858. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5859. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5860. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5861. foreach (var otherInfo in dac5)
  5862. {
  5863. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5864. }
  5865. #endregion
  5866. if (cellStr.Length > 8)
  5867. {
  5868. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5869. }
  5870. cellStr += ")";
  5871. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5872. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5873. decimal pxFee = dac4.Sum(it => it.Cost);
  5874. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5875. string celllastStr1 = "";
  5876. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5877. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5878. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5879. celllastStr1 += $",国际旅费 元";
  5880. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5881. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5882. designer.SetDataSource("cell4Str", cell4Str);
  5883. designer.SetDataSource("cellStr", cellStr);
  5884. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5885. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5886. designer.SetDataSource("celllastStr", celllastStr);
  5887. Workbook wb = designer.Workbook;
  5888. var sheet = wb.Worksheets[0];
  5889. //绑定datatable数据集
  5890. designer.SetDataSource(dtdac1);
  5891. designer.SetDataSource(dtdac2);
  5892. designer.Process();
  5893. var rowStart = dtdac1.Rows.Count;
  5894. while (rowStart > 0)
  5895. {
  5896. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5897. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5898. startIndex++;
  5899. rowStart--;
  5900. }
  5901. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5902. startIndex += 1; //总计行
  5903. rowStart = dtdac2.Rows.Count;
  5904. while (rowStart > 0)
  5905. {
  5906. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5907. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5908. startIndex++;
  5909. rowStart--;
  5910. }
  5911. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5912. wb.CalculateFormula(true);
  5913. //模板文件名
  5914. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5915. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5916. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5917. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5918. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5919. }
  5920. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5921. {
  5922. //获取模板
  5923. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5924. //载入模板
  5925. Document doc = new Document(tempPath);
  5926. DocumentBuilder builder = new DocumentBuilder(doc);
  5927. Dictionary<string, string> dic = new Dictionary<string, string>();
  5928. dic.Add("GroupName", _DelegationInfo.TeamName);
  5929. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5930. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5931. string missionLeaderJob = "";//负责人job
  5932. //int groupNumber = 0; //团人数
  5933. if (DeleClientList.Count > 0)
  5934. {
  5935. missionLeader = DeleClientList[0]?.Name ?? "";
  5936. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5937. }
  5938. dic.Add("MissionLeader", missionLeader); //团负责人
  5939. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5940. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5941. #region MyRegion
  5942. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5943. //{
  5944. // List<string> list = new List<string>();
  5945. // try
  5946. // {
  5947. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5948. // foreach (var item in spilitArr)
  5949. // {
  5950. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5951. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5952. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5953. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5954. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5955. // list.Add(depName);
  5956. // list.Add(arrName);
  5957. // }
  5958. // list = list.Distinct().ToList();
  5959. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5960. // }
  5961. // catch (Exception)
  5962. // {
  5963. // dic.Add("ReturnCode", "行程录入不正确!");
  5964. // }
  5965. //}
  5966. //else
  5967. //{
  5968. // dic.Add("ReturnCode", "未录入行程!");
  5969. //}
  5970. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5971. dic.Add("ReturnCode", string.Join("、", countrys));
  5972. #endregion
  5973. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5974. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5975. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5976. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5977. //{
  5978. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5979. // dic.Add("Day", sp.Days.ToString());
  5980. //}
  5981. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5982. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5983. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5984. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5985. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5986. //培训人员名单
  5987. int cultivateRowIndex = 7;
  5988. foreach (var item in DeleClientList)
  5989. {
  5990. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5991. builder.Write(item.Name);
  5992. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5993. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5994. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5995. string birthDay = "";
  5996. if (item.Birthday != null)
  5997. {
  5998. DateTime dt = Convert.ToDateTime(item.Birthday);
  5999. birthDay = $"{dt.Year}.{dt.Month}";
  6000. }
  6001. builder.Write(birthDay);
  6002. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6003. builder.Write(item.Company);
  6004. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6005. builder.Write(item.Job);
  6006. cultivateRowIndex++;
  6007. }
  6008. //删除多余行
  6009. //cultivateRowIndex -= 2;
  6010. int delRows = 10 + 7 - cultivateRowIndex;
  6011. if (delRows > 0)
  6012. {
  6013. for (int i = 0; i < delRows; i++)
  6014. {
  6015. table1.Rows.RemoveAt(cultivateRowIndex);
  6016. //cultivateRowIndex++;
  6017. }
  6018. }
  6019. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6020. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6021. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6022. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6023. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6024. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6025. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6026. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6027. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6028. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6029. //其他费用
  6030. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6031. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6032. //其他费用合计
  6033. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6034. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6035. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6036. //公务舱合计
  6037. //国际旅费
  6038. //string outsideJJ = "";
  6039. //string allPriceJJ = "";
  6040. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6041. {
  6042. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6043. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6044. }
  6045. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6046. {
  6047. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6048. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6049. }
  6050. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6051. {
  6052. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6053. dic.Add("AirFeeTotal", airFeeTotalStr);
  6054. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6055. dic.Add("FeeTotal", feeTotalStr);
  6056. }
  6057. foreach (var key in dic.Keys)
  6058. {
  6059. builder.MoveToBookmark(key);
  6060. builder.Write(dic[key]);
  6061. }
  6062. //模板文件名
  6063. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6064. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6065. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6066. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6067. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6068. }
  6069. }
  6070. else if (dto.ExportType == 2) //表格
  6071. {
  6072. //利用键值对存放数据
  6073. Dictionary<string, string> dic = new Dictionary<string, string>();
  6074. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6075. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6076. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6077. dic.Add("Day", sp.Days.ToString());
  6078. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6079. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6080. {
  6081. //获取模板
  6082. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6083. //载入模板
  6084. Document doc = new Document(tempPath);
  6085. DocumentBuilder builder = new DocumentBuilder(doc);
  6086. dic.Add("TeamName", _DelegationInfo.TeamName);
  6087. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6088. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6089. string missionLeaderName = "",
  6090. missionLeaderJob = "";
  6091. if (DeleClientList.Count > 0)
  6092. {
  6093. missionLeaderName = DeleClientList[0].Name;
  6094. missionLeaderJob = DeleClientList[0].Job;
  6095. }
  6096. dic.Add("MissionLeaderName", missionLeaderName);
  6097. dic.Add("MissionLeaderJob", missionLeaderJob);
  6098. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6099. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6100. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6101. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6102. int rowCount = 10;//总人数行
  6103. int startRowIndex = 7; //起始行
  6104. for (int i = 0; i < DeleClientList.Count; i++)
  6105. {
  6106. builder.MoveToCell(0, startRowIndex, 0, 0);
  6107. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6108. builder.MoveToCell(0, startRowIndex, 1, 0);
  6109. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6110. builder.Write(sex);//性别
  6111. builder.MoveToCell(0, startRowIndex, 2, 0);
  6112. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6113. builder.MoveToCell(0, startRowIndex, 3, 0);
  6114. builder.Write(DeleClientList[i].Company);//工作单位
  6115. builder.MoveToCell(0, startRowIndex, 4, 0);
  6116. builder.Write(DeleClientList[i].Job);//职务及级别
  6117. builder.MoveToCell(0, startRowIndex, 5, 0);
  6118. builder.Write("");//人员属性
  6119. builder.MoveToCell(0, startRowIndex, 6, 0);
  6120. builder.Write("");//上次出国时间
  6121. startRowIndex++;
  6122. }
  6123. int nullRow = rowCount - DeleClientList.Count;//空行
  6124. for (int i = 0; i < nullRow; i++)
  6125. {
  6126. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6127. }
  6128. foreach (var key in dic.Keys)
  6129. {
  6130. builder.MoveToBookmark(key);
  6131. builder.Write(dic[key]);
  6132. }
  6133. //模板文件名
  6134. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6135. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6136. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6137. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6138. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6139. }
  6140. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6141. {
  6142. //获取模板
  6143. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6144. //载入模板
  6145. Document doc = new Document(tempPath);
  6146. DocumentBuilder builder = new DocumentBuilder(doc);
  6147. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6148. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6149. dic.Add("Names", Names);
  6150. int accommodationRows = 12;
  6151. //int foodandotherRows = 12;
  6152. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6153. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6154. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6155. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6156. int accommodationStartIndex = 6;
  6157. decimal dac1totalPrice = 0.00M;
  6158. foreach (var dac in dac1)
  6159. {
  6160. if (dac.SubTotal == 0)
  6161. {
  6162. continue;
  6163. }
  6164. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6165. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6166. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6167. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6168. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6169. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6170. builder.Write(currency);//币种
  6171. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6172. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6173. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6174. builder.Write("");//人数
  6175. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6176. builder.Write("");//天数
  6177. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6178. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6179. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6180. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6181. builder.Write(rate.ToString("#0.0000"));//汇率
  6182. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6183. decimal rbmPrice = rate * dac.SubTotal;
  6184. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6185. accommodationStartIndex++;
  6186. dac1totalPrice += rbmPrice;
  6187. }
  6188. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6189. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6190. builder.Write("小计");
  6191. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6192. builder.Write(dac1totalPrice.ToString("#0.00"));
  6193. accommodationStartIndex++;
  6194. int nullRow = accommodationRows - dac1.Count;
  6195. //删除空行
  6196. //if (nullRow > 0)
  6197. //{
  6198. // int rowIndex = accommodationStartIndex;
  6199. // for (int i = 0; i < nullRow; i++)
  6200. // {
  6201. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6202. // row.Remove();
  6203. // rowIndex++;
  6204. // }
  6205. //}
  6206. if (dac2.Count == dac3.Count)//国家 币种 金额
  6207. {
  6208. for (int i = 0; i < dac2.Count; i++)
  6209. {
  6210. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6211. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6212. }
  6213. }
  6214. int foodandotherStartIndex = 19;//
  6215. decimal dac2totalPrice = 0.00M;
  6216. foreach (var dac in dac2)
  6217. {
  6218. if (dac.SubTotal == 0)
  6219. {
  6220. continue;
  6221. }
  6222. //foodandotherStartIndex = 12;
  6223. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6224. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6225. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6226. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6227. builder.Write(currency);//币种
  6228. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6229. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6230. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6231. builder.Write("");//人数
  6232. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6233. builder.Write("");//天数
  6234. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6235. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6236. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6237. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6238. builder.Write(rate.ToString("#0.0000"));//汇率
  6239. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6240. decimal rbmPrice = rate * dac.SubTotal;
  6241. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6242. foodandotherStartIndex++;
  6243. dac2totalPrice += rbmPrice;
  6244. }
  6245. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6246. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6247. //删除空行
  6248. //if (dac2.Count < foodandotherRows)
  6249. //{
  6250. // while (table2.Rows.Count > dac2.Count)
  6251. // {
  6252. // table2.Rows.RemoveAt(dac2.Count);
  6253. // }
  6254. //}
  6255. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6256. string otherFeeStr = "";
  6257. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6258. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6259. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6260. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6261. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6262. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6263. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6264. foreach (var otherInfo in dac5)
  6265. {
  6266. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6267. }
  6268. #endregion
  6269. if (otherFeeStr.Length > 0)
  6270. {
  6271. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6272. otherFeeStr = $"({otherFeeStr})";
  6273. dic.Add("OtherFeeStr", otherFeeStr);
  6274. }
  6275. foreach (var key in dic.Keys)
  6276. {
  6277. builder.MoveToBookmark(key);
  6278. builder.Write(dic[key]);
  6279. }
  6280. //模板文件名
  6281. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6282. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6283. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6284. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6285. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6286. }
  6287. }
  6288. else if (dto.ExportType == 3)
  6289. {
  6290. if (dto.SubTypeId == 1) //团组成员名单
  6291. {
  6292. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6293. //获取模板
  6294. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6295. //载入模板
  6296. Document doc = new Document(tempPath);
  6297. DocumentBuilder builder = new DocumentBuilder(doc);
  6298. //获取word里所有表格
  6299. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6300. //获取所填表格的序数
  6301. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6302. var rowStart = tableOne.Rows[0]; //获取第1行
  6303. //循环赋值
  6304. for (int i = 0; i < DeleClientList.Count; i++)
  6305. {
  6306. builder.MoveToCell(0, i + 1, 0, 0);
  6307. builder.Write(DeleClientList[i].Name);
  6308. builder.MoveToCell(0, i + 1, 1, 0);
  6309. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6310. builder.Write(sex);
  6311. builder.MoveToCell(0, i + 1, 2, 0);
  6312. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6313. builder.MoveToCell(0, i + 1, 3, 0);
  6314. builder.Write(DeleClientList[i].Company);
  6315. builder.MoveToCell(0, i + 1, 4, 0);
  6316. builder.Write(DeleClientList[i].Job);
  6317. }
  6318. //删除多余行
  6319. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6320. {
  6321. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6322. }
  6323. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6324. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6325. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6326. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6327. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6328. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6329. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6330. }
  6331. }
  6332. return Ok(JsonView(400, "操作失败!", ""));
  6333. }
  6334. catch (Exception ex)
  6335. {
  6336. return Ok(JsonView(400, ex.Message, ""));
  6337. }
  6338. }
  6339. /// <summary>
  6340. /// 获取三公费用标准city
  6341. /// </summary>
  6342. /// <param name="placeData"></param>
  6343. /// <param name="nationalTravelFeeId"></param>
  6344. /// <returns></returns>
  6345. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6346. {
  6347. string _city = string.Empty;
  6348. if (placeData.Count < 1) return _city;
  6349. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6350. if (data == null) return _city;
  6351. string country = data.Country;
  6352. string city = data.City;
  6353. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6354. else _city = city;
  6355. return _city;
  6356. }
  6357. /// <summary>
  6358. /// 团组模块 - 出入境费用 - 明细表导出
  6359. /// </summary>
  6360. /// <returns></returns>
  6361. [HttpPost]
  6362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6363. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6364. {
  6365. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6366. if (data.Code != 0)
  6367. {
  6368. return Ok(JsonView(false, data.Msg));
  6369. }
  6370. return Ok(JsonView(true, data.Msg, data.Data));
  6371. }
  6372. /// <summary>
  6373. /// 团组模块 - 出入境费用 - 一键清空
  6374. /// </summary>
  6375. /// <returns></returns>
  6376. [HttpPost]
  6377. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6379. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6380. {
  6381. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6382. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6383. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6384. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6385. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6386. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6387. .SetColumns(x => new Grp_DayOtherPrice
  6388. {
  6389. IsDel = 1,
  6390. DeleteUserId = dto.UserId,
  6391. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6392. })
  6393. .ExecuteCommandAsync();
  6394. if (_view.Code == 0)
  6395. {
  6396. return Ok(JsonView(true, "操作成功"));
  6397. }
  6398. return Ok(JsonView(false, "操作失败"));
  6399. }
  6400. /// <summary>
  6401. /// 团组模块 - 出入境费用 - 子项删除
  6402. /// </summary>
  6403. /// <returns></returns>
  6404. [HttpPost]
  6405. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6407. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6408. {
  6409. try
  6410. {
  6411. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6412. if (data.Code != 0)
  6413. {
  6414. return Ok(JsonView(false, data.Msg));
  6415. }
  6416. return Ok(JsonView(true, "操作成功!", data.Data));
  6417. }
  6418. catch (Exception ex)
  6419. {
  6420. return Ok(JsonView(false, ex.Message));
  6421. }
  6422. }
  6423. /// <summary>
  6424. /// 删除三公其他费用
  6425. /// </summary>
  6426. /// <param name="dto"></param>
  6427. /// <returns></returns>
  6428. [HttpPost]
  6429. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6430. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6431. {
  6432. var jw = JsonView(false, "删除失败!");
  6433. var data = new Grp_DayOtherPrice()
  6434. {
  6435. Id = dto.Id,
  6436. IsDel = 1,
  6437. DeleteUserId = dto.DeleteUserId,
  6438. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6439. };
  6440. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6441. if (del > 0)
  6442. {
  6443. jw.Code = 200;
  6444. jw.Msg = "删除成功!";
  6445. }
  6446. return Ok(jw);
  6447. }
  6448. /// <summary>
  6449. /// 团组模块 - 出入境国家费用标准 List
  6450. /// </summary>
  6451. /// <returns></returns>
  6452. [HttpPost]
  6453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6454. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6455. {
  6456. try
  6457. {
  6458. Stopwatch sw = new Stopwatch();
  6459. sw.Start();
  6460. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6461. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6462. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6463. Where gntf.Isdel = 0");
  6464. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6465. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6466. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6467. //foreach (var item in nationalTravel)
  6468. //{
  6469. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6470. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6471. // if (otherData != null)
  6472. // {
  6473. // cityData.Remove(otherData);
  6474. // cityData.Add(otherData);
  6475. // }
  6476. // nationalTravelFeeData1.Add(new
  6477. // {
  6478. // Country = item.Country,
  6479. // CityData = cityData
  6480. // });
  6481. //}
  6482. sw.Stop();
  6483. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6484. }
  6485. catch (Exception ex)
  6486. {
  6487. return Ok(JsonView(false, ex.Message));
  6488. throw;
  6489. }
  6490. }
  6491. /// <summary>
  6492. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6493. /// </summary>
  6494. /// <returns></returns>
  6495. [HttpPost]
  6496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6497. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6498. {
  6499. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6500. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6501. List<string> countryData = new List<string>();
  6502. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6503. countryData = countryData.Distinct().ToList();
  6504. List<dynamic> dataSource = new List<dynamic>();
  6505. foreach (var item in countryData)
  6506. {
  6507. var cityData1 = new List<string>();
  6508. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6509. var countryData2 = new
  6510. {
  6511. CountryName = item,
  6512. CityData = cityData1
  6513. };
  6514. dataSource.Add(countryData2);
  6515. }
  6516. return Ok(JsonView(true, "查询成功!", dataSource));
  6517. }
  6518. /// <summary>
  6519. /// 团组模块 - 出入境国家费用标准 Page List
  6520. /// </summary>
  6521. /// <returns></returns>
  6522. [HttpPost]
  6523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6524. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6525. {
  6526. int portId = dto.PortType;
  6527. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6528. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6529. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6530. string whereSql = string.Empty;
  6531. if (!string.IsNullOrEmpty(dto.Country))
  6532. {
  6533. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6534. }
  6535. if (!string.IsNullOrEmpty(dto.City))
  6536. {
  6537. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6538. }
  6539. string pageSql = string.Format(@"Select * From (
  6540. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6541. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6542. From Grp_NationalTravelFee gntf
  6543. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6544. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6545. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6546. RefAsync<int> total = 0;
  6547. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6548. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6549. }
  6550. /// <summary>
  6551. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6552. /// </summary>
  6553. /// <returns></returns>
  6554. [HttpPost]
  6555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6556. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6557. {
  6558. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6559. int portId = dto.PortType;
  6560. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6561. string whereSql = string.Empty;
  6562. if (!string.IsNullOrEmpty(dto.Country))
  6563. {
  6564. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6565. }
  6566. if (!string.IsNullOrEmpty(dto.City))
  6567. {
  6568. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6569. }
  6570. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6571. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6572. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6573. From Grp_NationalTravelFee gntf
  6574. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6575. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6576. Where gntf.Isdel = 0 {0} ", whereSql);
  6577. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6578. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6579. }
  6580. /// <summary>
  6581. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6582. /// </summary>
  6583. /// <returns></returns>
  6584. [HttpPost]
  6585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6586. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6587. {
  6588. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6589. if (data.Code != 0)
  6590. {
  6591. return Ok(JsonView(false, data.Msg));
  6592. }
  6593. return Ok(JsonView(true, "操作成功!", data.Data));
  6594. }
  6595. /// <summary>
  6596. /// 团组模块 - 出入境国家费用标准 - Del
  6597. /// </summary>
  6598. /// <returns></returns>
  6599. [HttpPost]
  6600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6601. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6602. {
  6603. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6604. {
  6605. Id = dto.Id,
  6606. DeleteUserId = dto.DeleteUserId,
  6607. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6608. IsDel = 1
  6609. };
  6610. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6611. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6612. .WhereColumns(it => new { it.Id })
  6613. .ExecuteCommandAsync();
  6614. if (delStatus <= 0)
  6615. {
  6616. return Ok(JsonView(false, "删除失败!"));
  6617. }
  6618. return Ok(JsonView(true, "操作成功!"));
  6619. }
  6620. /// <summary>
  6621. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6622. /// 注:Get 请求Headers 加 Token
  6623. /// </summary>
  6624. /// <param name="groupId"></param>
  6625. /// <returns></returns>
  6626. [HttpGet("{groupId}")]
  6627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6628. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6629. {
  6630. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6631. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6632. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6633. data.ForEach(x =>
  6634. {
  6635. x.CreateUserId = _currUserInfo.UserId;
  6636. });
  6637. if (data.Any())
  6638. {
  6639. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6640. if (add > 0)
  6641. {
  6642. return Ok(JsonView(true, "操作成功!"));
  6643. }
  6644. }
  6645. return Ok(JsonView(false, "未操作!"));
  6646. }
  6647. #endregion
  6648. #region 团组经理模块 出入境费用-草稿
  6649. /// <summary>
  6650. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6651. /// </summary>
  6652. /// <returns></returns>
  6653. [HttpPost]
  6654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6655. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6656. {
  6657. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6658. .Where(x => x.IsDel == 0)
  6659. .OrderByDescending(x => x.CreateTime)
  6660. .Select(x => new { x.Id, x.DraftName })
  6661. .ToListAsync();
  6662. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6663. //SetDataInfoView
  6664. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6665. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6666. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6667. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6668. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6669. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6670. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6671. //默认币种显示
  6672. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6673. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6674. return Ok(JsonView(true, "查询成功!", new
  6675. {
  6676. DraftNameDatas = draftNameDatas,
  6677. CurrencyData = _CurrencyData,
  6678. WordTypeData = _WordTypeData,
  6679. ExcelTypeData = _ExcelTypeData,
  6680. CurrencyInit = _currencyInfos,
  6681. ViewPermissionData = viewPermissionData
  6682. }));
  6683. }
  6684. /// <summary>
  6685. /// 团组模块 - 出入境费用-草稿
  6686. /// 实时汇率 tips
  6687. /// 机票费用 tips
  6688. /// </summary>
  6689. /// <returns></returns>
  6690. [HttpPost]
  6691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6692. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6693. {
  6694. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6695. return Ok(JsonView(true, "查询成功!", new
  6696. {
  6697. //GroupNameData = groupNameData.Data,
  6698. //visaData = visaData.Data,
  6699. //airData = airData.Data,
  6700. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6701. }));
  6702. }
  6703. /// <summary>
  6704. /// 团组模块 - 出入境费用-草稿
  6705. /// 签证费用 tips
  6706. /// </summary>
  6707. /// <returns></returns>
  6708. [HttpPost]
  6709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6710. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6711. {
  6712. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6713. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6714. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6715. .Select(x => x.NationalTravelFeeId)
  6716. .Distinct()
  6717. .ToListAsync();
  6718. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6719. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6720. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6721. .Select(x => x.Country)
  6722. .Distinct()
  6723. .ToArrayAsync();
  6724. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6725. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6726. return Ok(JsonView(true, "查询成功!", new
  6727. {
  6728. totalAmt = totalAmt,
  6729. remark = remark
  6730. }));
  6731. }
  6732. /// <summary>
  6733. /// 团组模块 - 出入境费用-草稿 - Info
  6734. /// </summary>
  6735. /// <returns></returns>
  6736. [HttpPost]
  6737. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6739. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6740. {
  6741. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6742. }
  6743. /// <summary>
  6744. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6745. /// </summary>
  6746. /// <returns></returns>
  6747. [HttpPost]
  6748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6749. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6750. {
  6751. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6752. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6753. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6754. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6755. foreach (var userId in dto.UserIds)
  6756. {
  6757. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6758. }
  6759. if (permissions.Any())
  6760. {
  6761. _sqlSugar.BeginTran();
  6762. try
  6763. {
  6764. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6765. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6766. if (result < 1)
  6767. {
  6768. _sqlSugar.RollbackTran();
  6769. return Ok(JsonView(false));
  6770. }
  6771. }
  6772. catch (Exception ex)
  6773. {
  6774. _sqlSugar.RollbackTran();
  6775. return Ok(JsonView(false, ex.Message));
  6776. }
  6777. _sqlSugar.CommitTran();
  6778. return Ok(JsonView(true));
  6779. }
  6780. return Ok(JsonView(false));
  6781. }
  6782. /// <summary>
  6783. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6784. /// </summary>
  6785. /// <returns></returns>
  6786. [HttpPost]
  6787. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6789. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6790. {
  6791. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6792. if (data.Code != 0)
  6793. {
  6794. return Ok(JsonView(false, data.Msg));
  6795. }
  6796. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6797. //汇率信息记录
  6798. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6799. return Ok(JsonView(true, data.Msg, data.Data));
  6800. }
  6801. /// <summary>
  6802. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6803. /// </summary>
  6804. /// <param name="dto"></param>
  6805. /// <returns></returns>
  6806. [HttpPost]
  6807. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6809. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6810. {
  6811. try
  6812. {
  6813. var id = dto.Id;
  6814. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6815. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6816. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6817. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6818. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6819. 3 团组成员名单 1 团组成员名单", ""));
  6820. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6821. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6822. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6823. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6824. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6825. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6826. //数据源
  6827. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6828. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6829. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6830. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6831. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6832. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6833. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6834. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6835. .Select((x, a, b) => new
  6836. {
  6837. x.Index,
  6838. itemName = a.Name,
  6839. CurrencyStr = b.Name,
  6840. x.Cost,
  6841. x.SubTotal,
  6842. x.Remark
  6843. })
  6844. .OrderBy((x) => x.Index)
  6845. .ToList(); //其他款项费用
  6846. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6847. var peiceItemCurrencys = new List<string>();
  6848. if (_DayAndCosts.Any())
  6849. {
  6850. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6851. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6852. }
  6853. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6854. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6855. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6856. {
  6857. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6858. }
  6859. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6860. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6861. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6862. if (dto.ExportType == 1) //明细表
  6863. {
  6864. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6865. {
  6866. //获取模板
  6867. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6868. //载入模板
  6869. Document doc = new Document(tempPath);
  6870. DocumentBuilder builder = new DocumentBuilder(doc);
  6871. //利用键值对存放数据
  6872. Dictionary<string, string> dic = new Dictionary<string, string>();
  6873. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6874. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6875. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6876. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6877. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6878. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6879. //境内费用(其他费用)
  6880. if (_EnterExitCosts.ChoiceOne == 1)
  6881. {
  6882. string row1_1 = "";
  6883. if (_EnterExitCosts.Visa > 0)
  6884. {
  6885. //insidePayTotal += _EnterExitCosts.Visa;
  6886. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6887. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6888. {
  6889. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6890. }
  6891. }
  6892. string row1_2 = "";
  6893. if (_EnterExitCosts.YiMiao > 0)
  6894. {
  6895. //insidePayTotal += _EnterExitCosts.YiMiao;
  6896. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6897. }
  6898. if (_EnterExitCosts.HeSuan > 0)
  6899. {
  6900. //insidePayTotal += _EnterExitCosts.HeSuan;
  6901. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6902. }
  6903. if (_EnterExitCosts.Service > 0)
  6904. {
  6905. //insidePayTotal += _EnterExitCosts.Service;
  6906. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6907. }
  6908. string row1_3 = "";
  6909. if (_EnterExitCosts.Safe > 0)
  6910. {
  6911. //insidePayTotal += _EnterExitCosts.Safe;
  6912. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6913. }
  6914. if (_EnterExitCosts.Ticket > 0)
  6915. {
  6916. //insidePayTotal += _EnterExitCosts.Ticket;
  6917. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6918. }
  6919. string row1 = "";
  6920. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6921. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6922. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6923. row1 += $"备注:{_EnterExitCosts.Remark}";
  6924. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6925. dic.Add("Row1Str", row1);
  6926. }
  6927. string airTotalStr = string.Empty,
  6928. airPriceStr = string.Empty;
  6929. //经济舱
  6930. if (_EnterExitCosts.SumJJC == 1)
  6931. {
  6932. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6933. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6934. }
  6935. //公务舱
  6936. if (_EnterExitCosts.SumGWC == 1)
  6937. {
  6938. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6939. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6940. }
  6941. //头等舱
  6942. if (_EnterExitCosts.SumTDC == 1)
  6943. {
  6944. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6945. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6946. }
  6947. //汇率描述
  6948. string rateStr = "";
  6949. if (peiceItemCurrencyInfos.Any())
  6950. {
  6951. rateStr = "\r\n汇率描述:";
  6952. foreach (var item in peiceItemCurrencyInfos)
  6953. {
  6954. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6955. }
  6956. }
  6957. string twoItemRemark = "备注:";
  6958. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6959. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6960. dic.Add("AirTotalStr", airTotalStr);
  6961. dic.Add("AirPriceStr", airPriceStr);
  6962. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6963. dic.Add("TwoItemRemark", twoItemRemark);
  6964. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6965. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6966. int table1Row = 0,
  6967. table2Row = 0,
  6968. table3Row = 0,
  6969. table4Row = 0,
  6970. table5Row = 0;
  6971. //住宿费
  6972. if (_EnterExitCosts.ChoiceThree == 1)
  6973. {
  6974. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6975. table1Row = dac1.Count;
  6976. #region 填充word表格内容
  6977. for (int i = 0; i < dac1.Count; i++)
  6978. {
  6979. var dac = dac1[i];
  6980. if (dac == null) continue;
  6981. builder.MoveToCell(0, i, 0, 0);
  6982. builder.Write("第" + dac.Days.ToString() + "晚:");
  6983. builder.MoveToCell(0, i, 1, 0);
  6984. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6985. //builder.Write(dac.Place == null ? "" : dac.Place);
  6986. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6987. builder.MoveToCell(0, i, 2, 0);
  6988. builder.Write("费用标准:");
  6989. string curr = "";
  6990. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6991. if (currData != null)
  6992. {
  6993. curr = currData.Name;
  6994. }
  6995. builder.MoveToCell(0, i, 3, 0);
  6996. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6997. builder.MoveToCell(0, i, 4, 0);
  6998. builder.Write("费用小计:");
  6999. builder.MoveToCell(0, i, 5, 0);
  7000. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7001. }
  7002. #endregion
  7003. }
  7004. else dic.Add("SubZS", "0.00");
  7005. //删除多余行
  7006. while (table1.Rows.Count > table1Row)
  7007. {
  7008. table1.Rows.RemoveAt(table1Row);
  7009. }
  7010. //伙食费
  7011. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7012. if (_EnterExitCosts.ChoiceFour == 1)
  7013. {
  7014. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7015. table2Row = dac2.Count;
  7016. #region 填充word表格内容
  7017. for (int i = 0; i < dac2.Count; i++)
  7018. {
  7019. var dac = dac2[i];
  7020. if (dac == null) continue;
  7021. builder.MoveToCell(1, i, 0, 0);
  7022. builder.Write("第" + dac.Days.ToString() + "天:");
  7023. builder.MoveToCell(1, i, 1, 0);
  7024. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7025. builder.MoveToCell(1, i, 2, 0);
  7026. builder.Write("费用标准:");
  7027. string curr = "";
  7028. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7029. if (currData != null)
  7030. {
  7031. curr = currData.Name;
  7032. }
  7033. builder.MoveToCell(1, i, 3, 0);
  7034. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7035. builder.MoveToCell(1, i, 4, 0);
  7036. builder.Write("费用小计:");
  7037. builder.MoveToCell(1, i, 5, 0);
  7038. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7039. }
  7040. #endregion
  7041. }
  7042. else dic.Add("SubHS", "0.00");
  7043. //删除多余行
  7044. while (table2.Rows.Count > table2Row)
  7045. {
  7046. table2.Rows.RemoveAt(table2Row);
  7047. }
  7048. //公杂费
  7049. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7050. if (_EnterExitCosts.ChoiceFive == 1)
  7051. {
  7052. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7053. table3Row = dac3.Count;
  7054. #region 填充word表格内容
  7055. for (int i = 0; i < dac3.Count; i++)
  7056. {
  7057. var dac = dac3[i];
  7058. if (dac == null) continue;
  7059. builder.MoveToCell(2, i, 0, 0);
  7060. builder.Write("第" + dac.Days.ToString() + "天:");
  7061. builder.MoveToCell(2, i, 1, 0);
  7062. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7063. builder.MoveToCell(2, i, 2, 0);
  7064. builder.Write("费用标准:");
  7065. string curr = "";
  7066. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7067. if (currData != null)
  7068. {
  7069. curr = currData.Name;
  7070. }
  7071. builder.MoveToCell(2, i, 3, 0);
  7072. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7073. builder.MoveToCell(2, i, 4, 0);
  7074. builder.Write("费用小计:");
  7075. builder.MoveToCell(2, i, 5, 0);
  7076. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7077. }
  7078. //删除多余行
  7079. while (table3.Rows.Count > table3Row)
  7080. {
  7081. table3.Rows.RemoveAt(table3Row);
  7082. }
  7083. #endregion
  7084. }
  7085. else dic.Add("SubGZF", "0.00");
  7086. //删除多余行
  7087. while (table3.Rows.Count > table3Row)
  7088. {
  7089. table3.Rows.RemoveAt(table3Row);
  7090. }
  7091. //培训费
  7092. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7093. if (_EnterExitCosts.ChoiceSix == 1)
  7094. {
  7095. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7096. dic.Add("SubPX", pxStr);
  7097. table4Row = dac4.Count;
  7098. #region 填充word表格内容
  7099. for (int i = 0; i < dac4.Count; i++)
  7100. {
  7101. var dac = dac4[i];
  7102. if (dac == null) continue;
  7103. builder.MoveToCell(3, i, 0, 0);
  7104. builder.Write("第" + dac.Days.ToString() + "天:");
  7105. builder.MoveToCell(3, i, 1, 0);
  7106. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7107. builder.MoveToCell(3, i, 2, 0);
  7108. builder.Write("费用标准:");
  7109. string curr = "";
  7110. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7111. if (currData != null)
  7112. {
  7113. curr = currData.Name;
  7114. }
  7115. builder.MoveToCell(3, i, 3, 0);
  7116. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7117. builder.MoveToCell(3, i, 4, 0);
  7118. builder.Write("费用小计:");
  7119. builder.MoveToCell(3, i, 5, 0);
  7120. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7121. }
  7122. #endregion
  7123. }
  7124. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7125. //删除多余行
  7126. while (table4.Rows.Count > table4Row)
  7127. {
  7128. table4.Rows.RemoveAt(table4Row);
  7129. }
  7130. //其他费用
  7131. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7132. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7133. {
  7134. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7135. dic.Add("titleQi", qtStr);
  7136. table5Row = dac5.Count;
  7137. #region 填充word表格内容
  7138. for (int i = 0; i < dac5.Count; i++)
  7139. {
  7140. var dac = dac5[i];
  7141. if (dac == null) continue;
  7142. builder.MoveToCell(4, i, 0, 0);
  7143. builder.Write("第" + dac.Index.ToString() + "项:");
  7144. builder.MoveToCell(4, i, 1, 0);
  7145. builder.Write(dac.itemName);
  7146. builder.MoveToCell(4, i, 2, 0);
  7147. builder.Write("费用标准:");
  7148. builder.MoveToCell(4, i, 3, 0);
  7149. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7150. builder.MoveToCell(4, i, 4, 0);
  7151. builder.Write("费用小计:");
  7152. builder.MoveToCell(4, i, 5, 0);
  7153. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7154. builder.MoveToCell(4, i, 6, 0);
  7155. builder.Write("备注:");
  7156. builder.MoveToCell(4, i, 7, 0);
  7157. builder.Write(dac.Remark);
  7158. }
  7159. #endregion
  7160. }
  7161. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7162. //删除多余行
  7163. while (table5.Rows.Count > table5Row)
  7164. {
  7165. table5.Rows.RemoveAt(table5Row);
  7166. }
  7167. //加上其他费用
  7168. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7169. decimal subJJC = 0.00M,
  7170. subGWC = 0.00M,
  7171. subTDC = 0.00M;
  7172. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7173. string totalLabel = string.Format("全部费用总计:");
  7174. //经济舱
  7175. if (_EnterExitCosts.SumJJC == 1)
  7176. {
  7177. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7178. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7179. }
  7180. //公务舱
  7181. if (_EnterExitCosts.SumGWC == 1)
  7182. {
  7183. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7184. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7185. }
  7186. //头等舱
  7187. if (_EnterExitCosts.SumTDC == 1)
  7188. {
  7189. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7190. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7191. }
  7192. //TotalLabel
  7193. dic.Add("TotalLabel", totalLabel);
  7194. #region 填充word模板书签内容
  7195. foreach (var key in dic.Keys)
  7196. {
  7197. Bookmark bookmark = doc.Range.Bookmarks[key];
  7198. if (bookmark != null)
  7199. {
  7200. builder.MoveToBookmark(key);
  7201. builder.Write(dic[key]);
  7202. }
  7203. }
  7204. #endregion
  7205. //文件名
  7206. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7207. strFileName = CommonFun.ValidFileName(strFileName);
  7208. AsposeHelper.removewatermark_v2180();
  7209. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7210. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7211. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7212. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7213. }
  7214. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7215. {
  7216. //获取模板
  7217. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7218. //载入模板
  7219. Document doc = new Document(tempPath);
  7220. DocumentBuilder builder = new DocumentBuilder(doc);
  7221. Dictionary<string, string> dic = new Dictionary<string, string>();
  7222. string returnCodeLabel = string.Empty;
  7223. if (nationalTravelFeeData.Any())
  7224. {
  7225. List<string> list = new List<string>();
  7226. foreach (var item in nationalTravelFeeData)
  7227. {
  7228. list.Add($"{item.Country}({item.City})");
  7229. }
  7230. list = list.Distinct().ToList();
  7231. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7232. }
  7233. var countryLabel = string.Empty;
  7234. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7235. if (countryData.Any())
  7236. {
  7237. countryLabel = string.Join("、", countryData);
  7238. }
  7239. dic.Add("ReturnCodeAir", returnCodeLabel);
  7240. dic.Add("VisitStartDate", "-");
  7241. dic.Add("VisitEndDate", "-");
  7242. dic.Add("Day", "-");
  7243. dic.Add("VisitCountry", countryLabel);
  7244. dic.Add("ClientUnit", "-");
  7245. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7246. //dic.Add("Names", Names);
  7247. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7248. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7249. decimal dac1totalPrice = 0.00M;
  7250. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7251. foreach (var dac in dac1)
  7252. {
  7253. if (dac.SubTotal == 0.00M)
  7254. {
  7255. continue;
  7256. }
  7257. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7258. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7259. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7260. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7261. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7262. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7263. builder.Write(currency);//币种
  7264. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7265. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7266. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7267. builder.Write("");//人数
  7268. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7269. builder.Write("");//天数
  7270. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7271. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7272. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7273. decimal rate = 0.00M;
  7274. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7275. builder.Write(rate.ToString("#0.0000"));//汇率
  7276. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7277. decimal rbmPrice = dac.SubTotal;
  7278. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7279. accommodationStartIndex++;
  7280. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7281. }
  7282. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7283. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7284. {
  7285. table1.Rows.RemoveAt(i - 1);
  7286. foodandotherStartIndex--;
  7287. }
  7288. if (dac2.Count == dac3.Count)//国家 币种 金额
  7289. {
  7290. for (int i = 0; i < dac2.Count; i++)
  7291. {
  7292. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7293. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7294. }
  7295. }
  7296. decimal dac2totalPrice = 0.00M;
  7297. foreach (var dac in dac2)
  7298. {
  7299. if (dac.SubTotal == 0)
  7300. {
  7301. continue;
  7302. }
  7303. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7304. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7305. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7306. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7307. builder.Write(currency);//币种
  7308. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7309. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7310. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7311. builder.Write("");//人数
  7312. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7313. builder.Write("");//天数
  7314. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7315. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7316. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7317. decimal rate = 0.00M;
  7318. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7319. builder.Write(rate.ToString("#0.0000"));//汇率
  7320. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7321. decimal rbmPrice = dac.SubTotal;
  7322. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7323. foodandotherStartIndex++;
  7324. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7325. }
  7326. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7327. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7328. {
  7329. table1.Rows.RemoveAt(i - 1);
  7330. }
  7331. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7332. string otherFeeStr = "";
  7333. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7334. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7335. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7336. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7337. foreach (var otherInfo in dac5)
  7338. {
  7339. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7340. }
  7341. #endregion
  7342. if (otherFeeStr.Length > 0)
  7343. {
  7344. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7345. otherFeeStr = $"({otherFeeStr})";
  7346. dic.Add("OtherFeeStr", otherFeeStr);
  7347. }
  7348. //总计
  7349. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7350. //国际旅费
  7351. string outsideAir = string.Empty;
  7352. string allPriceAir = string.Empty;
  7353. if (_EnterExitCosts.SumJJC == 1)
  7354. {
  7355. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7356. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7357. }
  7358. if (_EnterExitCosts.SumGWC == 1)
  7359. {
  7360. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7361. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7362. }
  7363. if (_EnterExitCosts.SumTDC == 1)
  7364. {
  7365. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7366. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7367. }
  7368. dic.Add("InTravelPrice", $"({outsideAir})");
  7369. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7370. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7371. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7372. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7373. foreach (var key in dic.Keys)
  7374. {
  7375. builder.MoveToBookmark(key);
  7376. builder.Write(dic[key]);
  7377. }
  7378. //模板文件名
  7379. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7380. strFileName = CommonFun.ValidFileName(strFileName);
  7381. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7382. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7383. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7384. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7385. }
  7386. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7387. {
  7388. //获取模板
  7389. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7390. //载入模板
  7391. WorkbookDesigner designer = new WorkbookDesigner();
  7392. designer.Workbook = new Workbook(tempPath);
  7393. Dictionary<string, string> dic = new Dictionary<string, string>();
  7394. string returnCodeLabel = string.Empty;
  7395. if (nationalTravelFeeData.Any())
  7396. {
  7397. List<string> list = new List<string>();
  7398. foreach (var item in nationalTravelFeeData)
  7399. {
  7400. list.Add($"{item.Country}({item.City})");
  7401. }
  7402. list = list.Distinct().ToList();
  7403. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7404. }
  7405. var countryLabel = string.Empty;
  7406. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7407. if (countryData.Any())
  7408. {
  7409. countryLabel = string.Join("、", countryData);
  7410. }
  7411. dic.Add("ReturnCodeAir", returnCodeLabel);
  7412. dic.Add("VisitStartDate", "-");
  7413. dic.Add("VisitEndDate", "-");
  7414. dic.Add("Day", "0");
  7415. dic.Add("VisitCountry", countryLabel);
  7416. dic.Add("ClientUnit", "-");
  7417. designer.SetDataSource("ClientUnit", "-");
  7418. designer.SetDataSource("VisitCountry", countryLabel);
  7419. designer.SetDataSource("Group", "-");
  7420. designer.SetDataSource("ClientUnitTitle", "-");
  7421. designer.SetDataSource("Name", "-");
  7422. designer.SetDataSource("VisitStartDate", "-");
  7423. designer.SetDataSource("Day", "0");
  7424. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7425. designer.SetDataSource("ReturnCodeAir", "-");
  7426. int startIndex = 10;
  7427. const int startIndexcopy = 10;
  7428. if (dac2.Count == dac3.Count)//国家 币种 金额
  7429. {
  7430. for (int i = 0; i < dac2.Count; i++)
  7431. {
  7432. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7433. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7434. }
  7435. }
  7436. DataTable dtdac1 = new DataTable();
  7437. List<string> place = new List<string>();
  7438. dtdac1.Columns.AddRange(new DataColumn[] {
  7439. new DataColumn(){ ColumnName = "city"},
  7440. new DataColumn(){ ColumnName = "curr"},
  7441. new DataColumn(){ ColumnName = "criterion"},
  7442. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7443. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7444. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7445. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7446. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7447. });
  7448. DataTable dtdac2 = new DataTable();
  7449. dtdac2.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. dtdac1.TableName = "tb1";
  7460. dtdac2.TableName = "tb2";
  7461. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7462. foreach (var item in dac1)
  7463. {
  7464. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7465. if (place.Contains(item.Place))
  7466. {
  7467. continue;
  7468. }
  7469. DataRow row = dtdac1.NewRow();
  7470. row["city"] = item.Place;
  7471. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7472. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7473. row["curr"] = currency;
  7474. row["rate"] = rate.ToString("#0.0000");
  7475. row["criterion"] = item.Cost.ToString("#0.00");
  7476. row["number"] = 1;
  7477. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7478. //row["costRMB"] = rbmPrice;
  7479. dtdac1.Rows.Add(row);
  7480. place.Add(item.Place);
  7481. }
  7482. place = new List<string>();
  7483. foreach (var item in dac2)
  7484. {
  7485. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7486. if (place.Contains(item.Place))
  7487. {
  7488. continue;
  7489. }
  7490. DataRow row = dtdac2.NewRow();
  7491. row["city"] = item.Place;
  7492. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7493. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7494. row["curr"] = currency;
  7495. row["rate"] = rate.ToString("#0.0000");
  7496. row["criterion"] = item.Cost.ToString("#0.00");
  7497. row["number"] = 1;
  7498. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7499. //row["cost"] = item.SubTotal;
  7500. //row["costRMB"] = rbmPrice;
  7501. dtdac2.Rows.Add(row);
  7502. place.Add(item.Place);
  7503. //dac2totalPrice += rbmPrice;
  7504. }
  7505. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7506. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7507. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7508. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7509. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7510. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7511. string cell4Str1 = string.Empty;
  7512. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7513. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7514. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7515. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7516. string cellStr = $" 5.其他费用(";
  7517. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7518. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7519. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7520. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7521. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7522. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7523. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7524. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7525. foreach (var otherInfo in dac5)
  7526. {
  7527. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7528. }
  7529. #endregion
  7530. if (cellStr.Length > 8)
  7531. {
  7532. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7533. }
  7534. cellStr += ")";
  7535. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7536. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7537. decimal pxFee = dac4.Sum(it => it.Cost);
  7538. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7539. string celllastStr1 = "";
  7540. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7541. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7542. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7543. celllastStr1 += $",国际旅费 元";
  7544. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7545. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7546. designer.SetDataSource("cell4Str", cell4Str);
  7547. designer.SetDataSource("cellStr", cellStr);
  7548. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7549. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7550. designer.SetDataSource("celllastStr", celllastStr);
  7551. Workbook wb = designer.Workbook;
  7552. var sheet = wb.Worksheets[0];
  7553. //绑定datatable数据集
  7554. designer.SetDataSource(dtdac1);
  7555. designer.SetDataSource(dtdac2);
  7556. designer.Process();
  7557. var rowStart = dtdac1.Rows.Count;
  7558. while (rowStart > 0)
  7559. {
  7560. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7561. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7562. startIndex++;
  7563. rowStart--;
  7564. }
  7565. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7566. startIndex += 1; //总计行
  7567. rowStart = dtdac2.Rows.Count;
  7568. while (rowStart > 0)
  7569. {
  7570. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7571. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7572. startIndex++;
  7573. rowStart--;
  7574. }
  7575. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7576. wb.CalculateFormula(true);
  7577. //模板文件名
  7578. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7579. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7580. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7581. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7582. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7583. }
  7584. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7585. {
  7586. //获取模板
  7587. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7588. //载入模板
  7589. Document doc = new Document(tempPath);
  7590. DocumentBuilder builder = new DocumentBuilder(doc);
  7591. Dictionary<string, string> dic = new Dictionary<string, string>();
  7592. dic.Add("GroupName", "-");
  7593. dic.Add("ClientUnit", "-");
  7594. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7595. //string missionLeaderJob = "";//负责人job
  7596. //int groupNumber = 0; //团人数
  7597. dic.Add("MissionLeader", "-"); //团负责人
  7598. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7599. dic.Add("GroupNumber", "0"); //团人数
  7600. dic.Add("Day", "0");
  7601. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7602. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7603. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7604. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7605. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7606. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7607. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7608. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7609. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7610. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7611. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7612. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7613. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7614. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7615. //其他费用
  7616. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7617. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7618. //其他费用合计
  7619. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7620. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7621. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7622. //公务舱合计
  7623. //国际旅费
  7624. //string outsideJJ = "";
  7625. //string allPriceJJ = "";
  7626. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7627. {
  7628. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7629. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7630. }
  7631. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7632. {
  7633. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7634. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7635. }
  7636. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7637. {
  7638. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7639. dic.Add("AirFeeTotal", airFeeTotalStr);
  7640. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7641. dic.Add("FeeTotal", feeTotalStr);
  7642. }
  7643. foreach (var key in dic.Keys)
  7644. {
  7645. builder.MoveToBookmark(key);
  7646. builder.Write(dic[key]);
  7647. }
  7648. //模板文件名
  7649. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7650. strFileName = CommonFun.ValidFileName(strFileName);
  7651. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7652. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7653. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7654. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7655. }
  7656. }
  7657. else if (dto.ExportType == 2) //表格
  7658. {
  7659. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7660. }
  7661. else if (dto.ExportType == 3)
  7662. {
  7663. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7664. }
  7665. return Ok(JsonView(400, "只可导出明细表!", ""));
  7666. }
  7667. catch (Exception ex)
  7668. {
  7669. return Ok(JsonView(400, ex.Message, ""));
  7670. }
  7671. }
  7672. /// <summary>
  7673. /// 获取三公费用标准city
  7674. /// </summary>
  7675. /// <param name="placeData"></param>
  7676. /// <param name="nationalTravelFeeId"></param>
  7677. /// <returns></returns>
  7678. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7679. {
  7680. string _city = string.Empty;
  7681. if (!placeData.Any()) return _city;
  7682. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7683. if (data == null) return _city;
  7684. string country = data.Country;
  7685. string city = data.City;
  7686. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7687. else _city = city;
  7688. return _city;
  7689. }
  7690. /// <summary>
  7691. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7692. /// </summary>
  7693. /// <returns></returns>
  7694. [HttpPost]
  7695. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7697. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7698. {
  7699. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7700. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7701. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7702. if (_view.Code == 0)
  7703. {
  7704. return Ok(JsonView(true, "操作成功"));
  7705. }
  7706. return Ok(JsonView(false, "操作失败"));
  7707. }
  7708. /// <summary>
  7709. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7710. /// </summary>
  7711. /// <returns></returns>
  7712. [HttpPost]
  7713. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7715. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7716. {
  7717. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7718. if (data.Code != 0)
  7719. {
  7720. return Ok(JsonView(false, data.Msg));
  7721. }
  7722. return Ok(JsonView(true, "操作成功!", data.Data));
  7723. }
  7724. /// <summary>
  7725. /// 三公其他费用草稿 删除
  7726. /// </summary>
  7727. /// <param name="dto"></param>
  7728. /// <returns></returns>
  7729. [HttpPost]
  7730. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7731. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7732. {
  7733. var jw = JsonView(false, "删除失败!");
  7734. var data = new Grp_DayOtherPriceDraft()
  7735. {
  7736. Id = dto.Id,
  7737. IsDel = 1,
  7738. DeleteUserId = dto.DeleteUserId,
  7739. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7740. };
  7741. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7742. if (del > 0)
  7743. {
  7744. jw.Code = 200;
  7745. jw.Msg = "删除成功!";
  7746. }
  7747. return Ok(jw);
  7748. }
  7749. /// <summary>
  7750. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7751. /// </summary>
  7752. /// <returns></returns>
  7753. [HttpPost]
  7754. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7755. {
  7756. var jw = JsonView(false);
  7757. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7758. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7759. jw.Code = StatusCodes.Status200OK;
  7760. jw.Msg = "操作成功!";
  7761. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7762. return Ok(jw);
  7763. }
  7764. /// <summary>
  7765. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7766. /// </summary>
  7767. /// <param name="dto"></param>
  7768. /// <returns></returns>
  7769. [HttpPost]
  7770. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7771. {
  7772. int userId = dto.UserId,
  7773. portId = dto.PortType,
  7774. groupId = dto.GroupId,
  7775. draftId = dto.DraftId;
  7776. _portTypeData.Add(1);
  7777. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7778. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7779. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7780. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7781. _sqlSugar.BeginTran();
  7782. try
  7783. {
  7784. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7785. if (draftDatas == null)
  7786. {
  7787. _sqlSugar.RollbackTran();
  7788. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7789. }
  7790. //验证可覆盖已有数据 两边创建人需为同一人;
  7791. int draftCreateUserId = draftDatas.CreateUserId,
  7792. formalCreateUserId = 0;
  7793. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7794. if (formalData != null)
  7795. {
  7796. formalCreateUserId = formalData.CreateUserId;
  7797. if (draftCreateUserId != formalCreateUserId)
  7798. {
  7799. _sqlSugar.RollbackTran();
  7800. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7801. }
  7802. }
  7803. //默认添加查看、编辑权限(创建人、自己)
  7804. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  7805. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7806. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7807. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7808. newExterData.DiId = groupId;
  7809. newExterData.CreateUserId = userId;
  7810. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7811. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7812. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7813. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7814. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7815. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7816. //数据如果存在执行删除
  7817. if (enterExitCostInfo != null)
  7818. {
  7819. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7820. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7821. .Where(x => x.Id == enterExitCostInfo.Id)
  7822. .ExecuteCommand();
  7823. _sqlSugar.Updateable<Grp_DayAndCost>()
  7824. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7825. .Where(x => x.DiId == groupId)
  7826. .ExecuteCommand();
  7827. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7828. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7829. .Where(x => x.Diid == groupId)
  7830. .ExecuteCommand();
  7831. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7832. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7833. .Where(x => x.GroupId == groupId)
  7834. .ExecuteCommand();
  7835. }
  7836. //执行insert
  7837. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7838. if (insertId < 1)
  7839. {
  7840. _sqlSugar.RollbackTran();
  7841. return Ok(JsonView(false, "草稿数据导入失败!"));
  7842. }
  7843. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7844. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7845. #region 默认添加权限
  7846. #endregion
  7847. _sqlSugar.CommitTran();
  7848. //执行操作之后
  7849. //生成默认文件pdf并且通知人员
  7850. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7851. {
  7852. DiId = groupId,
  7853. ExportType = 1,
  7854. SubTypeId = 1005
  7855. }, "pdf");
  7856. //发送通知
  7857. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7858. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7859. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7860. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7861. //汇率信息记录
  7862. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7863. return Ok(JsonView(true));
  7864. }
  7865. catch (Exception ex)
  7866. {
  7867. _sqlSugar.RollbackTran();
  7868. return Ok(JsonView(false, ex.Message));
  7869. }
  7870. }
  7871. #endregion
  7872. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7873. /// <summary>
  7874. /// 获取币种基础数据(含逻辑处理)
  7875. /// </summary>
  7876. /// <returns></returns>
  7877. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7878. {
  7879. return await GeneralMethod.EnterExitCostInitRate();
  7880. }
  7881. /// <summary>
  7882. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7883. /// </summary>
  7884. /// <returns></returns>
  7885. [HttpPost]
  7886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7887. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7888. {
  7889. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7890. //SetDataInfoView
  7891. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7892. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7893. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7894. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7895. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7896. //默认币种显示
  7897. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7898. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7899. return Ok(JsonView(true, "查询成功!", new
  7900. {
  7901. WordTypeData = _WordTypeData,
  7902. ExcelTypeData = _ExcelTypeData,
  7903. CurrencyInit = _currencyInfos,
  7904. viewPermissionData = viewPermissionData
  7905. }));
  7906. }
  7907. /// <summary>
  7908. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7909. /// </summary>
  7910. /// <returns></returns>
  7911. [HttpPost]
  7912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7913. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7914. {
  7915. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7916. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7917. RefAsync<int> total = 0;
  7918. int diId = 0;
  7919. var status = int.TryParse(dto.GroupName, out diId);
  7920. string sql = string.Format(@"SELECT
  7921. Id,
  7922. TeamName GroupName,
  7923. CASE WHEN EXISTS (
  7924. SELECT
  7925. 1
  7926. FROM
  7927. Grp_EnterExitCost
  7928. WHERE
  7929. IsDel = 0
  7930. AND DiId = di.Id
  7931. ) THEN 1 ELSE 0 END AS [IsNull],
  7932. CASE WHEN EXISTS(
  7933. SELECT
  7934. TOP 1 *
  7935. FROM
  7936. Grp_EnterExitCost
  7937. WHERE
  7938. IsDel = 0
  7939. AND DiId = di.Id
  7940. AND CreateUserId = {0}
  7941. ORDER BY
  7942. CreateTime DESC
  7943. ) THEN 1 ELSE 0 END AS [IsEdit],
  7944. CASE WHEN EXISTS(
  7945. SELECT
  7946. TOP 1 *
  7947. FROM
  7948. Grp_EnterExitCost
  7949. WHERE
  7950. IsDel = 0
  7951. AND DiId = di.Id
  7952. AND CreateUserId = {0}
  7953. ORDER BY
  7954. CreateTime DESC
  7955. ) THEN 1 WHEN EXISTS(
  7956. SELECT
  7957. TOP 1 *
  7958. FROM
  7959. Grp_EnterExitCostPermission
  7960. WHERE
  7961. IsDel = 0
  7962. AND GroupId = di.Id
  7963. AND Permission = 1
  7964. AND UserId = {0}
  7965. ORDER BY
  7966. CreateTime DESC
  7967. ) THEN 1 ELSE 0 END AS [IsView]
  7968. FROM
  7969. Grp_DelegationInfo di
  7970. WHERE
  7971. di.Isdel = 0
  7972. ORDER BY di.VisitStartDate DESC", dto.CurrUserId);
  7973. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7974. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7975. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7976. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7977. .OrderByDescending(x => x.Id)
  7978. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7979. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  7980. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  7981. {
  7982. foreach (var item in data)
  7983. {
  7984. item.IsView = true;
  7985. }
  7986. }
  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> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7996. {
  7997. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7998. RefAsync<int> total = 0;
  7999. var data = await _sqlSugar.Queryable<Sys_SetData>()
  8000. .Where(x => x.IsDel == 0 && x.STid == 66)
  8001. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  8002. .Select(x => new
  8003. {
  8004. id = x.Id,
  8005. name = x.Name,
  8006. remark = x.Remark,
  8007. })
  8008. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8009. return Ok(JsonView(true, "查询成功!", data, total));
  8010. }
  8011. /// <summary>
  8012. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  8013. /// </summary>
  8014. /// <returns></returns>
  8015. [HttpPost]
  8016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8017. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  8018. {
  8019. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8020. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8021. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  8022. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  8023. var groupOtherRateData = groupRateData.TeamRates;
  8024. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8025. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8026. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8027. groupOtherRateData = groupOtherRateData
  8028. .Select(x => new TeamRateDescAddCurrencyIdView
  8029. {
  8030. CurrencyId = x.CurrencyId,
  8031. CurrencyName = x.CurrencyName,
  8032. CurrencyCode = x.CurrencyCode,
  8033. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8034. }).ToList();
  8035. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8036. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8037. }
  8038. /// <summary>
  8039. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8040. /// </summary>
  8041. /// <returns></returns>
  8042. [HttpPost]
  8043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8044. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8045. {
  8046. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8047. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8048. var tipsData = new List<int>() { 1, 2, 3 };
  8049. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8050. if (dto.TipsType == 1)
  8051. {
  8052. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8053. }
  8054. else if (dto.TipsType == 2)
  8055. {
  8056. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8057. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8058. }
  8059. else if (dto.TipsType == 3)
  8060. {
  8061. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8062. return Ok(JsonView(true, "查询成功!", airData.Data));
  8063. }
  8064. return Ok(JsonView(false));
  8065. }
  8066. /// <summary>
  8067. /// 团组模块 - 出入境国家费用标准-移动端 List
  8068. /// </summary>
  8069. /// <returns></returns>
  8070. [HttpPost]
  8071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8072. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8073. {
  8074. Stopwatch sw = new Stopwatch();
  8075. sw.Start();
  8076. RefAsync<int> total = 0;
  8077. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8078. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8079. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8080. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8081. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8082. .Select((ntf, sd, u) => new
  8083. {
  8084. Id = ntf.Id,
  8085. Area = $"{ntf.Country}-{ntf.City}",
  8086. Currency = ntf.Currency,
  8087. CurrencyCode = sd.Name,
  8088. CurrencyName = sd.Remark,
  8089. RoomCost = ntf.RoomCost,
  8090. FoodCost = ntf.FoodCost,
  8091. PublicCost = ntf.PublicCost,
  8092. LastUpdateUserId = ntf.LastUpdateUserId,
  8093. LastUpdateUserName = u.CnName,
  8094. LastUpdateTime = ntf.LastUpdateTime,
  8095. })
  8096. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8097. sw.Stop();
  8098. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8099. }
  8100. /// <summary>
  8101. /// 团组模块 - 出入境费用-移动端 - Info
  8102. /// </summary>
  8103. /// <returns></returns>
  8104. [HttpPost]
  8105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8106. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8107. {
  8108. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8109. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8110. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8111. return Ok(data);
  8112. }
  8113. /// <summary>
  8114. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8115. /// </summary>
  8116. /// <returns></returns>
  8117. [HttpPost]
  8118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8119. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8120. {
  8121. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8122. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8123. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8124. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8125. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8126. mobileInfo.DiId = dto.DiId;
  8127. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8128. if (eecInfo == null) return Ok(mobileInfo);
  8129. //验证查看权限
  8130. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8131. //if (!isView) return Ok(JsonView(false, msg));
  8132. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8133. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8134. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8135. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8136. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8137. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8138. {
  8139. SubId = dac.Id,
  8140. DiId = dac.DiId,
  8141. Type = dac.Type,
  8142. Days = dac.Days,
  8143. NationalTravelFeeId = dac.NationalTravelFeeId,
  8144. Arae = $"{ntf.Country}-{ntf.City}",
  8145. Cost = dac.Cost,
  8146. Currency = dac.Currency,
  8147. CurrencyName = sd.Name,
  8148. SubTotal = dac.SubTotal,
  8149. })
  8150. .ToList();
  8151. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8152. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8153. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8154. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8155. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8156. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8157. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8158. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8159. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8160. //其他款项
  8161. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8162. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8163. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8164. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8165. .OrderBy((dop, sd1, sd2) => dop.Index)
  8166. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8167. {
  8168. SubId = dop.Id,
  8169. DiId = dop.Diid,
  8170. Index = dop.Index,
  8171. SetDataId = dop.SetDataId,
  8172. SetDataName = sd1.Name,
  8173. Cost = dop.Cost,
  8174. Currency = dop.Currency,
  8175. CurrencyName = sd2.Remark,
  8176. SubTotal = dop.SubTotal,
  8177. Remark = dop.Remark,
  8178. })
  8179. .ToArray();
  8180. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8181. return Ok(mobileInfo);
  8182. }
  8183. /// <summary>
  8184. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8185. /// </summary>
  8186. /// <returns></returns>
  8187. [HttpPost]
  8188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8189. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8190. {
  8191. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8192. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8193. //验证查看权限
  8194. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8195. if (!isView) return Ok(JsonView(false, msg));
  8196. var userIds = await _sqlSugar
  8197. .Queryable<Grp_EnterExitCostPermission>()
  8198. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8199. .Select(x => x.UserId)
  8200. .ToArrayAsync();
  8201. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8202. var perUsersView = new List<dynamic>();
  8203. foreach (var item in perUsers)
  8204. {
  8205. bool isView1 = false;
  8206. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8207. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8208. }
  8209. return Ok(JsonView(perUsersView));
  8210. }
  8211. /// <summary>
  8212. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8213. /// </summary>
  8214. /// <returns></returns>
  8215. [HttpPost]
  8216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8217. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8218. {
  8219. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8220. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8221. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8222. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8223. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8224. //验证查看权限
  8225. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8226. //if (!isView) return Ok(JsonView(false, msg));
  8227. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8228. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8229. var subType = dto.SubType;
  8230. if (subType == 1) //1:境内费用
  8231. {
  8232. var oneData = new ChoiceOneMobileSubInfoView()
  8233. {
  8234. Id = eecInfo.Id,
  8235. ChoiceOne = eecInfo.ChoiceOne,
  8236. ChoiceOneTotalCost = eecInfo.InsidePay,
  8237. Visa = eecInfo.Visa,
  8238. VisaRemark = eecInfo.VisaRemark,
  8239. YiMiao = eecInfo.YiMiao,
  8240. HeSuan = eecInfo.HeSuan,
  8241. Service = eecInfo.Service,
  8242. Ticket = eecInfo.Ticket,
  8243. Safe = eecInfo.Safe,
  8244. FirstItemRemark = eecInfo.FirstItemRemark
  8245. };
  8246. return Ok(JsonView(oneData));
  8247. }
  8248. else if (subType == 2) //2:国际旅费
  8249. {
  8250. var twoData = new ChoiceTwoMobileSubInfoView()
  8251. {
  8252. Id = eecInfo.Id,
  8253. ChoiceTwoJJ = eecInfo.SumJJC,
  8254. OutsideJJPay = eecInfo.OutsideJJPay,
  8255. ChoiceTwoGW = eecInfo.SumGWC,
  8256. OutsideGWPay = eecInfo.OutsideGWPay,
  8257. ChoiceTwoTD = eecInfo.SumTDC,
  8258. OutsideTDPay = eecInfo.OutsideTDPay,
  8259. AirJJ = eecInfo.AirJJ,
  8260. AirGW = eecInfo.AirGW,
  8261. AirTD = eecInfo.AirTD,
  8262. CityTranffic = eecInfo.CityTranffic,
  8263. TwoItemRemark = eecInfo.TwoItemRemark
  8264. };
  8265. return Ok(JsonView(twoData));
  8266. }
  8267. else if (subType == 3) //3:住宿费
  8268. {
  8269. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8270. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8271. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8272. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8273. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8274. {
  8275. SubId = dac.Id,
  8276. DiId = dac.DiId,
  8277. Type = dac.Type,
  8278. Days = dac.Days,
  8279. NationalTravelFeeId = dac.NationalTravelFeeId,
  8280. Arae = $"{ntf.Country}-{ntf.City}",
  8281. Cost = dac.Cost,
  8282. Currency = dac.Currency,
  8283. CurrencyName = sd.Name,
  8284. SubTotal = dac.SubTotal,
  8285. })
  8286. .ToArray();
  8287. var data = new ChoiceMobileSubInfo3To6View()
  8288. {
  8289. ParentId = eecInfo.Id,
  8290. Choice = eecInfo.ChoiceThree,
  8291. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8292. Details = dayAndCostDatas
  8293. };
  8294. return Ok(JsonView(data));
  8295. }
  8296. else if (subType == 4) //4:伙食费
  8297. {
  8298. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8299. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8300. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8301. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8302. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8303. {
  8304. SubId = dac.Id,
  8305. DiId = dac.DiId,
  8306. Type = dac.Type,
  8307. Days = dac.Days,
  8308. NationalTravelFeeId = dac.NationalTravelFeeId,
  8309. Arae = $"{ntf.Country}-{ntf.City}",
  8310. Cost = dac.Cost,
  8311. Currency = dac.Currency,
  8312. CurrencyName = sd.Name,
  8313. SubTotal = dac.SubTotal,
  8314. })
  8315. .ToArray();
  8316. var data = new ChoiceMobileSubInfo3To6View()
  8317. {
  8318. ParentId = eecInfo.Id,
  8319. Choice = eecInfo.ChoiceFour,
  8320. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8321. Details = dayAndCostDatas
  8322. };
  8323. return Ok(JsonView(data));
  8324. }
  8325. else if (subType == 5) //5:公杂费
  8326. {
  8327. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8328. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8329. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8330. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8331. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8332. {
  8333. SubId = dac.Id,
  8334. DiId = dac.DiId,
  8335. Type = dac.Type,
  8336. Days = dac.Days,
  8337. NationalTravelFeeId = dac.NationalTravelFeeId,
  8338. Arae = $"{ntf.Country}-{ntf.City}",
  8339. Cost = dac.Cost,
  8340. Currency = dac.Currency,
  8341. CurrencyName = sd.Name,
  8342. SubTotal = dac.SubTotal,
  8343. })
  8344. .ToArray();
  8345. var data = new ChoiceMobileSubInfo3To6View()
  8346. {
  8347. ParentId = eecInfo.Id,
  8348. Choice = eecInfo.ChoiceFive,
  8349. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8350. Details = dayAndCostDatas
  8351. };
  8352. return Ok(JsonView(data));
  8353. }
  8354. else if (subType == 6) //6:培训费
  8355. {
  8356. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8357. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8358. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8359. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8360. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8361. {
  8362. SubId = dac.Id,
  8363. DiId = dac.DiId,
  8364. Type = dac.Type,
  8365. Days = dac.Days,
  8366. NationalTravelFeeId = dac.NationalTravelFeeId,
  8367. Arae = $"{ntf.Country}-{ntf.City}",
  8368. Cost = dac.Cost,
  8369. Currency = dac.Currency,
  8370. CurrencyName = sd.Name,
  8371. SubTotal = dac.SubTotal,
  8372. })
  8373. .ToArray();
  8374. var data = new ChoiceMobileSubInfo3To6View()
  8375. {
  8376. ParentId = eecInfo.Id,
  8377. Choice = eecInfo.ChoiceSix,
  8378. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8379. Details = dayAndCostDatas
  8380. };
  8381. return Ok(JsonView(data));
  8382. }
  8383. else if (subType == 7) //7:其他
  8384. {
  8385. //其他款项
  8386. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8387. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8388. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8389. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8390. .OrderBy((dop, sd1, sd2) => dop.Index)
  8391. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8392. {
  8393. SubId = dop.Id,
  8394. DiId = dop.Diid,
  8395. Index = dop.Index,
  8396. SetDataId = dop.SetDataId,
  8397. SetDataName = sd1.Name,
  8398. Cost = dop.Cost,
  8399. Currency = dop.Currency,
  8400. CurrencyName = sd2.Name,
  8401. SubTotal = dop.SubTotal,
  8402. Remark = dop.Remark,
  8403. })
  8404. .ToArray();
  8405. var data = new ChoiceSevenMobileSubInfoView()
  8406. {
  8407. ParentId = eecInfo.Id,
  8408. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8409. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8410. Details = otherData
  8411. };
  8412. return Ok(JsonView(data));
  8413. }
  8414. return Ok(JsonView(false));
  8415. }
  8416. #region op
  8417. /// <summary>
  8418. /// 移动端更新费用消息通知
  8419. /// </summary>
  8420. /// <param name="diid"></param>
  8421. /// <param name="id"></param>
  8422. /// <param name="currUserId"></param>
  8423. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8424. {
  8425. try
  8426. {
  8427. ////生成默认文件pdf并且通知人员
  8428. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8429. //{
  8430. // DiId = diid,
  8431. // ExportType = 1,
  8432. // SubTypeId = 1005
  8433. //}, "pdf");
  8434. ////发送通知
  8435. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8436. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8437. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8438. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8439. ////汇率信息记录
  8440. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8441. }
  8442. catch (Exception ex)
  8443. {
  8444. //记录日志
  8445. throw;
  8446. }
  8447. }
  8448. /// <summary>
  8449. /// 验证出入境费用数据是否存在
  8450. /// 不存在添加
  8451. /// </summary>
  8452. /// <param name="diId"></param>
  8453. /// <param name="currUserId"></param>
  8454. /// <returns></returns>
  8455. /// <exception cref="CustomException"></exception>
  8456. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8457. {
  8458. var parentId = 0;
  8459. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8460. if (info != null)
  8461. {
  8462. parentId = info.Id;
  8463. }
  8464. else
  8465. {
  8466. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8467. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8468. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8469. parentId = addId;
  8470. }
  8471. return parentId;
  8472. }
  8473. /// <summary>
  8474. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8475. /// </summary>
  8476. /// <returns></returns>
  8477. [HttpPost]
  8478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8479. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8480. {
  8481. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8482. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8483. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8484. //验证编辑权限
  8485. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8486. //if (!isEdit) return Ok(JsonView(false, msg));
  8487. var permissions = new List<Grp_EnterExitCostPermission>();
  8488. foreach (var userId in dto.UserIds)
  8489. {
  8490. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8491. }
  8492. if (permissions.Any())
  8493. {
  8494. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8495. {
  8496. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8497. }
  8498. _sqlSugar.BeginTran();
  8499. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8500. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8501. if (result < 1)
  8502. {
  8503. _sqlSugar.RollbackTran();
  8504. return Ok(JsonView(false));
  8505. }
  8506. _sqlSugar.CommitTran();
  8507. return Ok(JsonView(true));
  8508. }
  8509. return Ok(JsonView(false));
  8510. }
  8511. /// <summary>
  8512. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8513. /// </summary>
  8514. /// <returns></returns>
  8515. [HttpPost]
  8516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8517. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8518. {
  8519. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8520. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8521. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8522. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8523. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8524. int id = dto.Id;
  8525. if (id <= 0) //add
  8526. {
  8527. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8528. if (add < 1) return Ok(JsonView(false));
  8529. id = add;
  8530. }
  8531. else //update
  8532. {
  8533. ////验证编辑权限
  8534. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8535. //if (!isEdit) return Ok(JsonView(false, msg));
  8536. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8537. if (upd < 1) return Ok(JsonView(false));
  8538. }
  8539. #region 汇率变更时更改币种相关费用
  8540. var opDayCosts = new List<Grp_DayAndCost>();
  8541. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8542. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8543. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8544. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8545. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8546. .Select((dac, sd) => new
  8547. {
  8548. dac.Id,
  8549. dac.DiId,
  8550. CurrencyCode = sd.Name,
  8551. dac.Cost
  8552. })
  8553. .ToList();
  8554. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8555. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8556. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8557. .Select((dop, sd) => new
  8558. {
  8559. dop.Id,
  8560. dop.Diid,
  8561. CurrencyCode = sd.Name,
  8562. dop.Cost
  8563. })
  8564. .ToList();
  8565. if (dayCosts.Count > 0)
  8566. {
  8567. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8568. foreach (var dc in new_dayCosts)
  8569. {
  8570. var thisCurrency = dc.Key.ToUpper();
  8571. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8572. if (thisRate == 0.00M) continue;
  8573. foreach (var dcSub in dc)
  8574. {
  8575. opDayCosts.Add(new Grp_DayAndCost()
  8576. {
  8577. Id = dcSub.Id,
  8578. DiId = dcSub.DiId,
  8579. Cost = dcSub.Cost,
  8580. SubTotal = dcSub.Cost * thisRate,
  8581. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8582. });
  8583. }
  8584. }
  8585. if (opDayCosts.Count > 0)
  8586. {
  8587. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8588. }
  8589. }
  8590. if (dayOtherCosts.Count > 0)
  8591. {
  8592. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8593. foreach (var dc in new_dayOtherCosts)
  8594. {
  8595. var thisCurrency = dc.Key.ToUpper();
  8596. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8597. if (thisRate == 0.00M) continue;
  8598. foreach (var dcSub in dc)
  8599. {
  8600. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8601. {
  8602. Id = dcSub.Id,
  8603. Diid = dcSub.Diid,
  8604. Cost = dcSub.Cost,
  8605. SubTotal = dcSub.Cost * thisRate,
  8606. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8607. });
  8608. }
  8609. }
  8610. if (opDayOtherCosts.Count > 0)
  8611. {
  8612. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8613. }
  8614. }
  8615. #endregion
  8616. //消息通知
  8617. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8618. //汇率信息记录
  8619. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8620. return Ok(JsonView(new { parentId = id }));
  8621. }
  8622. /// <summary>
  8623. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8624. /// </summary>
  8625. /// <returns></returns>
  8626. [HttpPost]
  8627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8628. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8629. {
  8630. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8631. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8632. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8633. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8634. int id = dto.Id;
  8635. if (id <= 0) //add
  8636. {
  8637. checkboxInfo.CreateUserId = dto.CurrUserId;
  8638. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8639. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8640. if (add < 1) return Ok(JsonView(false));
  8641. }
  8642. else //update
  8643. {
  8644. ////验证编辑权限
  8645. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8646. //if (!isEdit) return Ok(JsonView(false, msg));
  8647. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8648. .UpdateColumns(x => new
  8649. {
  8650. x.ChoiceOne,
  8651. x.ChoiceTwo,
  8652. x.SumJJC,
  8653. x.SumGWC,
  8654. x.SumTDC,
  8655. x.ChoiceThree,
  8656. x.ChoiceFour,
  8657. x.ChoiceFive,
  8658. x.ChoiceSix,
  8659. x.OtherExpenses_Checked
  8660. })
  8661. .Where(x => x.Id == id)
  8662. .ExecuteCommandAsync();
  8663. if (upd < 1) return Ok(JsonView(false));
  8664. }
  8665. return Ok(JsonView(new { parentId = id }));
  8666. }
  8667. /// <summary>
  8668. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8669. /// </summary>
  8670. /// <returns></returns>
  8671. [HttpPost]
  8672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8673. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8674. {
  8675. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8676. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8677. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8678. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8679. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8680. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8681. var checkboxInfo = new Grp_EnterExitCost()
  8682. {
  8683. Id = id,
  8684. DiId = diId,
  8685. CreateUserId = currUserId
  8686. };
  8687. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8688. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8689. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8690. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8691. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8692. if (id <= 0) //add
  8693. {
  8694. checkboxInfo.CreateUserId = dto.CurrUserId;
  8695. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8696. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8697. if (add < 1) return Ok(JsonView(false));
  8698. }
  8699. else //update
  8700. {
  8701. ////验证编辑权限
  8702. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8703. //if (!isEdit) return Ok(JsonView(false, msg));
  8704. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8705. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8706. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8707. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8708. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8709. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8710. .Where(x => x.Id == id)
  8711. .ExecuteCommandAsync();
  8712. if (upd < 1) return Ok(JsonView(false));
  8713. }
  8714. return Ok(JsonView(new { parentId = id }));
  8715. }
  8716. /// <summary>
  8717. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8718. /// </summary>
  8719. /// <returns></returns>
  8720. [HttpPost]
  8721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8722. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8723. {
  8724. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8725. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8726. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8727. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8728. info.FirstItemRemark = dto.FirstItemRemark;
  8729. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8730. int id = dto.Id;
  8731. if (id <= 0) //add
  8732. {
  8733. info.CreateUserId = dto.CurrUserId;
  8734. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8735. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8736. if (add < 1) return Ok(JsonView(false));
  8737. id = add;
  8738. }
  8739. else //update
  8740. {
  8741. ////验证编辑权限
  8742. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8743. //if (!isEdit) return Ok(JsonView(false, msg));
  8744. var upd = await _sqlSugar.Updateable(info)
  8745. .UpdateColumns(x => new
  8746. {
  8747. x.ChoiceOne,
  8748. x.InsidePay,
  8749. x.VisaRemark,
  8750. x.Visa,
  8751. x.Service,
  8752. x.Safe,
  8753. x.Ticket,
  8754. x.HeSuan,
  8755. x.YiMiao,
  8756. x.FirstItemRemark
  8757. })
  8758. .Where(x => x.Id == id)
  8759. .ExecuteCommandAsync();
  8760. if (upd < 1) return Ok(JsonView(false));
  8761. }
  8762. //消息通知
  8763. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8764. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8765. }
  8766. /// <summary>
  8767. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8768. /// </summary>
  8769. /// <returns></returns>
  8770. [HttpPost]
  8771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8772. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8773. {
  8774. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8775. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8776. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8777. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8778. info.OutsideJJPay = dto.OutsideJJPay;
  8779. info.OutsideGWPay = dto.OutsideGWPay;
  8780. info.OutsideTDPay = dto.OutsideTDPay;
  8781. info.AirJJ = dto.AirJJ;
  8782. info.AirGW = dto.AirGW;
  8783. info.AirTD = dto.AirTD;
  8784. info.CityTranffic = dto.CityTranffic;
  8785. info.TwoItemRemark = dto.TwoItemRemark;
  8786. info.SumJJC = dto.ChoiceTwoJJ;
  8787. info.SumGWC = dto.ChoiceTwoGW;
  8788. info.SumTDC = dto.ChoiceTwoTD;
  8789. int id = dto.Id;
  8790. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8791. if (id <= 0) //add
  8792. {
  8793. info.CreateUserId = dto.CurrUserId;
  8794. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8795. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8796. if (addId <= 0) return Ok(JsonView(false));
  8797. id = addId;
  8798. }
  8799. else //update
  8800. {
  8801. ////验证编辑权限
  8802. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8803. //if (!isEdit) return Ok(JsonView(false, msg));
  8804. var upd = await _sqlSugar.Updateable(info)
  8805. .UpdateColumns(x => new
  8806. {
  8807. x.SumJJC,
  8808. x.OutsideJJPay,
  8809. x.SumGWC,
  8810. x.OutsideGWPay,
  8811. x.SumTDC,
  8812. x.OutsideTDPay,
  8813. x.AirJJ,
  8814. x.AirGW,
  8815. x.AirTD,
  8816. x.CityTranffic,
  8817. x.TwoItemRemark
  8818. })
  8819. .Where(x => x.Id == id)
  8820. .ExecuteCommandAsync();
  8821. if (upd < 1) return Ok(JsonView(false));
  8822. }
  8823. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8824. gwcItemTotal = info.AirGW + info.CityTranffic;
  8825. tdcItemTotal = info.AirTD + info.CityTranffic;
  8826. //消息通知
  8827. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8828. return Ok(JsonView(new
  8829. {
  8830. parentId = id,
  8831. choiceTwoJJ = dto.ChoiceTwoJJ,
  8832. jjcItemTotal = jjcItemTotal,
  8833. choiceTwoGW = dto.ChoiceTwoGW,
  8834. gwcItemTotal = gwcItemTotal,
  8835. choiceTwoTD = dto.ChoiceTwoTD,
  8836. tdcItemTotal = tdcItemTotal
  8837. }));
  8838. }
  8839. /// <summary>
  8840. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8841. /// </summary>
  8842. /// <returns></returns>
  8843. [HttpPost]
  8844. [ApiExplorerSettings(IgnoreApi = true)]
  8845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8846. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8847. {
  8848. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8849. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8850. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8851. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8852. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8853. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8854. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8855. var infos = infos1.Select(x => new Grp_DayAndCost
  8856. {
  8857. Id = x.Id,
  8858. DiId = dto.DiId,
  8859. Type = dto.FeeType,
  8860. Days = x.Days,
  8861. NationalTravelFeeId = x.NationalTravelFeeId,
  8862. Cost = x.Cost,
  8863. Currency = x.Currency,
  8864. SubTotal = x.SubTotal,
  8865. CreateUserId = dto.CurrUserId
  8866. })
  8867. .ToList();
  8868. var adds = infos.Where(x => x.Id <= 0).ToList();
  8869. var upds = infos.Where(x => x.Id > 0).ToList();
  8870. if (adds.Count > 0)
  8871. {
  8872. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8873. if (add < 1) return Ok(JsonView(false));
  8874. }
  8875. if (upds.Count > 0)
  8876. {
  8877. var upd = await _sqlSugar.Updateable(adds)
  8878. .UpdateColumns(x => new
  8879. {
  8880. x.Days,
  8881. x.NationalTravelFeeId,
  8882. x.Cost,
  8883. x.Currency,
  8884. x.SubTotal
  8885. })
  8886. .WhereColumns(x => new { x.Id })
  8887. .ExecuteCommandAsync();
  8888. if (upd < 1) return Ok(JsonView(false));
  8889. }
  8890. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8891. //消息通知
  8892. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8893. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8894. return Ok(JsonView(new { itemTotal = itemTotal }));
  8895. }
  8896. /// <summary>
  8897. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8898. /// </summary>
  8899. /// <returns></returns>
  8900. [HttpPost]
  8901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8902. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8903. {
  8904. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8905. int subId = dto.SubId, feeType = dto.FeeType;
  8906. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8907. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8908. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8909. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8910. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8911. subInfo.Id = subId;
  8912. subInfo.DiId = dto.DiId;
  8913. if (feeType == 3) subInfo.Type = 1;
  8914. else if (feeType == 4) subInfo.Type = 2;
  8915. else if (feeType == 5) subInfo.Type = 3;
  8916. else if (feeType == 6) subInfo.Type = 4;
  8917. subInfo.CreateUserId = dto.CurrUserId;
  8918. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8919. if (parentId < 1) return Ok(JsonView(false));
  8920. //子表op
  8921. if (subId < 1)
  8922. {
  8923. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8924. if (subAdd < 1) return Ok(JsonView(false));
  8925. }
  8926. else
  8927. {
  8928. ////验证编辑权限
  8929. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8930. //if (!isEdit) return Ok(JsonView(false, msg));
  8931. var subUpd = await _sqlSugar.Updateable(subInfo)
  8932. .UpdateColumns(x => new
  8933. {
  8934. x.Days,
  8935. x.NationalTravelFeeId,
  8936. x.Cost,
  8937. x.Currency,
  8938. x.SubTotal
  8939. })
  8940. .WhereColumns(x => new { x.Id })
  8941. .ExecuteCommandAsync();
  8942. if (subUpd < 1) return Ok(JsonView(false));
  8943. }
  8944. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8945. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8946. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8947. }
  8948. /// <summary>
  8949. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8950. /// </summary>
  8951. /// <returns></returns>
  8952. [HttpPost]
  8953. [ApiExplorerSettings(IgnoreApi = true)]
  8954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8955. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8956. {
  8957. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8958. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8959. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8960. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8961. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8962. {
  8963. Id = x.Id,
  8964. Diid = dto.DiId,
  8965. SetDataId = x.SetDataId,
  8966. Index = x.Index,
  8967. Cost = x.Cost,
  8968. Currency = x.Currency,
  8969. SubTotal = x.SubTotal,
  8970. CreateUserId = dto.CurrUserId,
  8971. Remark = x.Remark
  8972. }).ToList();
  8973. var adds = infos.Where(x => x.Id <= 0).ToList();
  8974. var upds = infos.Where(x => x.Id > 0).ToList();
  8975. if (adds.Count > 0)
  8976. {
  8977. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8978. if (add < 1) return Ok(JsonView(false));
  8979. }
  8980. if (upds.Count > 0)
  8981. {
  8982. var upd = await _sqlSugar.Updateable(adds)
  8983. .UpdateColumns(x => new
  8984. {
  8985. x.Index,
  8986. x.SetDataId,
  8987. x.Cost,
  8988. x.Currency,
  8989. x.SubTotal,
  8990. x.Remark
  8991. })
  8992. .WhereColumns(x => new { x.Id })
  8993. .ExecuteCommandAsync();
  8994. if (upd < 1) return Ok(JsonView(false));
  8995. }
  8996. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8997. //消息通知
  8998. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8999. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9000. return Ok(JsonView(new { itemTotal = itemTotal }));
  9001. }
  9002. /// <summary>
  9003. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  9004. /// </summary>
  9005. /// <returns></returns>
  9006. [HttpPost]
  9007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9008. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  9009. {
  9010. int subId = dto.SubId;
  9011. int diId = dto.Diid;
  9012. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9013. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9014. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9015. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  9016. subInfo.Id = subId;
  9017. subInfo.Diid = dto.Diid;
  9018. subInfo.CreateUserId = dto.CurrUserId;
  9019. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  9020. if (parentId < 1) return Ok(JsonView(false));
  9021. #region 子表op
  9022. if (subId < 1)//add
  9023. {
  9024. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9025. if (subAdd < 1) return Ok(JsonView(false));
  9026. }
  9027. else //upd
  9028. {
  9029. ////验证编辑权限
  9030. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9031. //if (!isEdit) return Ok(JsonView(false, msg));
  9032. var subUpd = await _sqlSugar.Updateable(subInfo)
  9033. .UpdateColumns(x => new
  9034. {
  9035. x.Index,
  9036. x.SetDataId,
  9037. x.Cost,
  9038. x.Currency,
  9039. x.SubTotal,
  9040. x.Remark
  9041. })
  9042. .WhereColumns(x => new { x.Id })
  9043. .ExecuteCommandAsync();
  9044. if (subUpd < 1) return Ok(JsonView(false));
  9045. }
  9046. #endregion
  9047. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9048. //消息通知
  9049. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9050. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9051. }
  9052. /// <summary>
  9053. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9054. /// </summary>
  9055. /// <returns></returns>
  9056. [HttpPost]
  9057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9058. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9059. {
  9060. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9061. if (data.Code != 0)
  9062. {
  9063. return Ok(JsonView(false, data.Msg));
  9064. }
  9065. return Ok(JsonView(true, "操作成功!", data.Data));
  9066. }
  9067. /// <summary>
  9068. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9069. /// </summary>
  9070. /// <param name="dto"></param>
  9071. /// <returns></returns>
  9072. [HttpPost]
  9073. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9074. {
  9075. var data = new Grp_DayOtherPrice()
  9076. {
  9077. Id = dto.Id,
  9078. IsDel = 1,
  9079. DeleteUserId = dto.DeleteUserId,
  9080. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9081. };
  9082. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9083. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9084. return Ok(JsonView(false, "删除失败!"));
  9085. }
  9086. #endregion
  9087. #endregion
  9088. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9089. /// <summary>
  9090. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9091. /// </summary>
  9092. /// <returns></returns>
  9093. [HttpPost]
  9094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9095. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9096. {
  9097. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9098. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9099. RefAsync<int> total = 0;
  9100. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9101. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9102. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9103. .Select(x => new
  9104. {
  9105. Id = x.Id,
  9106. DraftName = x.DraftName,
  9107. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9108. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9109. .Any()
  9110. })
  9111. .OrderByDescending(x => x.Id)
  9112. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9113. return Ok(JsonView(true, "查询成功!", data, total));
  9114. }
  9115. /// <summary>
  9116. /// 出入境费用-草稿 移动端
  9117. /// 获取币种基础数据(含逻辑处理)
  9118. /// </summary>
  9119. /// <returns></returns>
  9120. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9121. {
  9122. return await GeneralMethod.EnterExitCostInitRate();
  9123. }
  9124. /// <summary>
  9125. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9126. /// </summary>
  9127. /// <returns></returns>
  9128. [HttpPost]
  9129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9130. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9131. {
  9132. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9133. //SetDataInfoView
  9134. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9135. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9136. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9137. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9138. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9139. //默认币种显示
  9140. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9141. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9142. return Ok(JsonView(true, "查询成功!", new
  9143. {
  9144. WordTypeData = _WordTypeData,
  9145. ExcelTypeData = _ExcelTypeData,
  9146. CurrencyInit = _currencyInfos,
  9147. viewPermissionData = viewPermissionData
  9148. }));
  9149. }
  9150. /// <summary>
  9151. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9152. /// </summary>
  9153. /// <returns></returns>
  9154. [HttpPost]
  9155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9156. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9157. {
  9158. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9159. RefAsync<int> total = 0;
  9160. int diId = 0;
  9161. var status = int.TryParse(dto.GroupName, out diId);
  9162. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9163. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9164. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9165. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9166. .OrderByDescending(x => x.VisitStartDate)
  9167. .Select(x => new
  9168. {
  9169. Id = x.Id,
  9170. GroupName = x.TeamName
  9171. })
  9172. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9173. return Ok(JsonView(true, "查询成功!", data, total));
  9174. }
  9175. /// <summary>
  9176. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9177. /// </summary>
  9178. /// <returns></returns>
  9179. [HttpPost]
  9180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9181. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9182. {
  9183. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9184. RefAsync<int> total = 0;
  9185. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9186. .Where(x => x.IsDel == 0 && x.STid == 66)
  9187. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9188. .Select(x => new
  9189. {
  9190. id = x.Id,
  9191. name = x.Name,
  9192. remark = x.Remark,
  9193. })
  9194. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9195. return Ok(JsonView(true, "查询成功!", data, total));
  9196. }
  9197. /// <summary>
  9198. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9199. /// </summary>
  9200. /// <returns></returns>
  9201. [HttpPost]
  9202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9203. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9204. {
  9205. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9206. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9207. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9208. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9209. var groupOtherRateData = groupRateData.TeamRates;
  9210. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9211. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9212. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9213. groupOtherRateData = groupOtherRateData
  9214. .Select(x => new TeamRateDescAddCurrencyIdView
  9215. {
  9216. CurrencyId = x.CurrencyId,
  9217. CurrencyName = x.CurrencyName,
  9218. CurrencyCode = x.CurrencyCode,
  9219. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9220. }).ToList();
  9221. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9222. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9223. }
  9224. /// <summary>
  9225. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9226. /// </summary>
  9227. /// <returns></returns>
  9228. [HttpPost]
  9229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9230. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9231. {
  9232. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9233. var tipsData = new List<int>() { 1, 2, 3 };
  9234. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9235. if (dto.TipsType == 1)
  9236. {
  9237. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9238. }
  9239. else if (dto.TipsType == 2)
  9240. {
  9241. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9242. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9243. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9244. .Select(x => x.NationalTravelFeeId)
  9245. .Distinct()
  9246. .ToListAsync();
  9247. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9248. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9249. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9250. .Select(x => x.Country)
  9251. .Distinct()
  9252. .ToArrayAsync();
  9253. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9254. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9255. return Ok(JsonView(true, "查询成功!", new
  9256. {
  9257. totalAmt = totalAmt,
  9258. remark = remark
  9259. }));
  9260. }
  9261. else if (dto.TipsType == 3)
  9262. {
  9263. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9264. }
  9265. return Ok(JsonView(false));
  9266. }
  9267. /// <summary>
  9268. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9269. /// </summary>
  9270. /// <returns></returns>
  9271. [HttpPost]
  9272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9273. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9274. {
  9275. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9276. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9277. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9278. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9279. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9280. var info = new Grp_EnterExitCostDraft()
  9281. {
  9282. DraftName = dto.DraftName,
  9283. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9284. CreateUserId = dto.CurrUserId
  9285. };
  9286. _sqlSugar.BeginTran();
  9287. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9288. if (draftId < 1)
  9289. {
  9290. _sqlSugar.RollbackTran();
  9291. return Ok(JsonView(false, "草稿创建失败!"));
  9292. }
  9293. //添加默认权限
  9294. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  9295. _sqlSugar.CommitTran();
  9296. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9297. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9298. mobileInfo.Id = draftId;
  9299. mobileInfo.DraftName = dto.DraftName;
  9300. mobileInfo.Currencys = rateInfos;
  9301. mobileInfo.IsAssignPerm = assignPerm;
  9302. return Ok(JsonView(mobileInfo));
  9303. }
  9304. /// <summary>
  9305. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9306. /// </summary>
  9307. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9308. /// <summary>
  9309. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9310. /// </summary>
  9311. /// <returns></returns>
  9312. [HttpPost]
  9313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9314. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9315. {
  9316. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9317. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9318. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9319. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9320. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9321. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9322. //验证查看编辑权限
  9323. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9324. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9325. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9326. mobileInfo.IsAssignPerm = assignPerm;
  9327. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9328. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9329. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9330. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9331. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9332. {
  9333. ParentId = dac.ParentId,
  9334. SubId = dac.Id,
  9335. Type = dac.Type,
  9336. Days = dac.Days,
  9337. NationalTravelFeeId = dac.NationalTravelFeeId,
  9338. Arae = $"{ntf.Country}-{ntf.City}",
  9339. Cost = dac.Cost,
  9340. Currency = dac.Currency,
  9341. CurrencyName = sd.Name,
  9342. SubTotal = dac.SubTotal,
  9343. })
  9344. .ToList();
  9345. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9346. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9347. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9348. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9349. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9350. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9351. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9352. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9353. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9354. //其他款项
  9355. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9356. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9357. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9358. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9359. .OrderBy((dop, sd1, sd2) => dop.Index)
  9360. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9361. {
  9362. ParentId = dop.ParentId,
  9363. SubId = dop.Id,
  9364. Index = dop.Index,
  9365. SetDataId = dop.SetDataId,
  9366. SetDataName = sd1.Name,
  9367. Cost = dop.Cost,
  9368. Currency = dop.Currency,
  9369. CurrencyName = sd2.Remark,
  9370. SubTotal = dop.SubTotal,
  9371. Remark = dop.Remark,
  9372. })
  9373. .ToArray();
  9374. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9375. return Ok(mobileInfo);
  9376. }
  9377. /// <summary>
  9378. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9379. /// </summary>
  9380. /// <returns></returns>
  9381. [HttpPost]
  9382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9383. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9384. {
  9385. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9386. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9387. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9388. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9389. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9390. //验证查看编辑权限
  9391. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9392. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9393. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9394. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9395. var subType = dto.SubType;
  9396. if (subType == 1) //1:境内费用
  9397. {
  9398. var oneData = new ChoiceOneMobileSubInfoView()
  9399. {
  9400. Id = eecInfo.Id,
  9401. ChoiceOne = eecInfo.ChoiceOne,
  9402. ChoiceOneTotalCost = eecInfo.InsidePay,
  9403. Visa = eecInfo.Visa,
  9404. VisaRemark = eecInfo.VisaRemark,
  9405. YiMiao = eecInfo.YiMiao,
  9406. HeSuan = eecInfo.HeSuan,
  9407. Service = eecInfo.Service,
  9408. Ticket = eecInfo.Ticket,
  9409. Safe = eecInfo.Safe,
  9410. FirstItemRemark = eecInfo.FirstItemRemark
  9411. };
  9412. return Ok(JsonView(oneData));
  9413. }
  9414. else if (subType == 2) //2:国际旅费
  9415. {
  9416. var twoData = new ChoiceTwoMobileSubInfoView()
  9417. {
  9418. Id = eecInfo.Id,
  9419. ChoiceTwoJJ = eecInfo.SumJJC,
  9420. OutsideJJPay = eecInfo.OutsideJJPay,
  9421. ChoiceTwoGW = eecInfo.SumGWC,
  9422. OutsideGWPay = eecInfo.OutsideGWPay,
  9423. ChoiceTwoTD = eecInfo.SumTDC,
  9424. OutsideTDPay = eecInfo.OutsideTDPay,
  9425. AirJJ = eecInfo.AirJJ,
  9426. AirGW = eecInfo.AirGW,
  9427. AirTD = eecInfo.AirTD,
  9428. CityTranffic = eecInfo.CityTranffic,
  9429. TwoItemRemark = eecInfo.TwoItemRemark
  9430. };
  9431. return Ok(JsonView(twoData));
  9432. }
  9433. else if (subType == 3) //3:住宿费
  9434. {
  9435. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9436. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9437. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9438. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9439. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9440. {
  9441. ParentId = dac.ParentId,
  9442. SubId = dac.Id,
  9443. Type = dac.Type,
  9444. Days = dac.Days,
  9445. NationalTravelFeeId = dac.NationalTravelFeeId,
  9446. Arae = $"{ntf.Country}-{ntf.City}",
  9447. Cost = dac.Cost,
  9448. Currency = dac.Currency,
  9449. CurrencyName = sd.Name,
  9450. SubTotal = dac.SubTotal,
  9451. })
  9452. .ToArray();
  9453. var data = new ChoiceDraftMobileSubInfo3To6View()
  9454. {
  9455. ParentId = eecInfo.Id,
  9456. Choice = eecInfo.ChoiceThree,
  9457. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9458. Details = dayAndCostDatas
  9459. };
  9460. return Ok(JsonView(data));
  9461. }
  9462. else if (subType == 4) //4:伙食费
  9463. {
  9464. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9465. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9466. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9467. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9468. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9469. {
  9470. ParentId = dac.ParentId,
  9471. SubId = dac.Id,
  9472. Type = dac.Type,
  9473. Days = dac.Days,
  9474. NationalTravelFeeId = dac.NationalTravelFeeId,
  9475. Arae = $"{ntf.Country}-{ntf.City}",
  9476. Cost = dac.Cost,
  9477. Currency = dac.Currency,
  9478. CurrencyName = sd.Name,
  9479. SubTotal = dac.SubTotal,
  9480. })
  9481. .ToArray();
  9482. var data = new ChoiceDraftMobileSubInfo3To6View()
  9483. {
  9484. ParentId = eecInfo.Id,
  9485. Choice = eecInfo.ChoiceFour,
  9486. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9487. Details = dayAndCostDatas
  9488. };
  9489. return Ok(JsonView(data));
  9490. }
  9491. else if (subType == 5) //5:公杂费
  9492. {
  9493. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9494. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9495. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9496. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9497. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9498. {
  9499. ParentId = dac.ParentId,
  9500. SubId = dac.Id,
  9501. Type = dac.Type,
  9502. Days = dac.Days,
  9503. NationalTravelFeeId = dac.NationalTravelFeeId,
  9504. Arae = $"{ntf.Country}-{ntf.City}",
  9505. Cost = dac.Cost,
  9506. Currency = dac.Currency,
  9507. CurrencyName = sd.Name,
  9508. SubTotal = dac.SubTotal,
  9509. })
  9510. .ToArray();
  9511. var data = new ChoiceDraftMobileSubInfo3To6View()
  9512. {
  9513. ParentId = eecInfo.Id,
  9514. Choice = eecInfo.ChoiceFive,
  9515. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9516. Details = dayAndCostDatas
  9517. };
  9518. return Ok(JsonView(data));
  9519. }
  9520. else if (subType == 6) //6:培训费
  9521. {
  9522. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9523. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9524. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9525. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9526. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9527. {
  9528. ParentId = dac.ParentId,
  9529. SubId = dac.Id,
  9530. Type = dac.Type,
  9531. Days = dac.Days,
  9532. NationalTravelFeeId = dac.NationalTravelFeeId,
  9533. Arae = $"{ntf.Country}-{ntf.City}",
  9534. Cost = dac.Cost,
  9535. Currency = dac.Currency,
  9536. CurrencyName = sd.Name,
  9537. SubTotal = dac.SubTotal,
  9538. })
  9539. .ToArray();
  9540. var data = new ChoiceDraftMobileSubInfo3To6View()
  9541. {
  9542. ParentId = eecInfo.Id,
  9543. Choice = eecInfo.ChoiceSix,
  9544. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9545. Details = dayAndCostDatas
  9546. };
  9547. return Ok(JsonView(data));
  9548. }
  9549. else if (subType == 7) //7:其他
  9550. {
  9551. //其他款项
  9552. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9553. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9554. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9555. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9556. .OrderBy((dop, sd1, sd2) => dop.Index)
  9557. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9558. {
  9559. ParentId = dop.ParentId,
  9560. SubId = dop.Id,
  9561. Index = dop.Index,
  9562. SetDataId = dop.SetDataId,
  9563. SetDataName = sd1.Name,
  9564. Cost = dop.Cost,
  9565. Currency = dop.Currency,
  9566. CurrencyName = sd2.Name,
  9567. SubTotal = dop.SubTotal,
  9568. Remark = dop.Remark,
  9569. })
  9570. .ToArray();
  9571. var data = new ChoiceSevenDraftMobileSubInfoView()
  9572. {
  9573. ParentId = eecInfo.Id,
  9574. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9575. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9576. Details = otherData
  9577. };
  9578. return Ok(JsonView(data));
  9579. }
  9580. return Ok(JsonView(false));
  9581. }
  9582. #region op
  9583. /// <summary>
  9584. /// 移动端更新费用消息通知
  9585. /// </summary>
  9586. /// <param name="draftId"></param>
  9587. /// <param name="id"></param>
  9588. /// <param name="currUserId"></param>
  9589. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9590. {
  9591. try
  9592. {
  9593. ////生成默认文件pdf并且通知人员
  9594. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9595. //{
  9596. // DiId = draftId,
  9597. // ExportType = 1,
  9598. // SubTypeId = 1005
  9599. //}, "pdf");
  9600. ////发送通知
  9601. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9602. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9603. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9604. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9605. ////汇率信息记录
  9606. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9607. }
  9608. catch (Exception ex)
  9609. {
  9610. //记录日志
  9611. throw;
  9612. }
  9613. }
  9614. /// <summary>
  9615. /// 验证出入境费用数据是否存在
  9616. /// 不存在添加
  9617. /// </summary>
  9618. /// <param name="draftId"></param>
  9619. /// <param name="currUserId"></param>
  9620. /// <returns></returns>
  9621. /// <exception cref="CustomException"></exception>
  9622. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9623. {
  9624. var parentId = 0;
  9625. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9626. if (info != null) parentId = info.Id;
  9627. else
  9628. {
  9629. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9630. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9631. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9632. parentId = addId;
  9633. }
  9634. return parentId;
  9635. }
  9636. /// <summary>
  9637. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  9638. /// </summary>
  9639. /// <returns></returns>
  9640. [HttpPost]
  9641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9642. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  9643. {
  9644. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9645. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9646. //验证查看权限
  9647. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9648. if (!isView) return Ok(JsonView(false, _viewPermStr));
  9649. var userIds = await _sqlSugar
  9650. .Queryable<Grp_EnterExitCostDraftPermission>()
  9651. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  9652. .Select(x => x.UserId)
  9653. .ToArrayAsync();
  9654. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9655. var perUsersView = new List<dynamic>();
  9656. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  9657. var viewPermissionData = new List<PermissionViewUserview>();
  9658. if (feeBasePerm.Any())
  9659. {
  9660. foreach (var item in feeBasePerm)
  9661. {
  9662. if (item.Users.Any())
  9663. {
  9664. viewPermissionData.AddRange(item.Users);
  9665. }
  9666. }
  9667. }
  9668. foreach (var item in perUsers)
  9669. {
  9670. bool isView1 = false;
  9671. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9672. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  9673. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9674. }
  9675. return Ok(JsonView(perUsersView));
  9676. }
  9677. /// <summary>
  9678. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9679. /// </summary>
  9680. /// <returns></returns>
  9681. [HttpPost]
  9682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9683. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9684. {
  9685. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9686. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9687. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9688. //验证查看编辑权限
  9689. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9690. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9691. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  9692. foreach (var userId in dto.UserIds)
  9693. {
  9694. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9695. }
  9696. if (permissions.Any())
  9697. {
  9698. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9699. {
  9700. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9701. }
  9702. _sqlSugar.BeginTran();
  9703. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9704. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9705. if (result < 1)
  9706. {
  9707. _sqlSugar.RollbackTran();
  9708. return Ok(JsonView(false));
  9709. }
  9710. _sqlSugar.CommitTran();
  9711. return Ok(JsonView(true));
  9712. }
  9713. return Ok(JsonView(false));
  9714. }
  9715. /// <summary>
  9716. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9717. /// </summary>
  9718. /// <returns></returns>
  9719. [HttpPost]
  9720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9721. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9722. {
  9723. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9724. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9725. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9726. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9727. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9728. int id = dto.DraftId;
  9729. if (id <= 0) //add
  9730. {
  9731. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9732. if (add < 1) return Ok(JsonView(false));
  9733. id = add;
  9734. }
  9735. else //update
  9736. {
  9737. //验证查看编辑权限
  9738. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9739. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9740. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9741. if (upd < 1) return Ok(JsonView(false));
  9742. }
  9743. #region 汇率变更时更改币种相关费用
  9744. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9745. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9746. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9747. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9748. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9749. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9750. .Select((dac, sd) => new
  9751. {
  9752. dac.Id,
  9753. dac.ParentId,
  9754. CurrencyCode = sd.Name,
  9755. dac.Cost
  9756. })
  9757. .ToList();
  9758. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9759. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9760. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9761. .Select((dop, sd) => new
  9762. {
  9763. dop.Id,
  9764. dop.ParentId,
  9765. CurrencyCode = sd.Name,
  9766. dop.Cost
  9767. })
  9768. .ToList();
  9769. if (dayCosts.Count > 0)
  9770. {
  9771. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9772. foreach (var dc in new_dayCosts)
  9773. {
  9774. var thisCurrency = dc.Key.ToUpper();
  9775. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9776. if (thisRate == 0.00M) continue;
  9777. foreach (var dcSub in dc)
  9778. {
  9779. opDayCosts.Add(new Grp_DayAndCostDraft()
  9780. {
  9781. Id = dcSub.Id,
  9782. ParentId = dcSub.ParentId,
  9783. Cost = dcSub.Cost,
  9784. SubTotal = dcSub.Cost * thisRate,
  9785. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9786. });
  9787. }
  9788. }
  9789. if (opDayCosts.Count > 0)
  9790. {
  9791. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9792. }
  9793. }
  9794. if (dayOtherCosts.Count > 0)
  9795. {
  9796. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9797. foreach (var dc in new_dayOtherCosts)
  9798. {
  9799. var thisCurrency = dc.Key.ToUpper();
  9800. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9801. if (thisRate == 0.00M) continue;
  9802. foreach (var dcSub in dc)
  9803. {
  9804. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9805. {
  9806. Id = dcSub.Id,
  9807. ParentId = dcSub.ParentId,
  9808. Cost = dcSub.Cost,
  9809. SubTotal = dcSub.Cost * thisRate,
  9810. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9811. });
  9812. }
  9813. }
  9814. if (opDayOtherCosts.Count > 0)
  9815. {
  9816. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9817. }
  9818. }
  9819. #endregion
  9820. ////消息通知
  9821. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9822. ////汇率信息记录
  9823. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9824. return Ok(JsonView(new { parentId = id }));
  9825. }
  9826. /// <summary>
  9827. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9828. /// </summary>
  9829. /// <returns></returns>
  9830. [HttpPost]
  9831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9832. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9833. {
  9834. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9835. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9836. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9837. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9838. int id = dto.DraftId;
  9839. if (id <= 0) //add
  9840. {
  9841. checkboxInfo.CreateUserId = dto.CurrUserId;
  9842. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9843. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9844. if (add < 1) return Ok(JsonView(false));
  9845. }
  9846. else //update
  9847. {
  9848. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9849. .UpdateColumns(x => new
  9850. {
  9851. x.ChoiceOne,
  9852. x.ChoiceTwo,
  9853. x.SumJJC,
  9854. x.SumGWC,
  9855. x.SumTDC,
  9856. x.ChoiceThree,
  9857. x.ChoiceFour,
  9858. x.ChoiceFive,
  9859. x.ChoiceSix,
  9860. x.OtherExpenses_Checked
  9861. })
  9862. .Where(x => x.Id == id)
  9863. .ExecuteCommandAsync();
  9864. if (upd < 1) return Ok(JsonView(false));
  9865. }
  9866. return Ok(JsonView(new { parentId = id }));
  9867. }
  9868. /// <summary>
  9869. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9870. /// </summary>
  9871. /// <returns></returns>
  9872. [HttpPost]
  9873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9874. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9875. {
  9876. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9877. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9878. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9879. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9880. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9881. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9882. var checkboxInfo = new Grp_EnterExitCostDraft()
  9883. {
  9884. Id = draftId,
  9885. CreateUserId = currUserId
  9886. };
  9887. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9888. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9889. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9890. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9891. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9892. if (draftId <= 0) //add
  9893. {
  9894. checkboxInfo.CreateUserId = dto.CurrUserId;
  9895. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9896. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9897. if (add < 1) return Ok(JsonView(false));
  9898. }
  9899. else //update
  9900. {
  9901. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9902. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9903. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9904. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9905. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9906. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9907. .Where(x => x.Id == draftId)
  9908. .ExecuteCommandAsync();
  9909. if (upd < 1) return Ok(JsonView(false));
  9910. }
  9911. return Ok(JsonView(new { parentId = draftId }));
  9912. }
  9913. /// <summary>
  9914. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9915. /// </summary>
  9916. /// <returns></returns>
  9917. [HttpPost]
  9918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9919. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9920. {
  9921. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9922. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9923. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9924. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9925. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9926. info.FirstItemRemark = dto.FirstItemRemark;
  9927. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9928. if (id <= 0) //add
  9929. {
  9930. info.CreateUserId = dto.CurrUserId;
  9931. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9932. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9933. if (add < 1) return Ok(JsonView(false));
  9934. id = add;
  9935. }
  9936. else //update
  9937. {
  9938. var upd = await _sqlSugar.Updateable(info)
  9939. .UpdateColumns(x => new
  9940. {
  9941. x.ChoiceOne,
  9942. x.InsidePay,
  9943. x.VisaRemark,
  9944. x.Visa,
  9945. x.Service,
  9946. x.Safe,
  9947. x.Ticket,
  9948. x.HeSuan,
  9949. x.YiMiao,
  9950. x.FirstItemRemark
  9951. })
  9952. .Where(x => x.Id == id)
  9953. .ExecuteCommandAsync();
  9954. if (upd < 1) return Ok(JsonView(false));
  9955. }
  9956. ////消息通知
  9957. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9958. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9959. }
  9960. /// <summary>
  9961. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9962. /// </summary>
  9963. /// <returns></returns>
  9964. [HttpPost]
  9965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9966. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9967. {
  9968. int id = dto.DraftId;
  9969. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9970. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9971. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9972. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9973. info.OutsideJJPay = dto.OutsideJJPay;
  9974. info.OutsideGWPay = dto.OutsideGWPay;
  9975. info.OutsideTDPay = dto.OutsideTDPay;
  9976. info.AirJJ = dto.AirJJ;
  9977. info.AirGW = dto.AirGW;
  9978. info.AirTD = dto.AirTD;
  9979. info.CityTranffic = dto.CityTranffic;
  9980. info.TwoItemRemark = dto.TwoItemRemark;
  9981. info.SumJJC = dto.ChoiceTwoJJ;
  9982. info.SumGWC = dto.ChoiceTwoGW;
  9983. info.SumTDC = dto.ChoiceTwoTD;
  9984. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9985. if (id <= 0) //add
  9986. {
  9987. info.CreateUserId = dto.CurrUserId;
  9988. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9989. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9990. if (addId <= 0) return Ok(JsonView(false));
  9991. id = addId;
  9992. }
  9993. else //update
  9994. {
  9995. var upd = await _sqlSugar.Updateable(info)
  9996. .UpdateColumns(x => new
  9997. {
  9998. x.SumJJC,
  9999. x.OutsideJJPay,
  10000. x.SumGWC,
  10001. x.OutsideGWPay,
  10002. x.SumTDC,
  10003. x.OutsideTDPay,
  10004. x.AirJJ,
  10005. x.AirGW,
  10006. x.AirTD,
  10007. x.CityTranffic,
  10008. x.TwoItemRemark
  10009. })
  10010. .Where(x => x.Id == id)
  10011. .ExecuteCommandAsync();
  10012. if (upd < 1) return Ok(JsonView(false));
  10013. }
  10014. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10015. gwcItemTotal = info.AirGW + info.CityTranffic;
  10016. tdcItemTotal = info.AirTD + info.CityTranffic;
  10017. ////消息通知
  10018. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10019. return Ok(JsonView(new
  10020. {
  10021. parentId = id,
  10022. choiceTwoJJ = dto.ChoiceTwoJJ,
  10023. jjcItemTotal = jjcItemTotal,
  10024. choiceTwoGW = dto.ChoiceTwoGW,
  10025. gwcItemTotal = gwcItemTotal,
  10026. choiceTwoTD = dto.ChoiceTwoTD,
  10027. tdcItemTotal = tdcItemTotal
  10028. }));
  10029. }
  10030. /// <summary>
  10031. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10032. /// </summary>
  10033. /// <returns></returns>
  10034. [HttpPost]
  10035. [ApiExplorerSettings(IgnoreApi = true)]
  10036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10037. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10038. {
  10039. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10040. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10041. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10042. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10043. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10044. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10045. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10046. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10047. {
  10048. Id = x.Id,
  10049. ParentId = dto.DraftId,
  10050. Type = dto.FeeType,
  10051. Days = x.Days,
  10052. NationalTravelFeeId = x.NationalTravelFeeId,
  10053. Cost = x.Cost,
  10054. Currency = x.Currency,
  10055. SubTotal = x.SubTotal,
  10056. CreateUserId = dto.CurrUserId
  10057. })
  10058. .ToList();
  10059. var adds = infos.Where(x => x.Id <= 0).ToList();
  10060. var upds = infos.Where(x => x.Id > 0).ToList();
  10061. if (adds.Count > 0)
  10062. {
  10063. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10064. if (add < 1) return Ok(JsonView(false));
  10065. }
  10066. if (upds.Count > 0)
  10067. {
  10068. var upd = await _sqlSugar.Updateable(adds)
  10069. .UpdateColumns(x => new
  10070. {
  10071. x.Days,
  10072. x.NationalTravelFeeId,
  10073. x.Cost,
  10074. x.Currency,
  10075. x.SubTotal
  10076. })
  10077. .WhereColumns(x => new { x.Id })
  10078. .ExecuteCommandAsync();
  10079. if (upd < 1) return Ok(JsonView(false));
  10080. }
  10081. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10082. ////消息通知
  10083. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10084. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10085. return Ok(JsonView(new { itemTotal = itemTotal }));
  10086. }
  10087. /// <summary>
  10088. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10089. /// </summary>
  10090. /// <returns></returns>
  10091. [HttpPost]
  10092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10093. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10094. {
  10095. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10096. int subId = dto.SubId, feeType = dto.FeeType;
  10097. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10098. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10099. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10100. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10101. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10102. subInfo.Id = subId;
  10103. subInfo.ParentId = dto.DraftId;
  10104. if (feeType == 3) subInfo.Type = 1;
  10105. else if (feeType == 4) subInfo.Type = 2;
  10106. else if (feeType == 5) subInfo.Type = 3;
  10107. else if (feeType == 6) subInfo.Type = 4;
  10108. subInfo.CreateUserId = dto.CurrUserId;
  10109. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10110. if (parentId < 1) return Ok(JsonView(false));
  10111. //子表op
  10112. if (subId < 1)
  10113. {
  10114. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10115. if (subAdd < 1) return Ok(JsonView(false));
  10116. }
  10117. else
  10118. {
  10119. var subUpd = await _sqlSugar.Updateable(subInfo)
  10120. .UpdateColumns(x => new
  10121. {
  10122. x.Days,
  10123. x.NationalTravelFeeId,
  10124. x.Cost,
  10125. x.Currency,
  10126. x.SubTotal
  10127. })
  10128. .WhereColumns(x => new { x.Id })
  10129. .ExecuteCommandAsync();
  10130. if (subUpd < 1) return Ok(JsonView(false));
  10131. }
  10132. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10133. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10134. }
  10135. /// <summary>
  10136. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10137. /// </summary>
  10138. /// <returns></returns>
  10139. [HttpPost]
  10140. [ApiExplorerSettings(IgnoreApi = true)]
  10141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10142. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10143. {
  10144. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10145. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10146. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10147. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10148. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10149. {
  10150. Id = x.Id,
  10151. ParentId = dto.DraftId,
  10152. SetDataId = x.SetDataId,
  10153. Index = x.Index,
  10154. Cost = x.Cost,
  10155. Currency = x.Currency,
  10156. SubTotal = x.SubTotal,
  10157. CreateUserId = dto.CurrUserId,
  10158. Remark = x.Remark
  10159. }).ToList();
  10160. var adds = infos.Where(x => x.Id <= 0).ToList();
  10161. var upds = infos.Where(x => x.Id > 0).ToList();
  10162. if (adds.Count > 0)
  10163. {
  10164. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10165. if (add < 1) return Ok(JsonView(false));
  10166. }
  10167. if (upds.Count > 0)
  10168. {
  10169. var upd = await _sqlSugar.Updateable(adds)
  10170. .UpdateColumns(x => new
  10171. {
  10172. x.Index,
  10173. x.SetDataId,
  10174. x.Cost,
  10175. x.Currency,
  10176. x.SubTotal,
  10177. x.Remark
  10178. })
  10179. .WhereColumns(x => new { x.Id })
  10180. .ExecuteCommandAsync();
  10181. if (upd < 1) return Ok(JsonView(false));
  10182. }
  10183. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10184. //消息通知
  10185. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10186. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10187. return Ok(JsonView(new { itemTotal = itemTotal }));
  10188. }
  10189. /// <summary>
  10190. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10191. /// </summary>
  10192. /// <returns></returns>
  10193. [HttpPost]
  10194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10195. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10196. {
  10197. int subId = dto.SubId, id = dto.DraftId;
  10198. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10199. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10200. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10201. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10202. subInfo.Id = subId;
  10203. subInfo.ParentId = id;
  10204. subInfo.CreateUserId = dto.CurrUserId;
  10205. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10206. if (parentId < 1) return Ok(JsonView(false));
  10207. #region 子表op
  10208. if (subId < 1)//add
  10209. {
  10210. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10211. if (subAdd < 1) return Ok(JsonView(false));
  10212. }
  10213. else //upd
  10214. {
  10215. var subUpd = await _sqlSugar.Updateable(subInfo)
  10216. .UpdateColumns(x => new
  10217. {
  10218. x.Index,
  10219. x.SetDataId,
  10220. x.Cost,
  10221. x.Currency,
  10222. x.SubTotal,
  10223. x.Remark
  10224. })
  10225. .WhereColumns(x => new { x.Id })
  10226. .ExecuteCommandAsync();
  10227. if (subUpd < 1) return Ok(JsonView(false));
  10228. }
  10229. #endregion
  10230. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10231. ////消息通知
  10232. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10233. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10234. }
  10235. /// <summary>
  10236. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10237. /// </summary>
  10238. /// <returns></returns>
  10239. [HttpPost]
  10240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10241. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10242. {
  10243. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10244. if (data.Code != 0)
  10245. {
  10246. return Ok(JsonView(false, data.Msg));
  10247. }
  10248. return Ok(JsonView(true, "操作成功!", data.Data));
  10249. }
  10250. /// <summary>
  10251. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10252. /// </summary>
  10253. /// <param name="dto"></param>
  10254. /// <returns></returns>
  10255. [HttpPost]
  10256. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10257. {
  10258. var data = new Grp_DayOtherPriceDraft()
  10259. {
  10260. Id = dto.Id,
  10261. IsDel = 1,
  10262. DeleteUserId = dto.DeleteUserId,
  10263. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10264. };
  10265. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10266. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10267. return Ok(JsonView(false, "删除失败!"));
  10268. }
  10269. #endregion
  10270. #endregion
  10271. #region 团组经理模块 出入境费用报价表
  10272. /// <summary>
  10273. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10274. /// </summary>
  10275. /// <returns></returns>
  10276. [HttpPost]
  10277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10278. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10279. {
  10280. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10281. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10282. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10283. initRates.Insert(0, cnyInfo);
  10284. liveRates.Insert(0, cnyInfo);
  10285. return Ok(JsonView(true, "查询成功!", new
  10286. {
  10287. InitRates = initRates,
  10288. LiveRates = liveRates
  10289. }));
  10290. }
  10291. /// <summary>
  10292. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10293. /// </summary>
  10294. /// <returns></returns>
  10295. [HttpPost]
  10296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10297. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10298. {
  10299. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10300. }
  10301. /// <summary>
  10302. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10303. /// </summary>
  10304. /// <returns></returns>
  10305. [HttpPost]
  10306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10307. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10308. {
  10309. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10310. }
  10311. /// <summary>
  10312. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10313. /// </summary>
  10314. /// <returns></returns>
  10315. [HttpPost]
  10316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10317. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10318. {
  10319. int groupId = dto.DiId,
  10320. currUserId = dto.CurrUserId;
  10321. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  10322. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10323. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10324. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10325. var infoView = info.Data as EnterExitCostInfoView;
  10326. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10327. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10328. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10329. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10330. var eecRates = infoView.Currencys;
  10331. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10332. int pplNum = 1;
  10333. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10334. var views = new List<QuoteSubItemInfo>();
  10335. #region 数据填充
  10336. var intTravelCosts = new List<QuoteSubItemInfo>();
  10337. #region 机票费用 1354
  10338. int intTravelIndex = 1;
  10339. if (infoView.SumJJC == 1)
  10340. {
  10341. intTravelCosts.Add(new QuoteSubItemInfo
  10342. {
  10343. ItemId = 1354,
  10344. Index = intTravelIndex,
  10345. FeeName = "经济舱",
  10346. UnitPrice = infoView.AirJJ,
  10347. Currency = "CNY",
  10348. Quantity = 1,
  10349. PplNum = 1,
  10350. TotalAmt = infoView.AirJJ,
  10351. Remark = "",
  10352. });
  10353. intTravelIndex++;
  10354. }
  10355. if (infoView.SumGWC == 1)
  10356. {
  10357. intTravelCosts.Add(new QuoteSubItemInfo
  10358. {
  10359. ItemId = 1354,
  10360. Index = intTravelIndex,
  10361. FeeName = "公务舱",
  10362. UnitPrice = infoView.AirGW,
  10363. Currency = "CNY",
  10364. Quantity = 1,
  10365. PplNum = 1,
  10366. TotalAmt = infoView.AirGW,
  10367. Remark = "",
  10368. });
  10369. intTravelIndex++;
  10370. }
  10371. if (infoView.SumTDC == 1)
  10372. {
  10373. intTravelCosts.Add(new QuoteSubItemInfo
  10374. {
  10375. ItemId = 1354,
  10376. Index = intTravelIndex,
  10377. FeeName = "头等舱",
  10378. UnitPrice = infoView.AirTD,
  10379. Currency = "CNY",
  10380. Quantity = 1,
  10381. PplNum = 1,
  10382. TotalAmt = infoView.AirTD,
  10383. Remark = "",
  10384. });
  10385. intTravelIndex++;
  10386. }
  10387. intTravelCosts.Add(new QuoteSubItemInfo
  10388. {
  10389. ItemId = 1354,
  10390. Index = intTravelIndex,
  10391. FeeName = "城市间交通费用",
  10392. UnitPrice = infoView.CityTranffic,
  10393. Currency = "CNY",
  10394. Quantity = 1,
  10395. PplNum = pplNum,
  10396. TotalAmt = infoView.CityTranffic * pplNum,
  10397. Remark = "",
  10398. });
  10399. views.AddRange(intTravelCosts);
  10400. #endregion
  10401. var accomCosts = new List<QuoteSubItemInfo>();
  10402. #region 住宿费 1355
  10403. if (infoView.QuarterageData.Any())
  10404. {
  10405. int accomIndex = 1;
  10406. int accomItemTypeId = 1355;
  10407. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10408. foreach (var item in groupData)
  10409. {
  10410. string feeName = string.Empty;
  10411. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10412. if (countryInfo != null)
  10413. {
  10414. feeName = countryInfo.Country;
  10415. var city = countryInfo.City;
  10416. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10417. {
  10418. feeName += $"-{city}";
  10419. }
  10420. }
  10421. var hotelInfo = item.FirstOrDefault();
  10422. if (hotelInfo == null) continue;
  10423. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10424. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10425. int quantity = item.ToList().Count;
  10426. accomCosts.Add(new QuoteSubItemInfo
  10427. {
  10428. ItemId = accomItemTypeId,
  10429. Index = accomIndex,
  10430. FeeName = feeName,
  10431. UnitPrice = hotelInfo.Cost,
  10432. Currency = thisCurrency,
  10433. Quantity = quantity,
  10434. PplNum = pplNum,
  10435. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10436. Remark = "",
  10437. });
  10438. accomIndex++;
  10439. }
  10440. views.AddRange(accomCosts);
  10441. }
  10442. #endregion
  10443. var mealCosts = new List<QuoteSubItemInfo>();
  10444. #region 餐饮费 1356
  10445. if (infoView.BoardWagesData.Any())
  10446. {
  10447. var mealIndex = 1;
  10448. int mealItemTypeId = 1356;
  10449. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10450. foreach (var item in groupData)
  10451. {
  10452. string feeName = string.Empty;
  10453. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10454. if (countryInfo != null)
  10455. {
  10456. feeName = countryInfo.Country;
  10457. var city = countryInfo.City;
  10458. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10459. {
  10460. feeName += $"-{city}";
  10461. }
  10462. }
  10463. var mealInfo = item.FirstOrDefault();
  10464. if (mealInfo == null) continue;
  10465. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10466. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10467. int quantity = item.ToList().Count;
  10468. mealCosts.Add(new QuoteSubItemInfo
  10469. {
  10470. ItemId = mealItemTypeId,
  10471. Index = mealIndex,
  10472. FeeName = feeName,
  10473. UnitPrice = mealInfo.Cost,
  10474. Currency = thisCurrency,
  10475. Quantity = quantity,
  10476. PplNum = pplNum,
  10477. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10478. Remark = "",
  10479. });
  10480. mealIndex++;
  10481. }
  10482. views.AddRange(mealCosts);
  10483. }
  10484. #endregion
  10485. var miscCosts = new List<QuoteSubItemInfo>();
  10486. #region 公杂费 1364
  10487. if (infoView.MiscellaneousFeeData.Any())
  10488. {
  10489. var miscIndex = 1;
  10490. int miscItemTypeId = 1364;
  10491. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10492. foreach (var item in groupData)
  10493. {
  10494. string feeName = string.Empty;
  10495. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10496. if (countryInfo != null)
  10497. {
  10498. feeName = countryInfo.Country;
  10499. var city = countryInfo.City;
  10500. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10501. {
  10502. feeName += $"-{city}";
  10503. }
  10504. }
  10505. var miscInfo = item.FirstOrDefault();
  10506. if (miscInfo == null) continue;
  10507. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10508. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10509. int quantity = item.ToList().Count;
  10510. mealCosts.Add(new QuoteSubItemInfo
  10511. {
  10512. ItemId = miscItemTypeId,
  10513. Index = miscIndex,
  10514. FeeName = feeName,
  10515. UnitPrice = miscInfo.Cost,
  10516. Currency = thisCurrency,
  10517. Quantity = quantity,
  10518. PplNum = pplNum,
  10519. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10520. Remark = "",
  10521. });
  10522. miscIndex++;
  10523. }
  10524. views.AddRange(mealCosts);
  10525. }
  10526. #endregion
  10527. #region 签证+保险 1362
  10528. int visaInsIndex = 1;
  10529. int visaInsItemTypeId = 1362;
  10530. if (infoView.Visa > 0)
  10531. {
  10532. views.Add(new QuoteSubItemInfo()
  10533. {
  10534. ItemId = visaInsItemTypeId,
  10535. Index = visaInsIndex,
  10536. FeeName = $"签证",
  10537. UnitPrice = infoView.Visa,
  10538. Currency = $"CNY",
  10539. Quantity = 1,
  10540. PplNum = pplNum,
  10541. TotalAmt = infoView.Visa * pplNum,
  10542. Remark = "",
  10543. });
  10544. visaInsIndex++;
  10545. }
  10546. if (infoView.Safe > 0)
  10547. {
  10548. views.Add(new QuoteSubItemInfo()
  10549. {
  10550. ItemId = visaInsItemTypeId,
  10551. Index = visaInsIndex,
  10552. FeeName = $"保险",
  10553. UnitPrice = infoView.Safe,
  10554. Currency = $"CNY",
  10555. Quantity = 1,
  10556. PplNum = pplNum,
  10557. TotalAmt = infoView.Safe * pplNum,
  10558. Remark = "",
  10559. });
  10560. }
  10561. #endregion
  10562. #region 服务费 1363
  10563. int serviceFeeIndex = 1;
  10564. int serviceFeeItemTypeId = 1363;
  10565. if (infoView.Service > 0)
  10566. {
  10567. views.Add(new QuoteSubItemInfo()
  10568. {
  10569. ItemId = serviceFeeItemTypeId,
  10570. Index = serviceFeeIndex,
  10571. FeeName = $"服务费",
  10572. UnitPrice = infoView.Service,
  10573. Currency = $"CNY",
  10574. Quantity = 1,
  10575. PplNum = pplNum,
  10576. TotalAmt = infoView.Service * pplNum,
  10577. Remark = "",
  10578. });
  10579. }
  10580. #endregion
  10581. #endregion
  10582. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10583. result.Rates = eecRates.ToArray();
  10584. if (result.FeeItems.Any())
  10585. {
  10586. result.FeeItems.Select(x =>
  10587. {
  10588. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10589. if (feeInfos.Any()) x.Infos = feeInfos;
  10590. return x;
  10591. }
  10592. )
  10593. .OrderBy(x => x.Index)
  10594. .ToList();
  10595. }
  10596. return Ok(JsonView(result));
  10597. }
  10598. /// <summary>
  10599. /// 团组模块 - 出入境费用报价表 - Info
  10600. /// </summary>
  10601. /// <returns></returns>
  10602. [HttpPost]
  10603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10604. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10605. {
  10606. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10607. if (!info.Rates.Any())
  10608. {
  10609. var rates = await GeneralMethod.EnterExitCostInitRate();
  10610. info.Rates = rates.ToArray();
  10611. }
  10612. return Ok(JsonView(info));
  10613. }
  10614. /// <summary>
  10615. /// 团组模块 - 出入境费用报价表 - OP
  10616. /// </summary>
  10617. /// <returns></returns>
  10618. [HttpPost]
  10619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10620. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10621. {
  10622. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10623. }
  10624. /// <summary>
  10625. /// 团组模块 - 出入境费用报价表 - 删除 项
  10626. /// </summary>
  10627. /// <returns></returns>
  10628. [HttpPost]
  10629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10630. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10631. {
  10632. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10633. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10634. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10635. }
  10636. /// <summary>
  10637. /// 团组模块 - 出入境费用报价表 - 导出
  10638. /// </summary>
  10639. /// <returns></returns>
  10640. [HttpPost]
  10641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10642. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10643. {
  10644. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10645. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10646. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  10647. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10648. var rates = info.Rates;
  10649. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10650. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10651. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10652. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10653. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10654. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10655. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10656. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10657. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10658. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10659. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10660. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10661. //获取模板
  10662. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10663. var designer = new WorkbookDesigner();
  10664. designer.Workbook = new Workbook(tempPath);
  10665. designer.SetDataSource("QuoteName", info.Name);
  10666. designer.SetDataSource("CompanyTitle", "公司名称");
  10667. designer.SetDataSource("CompanyLabel", "");
  10668. #region 国际旅费
  10669. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10670. if (intTravelCosts.Infos.Any())
  10671. {
  10672. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  10673. string label = string.Empty;
  10674. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10675. if (infos.Any())
  10676. {
  10677. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10678. }
  10679. foreach (var item in intTravelCosts.Infos)
  10680. {
  10681. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10682. }
  10683. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10684. designer.SetDataSource("IntTravelLabel", label);
  10685. }
  10686. #endregion
  10687. #region 住宿费
  10688. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10689. if (accomCosts.Infos.Any())
  10690. {
  10691. string currencyName = string.Empty;
  10692. decimal rate = 1.0000M;
  10693. string label = "全程五星酒店,每人1间房\r\n";
  10694. foreach (var item in accomCosts.Infos)
  10695. {
  10696. string hotelName = string.Empty;
  10697. if (item.FeeName.Contains("-"))
  10698. {
  10699. var feeName = item.FeeName.Split('-');
  10700. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10701. }
  10702. else hotelName = $"\r\n{item.FeeName}:";
  10703. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10704. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10705. rate = rateInfo?.Rate ?? 1.0000M;
  10706. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10707. }
  10708. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10709. designer.SetDataSource("AccomLabel", label);
  10710. }
  10711. #endregion
  10712. designer.Process();
  10713. //文件名
  10714. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10715. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10716. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10717. return Ok(JsonView(true, "成功", url));
  10718. }
  10719. #endregion
  10720. #region 签证费用录入
  10721. /// <summary>
  10722. /// 根据diid查询签证费用列表
  10723. /// </summary>
  10724. /// <param name="dto"></param>
  10725. /// <returns></returns>
  10726. [HttpPost]
  10727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10728. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10729. {
  10730. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10731. if (groupData.Code != 0)
  10732. {
  10733. return Ok(JsonView(false, groupData.Msg));
  10734. }
  10735. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10736. }
  10737. /// <summary>
  10738. /// 根据签证费用Id查询单条数据及c表数据
  10739. /// </summary>
  10740. /// <param name="dto"></param>
  10741. /// <returns></returns>
  10742. [HttpPost]
  10743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10744. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10745. {
  10746. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10747. if (groupData.Code != 0)
  10748. {
  10749. return Ok(JsonView(false, groupData.Msg));
  10750. }
  10751. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10752. }
  10753. /// <summary>
  10754. /// 签证费用删除
  10755. /// </summary>
  10756. /// <param name="dto"></param>
  10757. /// <returns></returns>
  10758. [HttpPost]
  10759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10760. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10761. {
  10762. _sqlSugar.BeginTran();
  10763. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10764. if (!res)
  10765. {
  10766. _sqlSugar.RollbackTran();
  10767. return Ok(JsonView(false, "删除失败"));
  10768. }
  10769. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10770. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10771. .SetColumns(a => new Grp_CreditCardPayment()
  10772. {
  10773. IsDel = 1,
  10774. DeleteUserId = dto.DeleteUserId,
  10775. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10776. })
  10777. .ExecuteCommand();
  10778. if (resSub < 1)
  10779. {
  10780. _sqlSugar.RollbackTran();
  10781. return Ok(JsonView(false, "删除失败"));
  10782. }
  10783. _sqlSugar.CommitTran();
  10784. return Ok(JsonView(true, "删除成功!"));
  10785. }
  10786. /// <summary>
  10787. /// 签证费用录入下拉框初始化
  10788. /// </summary>
  10789. /// <returns></returns>
  10790. [HttpPost]
  10791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10792. public async Task<IActionResult> VisaPriceAddSelect()
  10793. {
  10794. //支付方式
  10795. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10796. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10797. //币种
  10798. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10799. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10800. //乘客类型
  10801. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10802. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10803. //卡类型
  10804. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10805. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10806. //代办费类型
  10807. var agencyFeeTypeData = new List<dynamic>() {
  10808. new { id = 0 , Text = "未选择" },
  10809. new { id = 1 , Text = "小公务" },
  10810. new { id = 2 , Text = "大公务" },
  10811. };
  10812. //签证费用标准国家Data
  10813. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10814. var data = new
  10815. {
  10816. Payment = _Payment,
  10817. CurrencyList = _CurrencyList,
  10818. PassengerType = _PassengerType,
  10819. BankCard = _BankCard,
  10820. AgencyFeeType = agencyFeeTypeData,
  10821. CountryFeeData = visaCountryFeeData
  10822. };
  10823. return Ok(JsonView(true, "查询成功!", data));
  10824. }
  10825. /// <summary>
  10826. /// 签证费用录入操作(Status:1.新增,2.修改)
  10827. /// </summary>
  10828. /// <param name="dto"></param>
  10829. /// <returns></returns>
  10830. [HttpPost]
  10831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10832. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10833. {
  10834. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10835. if (groupData.Code != 0)
  10836. {
  10837. return Ok(JsonView(false, groupData.Msg));
  10838. }
  10839. #region 应用推送
  10840. try
  10841. {
  10842. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10843. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10844. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10845. //2024-10-21 新增LZ UID
  10846. var userIds = new List<int>() { 21 };
  10847. string title = $"系统通知";
  10848. string content = "";
  10849. var diId = dto.DiId;
  10850. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10851. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10852. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10853. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10854. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10855. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10856. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10857. }
  10858. catch (Exception ex)
  10859. {
  10860. }
  10861. #endregion
  10862. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10863. }
  10864. #endregion
  10865. #region 签证提成录入
  10866. /// <summary>
  10867. /// 签证提成录入
  10868. /// 基础数据
  10869. /// </summary>
  10870. /// <returns></returns>
  10871. [HttpGet]
  10872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10873. public async Task<IActionResult> VisaCommissionInit()
  10874. {
  10875. return Ok(await _visaCommissionRep.Init());
  10876. }
  10877. /// <summary>
  10878. /// 签证提成录入
  10879. /// Item
  10880. /// </summary>
  10881. /// <param name="_dto"></param>
  10882. /// <returns></returns>
  10883. [HttpPost]
  10884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10885. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10886. {
  10887. var validator = new VisaCommissionItemDtoValidator();
  10888. var validatorRes = await validator.ValidateAsync(_dto);
  10889. if (!validatorRes.IsValid)
  10890. {
  10891. StringBuilder sb = new StringBuilder();
  10892. foreach (var item in validatorRes.Errors)
  10893. {
  10894. sb.AppendLine(item.ErrorMessage);
  10895. }
  10896. return Ok(JsonView(false, sb.ToString()));
  10897. }
  10898. return Ok(await _visaCommissionRep.Item(_dto));
  10899. }
  10900. /// <summary>
  10901. /// 签证提成录入
  10902. /// Save
  10903. /// </summary>
  10904. /// <param name="_dto"></param>
  10905. /// <returns></returns>
  10906. [HttpPost]
  10907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10908. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10909. {
  10910. //参数验证
  10911. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10912. foreach (var item in _dto.Items)
  10913. {
  10914. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10915. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10916. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10917. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10918. }
  10919. return Ok(await _visaCommissionRep.Save(_dto));
  10920. }
  10921. /// <summary>
  10922. /// 签证提成录入
  10923. /// Create
  10924. /// </summary>
  10925. /// <param name="_dto"></param>
  10926. /// <returns></returns>
  10927. [HttpPost]
  10928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10929. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10930. {
  10931. var validator = new VisaCommissionCreateDtoValidator();
  10932. var validatorRes = await validator.ValidateAsync(_dto);
  10933. if (!validatorRes.IsValid)
  10934. {
  10935. StringBuilder sb = new StringBuilder();
  10936. foreach (var item in validatorRes.Errors)
  10937. {
  10938. sb.AppendLine(item.ErrorMessage);
  10939. }
  10940. return Ok(JsonView(false, sb.ToString()));
  10941. }
  10942. return Ok(await _visaCommissionRep.Create(_dto));
  10943. }
  10944. /// <summary>
  10945. /// 签证提成录入
  10946. /// Put(编辑)
  10947. /// </summary>
  10948. /// <param name="id"></param>
  10949. /// <param name="_dto"></param>
  10950. /// <returns></returns>
  10951. [HttpPut]
  10952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10953. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10954. {
  10955. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10956. var validator = new VisaCommissionCreateDtoValidator();
  10957. var validatorRes = await validator.ValidateAsync(_dto);
  10958. if (!validatorRes.IsValid)
  10959. {
  10960. StringBuilder sb = new StringBuilder();
  10961. foreach (var item in validatorRes.Errors)
  10962. {
  10963. sb.AppendLine(item.ErrorMessage);
  10964. }
  10965. return Ok(JsonView(false, sb.ToString()));
  10966. }
  10967. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10968. }
  10969. /// <summary>
  10970. /// 签证提成录入
  10971. /// Del
  10972. /// </summary>
  10973. /// <param name="id"></param>
  10974. /// <param name="currUserId"></param>
  10975. /// <returns></returns>
  10976. [HttpPost]
  10977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10978. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10979. {
  10980. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10981. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10982. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10983. }
  10984. #endregion
  10985. #region op费用录入
  10986. /// <summary>
  10987. /// 根据diid查询op费用列表
  10988. /// </summary>
  10989. /// <param name="dto"></param>
  10990. /// <returns></returns>
  10991. [HttpPost]
  10992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10993. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10994. {
  10995. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10996. if (groupData.Code != 0)
  10997. {
  10998. return Ok(JsonView(false, groupData.Msg));
  10999. }
  11000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11001. }
  11002. /// <summary>
  11003. /// 根据op费用Id查询单条数据及c表数据
  11004. /// </summary>
  11005. /// <param name="dto"></param>
  11006. /// <returns></returns>
  11007. [HttpPost]
  11008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11009. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11010. {
  11011. try
  11012. {
  11013. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11014. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11015. var data = new
  11016. {
  11017. CarTouristGuideGround = _groupData,
  11018. CreditCardPayment = _creditCardPayment
  11019. };
  11020. return Ok(JsonView(true, "查询成功!", data));
  11021. }
  11022. catch (Exception ex)
  11023. {
  11024. return Ok(JsonView(false, "程序错误!"));
  11025. }
  11026. }
  11027. /// <summary>
  11028. /// op费用删除
  11029. /// </summary>
  11030. /// <param name="dto"></param>
  11031. /// <returns></returns>
  11032. [HttpPost]
  11033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11034. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11035. {
  11036. try
  11037. {
  11038. _sqlSugar.BeginTran();
  11039. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11040. if (!res)
  11041. {
  11042. return Ok(JsonView(false, "删除失败"));
  11043. }
  11044. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11045. {
  11046. IsDel = 1,
  11047. DeleteUserId = dto.DeleteUserId,
  11048. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11049. }).ExecuteCommandAsync();
  11050. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11051. {
  11052. IsDel = 1,
  11053. DeleteUserId = dto.DeleteUserId,
  11054. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11055. }).ExecuteCommandAsync();
  11056. #region 删除超支相关数据
  11057. //删除导入的超支数据
  11058. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11059. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11060. {
  11061. IsDel = 1,
  11062. DeleteUserId = dto.DeleteUserId,
  11063. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11064. }).ExecuteCommand();
  11065. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11066. {
  11067. IsDel = 1,
  11068. DeleteUserId = dto.DeleteUserId,
  11069. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11070. }).ExecuteCommand();
  11071. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11072. {
  11073. IsDel = 1,
  11074. DeleteUserId = dto.DeleteUserId,
  11075. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11076. }).ExecuteCommand();
  11077. #endregion
  11078. _sqlSugar.CommitTran();
  11079. return Ok(JsonView(true, "删除成功!"));
  11080. }
  11081. catch (Exception ex)
  11082. {
  11083. _sqlSugar.RollbackTran();
  11084. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11085. }
  11086. }
  11087. /// <summary>
  11088. /// op费用录入操作(Status:1.新增,2.修改)
  11089. /// </summary>
  11090. /// <param name="dto"></param>
  11091. /// <returns></returns>
  11092. [HttpPost]
  11093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11094. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11095. {
  11096. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11097. if (groupData.Code != 0)
  11098. {
  11099. return Ok(JsonView(false, groupData.Msg));
  11100. }
  11101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11102. }
  11103. /// <summary>
  11104. /// 填写费用详细页面初始化绑定
  11105. /// </summary>
  11106. /// <param name="dto"></param>
  11107. /// <returns></returns>
  11108. [HttpPost]
  11109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11110. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11111. {
  11112. try
  11113. {
  11114. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(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. catch (Exception ex)
  11122. {
  11123. return Ok(JsonView(false, ex.Message));
  11124. }
  11125. }
  11126. /// <summary>
  11127. /// 根据op费用Id查询详细数据
  11128. /// </summary>
  11129. /// <param name="dto"></param>
  11130. /// <returns></returns>
  11131. [HttpPost]
  11132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11133. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11134. {
  11135. try
  11136. {
  11137. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11138. if (groupData.Code != 0)
  11139. {
  11140. return Ok(JsonView(false, groupData.Msg));
  11141. }
  11142. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11143. }
  11144. catch (Exception ex)
  11145. {
  11146. return Ok(JsonView(false, ex.Message));
  11147. }
  11148. }
  11149. /// <summary>
  11150. /// OP费用录入填写详情
  11151. /// </summary>
  11152. /// <param name="dto"></param>
  11153. /// <returns></returns>
  11154. [HttpPost]
  11155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11156. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11157. {
  11158. try
  11159. {
  11160. #region 参数校验
  11161. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11162. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11163. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11164. #endregion
  11165. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11166. if (groupData.Code != 0)
  11167. {
  11168. return Ok(JsonView(false, groupData.Msg));
  11169. }
  11170. //自动审核
  11171. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11172. #region 应用推送
  11173. try
  11174. {
  11175. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11176. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11177. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11178. //2024-10-21 新增LZ UID
  11179. var userIds = new List<int>() { 21 };
  11180. string title = $"系统通知";
  11181. var diId = dto.DiId;
  11182. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11183. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11184. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11185. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11186. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11187. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11188. }
  11189. catch (Exception ex)
  11190. {
  11191. }
  11192. #endregion
  11193. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11194. }
  11195. catch (Exception ex)
  11196. {
  11197. return Ok(JsonView(false, ex.Message));
  11198. }
  11199. }
  11200. /// <summary>
  11201. /// 获取三公详细所有城市
  11202. /// </summary>
  11203. /// <returns></returns>
  11204. [HttpGet]
  11205. public IActionResult OpCarCityResult()
  11206. {
  11207. var jw = JsonView(false);
  11208. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11209. {
  11210. x.Id,
  11211. x.Country,
  11212. x.City,
  11213. }).ToList();
  11214. if (data.Count > 0)
  11215. {
  11216. jw = JsonView(true, "获取成功!", data);
  11217. }
  11218. else
  11219. {
  11220. jw.Msg = "城市数据为空!";
  11221. jw.Data = new string[0];
  11222. }
  11223. return Ok(jw);
  11224. }
  11225. /// <summary>
  11226. /// 导出地接费用明细
  11227. /// </summary>
  11228. /// <param name="dto"></param>
  11229. /// <returns></returns>
  11230. [HttpPost]
  11231. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11232. {
  11233. var jw = JsonView(false);
  11234. if (dto.Diid < 1)
  11235. {
  11236. jw.Msg = "请输入正确的diid!";
  11237. return Ok(jw);
  11238. }
  11239. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11240. if (group == null)
  11241. {
  11242. jw.Msg = "未找到团组信息!";
  11243. return Ok(jw);
  11244. }
  11245. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11246. if (localGuideArr.Count == 0)
  11247. {
  11248. jw.Msg = "该团组暂无地接信息!";
  11249. return Ok(jw);
  11250. }
  11251. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11252. var overspendSoure = new Dictionary<int, int>
  11253. {
  11254. { 91, 982 }, //车
  11255. { 92 , 1059} ,//导游
  11256. { 994 , 1073}, //翻译
  11257. { 988 , 1074 }, //早餐
  11258. { 93 , 1075 }, //午餐
  11259. { 989 , 1076 }, //晚餐
  11260. };
  11261. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11262. foreach (var groupArr in localGroup)
  11263. {
  11264. var keyValue = groupArr.Key;
  11265. if (int.TryParse(keyValue, out int cityid))
  11266. {
  11267. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11268. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11269. }
  11270. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11271. foreach (var item in groupArr)
  11272. {
  11273. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11274. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11275. new Grp_CarTouristGuideGroundReservationsContentExtend
  11276. {
  11277. Count = a.Count,
  11278. CreateTime = a.CreateTime,
  11279. CreateUserId = a.CreateUserId,
  11280. CTGGRId = a.CTGGRId,
  11281. Currency = a.Currency,
  11282. DatePrice = a.DatePrice,
  11283. DeleteTime = a.DeleteTime,
  11284. DeleteUserId = a.DeleteUserId,
  11285. DiId = a.DiId,
  11286. Id = a.Id,
  11287. IsDel = a.IsDel,
  11288. Price = a.Price,
  11289. PriceContent = a.PriceContent,
  11290. Remark = a.Remark,
  11291. SId = a.SId,
  11292. SidName = b.Name,
  11293. Units = a.Units,
  11294. }
  11295. ).ToList();
  11296. if (content.Count > 0)
  11297. {
  11298. contentArr.Add(content);
  11299. }
  11300. }
  11301. //open excel
  11302. //set excel
  11303. //save excel
  11304. try
  11305. {
  11306. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11307. IWorkbook workbook;
  11308. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11309. {
  11310. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11311. }
  11312. else
  11313. {
  11314. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11315. }
  11316. ISheet sheet = workbook.GetSheetAt(0);
  11317. var rowStartIndex = 2;
  11318. var clounmCount = 10;
  11319. var initStyleRow = sheet.GetRow(2);
  11320. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11321. //var overspendArrDetail =
  11322. var existsId = new List<CarCompare>();
  11323. var lastElem = arr.Last();
  11324. var thisSid = -1;
  11325. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11326. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11327. {
  11328. Name = "未知币种!",
  11329. Remark = "未知币种!",
  11330. };
  11331. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11332. Action cloneRowFn = () =>
  11333. {
  11334. rowStartIndex++;
  11335. var cloneRow = sheet.CreateRow(rowStartIndex);
  11336. // 复制样式
  11337. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11338. {
  11339. ICell sourceCell = initStyleRow.GetCell(i);
  11340. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11341. // 确保单元格存在样式
  11342. if (sourceCell.CellStyle != null)
  11343. {
  11344. targetCell.CellStyle = sourceCell.CellStyle;
  11345. }
  11346. }
  11347. };
  11348. var mergeRow = () =>
  11349. {
  11350. for (int i = 2; i < sheet.LastRowNum; i++)
  11351. {
  11352. var row = sheet.GetRow(i);
  11353. var cellFirst = row.GetCell(0);
  11354. var thisIndex = i + 1;
  11355. while (thisIndex < sheet.LastRowNum)
  11356. {
  11357. var nextRow = sheet.GetRow(thisIndex);
  11358. var nextCellFirst = nextRow.GetCell(0);
  11359. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11360. {
  11361. thisIndex++;
  11362. }
  11363. else
  11364. {
  11365. break;
  11366. }
  11367. }
  11368. thisIndex--;
  11369. if (thisIndex != i)
  11370. {
  11371. //合并row
  11372. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11373. i, // 起始行索引(0-based)
  11374. thisIndex, // 结束行索引(0-based)
  11375. 0, // 起始列索引(0-based)
  11376. 0 // 结束列索引(0-based)
  11377. );
  11378. sheet.AddMergedRegion(cellRangeAddress);
  11379. i = thisIndex;
  11380. }
  11381. }
  11382. };
  11383. var chaoshiNumber = 0;
  11384. var totalNumber = 0.00M;
  11385. string lastStr = "";
  11386. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11387. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11388. {
  11389. b.IsAuditGM,
  11390. x.Id,
  11391. x.Area,
  11392. b.PayPercentage,
  11393. b.PayMoney,
  11394. }).ToList();
  11395. string yesPayment = "", noPayment = "";
  11396. foreach (var item in queryCarArrByCityAndDiid)
  11397. {
  11398. if (item.IsAuditGM == 1)
  11399. {
  11400. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11401. }
  11402. else
  11403. {
  11404. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11405. }
  11406. }
  11407. lastStr = yesPayment + noPayment;
  11408. foreach (var item in arr)
  11409. {
  11410. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11411. {
  11412. if (thisSid != item.SId)
  11413. {
  11414. if (thisSid == -1)
  11415. {
  11416. thisSid = item.SId;
  11417. }
  11418. else
  11419. {
  11420. //合并小计行
  11421. //创建合并区域的实例
  11422. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11423. rowStartIndex, // 起始行索引(0-based)
  11424. rowStartIndex, // 结束行索引(0-based)
  11425. 0, // 起始列索引(0-based)
  11426. 3 // 结束列索引(0-based)
  11427. );
  11428. sheet.AddMergedRegion(cellRangeAddress);
  11429. var CellStyle = workbook.CreateCellStyle();
  11430. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11431. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11432. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11433. for (int i = 0; i <= clounmCount; i++)
  11434. {
  11435. if (i > 6)
  11436. {
  11437. var CellStyle1 = workbook.CreateCellStyle();
  11438. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11439. IFont Font = workbook.CreateFont(); // 创建字体
  11440. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11441. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11442. CellStyle1.SetFont(Font);
  11443. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11444. }
  11445. else
  11446. {
  11447. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11448. }
  11449. }
  11450. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11451. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11452. //超时合计
  11453. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11454. //超时数
  11455. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11456. //超时合计费用
  11457. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11458. thisSid = item.SId;
  11459. cloneRowFn();
  11460. chaoshiNumber = 0;
  11461. totalNumber = 0;
  11462. }
  11463. }
  11464. IRow row = sheet.GetRow(rowStartIndex);
  11465. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11466. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11467. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11468. if (isOpenOverspendSoure)
  11469. {
  11470. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11471. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11472. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11473. }
  11474. for (int i = 0; i <= clounmCount; i++)
  11475. {
  11476. var cell = row.GetCell(i);
  11477. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11478. if (cell == null)
  11479. {
  11480. cell = row.CreateCell(i);
  11481. }
  11482. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11483. fontRed.CloneStyleFrom(cell.CellStyle);
  11484. IFont Font = workbook.CreateFont(); // 创建字体
  11485. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11486. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11487. fontRed.SetFont(Font);
  11488. byte[] rgb = new byte[3] { 255, 242, 204 };
  11489. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11490. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11491. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11492. if (workbook is XSSFWorkbook)
  11493. {
  11494. BackgroundColor255_242_204.FillForegroundColor = 0;
  11495. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11496. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11497. }
  11498. else
  11499. {
  11500. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11501. }
  11502. if (i == 1 || i > 6)
  11503. {
  11504. if (i > 6)
  11505. {
  11506. fontRed.FillForegroundColor = 0;
  11507. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11508. fontRed.FillPattern = FillPattern.SolidForeground;
  11509. }
  11510. cell.CellStyle = fontRed;
  11511. }
  11512. if (i > 2 && i < 7)
  11513. {
  11514. cell.CellStyle = BackgroundColor255_242_204;
  11515. }
  11516. cell.SetCellValue(setCellValue); //写入单元格
  11517. }
  11518. if (overspendSoure.ContainsKey(thisSid))
  11519. {
  11520. var overspendId = overspendSoure[thisSid];
  11521. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11522. }
  11523. cloneRowFn();
  11524. existsId.Add(new CarCompare
  11525. {
  11526. DataPrice = item.DatePrice.ObjToDate(),
  11527. Sid = item.SId
  11528. });
  11529. }
  11530. if (item.Equals(lastElem))
  11531. {
  11532. //合并小计行
  11533. //创建合并区域的实例
  11534. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11535. rowStartIndex, // 起始行索引(0-based)
  11536. rowStartIndex, // 结束行索引(0-based)
  11537. 0, // 起始列索引(0-based)
  11538. 3 // 结束列索引(0-based)
  11539. );
  11540. sheet.AddMergedRegion(cellRangeAddress);
  11541. var CellStyle = workbook.CreateCellStyle();
  11542. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11543. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11544. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11545. for (int i = 0; i <= clounmCount; i++)
  11546. {
  11547. if (i > 6)
  11548. {
  11549. var CellStyle1 = workbook.CreateCellStyle();
  11550. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11551. IFont Font = workbook.CreateFont(); // 创建字体
  11552. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11553. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11554. CellStyle1.SetFont(Font);
  11555. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11556. }
  11557. else
  11558. {
  11559. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11560. }
  11561. }
  11562. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11563. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11564. //超时合计
  11565. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11566. //超时数
  11567. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11568. //超时合计费用
  11569. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11570. cloneRowFn();
  11571. // 创建合并区域的实例
  11572. cellRangeAddress = new CellRangeAddress(
  11573. rowStartIndex, // 起始行索引(0-based)
  11574. rowStartIndex, // 结束行索引(0-based)
  11575. 0, // 起始列索引(0-based)
  11576. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11577. );
  11578. // 添加合并区域
  11579. sheet.AddMergedRegion(cellRangeAddress);
  11580. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11581. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11582. }
  11583. }
  11584. mergeRow();
  11585. // 保存修改后的Excel文件到新文件
  11586. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11587. // new FileStream(newFilePath, FileMode.CreateNew)
  11588. using (var stream = new MemoryStream())
  11589. {
  11590. workbook.Write(stream, true);
  11591. stream.Flush();
  11592. stream.Seek(0, SeekOrigin.Begin);
  11593. MemoryStream memoryStream = new MemoryStream();
  11594. stream.CopyTo(memoryStream);
  11595. memoryStream.Seek(0, SeekOrigin.Begin);
  11596. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11597. }
  11598. workbook.Close();
  11599. workbook.Dispose();
  11600. }
  11601. catch (Exception ex)
  11602. {
  11603. jw.Msg = "出现异常!" + ex.Message;
  11604. return Ok(jw);
  11605. }
  11606. }
  11607. if (Zips.Count > 0)
  11608. {
  11609. IOOperatorHelper io = new IOOperatorHelper();
  11610. var byts = io.ConvertZipStream(Zips);
  11611. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11612. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11613. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11614. }
  11615. else
  11616. {
  11617. jw.Msg = "暂无生成文件!";
  11618. }
  11619. return Ok(jw);
  11620. }
  11621. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11622. {
  11623. string outStr = string.Empty;
  11624. switch (i)
  11625. {
  11626. case 0:
  11627. outStr = arr[0].SidName;
  11628. break;
  11629. case 1:
  11630. outStr = arr[0].DataPriceStr;
  11631. break;
  11632. case 2:
  11633. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11634. break;
  11635. case 4:
  11636. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11637. break;
  11638. case 7:
  11639. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11640. {
  11641. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11642. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11643. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11644. }
  11645. break;
  11646. case 8:
  11647. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11648. {
  11649. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11650. }
  11651. break;
  11652. case 9:
  11653. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11654. {
  11655. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11656. }
  11657. break;
  11658. case 10:
  11659. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11660. {
  11661. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11662. }
  11663. break;
  11664. }
  11665. return outStr;
  11666. }
  11667. #region OP行程单
  11668. /// <summary>
  11669. /// OP行程单初始化
  11670. /// </summary>
  11671. /// <param name="dto"></param>
  11672. /// <returns></returns>
  11673. [HttpPost]
  11674. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11675. {
  11676. var jw = JsonView(false);
  11677. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11678. var group = groupList.First();
  11679. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11680. if (group == null)
  11681. {
  11682. jw.Msg = "暂无团组!";
  11683. return Ok(jw);
  11684. }
  11685. group = groupList.Find(x => x.Id == diid);
  11686. if (group == null)
  11687. {
  11688. jw.Msg = "请输入正确的团组ID!";
  11689. return Ok(jw);
  11690. }
  11691. string city = string.Empty;
  11692. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11693. if (blackCode.Count > 0)
  11694. {
  11695. var black = blackCode.First();
  11696. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11697. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11698. if (blackSp.Length > 0)
  11699. {
  11700. try
  11701. {
  11702. var cityArrCode = new List<string>(20);
  11703. foreach (var item in blackSp)
  11704. {
  11705. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11706. var IndexSelect = itemSp[2];
  11707. var cityArrCodeLength = cityArrCode.Count - 1;
  11708. var startCity = IndexSelect.Substring(0, 3);
  11709. if (cityArrCodeLength > 0)
  11710. {
  11711. var arrEndCity = cityArrCode[cityArrCodeLength];
  11712. if (arrEndCity != startCity)
  11713. {
  11714. cityArrCode.Add(startCity.ToUpper());
  11715. }
  11716. }
  11717. else
  11718. {
  11719. cityArrCode.Add(startCity.ToUpper());
  11720. }
  11721. var endCity = IndexSelect.Substring(3, 3);
  11722. cityArrCode.Add(endCity.ToUpper());
  11723. }
  11724. var cityThree = string.Empty;
  11725. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11726. cityThree = cityThree.TrimEnd(',');
  11727. if (string.IsNullOrWhiteSpace(cityThree))
  11728. {
  11729. throw new
  11730. Exception("error");
  11731. }
  11732. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11733. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11734. foreach (var item in cityArrCode)
  11735. {
  11736. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11737. if (find != null)
  11738. {
  11739. city += find.City + "/";
  11740. }
  11741. else
  11742. {
  11743. city += item + "三字码未收入/";
  11744. }
  11745. }
  11746. city = city.TrimEnd('/');
  11747. }
  11748. catch (Exception e)
  11749. {
  11750. city = "黑屏代码格式不正确!";
  11751. }
  11752. }
  11753. }
  11754. else
  11755. {
  11756. city = "未录入黑屏代码";
  11757. }
  11758. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11759. {
  11760. Date = x.Date,
  11761. Days = x.Days,
  11762. Diffgroup = x.Diffgroup,
  11763. Diid = x.Diid,
  11764. Traffic_First = x.Traffic_First,
  11765. Traffic_Second = x.Traffic_Second,
  11766. Trip = x.Trip,
  11767. WeekDay = x.WeekDay,
  11768. Id = x.Id
  11769. }).ToList();
  11770. jw.Data = new
  11771. {
  11772. groupList = groupList.Select(x => new
  11773. {
  11774. x.Id,
  11775. x.TeamName,
  11776. x.TourCode
  11777. }).ToList(),
  11778. groupInfo = new
  11779. {
  11780. group.VisitDays,
  11781. group.TourCode,
  11782. group.VisitPNumber,
  11783. group.TeamName,
  11784. city
  11785. },
  11786. OpTravelList
  11787. };
  11788. jw.Code = 200;
  11789. jw.Msg = "操作成功!";
  11790. return Ok(jw);
  11791. }
  11792. /// <summary>
  11793. /// 删除团组行程单
  11794. /// </summary>
  11795. /// <returns></returns>
  11796. [HttpPost]
  11797. public IActionResult DelTravel(DelOpTravelDto dto)
  11798. {
  11799. var jw = JsonView(false);
  11800. if (dto.UserId <= 0 || dto.Diid <= 0)
  11801. {
  11802. jw.Msg = "请输入正确的参数!";
  11803. return Ok(jw);
  11804. }
  11805. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11806. .SetColumns(x => new Grp_TravelList
  11807. {
  11808. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11809. DeleteUserId = dto.UserId,
  11810. IsDel = 1,
  11811. }).ExecuteCommand();
  11812. jw = JsonView(true);
  11813. return Ok(jw);
  11814. }
  11815. /// <summary>
  11816. /// 行程单保存
  11817. /// </summary>
  11818. /// <returns></returns>
  11819. [HttpPost]
  11820. public IActionResult TravelSave(TravelSaveDto dto)
  11821. {
  11822. var jw = JsonView(false);
  11823. if (dto.Arr.Count > 0)
  11824. {
  11825. try
  11826. {
  11827. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11828. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11829. .ToList();
  11830. _sqlSugar.BeginTran();
  11831. foreach (var item in dto.Arr)
  11832. {
  11833. if (item.Id == 0)
  11834. {
  11835. throw new Exception("请传入正确的Id");
  11836. }
  11837. //比较上一次的差异
  11838. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11839. if (findTravel != null)
  11840. {
  11841. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11842. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11843. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11844. }
  11845. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11846. .SetColumns(x => new Grp_TravelList
  11847. {
  11848. Trip = item.Trip
  11849. }).ExecuteCommand();
  11850. }
  11851. _sqlSugar.CommitTran();
  11852. jw = JsonView(true);
  11853. }
  11854. catch (Exception ex)
  11855. {
  11856. _sqlSugar.RollbackTran();
  11857. jw.Msg = "程序异常!" + ex.Message;
  11858. }
  11859. }
  11860. else
  11861. {
  11862. jw.Msg = "请传入正确的参数!";
  11863. }
  11864. return Ok(jw);
  11865. }
  11866. private string CheckStr(string original, string changed)
  11867. {
  11868. // 创建diff_match_patch对象
  11869. var dmp = new diff_match_patch();
  11870. // 计算差异
  11871. List<Diff> diffs = dmp.diff_main(original, changed);
  11872. // 清理和合并差异
  11873. dmp.diff_cleanupSemantic(diffs);
  11874. // 使用StringBuilder构建最终的字符串
  11875. StringBuilder finalString = new StringBuilder();
  11876. // 输出差异结果,并构建变动后的字符串
  11877. foreach (Diff diff in diffs)
  11878. {
  11879. switch (diff.operation)
  11880. {
  11881. case Operation.EQUAL:
  11882. // 相等的部分,直接添加到最终字符串
  11883. finalString.Append(diff.text);
  11884. break;
  11885. case Operation.INSERT:
  11886. // 插入的部分,添加标记并添加到最终字符串
  11887. finalString.Append("[++]" + diff.text + "[++]");
  11888. break;
  11889. case Operation.DELETE:
  11890. // 删除的部分,不添加到最终字符串
  11891. //finalString.Append("[++]" + diff.text + "[++]");
  11892. break;
  11893. }
  11894. }
  11895. // 输出变动后的字符串
  11896. return finalString.ToString();
  11897. }
  11898. private class tagContent
  11899. {
  11900. public DateTime Date { get; set; }
  11901. public string StartTag { get; set; }
  11902. public string EndTag { get; set; }
  11903. public string Content { get; set; }
  11904. public static int tagLength { get { return 3; } }
  11905. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11906. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11907. public bool IsFinally { get; set; }
  11908. }
  11909. private List<string> ExtractContentBetweenTags(string input, string tag)
  11910. {
  11911. List<string> results = new List<string>();
  11912. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11913. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11914. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11915. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11916. string[] strValueArr = new string[1];
  11917. foreach (System.Text.RegularExpressions.Match match in matches)
  11918. {
  11919. var strValue = match.Groups[1].Value;
  11920. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11921. }
  11922. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11923. return results;
  11924. }
  11925. /// <summary>
  11926. /// 导出行程单
  11927. /// </summary>
  11928. /// <param name="dto"></param>
  11929. /// <returns></returns>
  11930. [HttpPost]
  11931. public IActionResult ExportTravel(ExportTravelDto dto)
  11932. {
  11933. var jw = JsonView(false);
  11934. jw.Data = "";
  11935. int diid = 0;
  11936. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11937. if (Find == null)
  11938. {
  11939. jw.Msg = "请选择正确的团组!";
  11940. return Ok(jw);
  11941. }
  11942. else
  11943. {
  11944. diid = Find.Id;
  11945. }
  11946. //数据源
  11947. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11948. DataTable dtBlack = null;
  11949. try
  11950. {
  11951. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11952. }
  11953. catch (Exception)
  11954. {
  11955. jw.Msg = "机票黑屏代码有误!";
  11956. return Ok(jw);
  11957. }
  11958. string CityStr = string.Empty;
  11959. if (dtBlack.Rows.Count == 0)
  11960. {
  11961. jw.Msg = "机票黑屏代码有误!";
  11962. return Ok(jw);
  11963. }
  11964. else
  11965. {
  11966. foreach (DataRow row in dtBlack.Rows)
  11967. {
  11968. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11969. {
  11970. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11971. return Ok(jw);
  11972. }
  11973. }
  11974. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11975. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11976. }
  11977. // 指定的文字
  11978. var targetTextDic = new Dictionary<string, List<string>>();
  11979. //创建数据源Table
  11980. DataTable dtSource = new DataTable();
  11981. dtSource.Columns.Add("Days", typeof(string));
  11982. dtSource.Columns.Add("Date", typeof(string));
  11983. dtSource.Columns.Add("Week", typeof(string));
  11984. dtSource.Columns.Add("Traffic", typeof(string));
  11985. dtSource.Columns.Add("Trip", typeof(string));
  11986. //获取数据,放到datatable
  11987. foreach (var item in _travelList)
  11988. {
  11989. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11990. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11991. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11992. .Replace("[++]", string.Empty);
  11993. DataRow dr = dtSource.NewRow();
  11994. dr["Days"] = item.Days;
  11995. dr["Date"] = item.Date;
  11996. dr["Week"] = item.WeekDay;
  11997. dr["Traffic"] = item.Traffic_First
  11998. + "\r\n"
  11999. + item.Traffic_Second;
  12000. dr["Trip"] = item.Trip;
  12001. dtSource.Rows.Add(dr);
  12002. }
  12003. Dictionary<string, string> dic = new Dictionary<string, string>();
  12004. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12005. dic.Add("City", CityStr);
  12006. dic.Add("Days", Find.VisitDays.ToString());
  12007. dic.Add("DeleCode", Find.TourCode);
  12008. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12009. //模板路径
  12010. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12011. //载入模板
  12012. Document doc = null;
  12013. DocumentBuilder builder = null;
  12014. try
  12015. {
  12016. //载入模板
  12017. doc = new Document(tempPath);
  12018. builder = new DocumentBuilder(doc);
  12019. }
  12020. catch (Exception)
  12021. {
  12022. jw.Msg = "模板位置不存在!";
  12023. return Ok(jw);
  12024. }
  12025. foreach (var key in dic.Keys)
  12026. {
  12027. Bookmark bookmark = doc.Range.Bookmarks[key];
  12028. if (bookmark != null)
  12029. {
  12030. builder.MoveToBookmark(key);
  12031. builder.Write(dic[key]);
  12032. }
  12033. }
  12034. //获取word里所有表格
  12035. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12036. //获取所填表格的序数
  12037. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12038. try
  12039. {
  12040. //循环赋值
  12041. for (int i = 0; i < dtSource.Rows.Count; i++)
  12042. {
  12043. builder.MoveToCell(0, i + 1, 0, 0);
  12044. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12045. builder.MoveToCell(0, i + 1, 1, 0);
  12046. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12047. builder.MoveToCell(0, i + 1, 2, 0);
  12048. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12049. var trip = dtSource.Rows[i]["Trip"].ToString();
  12050. builder.MoveToCell(0, i + 1, 3, 0);
  12051. builder.Write(trip);
  12052. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12053. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12054. // 获取特定索引的段落
  12055. Paragraph paragraph = (Paragraph)paragraphs[0];
  12056. Run run = paragraph.Runs[0];
  12057. Aspose.Words.Font font = run.Font;
  12058. font.Name = "黑体";
  12059. //设置双休红色
  12060. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12061. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12062. paragraph = (Paragraph)paragraphs[1];
  12063. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12064. {
  12065. run = paragraph.Runs[0];
  12066. font = run.Font;
  12067. font.Color = Color.Red;
  12068. }
  12069. }
  12070. }
  12071. catch (Exception ex)
  12072. {
  12073. }
  12074. //删除多余行
  12075. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12076. {
  12077. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12078. }
  12079. var targetTextList = new List<string>();
  12080. // 遍历文档中的表格
  12081. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12082. {
  12083. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12084. {
  12085. var cellIndex = 0;
  12086. foreach (Cell cell in row.Cells)
  12087. {
  12088. if (cellIndex == 1 && row.Cells.Count == 4)
  12089. {
  12090. foreach (var target in targetTextDic.Keys)
  12091. {
  12092. if (cell.GetText().Contains(target))
  12093. {
  12094. targetTextList = targetTextDic[target];
  12095. break;
  12096. }
  12097. }
  12098. }
  12099. // 遍历单元格中的所有段落
  12100. foreach (Paragraph paragraph in cell.Paragraphs)
  12101. {
  12102. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12103. List<Run> runs = new List<Run>();
  12104. foreach (Run run in paragraph.Runs)
  12105. {
  12106. runs.Add(run);
  12107. }
  12108. foreach (Run run in runs)
  12109. {
  12110. foreach (var targetText in targetTextList)
  12111. {
  12112. // 检查文字是否包含指定文字
  12113. if (run.Text.Contains(targetText))
  12114. {
  12115. // 将包含的部分设置为红色
  12116. HighlightText(run, targetText, Color.Red);
  12117. }
  12118. }
  12119. }
  12120. }
  12121. cellIndex++;
  12122. }
  12123. }
  12124. }
  12125. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12126. if (!Directory.Exists(savePath))
  12127. {
  12128. try
  12129. {
  12130. Directory.CreateDirectory(savePath);
  12131. }
  12132. catch
  12133. {
  12134. }
  12135. }
  12136. string path = savePath + Find.TeamName + "出访日程";
  12137. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12138. try
  12139. {
  12140. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12141. string postfix = ".docx";
  12142. if (dto.IsPDF == 1)
  12143. {
  12144. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12145. postfix = ".pdf";
  12146. }
  12147. doc.Save(path + postfix, saveFormat);
  12148. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12149. }
  12150. catch (Exception)
  12151. {
  12152. jw = JsonView(false);
  12153. }
  12154. return Ok(jw);
  12155. }
  12156. /// <summary>
  12157. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12158. /// </summary>
  12159. /// <param name="num"></param>
  12160. /// <returns></returns>
  12161. string GetNum(string num)
  12162. {
  12163. string str = "";
  12164. switch (num)
  12165. {
  12166. case "1":
  12167. str = "一";
  12168. break;
  12169. case "2":
  12170. str = "二";
  12171. break;
  12172. case "3":
  12173. str = "三";
  12174. break;
  12175. case "4":
  12176. str = "四";
  12177. break;
  12178. case "5":
  12179. str = "五";
  12180. break;
  12181. case "6":
  12182. str = "六";
  12183. break;
  12184. case "7":
  12185. str = "七";
  12186. break;
  12187. case "8":
  12188. str = "八";
  12189. break;
  12190. case "9":
  12191. str = "九";
  12192. break;
  12193. case "10":
  12194. str = "十";
  12195. break;
  12196. case "11":
  12197. str = "十一";
  12198. break;
  12199. case "12":
  12200. str = "十二";
  12201. break;
  12202. case "一":
  12203. str = "1";
  12204. break;
  12205. case "二":
  12206. str = "2";
  12207. break;
  12208. case "三":
  12209. str = "3";
  12210. break;
  12211. case "四":
  12212. str = "4";
  12213. break;
  12214. case "五":
  12215. str = "5";
  12216. break;
  12217. case "六":
  12218. str = "6";
  12219. break;
  12220. case "七":
  12221. str = "7";
  12222. break;
  12223. case "八":
  12224. str = "8";
  12225. break;
  12226. case "九":
  12227. str = "9";
  12228. break;
  12229. case "十":
  12230. str = "10";
  12231. break;
  12232. case "十一":
  12233. str = "11";
  12234. break;
  12235. case "十二":
  12236. str = "12";
  12237. break;
  12238. }
  12239. return str;
  12240. }
  12241. // 高亮包含指定文字的部分
  12242. void HighlightText(Run run, string targetText, Color color)
  12243. {
  12244. string text = run.Text;
  12245. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12246. if (startIndex >= 0)
  12247. {
  12248. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12249. // 前部分
  12250. if (startIndex > 0)
  12251. {
  12252. Run beforeRun = (Run)run.Clone(true);
  12253. beforeRun.Text = text.Substring(0, startIndex);
  12254. parentParagraph.InsertBefore(beforeRun, run);
  12255. }
  12256. // 匹配部分
  12257. Run matchRun = (Run)run.Clone(true);
  12258. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12259. matchRun.Font.Color = color;
  12260. parentParagraph.InsertBefore(matchRun, run);
  12261. // 后部分
  12262. if (startIndex + targetText.Length < text.Length)
  12263. {
  12264. Run afterRun = (Run)run.Clone(true);
  12265. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12266. parentParagraph.InsertBefore(afterRun, run);
  12267. }
  12268. // 删除原始Run
  12269. run.Remove();
  12270. }
  12271. }
  12272. #endregion
  12273. #endregion
  12274. #region 团组成本
  12275. /// <summary>
  12276. /// 团组成本数据初始化
  12277. /// </summary>
  12278. /// <param name="dto"></param>
  12279. /// <returns></returns>
  12280. [HttpPost]
  12281. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12282. {
  12283. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12284. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12285. WHEN COUNT(*) >= 0 THEN 'True'
  12286. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12287. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12288. ").ToList(); //团组列表
  12289. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12290. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12291. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12292. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12293. if (groupinfoValue != null)
  12294. {
  12295. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12296. var spArr = new string[1] { countryArr };
  12297. if (countryArr.Contains("|"))
  12298. {
  12299. spArr = countryArr.Split("|");
  12300. }
  12301. else if (countryArr.Contains("、"))
  12302. {
  12303. spArr = countryArr.Split("、");
  12304. }
  12305. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12306. {
  12307. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12308. if (dbQueryCountry != null)
  12309. {
  12310. visaCountryInfoArr.Add(dbQueryCountry);
  12311. }
  12312. }
  12313. }
  12314. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12315. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12316. var create = _GroupCostRepository.
  12317. CreateGroupCostByBlackCode(dto.Diid);
  12318. if (groupCost.Count == 0 && create.Code == 0)
  12319. {
  12320. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12321. }
  12322. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12323. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12324. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12325. groupCostMap = groupCostMap.Select(x =>
  12326. {
  12327. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12328. {
  12329. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12330. }
  12331. return x;
  12332. }).ToList();
  12333. //GroupCostParameter.Add(new
  12334. // Grp_GroupCostParameter());
  12335. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12336. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12337. return Ok(JsonView(new
  12338. {
  12339. groupList,
  12340. groupInfo,
  12341. groupChecks,
  12342. groupCost = groupCostMap,
  12343. hotelNumber,
  12344. GroupCostParameter = GroupCostParameterMap,
  12345. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12346. {
  12347. x.VisaCountry,
  12348. x.VisaPrice,
  12349. x.Id,
  12350. }).ToList(),
  12351. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12352. blackCodeIsTrue = create.Code == 0 ? true : false,
  12353. hotelIsTrue = hotelIsTrue,
  12354. }));
  12355. }
  12356. /// <summary>
  12357. /// 团组成本信息保存
  12358. /// </summary>
  12359. /// <param name="dto"></param>
  12360. /// <returns></returns>
  12361. [HttpPost]
  12362. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12363. {
  12364. if (dto.Diid <= 0 || dto.Userid <= 0)
  12365. {
  12366. return Ok(JsonView(false));
  12367. }
  12368. JsonView jw = null;
  12369. bool isTrue = false;
  12370. #region 复制团组成本
  12371. //if (dto.Diid == 2581)
  12372. //{
  12373. // dto.Diid = 2599;
  12374. // dto.CheckBoxs.ForEach(x =>
  12375. // {
  12376. // x.Diid = 2599;
  12377. // });
  12378. // dto.GroupCosts.ForEach(x =>
  12379. // {
  12380. // x.Diid = 2599;
  12381. // });
  12382. // dto.CostTypeHotelNumbers.ForEach(x =>
  12383. // {
  12384. // x.Diid = 2599;
  12385. // });
  12386. // dto.GroupCostParameters.ForEach(x =>
  12387. // {
  12388. // x.DiId = 2599;
  12389. // });
  12390. //}
  12391. #endregion
  12392. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12393. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12394. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12395. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12396. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12397. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12398. try
  12399. {
  12400. _sqlSugar.BeginTran();
  12401. isTrue = await _GroupCostRepository.
  12402. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12403. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12404. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12405. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12406. _sqlSugar.CommitTran();
  12407. jw = JsonView(true, "保存成功!", isTrue);
  12408. }
  12409. catch (Exception)
  12410. {
  12411. _sqlSugar.RollbackTran();
  12412. jw = JsonView(false);
  12413. }
  12414. return Ok(jw);
  12415. }
  12416. /// <summary>
  12417. /// 司兼导数据
  12418. /// </summary>
  12419. /// <param name="dto"></param>
  12420. /// <returns></returns>
  12421. [HttpPost]
  12422. public IActionResult GetCarGuides(CarGuidesDto dto)
  12423. {
  12424. JsonView jw = null;
  12425. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12426. jw = JsonView(true, "获取成功!", Data);
  12427. return Ok(jw);
  12428. }
  12429. /// <summary>
  12430. /// 导游数据
  12431. /// </summary>
  12432. /// <param name="dto"></param>
  12433. /// <returns></returns>
  12434. [HttpPost]
  12435. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12436. {
  12437. JsonView jw = null;
  12438. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12439. // 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
  12440. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12441. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12442. jw = JsonView(true, "获取成功!", Data);
  12443. return Ok(jw);
  12444. }
  12445. /// <summary>
  12446. /// 成本车数据
  12447. /// </summary>
  12448. /// <param name="dto"></param>
  12449. /// <returns></returns>
  12450. [HttpPost]
  12451. public IActionResult GetCarInfo(CarGuidesDto dto)
  12452. {
  12453. JsonView jw = null;
  12454. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12455. jw = JsonView(true, "获取成功!", Data);
  12456. return Ok(jw);
  12457. }
  12458. /// <summary>
  12459. /// 景点数据
  12460. /// </summary>
  12461. /// <param name="dto"></param>
  12462. /// <returns></returns>
  12463. [HttpPost]
  12464. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12465. {
  12466. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12467. return Ok(JsonView(true, "获取成功!", Data));
  12468. }
  12469. /// <summary>
  12470. /// 成本通知
  12471. /// </summary>
  12472. /// <param name="dto"></param>
  12473. /// <returns></returns>
  12474. [HttpPost]
  12475. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12476. {
  12477. if (dto.Diid < 0)
  12478. {
  12479. return Ok(JsonView(false));
  12480. }
  12481. JsonView jw = null;
  12482. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12483. if (GroupCostParameter != null)
  12484. {
  12485. int IsShare = 0;
  12486. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12487. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12488. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12489. string msg = string.Empty;
  12490. if (isTrue)
  12491. {
  12492. if (IsShare == 0)
  12493. {
  12494. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12495. }
  12496. else
  12497. {
  12498. #region 企微通知对应岗位用户
  12499. try
  12500. {
  12501. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12502. }
  12503. catch (Exception ex)
  12504. {
  12505. }
  12506. #endregion
  12507. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12508. }
  12509. jw = JsonView(isTrue, msg, new { IsShare });
  12510. }
  12511. else
  12512. {
  12513. msg = "修改失败!";
  12514. jw = JsonView(isTrue, msg);
  12515. }
  12516. }
  12517. else
  12518. {
  12519. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12520. }
  12521. return Ok(jw);
  12522. }
  12523. /// <summary>
  12524. /// 导出报价单
  12525. /// </summary>
  12526. /// <param name="dto"></param>
  12527. /// <returns></returns>
  12528. [HttpPost]
  12529. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12530. {
  12531. if (dto.Diid == 0)
  12532. {
  12533. return Ok(JsonView(false, "请传递团组id"));
  12534. }
  12535. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12536. if (deleInfo.Code != 0)
  12537. {
  12538. return Ok(JsonView(false, "团组信息查询失败!"));
  12539. }
  12540. var di = deleInfo.Data as DelegationInfoWebView;
  12541. if (di != null)
  12542. {
  12543. di.TeamName = di.TeamName.Replace("|", "、");
  12544. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12545. //文件名
  12546. string strFileName = di.TeamName + "-收款账单.doc";
  12547. //获取模板
  12548. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12549. //载入模板
  12550. Document doc = new Document(tmppath);
  12551. decimal TotalPrice = 0.00M;
  12552. string itemStr = string.Empty;
  12553. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12554. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12555. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12556. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12557. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12558. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12559. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12560. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12561. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12562. foreach (var cost in groupCostType)
  12563. {
  12564. var List = cost.ToList();
  12565. if (cost.Key == "A")
  12566. {
  12567. foreach (var ListItem in List)
  12568. {
  12569. if (ListItem.number > 0)
  12570. {
  12571. if (ListItem.code.Contains("TBR"))
  12572. {
  12573. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12574. }
  12575. else
  12576. {
  12577. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12578. }
  12579. TotalPrice += (ListItem.number * ListItem.price);
  12580. }
  12581. }
  12582. }
  12583. else
  12584. {
  12585. itemStr = itemStr.Insert(0, "A段\r\n");
  12586. itemStr += "B段\r\n";
  12587. foreach (var ListItem in List)
  12588. {
  12589. if (ListItem.number > 0)
  12590. {
  12591. if (ListItem.code.Contains("TBR"))
  12592. {
  12593. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12594. }
  12595. else
  12596. {
  12597. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12598. }
  12599. TotalPrice += (ListItem.number * ListItem.price);
  12600. }
  12601. }
  12602. }
  12603. }
  12604. #region 替换Word模板书签内容
  12605. Dictionary<string, string> marks = new Dictionary<string, string>();
  12606. marks.Add("To", di.ClientUnit);//付款方
  12607. marks.Add("ToTel", di.TellPhone);//付款方电话
  12608. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12609. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12610. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12611. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12612. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12613. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12614. marks.Add("PayItemContent", itemStr);//详细信息
  12615. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12616. #endregion
  12617. ////注
  12618. //if (doc.Range.Bookmarks["Attention"] != null)
  12619. //{
  12620. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12621. // mark.Text = frList[0].Attention;
  12622. //}
  12623. foreach (var item in marks.Keys)
  12624. {
  12625. if (doc.Range.Bookmarks[item] != null)
  12626. {
  12627. Bookmark mark = doc.Range.Bookmarks[item];
  12628. mark.Text = marks[item];
  12629. }
  12630. }
  12631. byte[] bytes = null;
  12632. using (MemoryStream stream = new MemoryStream())
  12633. {
  12634. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12635. bytes = stream.ToArray();
  12636. }
  12637. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12638. return Ok(JsonView(true, "", new
  12639. {
  12640. Data = bytes,
  12641. strFileName,
  12642. }));
  12643. }
  12644. else
  12645. {
  12646. return Ok(JsonView(false, "团组信息不存在!"));
  12647. }
  12648. }
  12649. /// <summary>
  12650. /// 导出团组成本
  12651. /// </summary>
  12652. /// <param name="dto"></param>
  12653. /// <returns></returns>
  12654. [HttpPost]
  12655. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12656. {
  12657. var jw = JsonView(false);
  12658. if (dto.Diid == 0)
  12659. {
  12660. return Ok(JsonView(false, "请传递团组id"));
  12661. }
  12662. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12663. if (deleInfo.Code != 0)
  12664. {
  12665. return Ok(JsonView(false, "团组信息查询失败!"));
  12666. }
  12667. var di = deleInfo.Data as DelegationInfoWebView;
  12668. if (di == null)
  12669. {
  12670. return Ok(JsonView(false, "团组信息查询失败!"));
  12671. }
  12672. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12673. WorkbookDesigner designer = new WorkbookDesigner();
  12674. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12675. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12676. for (int i = 0; i < List_GC.Count; i++)
  12677. {
  12678. GroupCost_Excel gc = new GroupCost_Excel();
  12679. gc.Id = List_GC[i].Id;
  12680. gc.Diid = List_GC[i].Diid.ToString();
  12681. gc.DAY = List_GC[i].DAY;
  12682. string week = "";
  12683. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12684. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12685. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12686. gc.ITIN = List_GC[i].ITIN;
  12687. gc.CarType = List_GC[i].CarType;
  12688. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12689. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12690. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12691. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12692. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12693. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12694. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12695. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12696. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12697. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12698. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12699. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12700. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12701. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12702. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12703. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12704. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12705. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12706. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12707. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12708. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12709. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12710. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12711. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12712. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12713. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12714. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12715. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12716. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12717. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12718. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12719. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12720. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12721. List_GC1.Add(gc);
  12722. }
  12723. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12724. dt.TableName = "TB";
  12725. //报表标题等不用dt的值
  12726. designer.SetDataSource("TeamName", dto.title.TeamName);
  12727. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12728. designer.SetDataSource("Tax", dto.title.Tax);
  12729. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12730. designer.SetDataSource("Currency", dto.title.Currency);
  12731. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12732. designer.SetDataSource("Rate", dto.title.Rate);
  12733. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12734. var Aparams = hotels.Find(x => x.Type == "Default");
  12735. if (Aparams == null)
  12736. {
  12737. return Ok(jw);
  12738. }
  12739. //酒店数量
  12740. var txtSGRNumber = Aparams.SGR.ToString();
  12741. var txtTBRNumber = Aparams.TBR.ToString();
  12742. var txtJSESNumber = Aparams.JSES.ToString();
  12743. var txtSUITENumbe = Aparams.SUITE.ToString();
  12744. if (dto.costType == "B")
  12745. {
  12746. Aparams = hotels.Find(x => x.Type == "A");
  12747. var Bparams = hotels.Find(x => x.Type == "B");
  12748. if (Aparams == null || Bparams == null)
  12749. {
  12750. return Ok(jw);
  12751. }
  12752. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12753. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12754. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12755. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12756. }
  12757. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12758. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12759. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12760. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12761. var ws = designer.Workbook.Worksheets[0];
  12762. int Row = List_GC.Count;
  12763. int startIndex = 11;
  12764. int HideRows = 0;
  12765. List<int> hideRowsList = new List<int>();
  12766. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12767. #region A段left数据
  12768. var left = dto.leftInfo.Find(x => x.Type == "A");
  12769. if (left == null)
  12770. {
  12771. return Ok(jw);
  12772. }
  12773. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12774. if (leftBindData != null)
  12775. {
  12776. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12777. designer.SetDataSource("VisaRS", leftBindData.rs);
  12778. designer.SetDataSource("VisaXS", leftBindData.xs);
  12779. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12780. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12781. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12782. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12783. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12784. }
  12785. else
  12786. {
  12787. hideRowsList.Add(Row + startIndex + HideRows);
  12788. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12789. }
  12790. HideRows += 2;
  12791. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12792. if (leftBindData != null)
  12793. {
  12794. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12795. designer.SetDataSource("BXRS", leftBindData.rs);
  12796. designer.SetDataSource("BXXS", leftBindData.xs);
  12797. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12798. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12799. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12800. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12801. designer.SetDataSource("BXZLR", ((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("HSDRCB", leftBindData.cb);
  12813. designer.SetDataSource("HSRS", leftBindData.rs);
  12814. designer.SetDataSource("HSXS", leftBindData.xs);
  12815. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12816. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12817. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12818. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12819. designer.SetDataSource("HSZLR", ((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("JPJJCCB", leftBindData.cb);
  12831. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12832. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12833. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12834. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12835. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12836. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12837. designer.SetDataSource("JPJJCZLR", ((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("JPGWCCB", leftBindData.cb);
  12849. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12850. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12851. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12852. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12853. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12854. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12855. designer.SetDataSource("JPGWCZLR", ((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("JPTDCCB", leftBindData.cb);
  12867. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12868. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12869. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12870. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12871. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12872. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12873. designer.SetDataSource("JPTDCZLR", ((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("TBR"));
  12882. if (leftBindData != null)
  12883. {
  12884. ////TBR
  12885. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12886. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12887. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12888. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12889. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12890. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12891. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12892. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12893. }
  12894. else
  12895. {
  12896. hideRowsList.Add(Row + startIndex + HideRows);
  12897. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12898. }
  12899. HideRows += 2;
  12900. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12901. if (leftBindData != null)
  12902. {
  12903. ////SGR
  12904. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12905. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12906. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12907. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12908. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12909. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12910. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12911. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12912. }
  12913. else
  12914. {
  12915. hideRowsList.Add(Row + startIndex + HideRows);
  12916. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12917. }
  12918. HideRows += 2;
  12919. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12920. if (leftBindData != null)
  12921. {
  12922. ////JS/ES
  12923. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12924. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12925. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12926. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12927. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12928. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12929. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12930. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12931. }
  12932. else
  12933. {
  12934. hideRowsList.Add(Row + startIndex + HideRows);
  12935. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12936. }
  12937. HideRows += 2;
  12938. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12939. if (leftBindData != null)
  12940. {
  12941. ////SUITE
  12942. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12943. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12944. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12945. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12946. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12947. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12948. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12949. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12950. }
  12951. else
  12952. {
  12953. hideRowsList.Add(Row + startIndex + HideRows);
  12954. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12955. }
  12956. HideRows += 2;
  12957. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12958. if (leftBindData != null)
  12959. {
  12960. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12961. designer.SetDataSource("DJRS", leftBindData.rs);
  12962. designer.SetDataSource("DJXS", leftBindData.xs);
  12963. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12964. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12965. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12966. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12967. designer.SetDataSource("DJZLR", ((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("HCPCB", leftBindData.cb);
  12979. designer.SetDataSource("HCPRS", leftBindData.rs);
  12980. designer.SetDataSource("HCPXS", leftBindData.xs);
  12981. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12982. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12983. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12984. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12985. designer.SetDataSource("HCPZLR", ((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("CPCB", leftBindData.cb);
  12997. designer.SetDataSource("CPRS", leftBindData.rs);
  12998. designer.SetDataSource("CPXS", leftBindData.xs);
  12999. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13000. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13001. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13002. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13003. designer.SetDataSource("CPZLR", ((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("GWDRCD", leftBindData.cb);
  13015. designer.SetDataSource("GWRS", leftBindData.rs);
  13016. designer.SetDataSource("GWXS", leftBindData.xs);
  13017. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13018. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13019. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13020. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13021. designer.SetDataSource("GWZLR", ((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("LYJDRCB", leftBindData.cb);
  13033. designer.SetDataSource("LYJRS", leftBindData.rs);
  13034. designer.SetDataSource("LYJXS", leftBindData.xs);
  13035. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13036. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13037. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13038. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13039. designer.SetDataSource("LYJZLR", ((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. #endregion
  13047. #region A段Right信息
  13048. var right = dto.rightInfo.Find(x => x.Type == "A");
  13049. if (right == null)
  13050. {
  13051. return Ok(jw);
  13052. }
  13053. HideRows += 4;
  13054. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13055. if (rightBindData != null)
  13056. {
  13057. //经济舱 + 双人间 TBR
  13058. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13059. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13060. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13061. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13062. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13063. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13064. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13065. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13066. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13067. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13068. }
  13069. else
  13070. {
  13071. hideRowsList.Add(Row + startIndex + HideRows);
  13072. }
  13073. HideRows += 2;
  13074. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13075. if (rightBindData != null)
  13076. {
  13077. //经济舱 + 单人间 SGR
  13078. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13079. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13080. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13081. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13082. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13083. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13084. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13085. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13086. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13087. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13088. }
  13089. else
  13090. {
  13091. hideRowsList.Add(Row + startIndex + HideRows);
  13092. }
  13093. HideRows += 2;
  13094. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13095. if (rightBindData != null)
  13096. {
  13097. //公务舱 + 单人间 SGR
  13098. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13099. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13100. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13101. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13102. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13103. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13104. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13105. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13106. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13107. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13108. }
  13109. else
  13110. {
  13111. hideRowsList.Add(Row + startIndex + HideRows);
  13112. }
  13113. HideRows += 2;
  13114. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13115. if (rightBindData != null)
  13116. {
  13117. //公务舱 + 小套房 JSES
  13118. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13119. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13120. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13121. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13122. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13123. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13124. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13125. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13126. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13127. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13128. }
  13129. else
  13130. {
  13131. hideRowsList.Add(Row + startIndex + HideRows);
  13132. }
  13133. HideRows += 2;
  13134. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13135. if (rightBindData != null)
  13136. {
  13137. //公务舱 + 小套房 JSES
  13138. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13139. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13140. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13141. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13142. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13143. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13144. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13145. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13146. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13147. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13148. }
  13149. else
  13150. {
  13151. hideRowsList.Add(Row + startIndex + HideRows);
  13152. }
  13153. HideRows += 2;
  13154. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13155. if (rightBindData != null)
  13156. {
  13157. //经济舱 + 大套房
  13158. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13159. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13160. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13161. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13162. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13163. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13164. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13165. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13166. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13167. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13168. }
  13169. else
  13170. {
  13171. hideRowsList.Add(Row + startIndex + HideRows);
  13172. }
  13173. HideRows += 2;
  13174. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13175. if (rightBindData != null)
  13176. {
  13177. //头等舱 + 小套房 JSES
  13178. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13179. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13180. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13181. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13182. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13183. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13184. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13185. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13186. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13187. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13188. }
  13189. else
  13190. {
  13191. hideRowsList.Add(Row + startIndex + HideRows);
  13192. }
  13193. HideRows += 2;
  13194. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13195. if (rightBindData != null)
  13196. {
  13197. //头等舱 + 大套房
  13198. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13199. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13200. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13201. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13202. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13203. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13204. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13205. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13206. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13207. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13208. }
  13209. else
  13210. {
  13211. hideRowsList.Add(Row + startIndex + HideRows);
  13212. }
  13213. #endregion
  13214. #region B段标题清空
  13215. designer.SetDataSource("CostBDRCB", "");
  13216. designer.SetDataSource("CostBRS", "");
  13217. designer.SetDataSource("CostBXS", "");
  13218. designer.SetDataSource("CostBZCB", "");
  13219. designer.SetDataSource("CostBDRBJ", "");
  13220. designer.SetDataSource("CostBZBJ", "");
  13221. designer.SetDataSource("CostBDRLR", "");
  13222. designer.SetDataSource("CostBZLR", "");
  13223. designer.SetDataSource("CostBDRCBOM", "");
  13224. designer.SetDataSource("CostBRSOM", "");
  13225. designer.SetDataSource("CostBZCBOM", "");
  13226. designer.SetDataSource("CostBDRBJOM", "");
  13227. designer.SetDataSource("CostBZBJOM", "");
  13228. designer.SetDataSource("CostBDRLROM", "");
  13229. designer.SetDataSource("CostBZLROM", "");
  13230. #endregion
  13231. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13232. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13233. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13234. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13235. designer.SetDataSource("DJName", "地接(CNY)");
  13236. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13237. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13238. designer.SetDataSource("GWName", "公务(CNY)");
  13239. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13240. designer.SetDataSource("LYJName", "零用金(CNY)");
  13241. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13242. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13243. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13244. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13245. designer.SetDataSource("BXName", "保险(CNY)");
  13246. designer.SetDataSource("VisaName", "签证(CNY)");
  13247. #region B段基本数据
  13248. if (dto.costType == "B")
  13249. {
  13250. left = dto.leftInfo.Find(x => x.Type == "B");
  13251. if (left == null)
  13252. {
  13253. return Ok(jw);
  13254. }
  13255. #region B段left数据
  13256. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13257. if (leftBindData != null)
  13258. {
  13259. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13260. designer.SetDataSource("BHSRS", leftBindData.rs);
  13261. designer.SetDataSource("BHSXS", leftBindData.xs);
  13262. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13263. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13264. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13265. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13266. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13267. }
  13268. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13269. if (leftBindData != null)
  13270. {
  13271. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13272. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13273. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13274. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13275. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13276. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13277. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13278. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13279. }
  13280. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13281. if (leftBindData != null)
  13282. {
  13283. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13284. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13285. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13286. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13287. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13288. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13289. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13290. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13291. }
  13292. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13293. if (leftBindData != null)
  13294. {
  13295. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13296. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13297. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13298. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13299. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13300. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13301. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13302. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13303. }
  13304. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13305. if (leftBindData != null)
  13306. {
  13307. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13308. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13309. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13310. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13311. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13312. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13313. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13314. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13315. }
  13316. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13317. if (leftBindData != null)
  13318. {
  13319. designer.SetDataSource("BCPCB", leftBindData.cb);
  13320. designer.SetDataSource("BCPRS", leftBindData.rs);
  13321. designer.SetDataSource("BCPXS", leftBindData.xs);
  13322. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13323. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13324. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13325. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13326. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13327. }
  13328. //TBR
  13329. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13330. if (leftBindData != null)
  13331. {
  13332. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13333. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13334. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13335. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13336. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13337. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13338. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13339. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13340. }
  13341. //SGR
  13342. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13343. if (leftBindData != null)
  13344. {
  13345. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13346. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13347. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13348. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13349. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13350. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13351. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13352. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13353. }
  13354. //JS/ES
  13355. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13356. if (leftBindData != null)
  13357. {
  13358. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13359. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13360. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13361. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13362. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13363. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13364. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13365. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13366. }
  13367. //SUITE
  13368. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13369. if (leftBindData != null)
  13370. {
  13371. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13372. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13373. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13374. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13375. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13376. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13377. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13378. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13379. }
  13380. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13381. if (leftBindData != null)
  13382. {
  13383. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13384. designer.SetDataSource("BDJRS", leftBindData.rs);
  13385. designer.SetDataSource("BDJXS", leftBindData.xs);
  13386. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13387. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13388. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13389. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13390. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13391. }
  13392. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13393. if (leftBindData != null)
  13394. {
  13395. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13396. designer.SetDataSource("BGWRS", leftBindData.rs);
  13397. designer.SetDataSource("BGWXS", leftBindData.xs);
  13398. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13399. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13400. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13401. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13402. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13403. }
  13404. #region 优化方案
  13405. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13406. //excelBind.Add("零用金", new {
  13407. //cb="",
  13408. //rs="",
  13409. //xs ="",
  13410. //zcb = "",
  13411. //});
  13412. #endregion
  13413. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13414. if (leftBindData != null)
  13415. {
  13416. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13417. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13418. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13419. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13420. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13421. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13422. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13423. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13424. }
  13425. #endregion
  13426. #region B段Right信息
  13427. right = dto.rightInfo.Find(x => x.Type == "B");
  13428. if (right == null)
  13429. {
  13430. return Ok(jw);
  13431. }
  13432. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13433. if (rightBindData != null)
  13434. {
  13435. //经济舱 + 双人间 TBR
  13436. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13437. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13438. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13439. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13440. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13441. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13442. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13443. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13444. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13445. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13446. }
  13447. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13448. if (rightBindData != null)
  13449. {
  13450. //经济舱 + 单人间 SGR
  13451. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13452. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13453. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13454. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13455. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13456. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13457. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13458. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13459. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13460. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13461. }
  13462. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13463. if (rightBindData != null)
  13464. {
  13465. //公务舱 + 单人间 SGR
  13466. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13467. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13468. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13469. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13470. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13471. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13472. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13473. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13474. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13475. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13476. }
  13477. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13478. if (rightBindData != null)
  13479. {
  13480. //公务舱 + 小套房 JSES
  13481. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13482. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13483. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13484. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13485. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13486. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13487. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13488. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13489. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13490. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13491. }
  13492. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13493. if (rightBindData != null)
  13494. {
  13495. //公务舱 + 小套房 JSES
  13496. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13497. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13498. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13499. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13500. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13501. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13502. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13503. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13504. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13505. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13506. }
  13507. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13508. if (rightBindData != null)
  13509. {
  13510. //经济舱 + 大套房
  13511. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13512. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13513. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13514. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13515. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13516. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13517. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13518. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13519. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13520. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13521. }
  13522. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13523. if (rightBindData != null)
  13524. {
  13525. //头等舱 + 小套房 JSES
  13526. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13527. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13528. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13529. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13530. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13531. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13532. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13533. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13534. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13535. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13536. }
  13537. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13538. if (rightBindData != null)
  13539. {
  13540. //头等舱 + 大套房
  13541. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13542. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13543. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13544. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13545. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13546. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13547. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13548. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13549. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13550. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13551. }
  13552. #endregion
  13553. #region 标题
  13554. designer.SetDataSource("CostBDRCB", "单人成本");
  13555. designer.SetDataSource("CostBRS", "人数");
  13556. designer.SetDataSource("CostBXS", "系数");
  13557. designer.SetDataSource("CostBZCB", "总成本");
  13558. designer.SetDataSource("CostBDRBJ", "单人报价");
  13559. designer.SetDataSource("CostBZBJ", "总报价");
  13560. designer.SetDataSource("CostBDRLR", "单人利润");
  13561. designer.SetDataSource("CostBZLR", "总利润");
  13562. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13563. designer.SetDataSource("CostBRSOM", "人数");
  13564. designer.SetDataSource("CostBZCBOM", "总成本");
  13565. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13566. designer.SetDataSource("CostBZBJOM", "总报价");
  13567. designer.SetDataSource("CostBDRLROM", "单人利润");
  13568. designer.SetDataSource("CostBZLROM", "总利润");
  13569. #endregion
  13570. }
  13571. #endregion
  13572. designer.SetDataSource("TzZCB2", TzZCB2);
  13573. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13574. designer.SetDataSource("TzZLR2", TzZLR2);
  13575. string[] dataSourceKeys = new string[]
  13576. {
  13577. "VF",
  13578. "TGS",
  13579. "TGOF",
  13580. "TGM",
  13581. "TGA",
  13582. "TGTF",
  13583. "TGEF",
  13584. "CFM",
  13585. "CFOF",
  13586. "B",
  13587. "L",
  13588. "D",
  13589. "TBR",
  13590. "SGR",
  13591. "JSES",
  13592. "Suite",
  13593. "TV",
  13594. "1L",
  13595. "IF",
  13596. "EF",
  13597. "BRF",
  13598. "TE",
  13599. "TGT",
  13600. "DRVT",
  13601. "PC",
  13602. "TLF",
  13603. "ECT"
  13604. };
  13605. foreach (var item in dataSourceKeys)
  13606. {
  13607. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13608. if (find != null)
  13609. {
  13610. designer.SetDataSource(item, find.text);
  13611. }
  13612. else
  13613. {
  13614. designer.SetDataSource(item, 0);
  13615. }
  13616. }
  13617. designer.SetDataSource(dt);
  13618. //根据数据源处理生成报表内容
  13619. designer.Process();
  13620. designer.Workbook.Worksheets[0].Name = "清单";
  13621. Worksheet sheet = designer.Workbook.Worksheets[0];
  13622. foreach (var Rowindex in hideRowsList)
  13623. {
  13624. ws.Cells.HideRows(Rowindex, 2);
  13625. }
  13626. byte[] bytes = null;
  13627. string strFileName = di.TeamName + "-团组-成本.xls";
  13628. using (MemoryStream stream = new MemoryStream())
  13629. {
  13630. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13631. bytes = stream.ToArray();
  13632. }
  13633. return Ok(JsonView(true, "", new
  13634. {
  13635. Data = bytes,
  13636. strFileName,
  13637. }));
  13638. }
  13639. /// <summary>
  13640. /// 导出客户报表
  13641. /// </summary>
  13642. /// <returns></returns>
  13643. [HttpPost]
  13644. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13645. {
  13646. var jw = JsonView(false);
  13647. if (dto.Diid == 0)
  13648. {
  13649. return Ok(JsonView(false, "请传递团组id"));
  13650. }
  13651. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13652. if (deleInfo.Code != 0)
  13653. {
  13654. return Ok(JsonView(false, "团组信息查询失败!"));
  13655. }
  13656. var di = deleInfo.Data as DelegationInfoWebView;
  13657. if (di == null)
  13658. {
  13659. return Ok(JsonView(false, "团组信息查询失败!"));
  13660. }
  13661. //文件名
  13662. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13663. //获取模板
  13664. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13665. //载入模板
  13666. Document doc = new Document(tmppath);
  13667. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13668. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13669. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13670. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13671. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13672. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13673. if (AParameter == null)
  13674. {
  13675. return Ok(JsonView(false, "系数不存在!"));
  13676. }
  13677. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13678. , TzAirDesc, TzZCost;
  13679. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13680. = TzAirDesc = TzZCost = string.Empty;
  13681. TzNumber = AParameter.CostTypenumber.ToString();
  13682. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13683. CarGuides1 = dto.CarGuides1;
  13684. Meal = dto.Meal;
  13685. SubsidizedMeals = dto.SubsidizedMeals;
  13686. NightRepair = dto.NightRepair;
  13687. AttractionsTickets = dto.AttractionsTickets;
  13688. MiscellaneousFees = dto.MiscellaneousFees;
  13689. ATip = dto.ATip;
  13690. TzHotelDesc = "";
  13691. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13692. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13693. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13694. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13695. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13696. TzAirDesc = "";
  13697. TzZCost = dto.TzZCost;
  13698. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13699. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13700. var index = 1;
  13701. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13702. foreach (var item in TzHotelDescArr)
  13703. {
  13704. if (AinfoArr != null)
  13705. {
  13706. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13707. if (Ainfo != null)
  13708. {
  13709. if (int.Parse(Ainfo.rs) <= 0)
  13710. {
  13711. continue;
  13712. }
  13713. var hotelText = string.Empty;
  13714. switch (item)
  13715. {
  13716. case "SGR":
  13717. hotelText = "单人间";
  13718. break;
  13719. case "JSES":
  13720. hotelText = "小套房";
  13721. break;
  13722. case "SUITE":
  13723. hotelText = "套房";
  13724. break;
  13725. case "TBR":
  13726. hotelText = "双人间";
  13727. break;
  13728. }
  13729. if (item != "TBR")
  13730. {
  13731. 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";
  13732. }
  13733. else
  13734. {
  13735. 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";
  13736. }
  13737. index++;
  13738. }
  13739. }
  13740. }
  13741. index = 1;
  13742. foreach (var item in TzAirDescArr)
  13743. {
  13744. if (AinfoArr != null)
  13745. {
  13746. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13747. if (Ainfo != null)
  13748. {
  13749. if (int.Parse(Ainfo.rs) <= 0)
  13750. {
  13751. continue;
  13752. }
  13753. 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";
  13754. index++;
  13755. }
  13756. }
  13757. }
  13758. if (dto.costType == "B")
  13759. {
  13760. if (BParameter == null)
  13761. {
  13762. return Ok(JsonView(false, "B段系数不存在!"));
  13763. }
  13764. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13765. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13766. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13767. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13768. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13769. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13770. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13771. foreach (var item in TzHotelDescArr)
  13772. {
  13773. if (AinfoArr != null)
  13774. {
  13775. TzHotelDesc += "B段信息 \r\n";
  13776. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13777. if (Ainfo != null)
  13778. {
  13779. if (int.Parse(Ainfo.rs) <= 0)
  13780. {
  13781. continue;
  13782. }
  13783. var hotelText = string.Empty;
  13784. switch (item)
  13785. {
  13786. case "SGR":
  13787. hotelText = "单人间";
  13788. break;
  13789. case "JSES":
  13790. hotelText = "小套房";
  13791. break;
  13792. case "SUITE":
  13793. hotelText = "套房";
  13794. break;
  13795. case "TBR":
  13796. hotelText = "双人间";
  13797. break;
  13798. }
  13799. if (item != "TBR")
  13800. {
  13801. 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";
  13802. }
  13803. else
  13804. {
  13805. 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";
  13806. }
  13807. index++;
  13808. }
  13809. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13810. }
  13811. }
  13812. index = 1;
  13813. foreach (var item in TzAirDescArr)
  13814. {
  13815. if (AinfoArr != null)
  13816. {
  13817. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13818. if (Ainfo != null)
  13819. {
  13820. if (int.Parse(Ainfo.rs) <= 0)
  13821. {
  13822. continue;
  13823. }
  13824. 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";
  13825. index++;
  13826. }
  13827. }
  13828. }
  13829. }
  13830. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13831. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13832. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13833. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13834. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13835. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13836. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13837. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13838. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13839. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13840. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13841. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13842. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13843. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13844. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13845. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13846. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13847. DickeyValue.Add("TzZCost", TzZCost);
  13848. foreach (var key in DickeyValue.Keys)
  13849. {
  13850. if (doc.Range.Bookmarks[key] != null)
  13851. {
  13852. Bookmark mark = doc.Range.Bookmarks[key];
  13853. mark.Text = DickeyValue[key];
  13854. }
  13855. }
  13856. byte[] bytes = null;
  13857. string strFileName = di.TeamName + "-客户报价.doc";
  13858. using (MemoryStream stream = new MemoryStream())
  13859. {
  13860. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13861. bytes = stream.ToArray();
  13862. }
  13863. return Ok(JsonView(true, "", new
  13864. {
  13865. Data = bytes,
  13866. strFileName,
  13867. }));
  13868. }
  13869. /// <summary>
  13870. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13871. /// </summary>
  13872. /// <param name="dto"></param>
  13873. /// <returns></returns>
  13874. [HttpPost]
  13875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13876. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13877. {
  13878. try
  13879. {
  13880. #region 参数验证
  13881. if (dto.DiId < 0)
  13882. {
  13883. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13884. }
  13885. List<int> cTableIds = new List<int>() {
  13886. 76 ,//酒店预订
  13887. 77 ,//行程
  13888. 79 ,//车/导游地接
  13889. 80 ,//签证
  13890. 81 ,//邀请/公务活
  13891. 82 ,//团组客户保险
  13892. 85 ,//机票预订
  13893. 98 ,//其他款项
  13894. 285 ,//收款退还
  13895. 751 ,//酒店早餐
  13896. 1015 // 超支费用
  13897. };
  13898. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13899. {
  13900. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13901. }
  13902. #endregion
  13903. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13904. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13905. if (_GroupCostParameters.Count <= 0)
  13906. {
  13907. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13908. }
  13909. if (_GroupCostParameters[0].IsShare == 0)
  13910. {
  13911. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13912. }
  13913. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13914. //处理date为空问题
  13915. if (_GroupCosts.Count > 0)
  13916. {
  13917. for (int i = 0; i < _GroupCosts.Count; i++)
  13918. {
  13919. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13920. {
  13921. if (i > 0)
  13922. {
  13923. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13924. }
  13925. }
  13926. }
  13927. }
  13928. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13929. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13930. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13931. string currCode = "";
  13932. #region currCode 验证
  13933. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13934. if (isInt)
  13935. {
  13936. var currData = currDatas.Find(it => it.Id == intCurrency);
  13937. if (currData != null)
  13938. {
  13939. currCode = currData.Name;
  13940. }
  13941. }
  13942. else
  13943. {
  13944. currCode = _GroupCostParameters[0].Currency.Trim();
  13945. }
  13946. #endregion
  13947. //op,酒店单段模式存储
  13948. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13949. {
  13950. CurrencyCode = currCode,
  13951. Rate = _GroupCostParameters[0].Rate,
  13952. CostType = _GroupCostParameters[0].CostType,
  13953. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13954. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13955. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13956. };
  13957. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13958. if (_GroupCostParameters.Count == 2)
  13959. {
  13960. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13961. }
  13962. foreach (var item in _GroupCostParameters)
  13963. {
  13964. decimal _rate = 1;
  13965. decimal _rate1 = item.Rate;
  13966. decimal _scale = 1;
  13967. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13968. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13969. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13970. //if (userInfo != null)
  13971. //{
  13972. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13973. // {
  13974. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13975. // {
  13976. // _scale = 1.00M;
  13977. // }
  13978. // }
  13979. //}
  13980. #endregion
  13981. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13982. {
  13983. CurrencyCode = currCode,
  13984. Rate = _rate1,
  13985. CostType = item.CostType,
  13986. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13987. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13988. CostTypeNumber = item.CostTypenumber
  13989. };
  13990. if (_GroupCostParameters.Count > 1)
  13991. {
  13992. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13993. }
  13994. else
  13995. {
  13996. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13997. }
  13998. if (dto.CTable == 79)//
  13999. {
  14000. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14001. modulePromptInfo.TotalCost = item.DJCB;
  14002. }
  14003. List<string> costTypes = new List<string>() { "A", "B" };
  14004. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14005. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14006. if (_GroupCostsDuplicates.Count() == 1)
  14007. {
  14008. _GroupCostsTypeData = _GroupCosts;
  14009. }
  14010. else
  14011. {
  14012. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14013. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14014. }
  14015. /*
  14016. * 76 酒店预订
  14017. * 77 行程
  14018. * 79 车/导游地接
  14019. * 80 签证
  14020. * 81 邀请/公务活动
  14021. * 82 团组客户保险
  14022. * 85 机票预订
  14023. * 98 其他款项
  14024. * 285 收款退还
  14025. * 751 酒店早餐
  14026. * 1015 超支费用
  14027. */
  14028. switch (dto.CTable)
  14029. {
  14030. case 76: // 酒店预订
  14031. _ModuleSubPromptInfo.AddRange(
  14032. _GroupCostsTypeData.Select(it => new
  14033. {
  14034. it.DAY,
  14035. it.Date,
  14036. it.ACCON,
  14037. it.ITIN,
  14038. it.SGR,
  14039. it.TBR,
  14040. it.JS_ES,
  14041. it.Suite
  14042. })
  14043. );
  14044. break;
  14045. case 79: // 车/导游地接
  14046. _ModuleSubPromptInfo.AddRange(
  14047. _GroupCostsTypeData.Select(it => new
  14048. {
  14049. Date = it.Date, //日期
  14050. CarFee = it.CarCost * _rate * _scale, //车费用
  14051. CarType = it.CarType, //车型
  14052. DriverFee = it.CFS * _rate * _scale, //司机工资
  14053. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14054. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14055. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14056. GuideFee = it.TGS * _rate * _scale, //导游费用
  14057. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14058. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14059. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14060. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14061. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14062. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14063. Breakfast = it.B * _rate * _scale, //早餐费
  14064. Lunch = it.L * _rate * _scale, //午餐费
  14065. Dinner = it.D * _rate * _scale, //晚餐费
  14066. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14067. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14068. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14069. TicketFee = it.EF * _rate * _scale, //门票费
  14070. TicketRemark = it.EFR, //门票费描述
  14071. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14072. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14073. SpentCash = it.PC * _rate * _scale, //零用金
  14074. LeadersFee = it.TLF * _rate * _scale, //领队费
  14075. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14076. })
  14077. );
  14078. break;
  14079. case 85: // 机票
  14080. List<dynamic> datas = new List<dynamic>();
  14081. datas.Add(
  14082. new
  14083. {
  14084. AirType = "经济舱",
  14085. AirNum = item.JJCRS,
  14086. AirDRCB = item.JJCCB,
  14087. AirZCB = (item.JJCRS * item.JJCCB)
  14088. }
  14089. );
  14090. datas.Add(
  14091. new
  14092. {
  14093. AirType = "公务舱",
  14094. AirNum = item.GWCRS,
  14095. AirDRCB = item.GWCCB,
  14096. AirZCB = (item.GWCRS * item.GWCCB)
  14097. }
  14098. );
  14099. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14100. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14101. modulePromptInfo.Data = new
  14102. {
  14103. airFeeData = datas,
  14104. airInitData = initDatas
  14105. };
  14106. _ModulePromptInfos.Add(modulePromptInfo);
  14107. break;
  14108. default:
  14109. break;
  14110. }
  14111. }
  14112. if (dto.CTable != 85)
  14113. {
  14114. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14115. _ModulePromptInfos.Add(_ModulePromptInfo);
  14116. }
  14117. _view.ModulePromptInfos = _ModulePromptInfos;
  14118. return Ok(JsonView(true, "操作成功!", _view));
  14119. }
  14120. catch (Exception ex)
  14121. {
  14122. return Ok(JsonView(false, ex.Message));
  14123. }
  14124. }
  14125. /// <summary>
  14126. /// 根据黑屏代码重新生成行程
  14127. /// </summary>
  14128. /// <param name="dto"></param>
  14129. /// <returns></returns>
  14130. [HttpPost]
  14131. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14132. {
  14133. var jw = JsonView(false);
  14134. var Create = _GroupCostRepository.
  14135. CreateGroupCostByBlackCode(dto.Diid);
  14136. jw.Msg = Create.Msg;
  14137. if (Create.Code == 0)
  14138. {
  14139. jw.Code = 200;
  14140. jw.Data = new
  14141. {
  14142. groupCost = Create.Data,
  14143. blackCodeIsTrue = true
  14144. };
  14145. }
  14146. else
  14147. {
  14148. jw.Code = 400;
  14149. jw.Data = new
  14150. {
  14151. groupCost = Create.Data,
  14152. blackCodeIsTrue = false,
  14153. };
  14154. }
  14155. return Ok(jw);
  14156. }
  14157. /// <summary>
  14158. /// 成本获取OP历史车费用
  14159. /// </summary>
  14160. /// <param name="dto"></param>
  14161. /// <returns></returns>
  14162. [HttpPost]
  14163. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14164. {
  14165. var jw = JsonView(false);
  14166. try
  14167. {
  14168. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14169. //获取现有所有车的数据
  14170. if (!dto.Param.IsNullOrWhiteSpace())
  14171. {
  14172. string sql = $@"
  14173. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14174. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14175. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14176. 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
  14177. AND gctggr.ServiceEndTime is not NULL
  14178. ORDER by gctggrc.id DESC
  14179. ";
  14180. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14181. var numeberResult = await Task.Run(() =>
  14182. {
  14183. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14184. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14185. return numberArr;
  14186. });
  14187. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14188. foreach (var item in numeberResult)
  14189. {
  14190. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14191. {
  14192. Country = "数据异常!",
  14193. City = string.Empty,
  14194. };
  14195. item.Area = find.Country + " " + find.City;
  14196. }
  14197. dbResult.AddRange(numeberResult);
  14198. if (dto.Param.Contains("、"))
  14199. {
  14200. var sp = dto.Param.Split("、");
  14201. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14202. .Where(x =>
  14203. {
  14204. return System.Array.Exists(sp, e =>
  14205. {
  14206. bool where = false;
  14207. if (x.Area != null)
  14208. {
  14209. where = x.Area.Contains(e);
  14210. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14211. {
  14212. return false;
  14213. }
  14214. }
  14215. if (x.PriceName != null && !where)
  14216. {
  14217. where = x.PriceName.Contains(e);
  14218. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14219. {
  14220. return false;
  14221. }
  14222. }
  14223. return where;
  14224. });
  14225. }).ToList();
  14226. }
  14227. else
  14228. {
  14229. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14230. .Where(x =>
  14231. {
  14232. bool where = false;
  14233. if (x.Area != null)
  14234. {
  14235. where = x.Area.Contains(dto.Param);
  14236. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14237. {
  14238. return false;
  14239. }
  14240. }
  14241. if (x.PriceName != null && !where)
  14242. {
  14243. where = x.PriceName.Contains(dto.Param);
  14244. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14245. {
  14246. return false;
  14247. }
  14248. }
  14249. return where;
  14250. }
  14251. )
  14252. .ToList();
  14253. }
  14254. }
  14255. var view = dbResult.Select(x =>
  14256. {
  14257. decimal dp = 0.00M;
  14258. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14259. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14260. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14261. {
  14262. if (startB && endB)
  14263. {
  14264. var timesp = endD.Subtract(startD);
  14265. if ((timesp.Days + 1) != 0)
  14266. {
  14267. dp = x.Price / (timesp.Days + 1);
  14268. }
  14269. }
  14270. }
  14271. else
  14272. {
  14273. dp = x.Price;
  14274. }
  14275. return new
  14276. {
  14277. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14278. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14279. x.Area,
  14280. x.id,
  14281. price = x.Price.ToString("F2"),
  14282. x.PriceName,
  14283. x.PriceContent,
  14284. x.TeamName,
  14285. x.DatePrice,
  14286. dayPrice = dp.ToString("F2"),
  14287. };
  14288. }).OrderByDescending(x => x.id).ToList();
  14289. jw = JsonView(true, "获取成功!", view);
  14290. }
  14291. catch (Exception e)
  14292. {
  14293. jw = JsonView(false, e.Message);
  14294. }
  14295. return Ok(jw);
  14296. }
  14297. #endregion
  14298. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14299. /// <summary>
  14300. /// 酒店预订
  14301. /// 酒店费用列表 根据团组Id查询
  14302. /// </summary>
  14303. /// <param name="_dto"></param>
  14304. /// <returns></returns>
  14305. [HttpPost]
  14306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14307. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14308. {
  14309. #region 参数验证
  14310. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14311. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14312. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14313. #region 团组操作权限验证 76 酒店预定模块
  14314. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14315. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14316. #endregion
  14317. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14318. #region 页面操作权限验证
  14319. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14320. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14321. #endregion
  14322. #endregion
  14323. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14324. }
  14325. /// <summary>
  14326. /// 酒店预订
  14327. /// 基础数据
  14328. /// </summary>
  14329. /// <param name="_dto"></param>
  14330. /// <returns></returns>
  14331. [HttpPost]
  14332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14333. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14334. {
  14335. #region 参数验证
  14336. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14337. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14338. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14339. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14340. #region 页面操作权限验证
  14341. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14342. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14343. #endregion
  14344. #region 团组操作权限验证 76 酒店预定模块
  14345. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14346. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14347. #endregion
  14348. #endregion
  14349. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14350. }
  14351. /// <summary>
  14352. /// 酒店预订
  14353. /// 创建 入住卷号码
  14354. /// </summary>
  14355. /// <param name="_dto"></param>
  14356. /// <returns></returns>
  14357. [HttpPost]
  14358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14359. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14360. {
  14361. #region 参数验证
  14362. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14363. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14364. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14365. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14366. #region 页面操作权限验证
  14367. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14368. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14369. #endregion
  14370. #region 团组操作权限验证 76 酒店预定模块
  14371. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14372. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14373. #endregion
  14374. #endregion
  14375. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14376. if (data.Code != 0)
  14377. {
  14378. return Ok(JsonView(false, data.Msg));
  14379. }
  14380. return Ok(JsonView(true, data.Msg, data.Data));
  14381. }
  14382. /// <summary>
  14383. /// 酒店预订
  14384. /// 详情
  14385. /// </summary>
  14386. /// <param name="_dto"></param>
  14387. /// <returns></returns>
  14388. [HttpPost]
  14389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14390. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14391. {
  14392. #region 参数验证
  14393. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14394. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14395. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14396. #region 团组操作权限验证 76 酒店预定模块
  14397. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14398. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14399. #endregion
  14400. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14401. #region 页面操作权限验证
  14402. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14403. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14404. #endregion
  14405. #endregion
  14406. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14407. }
  14408. /// <summary>
  14409. /// 酒店预订
  14410. /// Add Or Edit
  14411. /// </summary>
  14412. /// <param name="_dto"></param>
  14413. /// <returns></returns>
  14414. [HttpPost]
  14415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14416. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14417. {
  14418. #region 参数验证
  14419. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14420. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14421. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14422. #region 团组操作权限验证 76 酒店预定模块
  14423. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14424. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14425. #endregion
  14426. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14427. #region 页面操作权限验证
  14428. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14429. if (_dto.Id == 0) // Add
  14430. {
  14431. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14432. }
  14433. else if (_dto.Id > 1) // Edit
  14434. {
  14435. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14436. }
  14437. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14438. #endregion
  14439. #endregion
  14440. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14441. if (_view.Code != 200)
  14442. {
  14443. return Ok(_view);
  14444. }
  14445. #region 成本无酒店价格数据进入超支
  14446. _sqlSugar.BeginTran();
  14447. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14448. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14449. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14450. for (int i = 0; i < groupCost.Count; i++)
  14451. {
  14452. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14453. {
  14454. groupCost[i].Date = groupCost[i - 1].Date;
  14455. }
  14456. }
  14457. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14458. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14459. List<Fin_GroupExtraCostDto_OP>();
  14460. if (start_Bool && end_Bool)
  14461. {
  14462. while (start_Time < end_Time)
  14463. {
  14464. foreach (var item in groupCost_Grp)
  14465. {
  14466. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14467. {
  14468. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14469. {
  14470. extraCostList.Add(new
  14471. Fin_GroupExtraCostDto_OP
  14472. {
  14473. Area = _dto.AreaId,
  14474. coefficient = 1.5M,
  14475. createUser = _dto.UserId,
  14476. currency = _dto.CardPriceCurrency,
  14477. diId = _dto.DiId,
  14478. ManagerConfirm = 0,
  14479. SupervisorConfirm = 0,
  14480. SYsupervisorConfirm = 0,
  14481. editType = 1,
  14482. PortType = 1,
  14483. price = _dto.CardPrice,
  14484. PriceCount = 1,
  14485. priceType = 1027,
  14486. priceDetailType = 1044,
  14487. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14488. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14489. });
  14490. }
  14491. }
  14492. }
  14493. start_Time = start_Time.AddDays(1);
  14494. }
  14495. }
  14496. if (extraCostList.Any())
  14497. {
  14498. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14499. }
  14500. _sqlSugar.CommitTran();
  14501. #endregion
  14502. #region 应用推送
  14503. try
  14504. {
  14505. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14506. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14507. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14508. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14509. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14510. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14511. var diId = _dto.DiId;
  14512. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14513. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14514. #region 操作记录
  14515. var opInfo = new Crm_TableOperationRecord()
  14516. {
  14517. TableName = "Grp_HotelReservations",
  14518. PortType = _dto.PortType,
  14519. DataId = hotelId,
  14520. CreateUserId = _dto.UserId
  14521. };
  14522. //var opStatus = OperationEnum.NoOperation;
  14523. if (_dto.Id < 1) //添加操作
  14524. {
  14525. opInfo.OperationItem = OperationEnum.Add;
  14526. }
  14527. else if (_dto.Id > 0)
  14528. {
  14529. opInfo.OperationItem = OperationEnum.Edit;
  14530. }
  14531. string opRemark = string.Empty;
  14532. if (ccpInfo != null)
  14533. {
  14534. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14535. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14536. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14537. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14538. }
  14539. opInfo.Remark = opRemark;
  14540. await _tableorRep.AddAsync(opInfo);
  14541. #endregion
  14542. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14543. //2024-10-21 新增LZ UID
  14544. var userIds = new List<int>() { 21 };
  14545. string title = $"费用审核";
  14546. string content = "";
  14547. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14548. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14549. try
  14550. {
  14551. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14552. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14553. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14554. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14555. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14556. }
  14557. catch (Exception ex)
  14558. {
  14559. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14560. }
  14561. }
  14562. catch (Exception ex)
  14563. {
  14564. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14565. }
  14566. try
  14567. {
  14568. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14569. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14570. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14571. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14572. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14573. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14574. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14575. //自动审核
  14576. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14577. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14578. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14579. //2024-10-21 新增LZ UID
  14580. var userIds = new List<int>() { 21 };
  14581. string title = $"系统通知";
  14582. var diId = _dto.DiId;
  14583. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14584. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14585. string content = "";
  14586. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14587. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14588. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14589. }
  14590. catch (Exception ex)
  14591. {
  14592. }
  14593. #endregion
  14594. return Ok(_view);
  14595. }
  14596. /// <summary>
  14597. /// 酒店自动审核测试
  14598. /// Add Or Edit
  14599. /// </summary>
  14600. /// <param name="diid"></param>
  14601. /// <param name="dataId"></param>
  14602. /// <returns></returns>
  14603. [HttpPost]
  14604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14605. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14606. {
  14607. #region 应用推送
  14608. try
  14609. {
  14610. //自动审核
  14611. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14612. }
  14613. catch (Exception ex)
  14614. {
  14615. return Ok(JsonView(false, "操作失败"));
  14616. }
  14617. #endregion
  14618. return Ok(JsonView(false, "操作成功"));
  14619. }
  14620. /// <summary>
  14621. /// 酒店预订
  14622. /// Del
  14623. /// </summary>
  14624. /// <param name="_dto"></param>
  14625. /// <returns></returns>
  14626. [HttpPost]
  14627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14628. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14629. {
  14630. #region 参数验证
  14631. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14632. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14633. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14634. #region 团组操作权限验证 76 酒店预定模块
  14635. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14636. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14637. #endregion
  14638. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14639. #region 页面操作权限验证
  14640. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14641. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14642. #endregion
  14643. #endregion
  14644. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14645. #region 操作记录
  14646. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14647. {
  14648. TableName = "Grp_HotelReservations",
  14649. PortType = _dto.PortType,
  14650. OperationItem = OperationEnum.Del,
  14651. DataId = _dto.Id,
  14652. CreateUserId = _dto.UserId
  14653. });
  14654. #endregion
  14655. return Ok(data);
  14656. }
  14657. /// <summary>
  14658. /// 酒店预订
  14659. /// 生成VOUCHER
  14660. /// 2024.05.06 之前版本
  14661. /// </summary>
  14662. /// <param name="_dto"></param>
  14663. /// <returns></returns>
  14664. [HttpPost]
  14665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14666. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14667. {
  14668. try
  14669. {
  14670. #region 参数验证
  14671. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14672. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14673. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14674. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14675. #region 团组操作权限验证 76 酒店预定模块
  14676. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14677. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14678. #endregion
  14679. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14680. #region 页面操作权限验证
  14681. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14682. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14683. #endregion
  14684. #endregion
  14685. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14686. //判断数据是否完整
  14687. if (hr != null)
  14688. {
  14689. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14690. {
  14691. string strFileName = "HotelStatement/";
  14692. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14693. if (dele != null)
  14694. strFileName += dele.TourCode;
  14695. //载入模板
  14696. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14697. Document doc = new Document(sss);
  14698. DocumentBuilder builder = new DocumentBuilder(doc);
  14699. #region 替换Word模板书签内容
  14700. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14701. //入住卷预定号码
  14702. if (doc.Range.Bookmarks["VNO"] != null)
  14703. {
  14704. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14705. mark.Text = hr.CheckNumber;
  14706. }
  14707. //酒店时间
  14708. if (doc.Range.Bookmarks["Date"] != null)
  14709. {
  14710. Bookmark mark = doc.Range.Bookmarks["Date"];
  14711. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14712. }
  14713. //团号
  14714. if (doc.Range.Bookmarks["TNo"] != null)
  14715. {
  14716. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14717. mark.Text = dele.TourCode;
  14718. }
  14719. //预定号码
  14720. if (doc.Range.Bookmarks["BookingId"] != null)
  14721. {
  14722. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14723. mark.Text = hr.ReservationsNo;
  14724. }
  14725. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14726. {
  14727. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14728. mark.Text = hr.DetermineNo;
  14729. }
  14730. //酒店城市
  14731. if (doc.Range.Bookmarks["City"] != null)
  14732. {
  14733. Bookmark mark = doc.Range.Bookmarks["City"];
  14734. mark.Text = hr.City;
  14735. }
  14736. //酒店名称
  14737. if (doc.Range.Bookmarks["HName"] != null)
  14738. {
  14739. Bookmark mark = doc.Range.Bookmarks["HName"];
  14740. mark.Text = hr.HotelName;
  14741. }
  14742. //酒店地址
  14743. if (doc.Range.Bookmarks["Address"] != null)
  14744. {
  14745. Bookmark mark = doc.Range.Bookmarks["Address"];
  14746. mark.Text = hr.HotelAddress;
  14747. }
  14748. //酒店电话
  14749. if (doc.Range.Bookmarks["Tel"] != null)
  14750. {
  14751. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14752. mark.Text = hr.HotelTel;
  14753. }
  14754. //酒店传真
  14755. if (doc.Range.Bookmarks["Fax"] != null)
  14756. {
  14757. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14758. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14759. {
  14760. mark.Text = hr.HotelFax;
  14761. }
  14762. }
  14763. //入住时间
  14764. if (doc.Range.Bookmarks["CIn"] != null)
  14765. {
  14766. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14767. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14768. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14769. }
  14770. //退房时间
  14771. if (doc.Range.Bookmarks["COut"] != null)
  14772. {
  14773. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14774. Bookmark mark = doc.Range.Bookmarks["COut"];
  14775. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14776. }
  14777. //客户名称
  14778. if (doc.Range.Bookmarks["GName"] != null)
  14779. {
  14780. string guestName = "";
  14781. string[] clients = new string[] { };
  14782. if (hr.GuestName.Contains(","))
  14783. {
  14784. clients = hr.GuestName.Split(",");
  14785. }
  14786. else
  14787. {
  14788. clients = new string[] { hr.GuestName };
  14789. }
  14790. List<int> clientIds_int = new List<int>();
  14791. if (clients.Length > 0)
  14792. {
  14793. foreach (var item in clients)
  14794. {
  14795. if (item.IsNumeric())
  14796. {
  14797. clientIds_int.Add(int.Parse(item));
  14798. }
  14799. }
  14800. }
  14801. if (clientIds_int.Count > 0)
  14802. {
  14803. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14804. foreach (var client in _clientDatas)
  14805. {
  14806. //男
  14807. if (client.Sex == 0) guestName += $"Mr.";
  14808. //女
  14809. else if (client.Sex == 1) guestName += $"Ms.";
  14810. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14811. {
  14812. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14813. }
  14814. //guestName += $"{client.Pinyin},";
  14815. }
  14816. if (guestName.Length > 0)
  14817. {
  14818. guestName = guestName.Substring(0, guestName.Length - 1);
  14819. }
  14820. }
  14821. else
  14822. {
  14823. guestName = hr.GuestName;
  14824. }
  14825. Bookmark mark = doc.Range.Bookmarks["GName"];
  14826. mark.Text = guestName;
  14827. }
  14828. //房间介绍
  14829. if (doc.Range.Bookmarks["ROOM"] != null)
  14830. {
  14831. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14832. mark.Text = hr.RoomExplanation;
  14833. }
  14834. //报价描述
  14835. if (doc.Range.Bookmarks["NOTE"] != null)
  14836. {
  14837. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14838. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14839. if (ss != null)
  14840. mark.Text = ss.Name;
  14841. }
  14842. //入住时间
  14843. if (doc.Range.Bookmarks["CheckIn"] != null)
  14844. {
  14845. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14846. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14847. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14848. }
  14849. //退房时间
  14850. if (doc.Range.Bookmarks["CheckOut"] != null)
  14851. {
  14852. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14853. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14854. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14855. }
  14856. //日期
  14857. if (doc.Range.Bookmarks["DT"] != null)
  14858. {
  14859. Bookmark mark = doc.Range.Bookmarks["DT"];
  14860. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14861. }
  14862. //名称
  14863. if (doc.Range.Bookmarks["VName"] != null)
  14864. {
  14865. Bookmark mark = doc.Range.Bookmarks["VName"];
  14866. mark.Text = hr.HotelName;
  14867. }
  14868. //号码
  14869. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14870. {
  14871. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14872. mark.Text = hr.CheckNumber;
  14873. }
  14874. #endregion
  14875. strFileName += "VOUCHER.doc";
  14876. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14877. doc.Save(fileDir);
  14878. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14879. return Ok(JsonView(true, "操作成功!", Url));
  14880. }
  14881. else
  14882. {
  14883. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14884. }
  14885. }
  14886. else
  14887. {
  14888. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14889. }
  14890. }
  14891. catch (Exception ex)
  14892. {
  14893. return Ok(JsonView(false, ex.Message));
  14894. }
  14895. }
  14896. /// <summary>
  14897. /// 酒店预订
  14898. /// 生成VOUCHER
  14899. /// 2024.05.06 之后版本
  14900. /// </summary>
  14901. /// <param name="_dto"></param>
  14902. /// <returns></returns>
  14903. [HttpPost]
  14904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14905. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14906. {
  14907. #region 参数验证
  14908. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14909. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14910. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14911. #region 团组操作权限验证 76 酒店预定模块
  14912. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14913. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14914. #endregion
  14915. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14916. #region 页面操作权限验证
  14917. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14918. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14919. #endregion
  14920. #endregion
  14921. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14922. //判断数据是否完整
  14923. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14924. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14925. string strFileName = "HotelStatement/";
  14926. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14927. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14928. #region 数据处理
  14929. List<int> guestIds = new List<int>();
  14930. //int index = 0;
  14931. foreach (var item in hrDtas)
  14932. {
  14933. if (item.GuestName.Contains(","))
  14934. {
  14935. string[] guestIdArr = item.GuestName.Split(',');
  14936. foreach (var guestIdStr in guestIdArr)
  14937. {
  14938. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14939. if (guestBool)
  14940. {
  14941. guestIds.Add(guestId);
  14942. }
  14943. }
  14944. }
  14945. else guestNames += item.GuestName;
  14946. var voucherInfo = new HotelVoucherInfoView()
  14947. {
  14948. HotelName = item.HotelName,
  14949. CheckInDate = item.CheckInDate,
  14950. CheckOutDate = item.CheckOutDate,
  14951. ConfirmationNumber = item.DetermineNo.Trim(),
  14952. RoomType = item.RoomExplanation
  14953. };
  14954. vouchers.Add(voucherInfo);
  14955. }
  14956. if (guestIds.Count > 0)
  14957. {
  14958. guestIds = guestIds.Distinct().ToList();
  14959. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14960. if (guestDatas.Count > 0)
  14961. {
  14962. guestNames = "";
  14963. foreach (var guest in guestDatas)
  14964. {
  14965. string guestName = "";
  14966. if (guest.Sex == 0) guestName += @"MR.";
  14967. else if (guest.Sex == 1) guestName += @"MS.";
  14968. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14969. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14970. guestNames += @$"{guestName.Trim()}、";
  14971. }
  14972. if (guestNames.Length > 0)
  14973. {
  14974. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14975. }
  14976. }
  14977. }
  14978. #endregion
  14979. //载入模板
  14980. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14981. Document doc = new Document(sss);
  14982. DocumentBuilder builder = new DocumentBuilder(doc);
  14983. if (doc.Range.Bookmarks["GuestName"] != null)
  14984. {
  14985. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14986. mark.Text = guestNames;
  14987. }
  14988. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14989. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14990. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14991. for (int i = 1; i <= vouchers.Count; i++)
  14992. {
  14993. HotelVoucherInfoView hviv = vouchers[i - 1];
  14994. builder.MoveToCell(0, i, 0, 0);
  14995. builder.Write(hviv.HotelName);
  14996. builder.MoveToCell(0, i, 1, 0);
  14997. builder.Write(hviv.CheckInDate);
  14998. builder.MoveToCell(0, i, 2, 0);
  14999. builder.Write(hviv.CheckOutDate);
  15000. builder.MoveToCell(0, i, 3, 0);
  15001. builder.Write(hviv.RoomType);
  15002. builder.MoveToCell(0, i, 4, 0);
  15003. builder.Write(hviv.ConfirmationNumber);
  15004. }
  15005. //删除多余行
  15006. int currRowIndex = vouchers.Count + 1;
  15007. int delRows = 21 - currRowIndex;
  15008. if (delRows > 0)
  15009. {
  15010. for (int i = 0; i < delRows; i++)
  15011. {
  15012. table.Rows.RemoveAt(currRowIndex);
  15013. //cultivateRowIndex++;
  15014. }
  15015. }
  15016. strFileName += "VOUCHER.docx";
  15017. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15018. doc.Save(fileDir);
  15019. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15020. return Ok(JsonView(true, "操作成功!", Url));
  15021. }
  15022. /// <summary>
  15023. /// 酒店预订
  15024. /// 生成VOUCHER 批量生成
  15025. /// New
  15026. /// </summary>
  15027. /// <param name="_dto"></param>
  15028. /// <returns></returns>
  15029. [HttpPost]
  15030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15031. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15032. {
  15033. #region 参数验证
  15034. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15035. if (_dto.PageId < 1) _dto.PageId = 28;
  15036. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15037. #region 团组操作权限验证 76 酒店预定模块
  15038. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15039. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15040. #endregion
  15041. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15042. #region 页面操作权限验证
  15043. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15044. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15045. #endregion
  15046. #endregion
  15047. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15048. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15049. .OrderBy(x => x.CheckInDate)
  15050. .ToListAsync();
  15051. //判断数据是否完整
  15052. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15053. string strFileName = "HotelStatement/";
  15054. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15055. if (dele != null)
  15056. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15057. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15058. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15059. .Where(it => it.IsDel == 0)
  15060. .ToListAsync();
  15061. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15062. for (int i = 0; i < hrDtas.Count; i++)
  15063. {
  15064. string guestNames = string.Empty;
  15065. List<int> guestIds = new List<int>();
  15066. var item = hrDtas[i];
  15067. //处理客户姓名
  15068. if (item.GuestName.Contains(","))
  15069. {
  15070. string[] guestIdArr = item.GuestName.Split(',');
  15071. foreach (var guestIdStr in guestIdArr)
  15072. if (int.TryParse(guestIdStr, out int guestId))
  15073. guestIds.Add(guestId);
  15074. }
  15075. else
  15076. {
  15077. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15078. if (guestIdBool)
  15079. {
  15080. guestIds.Add(guestId);
  15081. }
  15082. //NaN
  15083. if (item.GuestName.Contains("NaN"))
  15084. {
  15085. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15086. }
  15087. }
  15088. if (guestIds.Count > 0)
  15089. {
  15090. guestIds = guestIds.Distinct().ToList();
  15091. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15092. if (guestDatas1.Count > 0)
  15093. {
  15094. guestNames = "";
  15095. foreach (var guest in guestDatas1)
  15096. {
  15097. string guestName = "";
  15098. if (guest.Sex == 0) guestName += @"MR.";
  15099. else if (guest.Sex == 1) guestName += @"MS.";
  15100. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15101. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15102. guestNames += @$"{guestName.Trim()}、";
  15103. }
  15104. if (guestNames.Length > 0)
  15105. {
  15106. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15107. }
  15108. }
  15109. }
  15110. //if (!string.IsNullOrEmpty(guestNames))
  15111. //{
  15112. hrDtas[i].GuestName = guestNames;
  15113. //}
  15114. }
  15115. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15116. Document doc = new Document();
  15117. DocumentBuilder builder = new DocumentBuilder(doc);
  15118. try
  15119. {
  15120. builder.MoveToDocumentStart();
  15121. foreach (var item in hrDtas)
  15122. {
  15123. //标题
  15124. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15125. builder.ParagraphFormat.LineSpacing = 1;
  15126. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15127. builder.ParagraphFormat.Style.Font.Size = 9;
  15128. builder.ParagraphFormat.Style.Font.Bold = true;
  15129. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15130. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15131. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15132. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15133. builder.ParagraphFormat.LineSpacing = 1;
  15134. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15135. builder.ParagraphFormat.Style.Font.Size = 9;
  15136. builder.ParagraphFormat.Style.Font.Bold = true;
  15137. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15138. builder.StartTable();
  15139. // 设置边框颜色
  15140. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15141. //设置边框样式
  15142. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15143. //表格
  15144. #region 第一行
  15145. builder.InsertCell();
  15146. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15147. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15148. //builder.CellFormat.AllowAutoFit = false;
  15149. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15150. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15151. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15152. builder.CellFormat.WrapText = true; //自动换行
  15153. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15154. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15155. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15156. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15157. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15158. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15159. builder.Write("TOUR NO:");
  15160. builder.InsertCell();
  15161. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15162. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15163. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15164. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15165. builder.ParagraphFormat.Style.Font.Bold = false;
  15166. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15167. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15168. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15169. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15170. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15171. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15172. builder.Write($"{dele?.TourCode ?? "-"}");
  15173. builder.InsertCell();
  15174. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15175. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15176. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15177. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15178. builder.ParagraphFormat.Style.Font.Bold = false;
  15179. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15180. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15181. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15182. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15183. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15184. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15185. builder.Write($"CITY:");
  15186. builder.InsertCell();
  15187. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15188. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15189. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15190. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15191. builder.ParagraphFormat.Style.Font.Bold = false;
  15192. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15193. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15194. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15195. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15196. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15197. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15198. builder.Write($"{item.City}");
  15199. builder.EndRow();
  15200. #endregion
  15201. #region 第二行
  15202. builder.InsertCell();
  15203. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15204. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15205. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15206. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15207. builder.ParagraphFormat.Style.Font.Bold = false;
  15208. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15209. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15210. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15211. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15212. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15213. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15214. builder.Write("CONFIRMATION NO:");
  15215. builder.InsertCell();
  15216. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15217. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15218. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15219. builder.ParagraphFormat.Style.Font.Bold = false;
  15220. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15221. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15222. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15223. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15224. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15225. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15226. builder.CellFormat.VerticalMerge = CellMerge.None;
  15227. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15228. builder.Write($"{item.DetermineNo}");
  15229. builder.InsertCell();
  15230. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15231. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15232. builder.InsertCell();
  15233. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15234. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15235. builder.EndRow();
  15236. #endregion
  15237. #region 第三行
  15238. builder.InsertCell();
  15239. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15240. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15241. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15242. builder.ParagraphFormat.Style.Font.Bold = false;
  15243. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15244. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15245. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15246. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15247. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15248. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15249. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15250. builder.Write($"HOTEL NAME:");
  15251. builder.InsertCell();
  15252. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15253. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15254. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15255. builder.ParagraphFormat.Style.Font.Bold = false;
  15256. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15257. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15258. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15259. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15260. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15261. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15262. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15263. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15264. builder.Write($"{item.HotelName}");
  15265. builder.InsertCell();
  15266. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15267. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15268. builder.InsertCell();
  15269. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15270. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15271. builder.EndRow();
  15272. #endregion
  15273. #region 第四行
  15274. builder.InsertCell();
  15275. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15276. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15277. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15278. builder.ParagraphFormat.Style.Font.Bold = false;
  15279. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15280. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15281. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15282. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15283. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15284. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15285. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15286. builder.Write($"HOTEL ADDRESS:");
  15287. builder.InsertCell();
  15288. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15289. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15290. builder.ParagraphFormat.Style.Font.Size = 8;
  15291. builder.ParagraphFormat.Style.Font.Bold = false;
  15292. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15293. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15294. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15295. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15296. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15297. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15298. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15299. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15300. builder.Write($"{item.HotelAddress}");
  15301. builder.InsertCell();
  15302. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15303. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15304. builder.InsertCell();
  15305. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15306. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15307. builder.EndRow();
  15308. #endregion
  15309. #region 第五行
  15310. builder.InsertCell();
  15311. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15312. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15313. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15314. builder.ParagraphFormat.Style.Font.Bold = false;
  15315. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15316. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15317. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15318. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15319. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15320. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15321. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15322. builder.Write("TEL:");
  15323. builder.InsertCell();
  15324. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15325. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15326. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15327. builder.ParagraphFormat.Style.Font.Bold = false;
  15328. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15329. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15330. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15331. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15332. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15333. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15334. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15335. builder.Write($"{item.HotelTel}");
  15336. builder.InsertCell();
  15337. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15338. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15339. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15340. builder.ParagraphFormat.Style.Font.Bold = false;
  15341. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15342. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15343. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15344. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15345. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15346. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15347. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15348. builder.Write($"FAX:");
  15349. builder.InsertCell();
  15350. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15351. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15352. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15353. builder.ParagraphFormat.Style.Font.Bold = false;
  15354. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15355. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15356. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15357. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15358. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15359. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15360. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15361. builder.Write($"{item.HotelFax}");
  15362. builder.EndRow();
  15363. #endregion
  15364. #region 第六行
  15365. builder.InsertCell();
  15366. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15367. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15368. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15369. builder.ParagraphFormat.Style.Font.Bold = false;
  15370. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15371. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15372. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15373. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15374. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15375. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15376. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15377. builder.Write("CHECK IN:");
  15378. builder.InsertCell();
  15379. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15380. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15381. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15382. builder.ParagraphFormat.Style.Font.Bold = false;
  15383. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15384. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15385. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15386. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15387. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15388. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15389. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15390. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15391. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15392. builder.Write($"{checkInStr}");
  15393. builder.InsertCell();
  15394. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15395. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15396. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15397. builder.ParagraphFormat.Style.Font.Bold = false;
  15398. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15399. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15400. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15401. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15402. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15403. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15404. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15405. builder.Write($"CHECK OUT:");
  15406. builder.InsertCell();
  15407. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15408. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15409. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15410. builder.ParagraphFormat.Style.Font.Bold = false;
  15411. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15412. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15413. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15414. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15415. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15416. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15417. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15418. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15419. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15420. builder.Write($"{checkOutStr}");
  15421. builder.EndRow();
  15422. #endregion
  15423. #region 第七行
  15424. builder.InsertCell();
  15425. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  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.Right;//对齐
  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. builder.Write($"GUEST NAME:");
  15437. builder.InsertCell();
  15438. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15439. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15440. builder.ParagraphFormat.Style.Font.Size = 8;
  15441. builder.ParagraphFormat.Style.Font.Bold = false;
  15442. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15443. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15444. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15445. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15446. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15447. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15448. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15449. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15450. builder.Write($"{item.GuestName}");
  15451. builder.InsertCell();
  15452. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15453. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15454. builder.InsertCell();
  15455. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15456. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15457. builder.EndRow();
  15458. #endregion
  15459. #region 第八行
  15460. builder.InsertCell();
  15461. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15462. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15463. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15464. builder.ParagraphFormat.Style.Font.Bold = false;
  15465. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15466. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15467. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15468. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15469. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15470. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15471. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15472. builder.Write($"ROOM TYPE:");
  15473. builder.InsertCell();
  15474. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15475. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15476. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15477. builder.ParagraphFormat.Style.Font.Bold = false;
  15478. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15479. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15480. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15481. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15482. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15483. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15484. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15485. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15486. builder.Write($"{item.RoomExplanation}");
  15487. builder.InsertCell();
  15488. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15489. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15490. builder.InsertCell();
  15491. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15492. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15493. builder.EndRow();
  15494. #endregion
  15495. #region 第九行
  15496. builder.InsertCell();
  15497. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15498. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15499. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15500. builder.ParagraphFormat.Style.Font.Bold = false;
  15501. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15502. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15503. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15504. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15505. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15506. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15507. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15508. builder.Write($"NOTE:");
  15509. builder.InsertCell();
  15510. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15511. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15512. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15513. builder.ParagraphFormat.Style.Font.Bold = false;
  15514. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15515. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15516. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15517. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15518. 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.");
  15519. builder.InsertCell();
  15520. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15521. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15522. builder.InsertCell();
  15523. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15524. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15525. builder.EndRow();
  15526. #endregion
  15527. builder.EndTable();
  15528. //换行
  15529. builder.Writeln("");
  15530. builder.Writeln("");
  15531. }
  15532. #region 获取文档中的所有表格 设置文字自适应
  15533. // 获取文档中的所有表格。
  15534. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15535. {
  15536. // 遍历表格中的所有行。
  15537. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15538. {
  15539. foreach (Cell cell in row.Cells)
  15540. {
  15541. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15542. cellFormat.Width = 0;
  15543. }
  15544. }
  15545. }
  15546. #endregion
  15547. #region 设置页眉
  15548. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15549. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15550. if (System.IO.File.Exists(voucherHeaderPath))
  15551. {
  15552. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15553. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15554. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15555. Shape shape = builder.InsertImage(imageBytes);
  15556. // 调整图片位置
  15557. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15558. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15559. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15560. shape.Left = 0; // 将图片距离页面左边缘的距离
  15561. shape.Width = 81; // 设置图片宽度
  15562. shape.Height = 36; // 设置图片高度
  15563. }
  15564. //靠右
  15565. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15566. //// 设置页脚上下边距
  15567. //builder.PageSetup.HeaderDistance = 42;
  15568. // 添加页眉线
  15569. Aspose.Words.Border borderHeader = null;
  15570. try
  15571. {
  15572. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15573. }
  15574. catch (Exception e)
  15575. {
  15576. // TODO Auto-generated catch block
  15577. //e.printStackTrace();
  15578. }
  15579. borderHeader.Shadow = true;
  15580. borderHeader.DistanceFromText = 2;
  15581. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15582. #endregion
  15583. }
  15584. catch (Exception ex)
  15585. {
  15586. }
  15587. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15588. doc.Save(fileDir);
  15589. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15590. return Ok(JsonView(true, "操作成功!", Url));
  15591. }
  15592. /// <summary>
  15593. /// 酒店预订
  15594. /// 生成 预定成本 Excel
  15595. /// </summary>
  15596. /// <param name="_dto"></param>
  15597. /// <returns></returns>
  15598. [HttpPost]
  15599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15600. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15601. {
  15602. #region 参数验证
  15603. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15604. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15605. if (!vadalitorRes.IsValid)
  15606. {
  15607. var errors = new StringBuilder();
  15608. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15609. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15610. }
  15611. #region 团组操作权限验证 76 酒店预定模块
  15612. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15613. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15614. #endregion
  15615. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15616. #region 页面操作权限验证
  15617. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15618. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15619. #endregion
  15620. #endregion
  15621. decimal _rate = 1.00M;
  15622. string _currency = string.Empty;
  15623. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15624. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15625. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15626. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15627. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15628. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15629. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15630. if (_GroupCostParameter == null)
  15631. {
  15632. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15633. bool isIntType = int.TryParse(_currency, out int currId);
  15634. if (isIntType)
  15635. {
  15636. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15637. }
  15638. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15639. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15640. if (currInfo == null)
  15641. {
  15642. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15643. }
  15644. else _rate = currInfo.Rate;
  15645. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15646. {
  15647. _rate = _GroupCostParameter.Rate;
  15648. }
  15649. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15650. //string strFileName = "HotelStatement/";
  15651. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15652. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15653. var rateDatas = new List<dynamic>();
  15654. #region 数据处理
  15655. foreach (var item in hrDtas)
  15656. {
  15657. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15658. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15659. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15660. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15661. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15662. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15663. {
  15664. continue;
  15665. }
  15666. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15667. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15668. string singleRoomFeeStr = string.Empty,
  15669. doubleRoomFeeStr = string.Empty,
  15670. suiteRoomFeeStr = string.Empty,
  15671. otherRoomFeeStr = string.Empty,
  15672. payMoneyStr = string.Empty,
  15673. cardPriceStr = string.Empty;
  15674. if (roomCurr.Equals("CNY"))
  15675. {
  15676. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15677. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15678. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15679. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15680. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15681. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15682. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15683. }
  15684. else
  15685. {
  15686. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15687. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15688. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15689. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15690. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15691. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15692. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15693. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15694. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15695. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15696. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15697. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15698. if (ccpPaymentCurrency.Equals("CNY"))
  15699. {
  15700. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15701. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15702. }
  15703. else
  15704. {
  15705. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15706. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15707. }
  15708. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15709. if (hotelcardPriceCurrency.Equals("CNY"))
  15710. {
  15711. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15712. }
  15713. else
  15714. {
  15715. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15716. }
  15717. }
  15718. string breakfastPriceStr = string.Empty,
  15719. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15720. governmentRentStr = string.Empty,
  15721. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15722. cityTaxStr = string.Empty,
  15723. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15724. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15725. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15726. {
  15727. if (breakfastCurrency1.Equals("CNY"))
  15728. {
  15729. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15730. }
  15731. else
  15732. {
  15733. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15734. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15735. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15736. }
  15737. }
  15738. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15739. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15740. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15741. {
  15742. if (governmentRentCurrency.Equals("CNY"))
  15743. {
  15744. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15745. }
  15746. else
  15747. {
  15748. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15749. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15750. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15751. }
  15752. }
  15753. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15754. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15755. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15756. {
  15757. if (cityTaxStrCurrency1.Equals("CNY"))
  15758. {
  15759. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15760. }
  15761. else
  15762. {
  15763. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15764. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15765. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15766. }
  15767. }
  15768. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15769. int payDId = roomInfo?.PayDId ?? 0;
  15770. pcfds.Add(new HotelReservations_PCFD_View()
  15771. {
  15772. City = item.City,
  15773. HotelName = item.HotelName,
  15774. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15775. // SingleRoomCount = item.SingleRoomCount,
  15776. SingleRoomPrice = singleRoomFeeStr,
  15777. // DoubleRoomCount = item.DoubleRoomCount,
  15778. DoubleRoomPrice = doubleRoomFeeStr,
  15779. //SuiteRoomCount = item.SuiteRoomCount,
  15780. SuiteRoomPrice = suiteRoomFeeStr,
  15781. OtherRoomPrice = otherRoomFeeStr,
  15782. //OtherRoomCount = item.OtherRoomCount,
  15783. BreakfastPrice = breakfastPriceStr,
  15784. GovernmentRent = governmentRentStr,
  15785. CityTax = cityTaxStr,
  15786. RoomExplanation = item.RoomExplanation,
  15787. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15788. PayTime = roomInfo?.ConsumptionDate,
  15789. BankNo = roomInfo?.BankNo,
  15790. PayMoney = payMoneyStr,
  15791. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15792. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15793. CardPrice = cardPriceStr,
  15794. Remark = ccpInfo.Remark
  15795. });
  15796. }
  15797. #endregion
  15798. //载入模板
  15799. WorkbookDesigner designer = new WorkbookDesigner();
  15800. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15801. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15802. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15803. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15804. var rateDatas1 = rateDatas.Distinct();
  15805. var rateStr = string.Empty;
  15806. foreach (var item in rateDatas1)
  15807. {
  15808. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15809. }
  15810. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15811. designer.SetDataSource("Opertor", userInfo.CnName);
  15812. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15813. dt.TableName = "ViewMyHotelReservations";
  15814. designer.SetDataSource(dt);
  15815. designer.Process();
  15816. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15817. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15818. designer.Workbook.Save(serverPath);
  15819. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15820. #region 删除指定行
  15821. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15822. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15823. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15824. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15825. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15826. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15827. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15828. cssIndex = dt.Columns["CityTax"].Ordinal,
  15829. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15830. remarkIndex = dt.Columns["Remark"].Ordinal;
  15831. //删除指定列
  15832. foreach (DataRow item in dt.Rows)
  15833. {
  15834. string singleStr = item["SingleRoomPrice"].ToString();
  15835. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15836. if (containsDigitButNotZero1) singleDel = false;
  15837. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15838. string doubleStr = item["DoubleRoomPrice"].ToString();
  15839. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15840. if (containsDigitButNotZero2) doubleDel = false;
  15841. string suiteStr = item["SuiteRoomPrice"].ToString();
  15842. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15843. if (containsDigitButNotZero3) suiteDel = false;
  15844. string otherStr = item["OtherRoomPrice"].ToString();
  15845. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15846. if (containsDigitButNotZero4) otherDel = false;
  15847. string zcStr = item["BreakfastPrice"].ToString();
  15848. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15849. if (containsDigitButNotZero5) zcDel = false;
  15850. string dsStr = item["GovernmentRent"].ToString();
  15851. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15852. if (containsDigitButNotZero6) dsDel = false;
  15853. string cssStr = item["CityTax"].ToString();
  15854. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15855. if (containsDigitButNotZero7) cssDel = false;
  15856. string cpStr = item["ConsumptionPatterns"].ToString();
  15857. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15858. string remarkStr = item["Remark"].ToString();
  15859. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15860. }
  15861. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15862. DeleteColumn(serverPath, cpIndex, cpDel);
  15863. DeleteColumn(serverPath, dsIndex, dsDel);
  15864. DeleteColumn(serverPath, cssIndex, cssDel);
  15865. DeleteColumn(serverPath, zcIndex, zcDel);
  15866. DeleteColumn(serverPath, otherIndex, otherDel);
  15867. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15868. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15869. DeleteColumn(serverPath, singleIndex, singleDel);
  15870. #endregion
  15871. //只保留第一个表格
  15872. DeleteSheet(serverPath);
  15873. return Ok(JsonView(true, "操作成功", url = rst));
  15874. }
  15875. else
  15876. {
  15877. _currency = _GroupCostParameter.Currency;
  15878. bool isIntType = int.TryParse(_currency, out int currId);
  15879. if (isIntType)
  15880. {
  15881. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15882. }
  15883. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15884. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15885. if (currInfo == null)
  15886. {
  15887. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15888. }
  15889. if (!_currency.ToUpper().Equals("CNY"))
  15890. {
  15891. _rate = _GroupCostParameter.Rate;
  15892. }
  15893. _rate = currInfo.Rate;
  15894. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15895. //string strFileName = "HotelStatement/";
  15896. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15897. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15898. #region 数据处理
  15899. foreach (var item in hrDtas)
  15900. {
  15901. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15902. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15903. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15904. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15905. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15906. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15907. string singleRoomFeeStr = string.Empty,
  15908. doubleRoomFeeStr = string.Empty,
  15909. suiteRoomFeeStr = string.Empty,
  15910. otherRoomFeeStr = string.Empty,
  15911. payMoneyStr = string.Empty,
  15912. cardPriceStr = string.Empty;
  15913. if (roomCurr.Equals(_currency))
  15914. {
  15915. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15916. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15917. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15918. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15919. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15920. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15921. }
  15922. else
  15923. {
  15924. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15925. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15926. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15927. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15928. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15929. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15930. }
  15931. string breakfastPriceStr = string.Empty,
  15932. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15933. governmentRentStr = string.Empty,
  15934. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15935. cityTaxStrStr = string.Empty,
  15936. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15937. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15938. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15939. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15940. int payDId = roomInfo?.PayDId ?? 0;
  15941. pcfds.Add(new HotelReservations_PCFD_View()
  15942. {
  15943. City = item.City,
  15944. HotelName = item.HotelName,
  15945. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15946. // SingleRoomCount = item.SingleRoomCount,
  15947. SingleRoomPrice = singleRoomFeeStr,
  15948. // DoubleRoomCount = item.DoubleRoomCount,
  15949. DoubleRoomPrice = doubleRoomFeeStr,
  15950. //SuiteRoomCount = item.SuiteRoomCount,
  15951. SuiteRoomPrice = suiteRoomFeeStr,
  15952. OtherRoomPrice = otherRoomFeeStr,
  15953. //OtherRoomCount = item.OtherRoomCount,
  15954. BreakfastPrice = breakfastPriceStr,
  15955. GovernmentRent = governmentRentStr,
  15956. CityTax = cityTaxStrStr,
  15957. RoomExplanation = item.RoomExplanation,
  15958. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15959. PayTime = roomInfo?.ConsumptionDate,
  15960. BankNo = roomInfo?.BankNo,
  15961. PayMoney = payMoneyStr,
  15962. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15963. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15964. CardPrice = cardPriceStr,
  15965. Remark = ccpInfo.Remark
  15966. });
  15967. }
  15968. #endregion
  15969. //载入模板
  15970. WorkbookDesigner designer = new WorkbookDesigner();
  15971. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15972. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15973. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15974. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15975. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15976. designer.SetDataSource("Opertor", userInfo.CnName);
  15977. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15978. dt.TableName = "ViewMyHotelReservations";
  15979. designer.SetDataSource(dt);
  15980. designer.Process();
  15981. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15982. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15983. designer.Workbook.Save(serverPath);
  15984. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15985. #region 删除指定行
  15986. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15987. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15988. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15989. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15990. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15991. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15992. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15993. cssIndex = dt.Columns["CityTax"].Ordinal,
  15994. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15995. remarkIndex = dt.Columns["Remark"].Ordinal;
  15996. //删除指定列
  15997. foreach (DataRow item in dt.Rows)
  15998. {
  15999. string singleStr = item["SingleRoomPrice"].ToString();
  16000. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16001. if (containsDigitButNotZero1) singleDel = false;
  16002. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16003. string doubleStr = item["DoubleRoomPrice"].ToString();
  16004. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16005. if (containsDigitButNotZero2) doubleDel = false;
  16006. string suiteStr = item["SuiteRoomPrice"].ToString();
  16007. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16008. if (containsDigitButNotZero3) suiteDel = false;
  16009. string otherStr = item["OtherRoomPrice"].ToString();
  16010. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16011. if (containsDigitButNotZero4) otherDel = false;
  16012. string zcStr = item["BreakfastPrice"].ToString();
  16013. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16014. if (containsDigitButNotZero5) zcDel = false;
  16015. string dsStr = item["GovernmentRent"].ToString();
  16016. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16017. if (containsDigitButNotZero6) dsDel = false;
  16018. string cssStr = item["CityTax"].ToString();
  16019. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16020. if (containsDigitButNotZero7) cssDel = false;
  16021. string cpStr = item["ConsumptionPatterns"].ToString();
  16022. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16023. string remarkStr = item["Remark"].ToString();
  16024. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16025. }
  16026. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16027. DeleteColumn(serverPath, cpIndex, cpDel);
  16028. DeleteColumn(serverPath, dsIndex, dsDel);
  16029. DeleteColumn(serverPath, cssIndex, cssDel);
  16030. DeleteColumn(serverPath, zcIndex, zcDel);
  16031. DeleteColumn(serverPath, otherIndex, otherDel);
  16032. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16033. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16034. DeleteColumn(serverPath, singleIndex, singleDel);
  16035. #endregion
  16036. //只保留第一个表格
  16037. DeleteSheet(serverPath);
  16038. return Ok(JsonView(true, "操作成功", url = rst));
  16039. }
  16040. //return Ok(JsonView(false));
  16041. }
  16042. /// <summary>
  16043. /// 删除指定列
  16044. /// </summary>
  16045. /// <param name="file"></param>
  16046. /// <param name="columnIndex"></param>
  16047. /// <param name="isDel"></param>
  16048. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16049. {
  16050. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16051. //wb.Save(file);
  16052. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16053. if (sheet1 != null)
  16054. {
  16055. if (isDel)
  16056. {
  16057. Cells cells = sheet1.Cells;
  16058. cells.DeleteColumn(columnIndex);
  16059. }
  16060. }
  16061. wb.Save(file);
  16062. }
  16063. /// <summary>
  16064. /// 删除sheet
  16065. /// </summary>
  16066. /// <param name="file"></param>
  16067. /// <param name="sheetName"></param>
  16068. private void DeleteSheet(string file, string sheetName = "")
  16069. {
  16070. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16071. //wb.Save(file);
  16072. List<string> sheets = new List<string>();
  16073. foreach (var item in wb.Worksheets)
  16074. {
  16075. sheets.Add(item.Name);
  16076. }
  16077. if (sheets.Count > 0)
  16078. {
  16079. sheets.RemoveAt(0);//不删除第一个sheet
  16080. foreach (var item in sheets)
  16081. {
  16082. wb.Worksheets.RemoveAt(item);
  16083. }
  16084. }
  16085. wb.Save(file);
  16086. }
  16087. /// <summary>
  16088. /// 酒店预订
  16089. /// 确认单
  16090. /// </summary>
  16091. /// <param name="_dto"></param>
  16092. /// <returns></returns>
  16093. [HttpPost]
  16094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16095. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16096. {
  16097. try
  16098. {
  16099. #region 参数验证
  16100. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16101. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16102. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16103. #region 团组操作权限验证 76 酒店预定模块
  16104. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16105. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16106. #endregion
  16107. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16108. #region 页面操作权限验证
  16109. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16110. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16111. #endregion
  16112. #endregion
  16113. //团组信息
  16114. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16115. //酒店数据
  16116. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16117. if (listhoteldata.Count < 0)
  16118. {
  16119. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16120. }
  16121. //利datatable存储
  16122. DataTable dt = new DataTable();
  16123. dt.Columns.Add("CheckInDate", typeof(string));
  16124. dt.Columns.Add("City", typeof(string));
  16125. dt.Columns.Add("Hotel", typeof(string));
  16126. dt.Columns.Add("Room", typeof(string));
  16127. for (int i = 0; i < listhoteldata.Count; i++)
  16128. {
  16129. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16130. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16131. while (dayStart < dayEnd)
  16132. {
  16133. string temp = "";
  16134. DataRow row = dt.NewRow();
  16135. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16136. row["City"] = listhoteldata[i].City;
  16137. row["Hotel"] = listhoteldata[i].HotelName;
  16138. if (listhoteldata[i].SingleRoomCount > 0)
  16139. {
  16140. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16141. }
  16142. if (listhoteldata[i].DoubleRoomCount > 0)
  16143. {
  16144. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16145. }
  16146. if (listhoteldata[i].SuiteRoomCount > 0)
  16147. {
  16148. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16149. }
  16150. if (listhoteldata[i].OtherRoomCount > 0)
  16151. {
  16152. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16153. }
  16154. row["Room"] = temp;
  16155. dt.Rows.Add(row);
  16156. dayStart = dayStart.AddDays(1);
  16157. }
  16158. }
  16159. Dictionary<string, string> dic = new Dictionary<string, string>();
  16160. dic.Add("Dele", di.TeamName);
  16161. dic.Add("City", di.VisitCountry);
  16162. //模板路径
  16163. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16164. //载入模板
  16165. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16166. DocumentBuilder builder = new DocumentBuilder(doc);
  16167. foreach (var key in dic.Keys)
  16168. {
  16169. builder.MoveToBookmark(key);
  16170. builder.Write(dic[key]);
  16171. }
  16172. //获取word里所有表格
  16173. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16174. //获取所填表格的序数
  16175. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16176. var rowStart = tableOne.Rows[0]; //获取第1行
  16177. //循环赋值
  16178. for (int i = 0; i < dt.Rows.Count; i++)
  16179. {
  16180. builder.MoveToCell(0, i + 1, 0, 0);
  16181. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16182. builder.MoveToCell(0, i + 1, 1, 0);
  16183. builder.Write(dt.Rows[i]["City"].ToString());
  16184. builder.MoveToCell(0, i + 1, 2, 0);
  16185. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16186. builder.MoveToCell(0, i + 1, 3, 0);
  16187. builder.Write(dt.Rows[i]["Room"].ToString());
  16188. }
  16189. //删除多余行
  16190. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16191. {
  16192. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16193. }
  16194. string strFileName = di.TeamName + "酒店确认单.doc";
  16195. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16196. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16197. return Ok(JsonView(true, "成功", url));
  16198. }
  16199. catch (Exception ex)
  16200. {
  16201. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16202. }
  16203. }
  16204. #endregion
  16205. #region 团组状态
  16206. /// <summary>
  16207. /// 团组状态列表 Page
  16208. /// </summary>
  16209. /// <param name="dto">团组列表请求dto</param>
  16210. /// <returns></returns>
  16211. [HttpPost]
  16212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16213. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16214. {
  16215. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16216. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16217. {
  16218. string sqlWhere = string.Empty;
  16219. if (dto.IsSure == 0) //未完成
  16220. {
  16221. sqlWhere += string.Format(@" And IsSure = 0");
  16222. }
  16223. else if (dto.IsSure == 1) //已完成
  16224. {
  16225. sqlWhere += string.Format(@" And IsSure = 1");
  16226. }
  16227. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16228. {
  16229. string tj = dto.SearchCriteria;
  16230. 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}%')",
  16231. tj, tj, tj, tj, tj);
  16232. }
  16233. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16234. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16235. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16236. From (
  16237. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16238. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16239. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16240. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16241. From Grp_DelegationInfo gdi
  16242. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16243. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16244. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16245. Where gdi.IsDel = 0 {0}
  16246. ) temp ", sqlWhere);
  16247. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16248. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16249. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16250. }
  16251. else
  16252. {
  16253. return Ok(JsonView(false, "查询失败"));
  16254. }
  16255. }
  16256. /// <summary>
  16257. /// 团组状态
  16258. /// 设置操作完成
  16259. /// </summary>
  16260. /// <param name="dto">团组列表请求dto</param>
  16261. /// <returns></returns>
  16262. [HttpPost]
  16263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16264. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16265. {
  16266. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16267. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16268. {
  16269. Id = dto.Id,
  16270. IsSure = 1
  16271. };
  16272. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16273. .UpdateColumns(it => new { it.IsSure })
  16274. .WhereColumns(it => new { it.Id })
  16275. .ExecuteCommandAsync();
  16276. if (result > 0)
  16277. {
  16278. return Ok(JsonView(true, "操作完成!"));
  16279. }
  16280. return Ok(JsonView(false, "操作失败!"));
  16281. }
  16282. #endregion
  16283. #region 保险费用录入
  16284. /// <summary>
  16285. /// 根据团组Id查询保险费用列表
  16286. /// </summary>
  16287. /// <param name="dto"></param>
  16288. /// <returns></returns>
  16289. [HttpPost]
  16290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16291. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16292. {
  16293. Result groupData = await _customersRep.CustomersByDiId(dto);
  16294. if (groupData.Code != 0)
  16295. {
  16296. return Ok(JsonView(false, groupData.Msg));
  16297. }
  16298. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16299. }
  16300. /// <summary>
  16301. /// 根据保险费用Id查询保险费用详细
  16302. /// </summary>
  16303. /// <param name="dto"></param>
  16304. /// <returns></returns>
  16305. [HttpPost]
  16306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16307. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16308. {
  16309. try
  16310. {
  16311. Result groupData = await _customersRep.CustomersById(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. catch (Exception ex)
  16319. {
  16320. return Ok(JsonView(false, ex.Message));
  16321. }
  16322. }
  16323. /// <summary>
  16324. /// 保险费用录入页面初始化绑定
  16325. /// </summary>
  16326. /// <param name="dto"></param>
  16327. /// <returns></returns>
  16328. [HttpPost]
  16329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16330. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16331. {
  16332. try
  16333. {
  16334. Result groupData = await _customersRep.CustomersInitialize(dto);
  16335. if (groupData.Code != 0)
  16336. {
  16337. return Ok(JsonView(false, groupData.Msg));
  16338. }
  16339. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16340. }
  16341. catch (Exception ex)
  16342. {
  16343. return Ok(JsonView(false, ex.Message));
  16344. }
  16345. }
  16346. /// <summary>
  16347. /// 保险费用操作(Status:1.新增,2.修改)
  16348. /// </summary>
  16349. /// <param name="dto"></param>
  16350. /// <returns></returns>
  16351. [HttpPost]
  16352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16353. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16354. {
  16355. Result groupData = await _customersRep.OpCustomers(dto);
  16356. if (groupData.Code != 0)
  16357. {
  16358. return Ok(JsonView(false, groupData.Msg));
  16359. }
  16360. #region 应用推送
  16361. try
  16362. {
  16363. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16364. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16365. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16366. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16367. //自动审核
  16368. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16369. //2024-10-21 新增LZ UID
  16370. var userIds = new List<int>() { 21 };
  16371. string title = $"系统通知";
  16372. var diId = dto.DiId;
  16373. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16374. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16375. string content = "";
  16376. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16377. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16378. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16379. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16380. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16381. }
  16382. catch (Exception ex)
  16383. {
  16384. }
  16385. #endregion
  16386. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16387. }
  16388. /// <summary>
  16389. /// 保险文件上传
  16390. /// </summary>
  16391. /// <param name="file"></param>
  16392. /// <returns></returns>
  16393. [HttpPost]
  16394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16395. public async Task<IActionResult> UploadCus(IFormFile file)
  16396. {
  16397. try
  16398. {
  16399. if (file != null)
  16400. {
  16401. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16402. //文件名称
  16403. string projectFileName = file.FileName;
  16404. //上传的文件的路径
  16405. string filePath = "";
  16406. if (!Directory.Exists(fileDir))
  16407. {
  16408. Directory.CreateDirectory(fileDir);
  16409. }
  16410. //上传的文件的路径
  16411. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16412. using (FileStream fs = System.IO.File.Create(filePath))
  16413. {
  16414. file.CopyTo(fs);
  16415. fs.Flush();
  16416. }
  16417. return Ok(JsonView(true, "上传成功!", projectFileName));
  16418. }
  16419. else
  16420. {
  16421. return Ok(JsonView(false, "上传失败!"));
  16422. }
  16423. }
  16424. catch (Exception ex)
  16425. {
  16426. return Ok(JsonView(false, "程序错误!"));
  16427. throw;
  16428. }
  16429. }
  16430. /// <summary>
  16431. /// 保险删除指定文件
  16432. /// </summary>
  16433. /// <param name="dto"></param>
  16434. /// <returns></returns>
  16435. [HttpPost]
  16436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16437. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16438. {
  16439. try
  16440. {
  16441. string filePath = "";
  16442. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16443. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16444. //int id = 0;
  16445. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16446. // 删除该文件
  16447. try
  16448. {
  16449. System.IO.File.Delete(filePath);
  16450. 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()
  16451. {
  16452. Attachment = "",
  16453. }).ExecuteCommandAsync();
  16454. if (result != 0)
  16455. {
  16456. return Ok(JsonView(true, "成功!"));
  16457. }
  16458. else
  16459. {
  16460. return Ok(JsonView(false, "失败!"));
  16461. }
  16462. }
  16463. catch (Exception)
  16464. {
  16465. 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()
  16466. {
  16467. Attachment = "",
  16468. }).ExecuteCommandAsync();
  16469. if (result != 0)
  16470. {
  16471. return Ok(JsonView(true, "成功!"));
  16472. }
  16473. else
  16474. {
  16475. return Ok(JsonView(false, "失败!"));
  16476. }
  16477. }
  16478. }
  16479. catch (Exception ex)
  16480. {
  16481. return Ok(JsonView(false, "程序错误!"));
  16482. throw;
  16483. }
  16484. }
  16485. /// <summary>
  16486. /// 保险费用操作(删除)
  16487. /// </summary>
  16488. /// <param name="dto"></param>
  16489. /// <returns></returns>
  16490. [HttpPost]
  16491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16492. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16493. {
  16494. try
  16495. {
  16496. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16497. if (!res)
  16498. {
  16499. return Ok(JsonView(false, "删除失败"));
  16500. }
  16501. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16502. {
  16503. IsDel = 1,
  16504. DeleteUserId = dto.DeleteUserId,
  16505. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16506. }).ExecuteCommandAsync();
  16507. return Ok(JsonView(true, "删除成功!"));
  16508. }
  16509. catch (Exception ex)
  16510. {
  16511. return Ok(JsonView(false, "程序错误!"));
  16512. throw;
  16513. }
  16514. }
  16515. #endregion
  16516. #region 接团客户名单 PageId 104
  16517. /// <summary>
  16518. /// 接团客户名单
  16519. /// 迁移数据(慎用!)
  16520. /// </summary>
  16521. /// <returns></returns>
  16522. [HttpPost]
  16523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16524. public async Task<IActionResult> PostTourClientListChange()
  16525. {
  16526. try
  16527. {
  16528. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16529. //var groupClinetData1
  16530. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16531. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16532. int updateCount = 0;
  16533. if (oldOAClientList.Count > 0)
  16534. {
  16535. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16536. _sqlSugar.BeginTran();
  16537. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16538. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16539. foreach (var item in oldOAClientList)
  16540. {
  16541. int comId = 0;
  16542. string format = "yyyy-MM-dd HH:mm:ss";
  16543. string data11 = "1990-01-01 00:00";
  16544. var data1 = IsValidDate(item.OPdate, format);
  16545. if (data1) data11 = item.OPdate;
  16546. //客户公司验证
  16547. if (!string.IsNullOrEmpty(item.Company))
  16548. {
  16549. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16550. if (clientComInfo == null) // add
  16551. {
  16552. var addInfo = new Crm_CustomerCompany()
  16553. {
  16554. CompanyAbbreviation = "",
  16555. CompanyFullName = item.Company,
  16556. Address = "",
  16557. PostCodes = "",
  16558. LastedOpUserId = item.OPer,
  16559. LastedOpDt = Convert.ToDateTime(data11),
  16560. CreateUserId = item.OPer,
  16561. CreateTime = Convert.ToDateTime(data11),
  16562. IsDel = 0
  16563. };
  16564. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16565. if (comId1 > 0) comId = comId1;
  16566. }
  16567. else comId = clientComInfo.Id;
  16568. }
  16569. //客户人员验证
  16570. int clientId = 0;
  16571. string name = item.LastName + item.Name;
  16572. if (!string.IsNullOrEmpty(name))
  16573. {
  16574. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16575. if (clientInfo == null)
  16576. {
  16577. DateTime? dateTime = null;
  16578. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16579. if (isDt) dateTime = birthDayDt;
  16580. var addInfo1 = new Crm_DeleClient()
  16581. {
  16582. CrmCompanyId = comId,
  16583. DiId = -1,
  16584. LastName = item.LastName,
  16585. FirstName = item.Name,
  16586. OldName = "",
  16587. Pinyin = item.Pinyin,
  16588. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16589. Marriage = 0,
  16590. Phone = item.Phone,
  16591. Job = item.Job,
  16592. BirthDay = dateTime
  16593. };
  16594. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16595. if (clientId1 > 0) clientId = clientId1;
  16596. }
  16597. else clientId = clientInfo.Id;
  16598. }
  16599. if (clientId < 1)
  16600. {
  16601. continue;
  16602. }
  16603. int airType = 0;
  16604. if (item.AirType == "超经舱") airType = 459;
  16605. else if (item.AirType == "公务舱") airType = 458;
  16606. else if (item.AirType == "经济舱") airType = 460;
  16607. else if (item.AirType == "其他") airType = 565;
  16608. else if (item.AirType == "头等舱") airType = 457;
  16609. var _TourClientListEntity = new Grp_TourClientList()
  16610. {
  16611. DiId = item.Diid,
  16612. ClientId = clientId,
  16613. CreateUserId = item.OPer,
  16614. CreateTime = Convert.ToDateTime(data11),
  16615. Remark = item.Remark,
  16616. IsDel = item.Isdel,
  16617. ShippingSpaceTypeId = airType,
  16618. ShippingSpaceSpecialNeeds = item.AirRemark,
  16619. HotelSpecialNeeds = item.RoomType
  16620. };
  16621. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16622. if (_TourClientList > 0)
  16623. {
  16624. updateCount++;
  16625. }
  16626. }
  16627. _sqlSugar.CommitTran();
  16628. }
  16629. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16630. }
  16631. catch (Exception ex)
  16632. {
  16633. _sqlSugar.RollbackTran();
  16634. return Ok(JsonView(false, ex.Message));
  16635. }
  16636. //return Ok(JsonView(true));
  16637. }
  16638. private bool IsValidDate(string dateString, string format)
  16639. {
  16640. DateTime dateValue;
  16641. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16642. return valid;
  16643. }
  16644. /// <summary>
  16645. /// 接团客户名单
  16646. /// 根据团组Id查询List
  16647. /// </summary>
  16648. /// <param name="_dto"></param>
  16649. /// <returns></returns>
  16650. [HttpPost]
  16651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16652. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16653. {
  16654. #region 参数验证
  16655. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16656. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16657. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16658. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16659. #region 页面操作权限验证
  16660. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16661. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16662. #endregion
  16663. #endregion
  16664. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16665. if (viewData.Code != 0)
  16666. {
  16667. return Ok(JsonView(false, viewData.Msg));
  16668. }
  16669. return Ok(JsonView(viewData.Data));
  16670. }
  16671. /// <summary>
  16672. /// 接团客户名单
  16673. /// 基础数据 Init
  16674. /// </summary>
  16675. /// <param name="_dto"></param>
  16676. /// <returns></returns>
  16677. [HttpPost]
  16678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16679. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16680. {
  16681. #region 参数验证
  16682. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16683. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16684. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16685. #region 页面操作权限验证
  16686. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16687. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16688. #endregion
  16689. #endregion
  16690. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16691. }
  16692. /// <summary>
  16693. /// 接团客户名单
  16694. /// 根据 Id查询 Details
  16695. /// </summary>
  16696. /// <param name="_dto"></param>
  16697. /// <returns></returns>
  16698. [HttpPost]
  16699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16700. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16701. {
  16702. #region 参数验证
  16703. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16704. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16705. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16706. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16707. #region 页面操作权限验证
  16708. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16709. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16710. #endregion
  16711. #endregion
  16712. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16713. if (viewData.Code != 0)
  16714. {
  16715. return Ok(JsonView(false, viewData.Msg));
  16716. }
  16717. return Ok(JsonView(viewData.Data));
  16718. }
  16719. /// <summary>
  16720. /// 接团客户名单
  16721. /// Add Or Edit
  16722. /// </summary>
  16723. /// <param name="_dto"></param>
  16724. /// <returns></returns>
  16725. [HttpPost]
  16726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16727. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16728. {
  16729. #region 参数验证
  16730. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16731. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16732. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16733. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16734. #region 页面操作权限验证
  16735. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16736. if (_dto.Id == 0) //添加
  16737. {
  16738. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16739. }
  16740. else if (_dto.Id >= 0) //修改
  16741. {
  16742. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16743. }
  16744. #endregion
  16745. #endregion
  16746. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16747. if (viewData.Code != 0)
  16748. {
  16749. return Ok(JsonView(false, viewData.Msg));
  16750. }
  16751. return Ok(JsonView(true));
  16752. }
  16753. /// <summary>
  16754. /// 接团客户名单
  16755. /// json字符串 AddMultiple(添加多个)
  16756. /// </summary>
  16757. /// <param name="_dto"></param>
  16758. /// <returns></returns>
  16759. [HttpPost]
  16760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16761. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16762. {
  16763. #region 参数验证
  16764. string jsonLabel = _dto.JsonLabel;
  16765. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16766. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16767. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16768. #region 页面操作权限验证
  16769. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16770. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16771. #endregion
  16772. #endregion
  16773. var request = new TourClientListAddMultipleDto();
  16774. request.DiId = _dto.DiId;
  16775. request.UserId = _dto.UserId;
  16776. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16777. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16778. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16779. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16780. var infos = new List<TourClientListInfo>();
  16781. foreach (var data in datas)
  16782. {
  16783. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16784. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16785. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16786. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16787. {
  16788. continue;
  16789. }
  16790. infos.Add(new TourClientListInfo()
  16791. {
  16792. IsAccompany = 1,
  16793. LastName = lastName,
  16794. FirstName = firstName,
  16795. Pinyin = lastNameEn + @"/" + firstNameEn,
  16796. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16797. CompanyFullName = data.CompanyFullName,
  16798. Job = data.Job
  16799. });
  16800. }
  16801. if (infos.Any())
  16802. {
  16803. var viewData = await _tourClientListRep._AddMultiple(request);
  16804. if (viewData.Code != 0)
  16805. {
  16806. return Ok(JsonView(false, viewData.Msg));
  16807. }
  16808. return Ok(JsonView(true));
  16809. }
  16810. return Ok(JsonView(false));
  16811. }
  16812. /// <summary>
  16813. /// 接团客户名单
  16814. /// AddMultiple(添加多个)
  16815. /// </summary>
  16816. /// <param name="_dto"></param>
  16817. /// <returns></returns>
  16818. [HttpPost]
  16819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16820. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16821. {
  16822. #region 参数验证
  16823. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16824. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16825. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16826. #region 页面操作权限验证
  16827. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16828. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16829. #endregion
  16830. #endregion
  16831. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16832. if (viewData.Code != 0)
  16833. {
  16834. return Ok(JsonView(false, viewData.Msg));
  16835. }
  16836. return Ok(JsonView(true));
  16837. }
  16838. /// <summary>
  16839. /// 接团客户名单
  16840. /// Del
  16841. /// </summary>
  16842. /// <param name="_dto"></param>
  16843. /// <returns></returns>
  16844. [HttpPost]
  16845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16846. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16847. {
  16848. #region 参数验证
  16849. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16850. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16851. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16852. #region 页面操作权限验证
  16853. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16854. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16855. #endregion
  16856. #endregion
  16857. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16858. if (viewData.Code != 0)
  16859. {
  16860. return Ok(JsonView(false, viewData.Msg));
  16861. }
  16862. return Ok(JsonView(true));
  16863. }
  16864. /// <summary>
  16865. /// 接团客户名单
  16866. /// 文件下载 客户名单
  16867. /// </summary>
  16868. /// <param name="_dto"></param>
  16869. /// <returns></returns>
  16870. [HttpPost]
  16871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16872. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16873. {
  16874. #region 参数验证
  16875. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16876. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16877. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16878. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16879. #region 页面操作权限验证
  16880. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16881. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16882. #endregion
  16883. #endregion
  16884. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16885. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16886. From Grp_TourClientList tcl
  16887. Left Join
  16888. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16889. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16890. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16891. From Crm_DeleClient dc
  16892. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16893. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16894. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16895. Where dc.IsDel = 0) temp
  16896. On temp.DcId =tcl.ClientId
  16897. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16898. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16899. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16900. //载入模板
  16901. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16902. if (_dto.Language == 1)
  16903. {
  16904. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16905. }
  16906. //载入模板
  16907. var doc = new Document(tempPath);
  16908. DocumentBuilder builder = new DocumentBuilder(doc);
  16909. //获取word里所有表格
  16910. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16911. //获取所填表格的序数
  16912. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16913. var rowStart = tableOne.Rows[0]; //获取第1行
  16914. if (_dto.Language == 0)
  16915. {
  16916. //循环赋值
  16917. for (int i = 0; i < DcList.Count; i++)
  16918. {
  16919. EncryptionProcessor.DecryptProperties(DcList[i]);
  16920. builder.MoveToCell(0, i + 1, 0, 0);
  16921. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16922. builder.MoveToCell(0, i + 1, 1, 0);
  16923. int sex = DcList[i].Sex;
  16924. string sexStr = string.Empty;
  16925. if (sex == 0) sexStr = "男";
  16926. else if (sex == 1) sexStr = "女";
  16927. else sexStr = "未设置";
  16928. builder.Write(sexStr);
  16929. builder.MoveToCell(0, i + 1, 2, 0);
  16930. string birthDay = DcList[i].BirthDay;
  16931. string birthDayStr = string.Empty;
  16932. if (!string.IsNullOrEmpty(birthDay))
  16933. {
  16934. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16935. }
  16936. builder.Write(birthDayStr);
  16937. builder.MoveToCell(0, i + 1, 3, 0);
  16938. string company = "";
  16939. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16940. {
  16941. company = DcList[i].CompanyFullName.ToString();
  16942. }
  16943. builder.Write(company);
  16944. builder.MoveToCell(0, i + 1, 4, 0);
  16945. builder.Write(DcList[i].Job);
  16946. }
  16947. }
  16948. else if (_dto.Language == 1)
  16949. {
  16950. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16951. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16952. List<string> transArrayStr = new List<string>();
  16953. string transStrRes1 = "";
  16954. for (int i = 0; i < DcList.Count; i++)
  16955. {
  16956. var dc = DcList[i];
  16957. EncryptionProcessor.DecryptProperties(dc);
  16958. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16959. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16960. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16961. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16962. else transStrRes1 += $"{str1}|";
  16963. }
  16964. //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";
  16965. string transStrRes = "";
  16966. if (transStrRes1.Length > 0)
  16967. {
  16968. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16969. }
  16970. //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
  16971. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16972. //List<string> transArray = new List<string> { };
  16973. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16974. if (transStrRes.Contains("|"))
  16975. {
  16976. string[] transArray1 = transStrRes.Split('|');
  16977. if (transArray1.Length > 0)
  16978. {
  16979. foreach (var item in transArray1)
  16980. {
  16981. if (item.Contains("&"))
  16982. {
  16983. string[] transArray2 = item.Split('&');
  16984. int index = 0;
  16985. string companyName = "", job = "";
  16986. if (transArray2.Length > 0)
  16987. {
  16988. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16989. if (1 < transArray2.Length) companyName = transArray2[1];
  16990. if (2 < transArray2.Length) job = transArray2[2];
  16991. }
  16992. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16993. }
  16994. }
  16995. }
  16996. }
  16997. //循环赋值
  16998. for (int i = 0; i < DcList.Count; i++)
  16999. {
  17000. string PYName = "";
  17001. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17002. {
  17003. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17004. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17005. PYName = PY_First + " " + PY_Last;
  17006. }
  17007. else
  17008. {
  17009. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17010. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17011. PYName = PY_First + " " + PY_Last;
  17012. }
  17013. builder.MoveToCell(0, i + 1, 0, 0);
  17014. builder.Write(PYName);
  17015. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17016. builder.MoveToCell(0, i + 1, 1, 0);
  17017. builder.Write(sex);
  17018. DateTime birthDt;
  17019. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17020. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17021. builder.MoveToCell(0, i + 1, 2, 0);
  17022. builder.Write(birthday);
  17023. string company = string.Empty, job = string.Empty;
  17024. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17025. if (dcTransInfo != null)
  17026. {
  17027. company = dcTransInfo.CompanyName;
  17028. job = dcTransInfo.Job;
  17029. }
  17030. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17031. {
  17032. //查询对照表
  17033. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17034. if (tempCec != null)
  17035. {
  17036. company = tempCec.enName;
  17037. }
  17038. //翻译
  17039. else
  17040. {
  17041. }
  17042. }
  17043. builder.MoveToCell(0, i + 1, 3, 0);
  17044. builder.Write(company);
  17045. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17046. {
  17047. //查询对照表
  17048. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17049. if (tempPec != null)
  17050. {
  17051. job = tempPec.enName;
  17052. }
  17053. //翻译
  17054. else
  17055. {
  17056. }
  17057. }
  17058. builder.MoveToCell(0, i + 1, 4, 0);
  17059. builder.Write(job);
  17060. }
  17061. }
  17062. //删除多余行
  17063. while (tableOne.Rows.Count > DcList.Count + 1)
  17064. {
  17065. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17066. }
  17067. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17068. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17069. doc.Save(fileDir);
  17070. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17071. return Ok(JsonView(true, "操作成功!", Url));
  17072. }
  17073. private class TranslateInfo
  17074. {
  17075. public int Index { get; set; }
  17076. public string CompanyName { get; set; }
  17077. public string Job { get; set; }
  17078. }
  17079. #endregion
  17080. #region 团组倒推表
  17081. /// <summary>
  17082. /// 倒推表基础数据
  17083. /// Init
  17084. /// </summary>
  17085. /// <returns></returns>
  17086. [HttpPost]
  17087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17088. public async Task<IActionResult> PostInvertedListInit()
  17089. {
  17090. var viewData = await _invertedListRep._Init();
  17091. if (viewData.Code != 0)
  17092. {
  17093. return Ok(JsonView(false, viewData.Msg));
  17094. }
  17095. return Ok(JsonView(viewData.Data));
  17096. }
  17097. /// <summary>
  17098. /// 倒推表
  17099. /// Info
  17100. /// </summary>
  17101. /// <param name="dto"></param>
  17102. /// <returns></returns>
  17103. [HttpPost]
  17104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17105. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17106. {
  17107. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17108. if (viewData.Code != 0)
  17109. {
  17110. return Ok(JsonView(false, viewData.Msg));
  17111. }
  17112. return Ok(JsonView(viewData.Data));
  17113. }
  17114. /// <summary>
  17115. /// 倒推表
  17116. /// Create
  17117. /// </summary>
  17118. /// <param name="dto"></param>
  17119. /// <returns></returns>
  17120. [HttpPost]
  17121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17122. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17123. {
  17124. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17125. if (viewData.Code != 0)
  17126. {
  17127. return Ok(JsonView(false, viewData.Msg));
  17128. }
  17129. return Ok(JsonView(viewData.Data));
  17130. }
  17131. /// <summary>
  17132. /// 倒推表
  17133. /// Update
  17134. /// </summary>
  17135. /// <param name="dto"></param>
  17136. /// <returns></returns>
  17137. [HttpPost]
  17138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17139. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17140. {
  17141. var viewData = await _invertedListRep._Update(dto);
  17142. if (viewData.Code != 0)
  17143. {
  17144. return Ok(JsonView(false, viewData.Msg));
  17145. }
  17146. return Ok(JsonView(viewData.Data));
  17147. }
  17148. /// <summary>
  17149. /// 倒推表
  17150. /// File Download
  17151. /// </summary>
  17152. /// <param name="dto"></param>
  17153. /// <returns></returns>
  17154. [HttpPost]
  17155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17156. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17157. {
  17158. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17159. if (info2.Code != 0)
  17160. {
  17161. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17162. }
  17163. var info1 = info2.Data as InvertedListInfoView;
  17164. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17165. string teamName = "";
  17166. if (info != null) teamName = info.TeamName;
  17167. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17168. var doc = new Document();
  17169. var builder = new DocumentBuilder(doc);
  17170. #region old insert
  17171. ////载入模板
  17172. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17173. //Document doc = new Document(tempPath);
  17174. //DocumentBuilder builder = new DocumentBuilder(doc);
  17175. //利用键值对存放数据
  17176. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17177. //dic.Add("TeamName", teamName);
  17178. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17179. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17180. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17181. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17182. //dic.Add("SQRemark", info1.ApprovalRemark);
  17183. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17184. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17185. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17186. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17187. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17188. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17189. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17190. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17191. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17192. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17193. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17194. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17195. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17196. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17197. //#region 填充word模板书签内容
  17198. //foreach (var key in dic.Keys)
  17199. //{
  17200. // builder.MoveToBookmark(key);
  17201. // builder.Write(dic[key]);
  17202. //}
  17203. //#endregion
  17204. #endregion
  17205. #region New Insert
  17206. string titleFont = $"仿宋",
  17207. contentFont = $"仿宋";
  17208. var fontColor = Color.FromArgb(64, 64, 64);
  17209. //设置标题 团组名称
  17210. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17211. builder.Font.Name = titleFont;
  17212. builder.Font.Color = fontColor;
  17213. builder.Font.Size = 12;
  17214. builder.Font.Bold = true;
  17215. builder.Writeln(teamName);
  17216. //设置副标题 团组出访时间
  17217. builder.Font.Size = 12;
  17218. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17219. builder.Writeln();
  17220. var backgroundColor = Color.FromArgb(199, 199, 199);
  17221. var table = builder.StartTable();
  17222. builder.InsertCell();
  17223. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17224. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17225. builder.CellFormat.Borders.LineWidth = 1;
  17226. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17227. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17228. builder.RowFormat.Height = 40;
  17229. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17230. builder.Font.Name = contentFont;
  17231. builder.Font.Size = 12;
  17232. builder.Font.Bold = true;
  17233. builder.Font.Color = fontColor;
  17234. builder.Write("时间");
  17235. builder.InsertCell();
  17236. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17237. builder.Write("流程");
  17238. builder.InsertCell();
  17239. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17240. builder.Write("说明");
  17241. builder.EndRow();
  17242. //报批资料准备
  17243. if (info1.IsSelectedAirportd)
  17244. {
  17245. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17246. }
  17247. //报批/提供送签资料
  17248. if (info1.IsSelectedApprovalData)
  17249. {
  17250. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17251. }
  17252. //出批件护照办理
  17253. if (info1.IsSelectedIssueApproval)
  17254. {
  17255. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17256. }
  17257. //签证资料准备
  17258. if (info1.IsSelectedVisaInfo)
  17259. {
  17260. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17261. }
  17262. //送签
  17263. if (info1.IsSelectedSendVisa)
  17264. {
  17265. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17266. }
  17267. //出签
  17268. if (info1.IsSelectedIssueVisa)
  17269. {
  17270. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17271. }
  17272. //机票
  17273. if (info1.IsSelectedAirTicket)
  17274. {
  17275. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17276. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17277. }
  17278. //酒店
  17279. if (info1.IsSelectedHotel)
  17280. {
  17281. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17282. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17283. }
  17284. //开行前会
  17285. if (info1.IsSelectedPreTripMeeting)
  17286. {
  17287. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17288. }
  17289. //送机
  17290. if (info1.IsSelectedAirportdDropOff)
  17291. {
  17292. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17293. }
  17294. builder.EndTable();
  17295. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17296. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17297. for (int i = 0; i < table.Rows.Count; i++)
  17298. {
  17299. var row = table.Rows[i];
  17300. //设置宽度
  17301. row.Cells[0].CellFormat.Width = 20.00;
  17302. row.Cells[1].CellFormat.Width = 30.00;
  17303. row.Cells[2].CellFormat.Width = 50.00;
  17304. if (i != 0)
  17305. {
  17306. //边框设置
  17307. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17308. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17309. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17310. }
  17311. }
  17312. #region 页脚插入图片
  17313. // 创建页脚
  17314. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17315. doc.FirstSection.HeadersFooters.Add(footer);
  17316. Paragraph para = new Paragraph(doc);
  17317. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17318. footer.AppendChild(para);
  17319. builder.MoveTo(para);
  17320. string imagePath = "./Images/FMGJ_Log.png";
  17321. builder.InsertImage(imagePath);
  17322. #endregion
  17323. #endregion
  17324. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17325. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17326. string filePath = fileDir + $@"InvertedList/{fileName}";
  17327. doc.Save(filePath);
  17328. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17329. return Ok(JsonView(true, "操作成功!", Url));
  17330. }
  17331. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  17332. {
  17333. var fontColor = Color.FromArgb(64, 64, 64);
  17334. builder.InsertCell();
  17335. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17336. builder.RowFormat.Height = 40;
  17337. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17338. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17339. builder.Font.Name = fontName;
  17340. builder.Font.Size = 8;
  17341. builder.Font.Bold = true;
  17342. builder.Font.Color = fontColor;
  17343. builder.Write(dateTime);
  17344. builder.InsertCell();
  17345. builder.Font.Size = 9;
  17346. builder.Font.Bold = true;
  17347. builder.Font.Color = fontColor;
  17348. builder.Write(content);
  17349. builder.InsertCell();
  17350. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17351. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17352. builder.Font.Size = 9;
  17353. builder.Font.Bold = false;
  17354. builder.Font.Color = fontColor;
  17355. builder.Write(reamrk);
  17356. builder.EndRow();
  17357. }
  17358. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  17359. {
  17360. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17361. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17362. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17363. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17364. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17365. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17366. }
  17367. #endregion
  17368. #region 会务倒推表
  17369. /// <summary>
  17370. /// 会务倒推表
  17371. /// Init
  17372. /// </summary>
  17373. /// <returns></returns>
  17374. [HttpPost]
  17375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17376. public async Task<IActionResult> InforRetrogressTableInit()
  17377. {
  17378. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17379. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17380. return Ok(JsonView(false, groupData.Msg));
  17381. }
  17382. /// <summary>
  17383. /// 会务倒推表
  17384. /// ExcelDownload
  17385. /// </summary>
  17386. /// <param name="dto"></param>
  17387. /// <returns></returns>
  17388. [HttpPost]
  17389. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17391. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17392. {
  17393. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17394. var validatorRes = await validator.ValidateAsync(dto);
  17395. if (!validatorRes.IsValid)
  17396. {
  17397. StringBuilder sb = new StringBuilder();
  17398. foreach (var item in validatorRes.Errors)
  17399. {
  17400. sb.AppendLine(item.ErrorMessage);
  17401. }
  17402. return Ok(JsonView(false, sb.ToString()));
  17403. }
  17404. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17405. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17406. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17407. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17408. #region Excel
  17409. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17410. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17411. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17412. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17413. var fileNamePrefix = string.Empty;
  17414. if (days >= 30)
  17415. {
  17416. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17417. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17418. }
  17419. else if (days < 30 && days > 7)
  17420. {
  17421. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17422. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17423. }
  17424. else if (days <= 7)
  17425. {
  17426. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17427. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17428. }
  17429. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17430. fileName = CommonFun.ValidFileName(fileName);
  17431. //载入模板
  17432. WorkbookDesigner designer = new WorkbookDesigner();
  17433. designer.Workbook = new Workbook(tempPath);
  17434. designer.Process();
  17435. if (!Directory.Exists(savePath))
  17436. {
  17437. Directory.CreateDirectory(savePath);
  17438. }
  17439. string serverPath = $"{savePath}{fileName}";
  17440. designer.Workbook.Save(serverPath);
  17441. string rst = $"{servicePath}{ftpPath}{fileName}";
  17442. #endregion
  17443. return Ok(JsonView(new { url = rst }));
  17444. }
  17445. #endregion
  17446. #region 三公签证费用(签证费、代办费)
  17447. /// <summary>
  17448. /// 三公签证费用(签证费、代办费)
  17449. /// List
  17450. /// </summary>
  17451. /// <returns></returns>
  17452. [HttpPost]
  17453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17454. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17455. {
  17456. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17457. if (_view.Code != 0)
  17458. {
  17459. return Ok(JsonView(false, _view.Msg));
  17460. }
  17461. return Ok(JsonView(true, "操作成功!", _view.Data));
  17462. }
  17463. /// <summary>
  17464. /// 三公签证费用(签证费、代办费)
  17465. /// Add Or Update
  17466. /// </summary>
  17467. /// <returns></returns>
  17468. [HttpPost]
  17469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17470. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17471. {
  17472. var _view = await _visaFeeInfoRep._Update(_dto);
  17473. if (_view.Code != 0)
  17474. {
  17475. return Ok(JsonView(false, _view.Msg));
  17476. }
  17477. return Ok(JsonView(true, _view.Msg));
  17478. }
  17479. #endregion
  17480. #region 酒店询价
  17481. /// <summary>
  17482. /// 酒店询价
  17483. /// Init
  17484. /// </summary>
  17485. /// <returns></returns>
  17486. [HttpPost]
  17487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17488. public async Task<IActionResult> PostHotelInquiryInit()
  17489. {
  17490. var res = await _hotelInquiryRep._Init();
  17491. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17492. return Ok(JsonView(true, res.Msg, res.Data));
  17493. }
  17494. /// <summary>
  17495. /// 酒店询价
  17496. /// page Item
  17497. /// </summary>
  17498. /// <param name="_dto"></param>
  17499. /// <returns></returns>
  17500. [HttpPost]
  17501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17502. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17503. {
  17504. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17505. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17506. var view = res.Data as PageDataViewBase;
  17507. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17508. }
  17509. /// <summary>
  17510. /// 酒店询价
  17511. /// info
  17512. /// </summary>
  17513. /// <param name="_dto"></param>
  17514. /// <returns></returns>
  17515. [HttpPost]
  17516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17517. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17518. {
  17519. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17520. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17521. return Ok(JsonView(true, res.Msg, res.Data));
  17522. }
  17523. /// <summary>
  17524. /// 酒店询价
  17525. /// Add Or Edit
  17526. /// </summary>
  17527. /// <param name="_dto"></param>
  17528. /// <returns></returns>
  17529. [HttpPost]
  17530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17531. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17532. {
  17533. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17534. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17535. return Ok(JsonView(true, res.Msg, res.Data));
  17536. }
  17537. /// <summary>
  17538. /// 酒店询价
  17539. /// Del
  17540. /// </summary>
  17541. /// <param name="_dto"></param>
  17542. /// <returns></returns>
  17543. [HttpPost]
  17544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17545. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17546. {
  17547. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17548. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17549. return Ok(JsonView(true, res.Msg, res.Data));
  17550. }
  17551. #endregion
  17552. #region 下载匹配op行程单
  17553. /// <summary>
  17554. /// 匹配op行程单
  17555. /// Init
  17556. /// </summary>
  17557. /// <param name="dto">团组列表请求dto</param>
  17558. /// <returns></returns>
  17559. [HttpPost]
  17560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17561. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17562. {
  17563. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17564. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17565. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17566. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17567. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17568. .Where(it => it.IsDel == 0)
  17569. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17570. .OrderByDescending(it => it.VisitStartDate)
  17571. .ToList();
  17572. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17573. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17574. var diids = groupInfos.Select(it => it.Id).ToList();
  17575. List<string> countrys = new List<string>();
  17576. foreach (var item in country)
  17577. {
  17578. var data = _groupRepository.FormartTeamName(item);
  17579. var dataArray = _groupRepository.GroupSplitCountry(data);
  17580. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17581. }
  17582. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17583. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17584. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17585. foreach (var item in areaItem)
  17586. {
  17587. string areaStr = item.Value;
  17588. if (!string.IsNullOrEmpty(areaStr))
  17589. {
  17590. string[] str1 = areaStr.Split("-");
  17591. if (str1.Length > 0)
  17592. {
  17593. areaArray.AddRange(str1);
  17594. }
  17595. }
  17596. }
  17597. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17598. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17599. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17600. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17601. .ToList();
  17602. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17603. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17604. .Where(it => countriesIds.Contains(it.Id))
  17605. .Select(it => new { it.Id, Name = it.Name_CN })
  17606. .ToList();
  17607. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17608. .Select(it => it.TeamName).ToList();
  17609. stopwatch.Stop();
  17610. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17611. }
  17612. ///// <summary>
  17613. ///// 匹配op行程单
  17614. ///// Init 查询区域数据
  17615. ///// </summary>
  17616. ///// <param name="dto">团组列表请求dto</param>
  17617. ///// <returns></returns>
  17618. //[HttpPost]
  17619. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17620. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17621. //{
  17622. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17623. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17624. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17625. // if (string.IsNullOrEmpty(countriesDataStr))
  17626. // {
  17627. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17628. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17629. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17630. // }
  17631. // else
  17632. // {
  17633. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17634. // }
  17635. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17636. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17637. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17638. // List<dynamic> childList = new List<dynamic>();
  17639. // int parentId = dto.CountriesId;
  17640. // if (provinceData.Count > 1)
  17641. // {
  17642. // foreach (var item1 in provinceData)
  17643. // {
  17644. // List<dynamic> childList1 = new List<dynamic>();
  17645. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17646. // foreach (var item2 in citiesData1)
  17647. // {
  17648. // List<dynamic> childList2 = new List<dynamic>();
  17649. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17650. // foreach (var item3 in countiesData1)
  17651. // {
  17652. // childList2.Add(new
  17653. // {
  17654. // id = item3.Id,
  17655. // parentId = item2.Id,
  17656. // level = "district",
  17657. // name = item3.Name_CN,
  17658. // });
  17659. // }
  17660. // childList1.Add(new
  17661. // {
  17662. // id = item2.Id,
  17663. // parentId = item1.Id,
  17664. // level = "city",
  17665. // name = item2.Name_CN,
  17666. // childList = childList2
  17667. // });
  17668. // }
  17669. // childList.Add(new
  17670. // {
  17671. // id = item1.Id,
  17672. // parentId = parentId,
  17673. // level = "province",
  17674. // name = item1.Name_CN,
  17675. // childList = childList1
  17676. // });
  17677. // }
  17678. // //城市
  17679. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17680. // foreach (var item2 in citiesData2)
  17681. // {
  17682. // List<dynamic> childList22 = new List<dynamic>();
  17683. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17684. // foreach (var item3 in countiesData1)
  17685. // {
  17686. // childList22.Add(new
  17687. // {
  17688. // id = item3.Id,
  17689. // parentId = item2.Id,
  17690. // level = "district",
  17691. // name = item3.Name_CN,
  17692. // });
  17693. // }
  17694. // childList.Add(new
  17695. // {
  17696. // id = item2.Id,
  17697. // parentId = parentId,
  17698. // level = "city",
  17699. // name = item2.Name_CN,
  17700. // childList = childList22
  17701. // });
  17702. // }
  17703. // }
  17704. // else
  17705. // {
  17706. // foreach (var item2 in citiesData)
  17707. // {
  17708. // string cname = item2.Name_CN;
  17709. // List<dynamic> childList1 = new List<dynamic>();
  17710. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17711. // foreach (var item3 in countiesData1)
  17712. // {
  17713. // childList1.Add(new
  17714. // {
  17715. // Id = item3.Id,
  17716. // parentId = item2.Id,
  17717. // level = "district",
  17718. // name = item3.Name_CN
  17719. // });
  17720. // }
  17721. // childList.Add(new
  17722. // {
  17723. // id = item2.Id,
  17724. // parentId = parentId,
  17725. // level = "city",
  17726. // name = item2.Name_CN,
  17727. // childList = childList1
  17728. // });
  17729. // }
  17730. // }
  17731. // stopwatch.Stop();
  17732. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17733. //}
  17734. /// <summary>
  17735. /// 匹配op行程单
  17736. /// 接团信息列表 Page
  17737. /// </summary>
  17738. /// <param name="dto">团组列表请求dto</param>
  17739. /// <returns></returns>
  17740. [HttpPost]
  17741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17742. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17743. {
  17744. var swatch = new Stopwatch();
  17745. swatch.Start();
  17746. #region 参数验证
  17747. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17748. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17749. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17750. #region 页面操作权限验证
  17751. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17752. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17753. #endregion
  17754. #endregion
  17755. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17756. {
  17757. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17758. //string sqlWhere = "";
  17759. if (!string.IsNullOrEmpty(dto.Country))
  17760. {
  17761. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17762. }
  17763. if (!string.IsNullOrEmpty(dto.Area))
  17764. {
  17765. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17766. }
  17767. if (!string.IsNullOrEmpty(dto.TeamName))
  17768. {
  17769. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17770. }
  17771. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17772. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17773. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17774. swatch.Stop();
  17775. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17776. }
  17777. else
  17778. {
  17779. return Ok(JsonView(false, "查询失败"));
  17780. }
  17781. }
  17782. /// <summary>
  17783. /// 匹配op行程单
  17784. /// 行程单下载
  17785. /// </summary>
  17786. /// <param name="dto">团组列表请求dto</param>
  17787. /// <returns></returns>
  17788. [HttpPost]
  17789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17790. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17791. {
  17792. #region 参数验证
  17793. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17794. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17795. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17796. #region 页面操作权限验证
  17797. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17798. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17799. #endregion
  17800. #endregion
  17801. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17802. {
  17803. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17804. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17805. }
  17806. else
  17807. {
  17808. return Ok(JsonView(false, "下载失败!"));
  17809. }
  17810. }
  17811. #endregion
  17812. #region 国家信息 数据 注释
  17813. //[HttpPost]
  17814. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17815. //{
  17816. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17817. // foreach (var item in dto)
  17818. // {
  17819. // infos.Add(new Grp_GroupsTaskAssignment()
  17820. // {
  17821. // DIId = item,
  17822. // CTId = 82,
  17823. // UId = 248,
  17824. // IsEnable = 1,
  17825. // CreateUserId = 233,
  17826. // CreateTime = DateTime.Now,
  17827. // IsDel = 0
  17828. // });
  17829. // infos.Add(new Grp_GroupsTaskAssignment()
  17830. // {
  17831. // DIId = item,
  17832. // CTId = 82,
  17833. // UId = 286,
  17834. // IsEnable = 1,
  17835. // CreateUserId = 233,
  17836. // CreateTime = DateTime.Now,
  17837. // IsDel = 0
  17838. // });
  17839. // }
  17840. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17841. // return Ok("操作成功");
  17842. //}
  17843. //public class paramJsonDto
  17844. //{
  17845. // public List<CountriesInfo> str { get; set; }
  17846. //}
  17847. //[HttpPost]
  17848. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17849. //{
  17850. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17851. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17852. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17853. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17854. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17855. // _sqlSugar.BeginTran();
  17856. // int countitiesIndex = 0;
  17857. // foreach (var item in dto.str)
  17858. // {
  17859. // dynamic data = item.c;
  17860. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17861. // if (data != null)
  17862. // {
  17863. // countitiesIndex++;
  17864. // foreach (var item1 in data)
  17865. // {
  17866. // string cnname = item1.cn;
  17867. // string enname = item1.en;
  17868. // Sys_Cities provinceInfo = new Sys_Cities()
  17869. // {
  17870. // CountriesId = countriesId,
  17871. // Name_CN = cnname,
  17872. // Name_EN = enname,
  17873. // ParentId = 0,
  17874. // IsCapital = 1,
  17875. // CreateUserId = 208,
  17876. // CreateTime = DateTime.Now,
  17877. // IsDel = 0
  17878. // };
  17879. // if (item1.lv == "province") //省份
  17880. // {
  17881. // provinceInfo.Level = 1;
  17882. // int provinceId = 0;
  17883. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17884. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17885. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17886. // var data1 = item1.c;
  17887. // foreach (var item2 in data1)
  17888. // {
  17889. // if (item2.lv == "city")
  17890. // {
  17891. // string citycnname = item2.cn;
  17892. // string cityenname = item2.en;
  17893. // Sys_Cities cityInfo = new Sys_Cities()
  17894. // {
  17895. // CountriesId = countriesId,
  17896. // ParentId = provinceId,
  17897. // Level = 2,
  17898. // Name_CN = citycnname,
  17899. // Name_EN = cityenname,
  17900. // IsCapital = 1,
  17901. // CreateUserId = 208,
  17902. // CreateTime = DateTime.Now,
  17903. // IsDel = 0
  17904. // };
  17905. // if (item2.c != null)
  17906. // {
  17907. // int cityId = 0;
  17908. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17909. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17910. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17911. // foreach (var item3 in item2.c)
  17912. // {
  17913. // if (item3.lv == "district")
  17914. // {
  17915. // var districtInfo = new Sys_Cities()
  17916. // {
  17917. // CountriesId = countriesId,
  17918. // Name_CN = item3.cn,
  17919. // Name_EN = item3.en,
  17920. // Level = 3,
  17921. // ParentId = cityId,
  17922. // IsCapital = 1,
  17923. // CreateUserId = 208,
  17924. // CreateTime = DateTime.Now,
  17925. // IsDel = 0
  17926. // };
  17927. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17928. // //{
  17929. // districts.Add(districtInfo);
  17930. // //}
  17931. // }
  17932. // }
  17933. // }
  17934. // else
  17935. // {
  17936. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17937. // //{
  17938. // cities.Add(cityInfo);
  17939. // //}
  17940. // }
  17941. // }
  17942. // }
  17943. // }
  17944. // else if (item1.lv == "city")//城市
  17945. // {
  17946. // provinceInfo.Level = 2;
  17947. // if (item1.c != null)
  17948. // {
  17949. // int cityId = 0;
  17950. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17951. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17952. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17953. // foreach (var item3 in item1.c)
  17954. // {
  17955. // if (item3.lv == "district")
  17956. // {
  17957. // var districtInfo = new Sys_Cities()
  17958. // {
  17959. // CountriesId = countriesId,
  17960. // Name_CN = item3.cn,
  17961. // Name_EN = item3.en,
  17962. // Level = 3,
  17963. // ParentId = cityId,
  17964. // IsCapital = 1,
  17965. // CreateUserId = 208,
  17966. // CreateTime = DateTime.Now,
  17967. // IsDel = 0
  17968. // };
  17969. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17970. // //{
  17971. // districts.Add(districtInfo);
  17972. // //}
  17973. // }
  17974. // }
  17975. // }
  17976. // else
  17977. // {
  17978. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17979. // //{
  17980. // cities.Add(provinceInfo);
  17981. // //}
  17982. // }
  17983. // }
  17984. // }
  17985. // }
  17986. // }
  17987. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17988. // cities = cities.Distinct().ToList();
  17989. // districts = districts.Distinct().ToList();
  17990. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17991. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17992. // cities.AddRange(districts);
  17993. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17994. // //_sqlSugar.RollbackTran();
  17995. // _sqlSugar.CommitTran();
  17996. // return Ok(JsonView(false, "操作成功!"));
  17997. //}
  17998. //[HttpPost]
  17999. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18000. //{
  18001. // List<CountitiesInfo> infos = dto.MyProperty;
  18002. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18003. // _sqlSugar.BeginTran();
  18004. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18005. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18006. // foreach (var item in infos)
  18007. // {
  18008. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18009. // if (countryInfo != null)
  18010. // {
  18011. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18012. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18013. // if (cityInfo1 != null)
  18014. // {
  18015. // cityInfo1.IsCapital = 0;
  18016. // cityInfos.Add(cityInfo1);
  18017. // }
  18018. // }
  18019. // }
  18020. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18021. // .UpdateColumns(it => it.IsCapital)
  18022. // .WhereColumns(it => it.Id)
  18023. // .ExecuteCommand();
  18024. // //_sqlSugar.RollbackTran();
  18025. // _sqlSugar.CommitTran();
  18026. // return Ok(JsonView(false, "操作成功!"));
  18027. //}
  18028. //public class CounrtiesDto
  18029. //{
  18030. // public List<CountitiesInfo> MyProperty { get; set; }
  18031. //}
  18032. //public class CountitiesInfo
  18033. //{
  18034. // /// <summary>
  18035. // /// 圣约翰
  18036. // /// </summary>
  18037. // public string capital_name_chinese { get; set; }
  18038. // /// <summary>
  18039. // ///
  18040. // /// </summary>
  18041. // public string capital_name { get; set; }
  18042. // /// <summary>
  18043. // ///
  18044. // /// </summary>
  18045. // public string country_type { get; set; }
  18046. // /// <summary>
  18047. // /// 安提瓜和巴布达
  18048. // /// </summary>
  18049. // public string country_name_chinese { get; set; }
  18050. // /// <summary>
  18051. // /// 安提瓜和巴布达
  18052. // /// </summary>
  18053. // public string country_name_chinese_short { get; set; }
  18054. // /// <summary>
  18055. // /// 安提瓜和巴布达
  18056. // /// </summary>
  18057. // public string country_name_chinese_UN { get; set; }
  18058. // /// <summary>
  18059. // ///
  18060. // /// </summary>
  18061. // public string country_name_english_abbreviation { get; set; }
  18062. // /// <summary>
  18063. // ///
  18064. // /// </summary>
  18065. // public string country_name_english_formal { get; set; }
  18066. // /// <summary>
  18067. // ///
  18068. // /// </summary>
  18069. // public string country_name_english_UN { get; set; }
  18070. // /// <summary>
  18071. // ///
  18072. // /// </summary>
  18073. // public string continent_name { get; set; }
  18074. // /// <summary>
  18075. // ///
  18076. // /// </summary>
  18077. // public string subregion_name { get; set; }
  18078. // /// <summary>
  18079. // ///
  18080. // /// </summary>
  18081. // public string country_code2 { get; set; }
  18082. // /// <summary>
  18083. // ///
  18084. // /// </summary>
  18085. // public string country_code3 { get; set; }
  18086. // /// <summary>
  18087. // ///
  18088. // /// </summary>
  18089. // public string phone_code { get; set; }
  18090. //}
  18091. //public class CountriesInfo : BasicInfo
  18092. //{
  18093. // public List<CitiesInfo> c { get; set; }
  18094. //}
  18095. //public class CitiesInfo : BasicInfo
  18096. //{
  18097. // public List<AreaInfo> c { get; set; }
  18098. //}
  18099. //public class AreaInfo : BasicInfo
  18100. //{
  18101. // public List<AreaInfo> c { get; set; }
  18102. //}
  18103. //public class BasicInfo
  18104. //{
  18105. // public string code { get; set; }
  18106. // public string cn { get; set; }
  18107. // public string lv { get; set; }
  18108. // public string en { get; set; }
  18109. //}
  18110. #endregion
  18111. #region 查看邀请方
  18112. /// <summary>
  18113. /// 查看邀请方
  18114. /// 邀请方信息 Init
  18115. /// </summary>
  18116. /// <param name="dto"></param>
  18117. /// <returns></returns>
  18118. [HttpPost]
  18119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18120. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18121. {
  18122. string sqlWhere = string.Empty;
  18123. if (!string.IsNullOrEmpty(dto.Search))
  18124. {
  18125. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18126. }
  18127. string sql = string.Format($@"Select
  18128. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18129. Id,
  18130. UnitName
  18131. From Res_InvitationOfficialActivityData
  18132. Where IsDel = 0
  18133. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18134. RefAsync<int> total = 0;
  18135. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18136. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18137. }
  18138. /// <summary>
  18139. /// 查看邀请方
  18140. /// 国家信息 Init
  18141. /// </summary>
  18142. /// <param name="dto"></param>
  18143. /// <returns></returns>
  18144. [HttpPost]
  18145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18146. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18147. {
  18148. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18149. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18150. var diids = groupInfos.Select(it => it.Id).ToList();
  18151. List<string> countrys = new List<string>();
  18152. foreach (var item in country)
  18153. {
  18154. var data = _groupRepository.FormartTeamName(item);
  18155. var dataArray = _groupRepository.GroupSplitCountry(data);
  18156. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18157. }
  18158. countrys = countrys.Distinct().ToList();
  18159. for (int i = 0; i < countrys.Count; i++)
  18160. {
  18161. string item = countrys[i];
  18162. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18163. {
  18164. countrys.Remove(item);
  18165. i--;
  18166. }
  18167. }
  18168. RefAsync<int> total = 0;
  18169. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18170. .Where(it => countrys.Contains(it.Name_CN))
  18171. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18172. .Select(it => new { id = it.Id, name = it.Name_CN })
  18173. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18174. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18175. }
  18176. /// <summary>
  18177. /// 查看邀请方
  18178. /// 城市信息 Init
  18179. /// </summary>
  18180. /// <param name="dto"></param>
  18181. /// <returns></returns>
  18182. [HttpPost]
  18183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18184. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18185. {
  18186. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18187. RefAsync<int> total = 0;
  18188. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18189. .Where(it => it.CountriesId == dto.CountiesId)
  18190. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18191. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18192. .Select(it => new { id = it.Id, name = it.Name_CN })
  18193. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18194. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18195. }
  18196. /// <summary>
  18197. /// 查看邀请方
  18198. /// 团组名称 Init
  18199. /// </summary>
  18200. /// <param name="dto"></param>
  18201. /// <returns></returns>
  18202. [HttpPost]
  18203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18204. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18205. {
  18206. var watch = new Stopwatch();
  18207. watch.Start();
  18208. RefAsync<int> total = 0;
  18209. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18210. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18211. .Where((oa, di) => oa.IsDel == 0)
  18212. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18213. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18214. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18215. .Distinct()
  18216. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18217. watch.Stop();
  18218. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18219. }
  18220. /// <summary>
  18221. /// 查看邀请方
  18222. /// 团组 & 邀请方信息
  18223. /// </summary>
  18224. /// <param name="dto"></param>
  18225. /// <returns></returns>
  18226. [HttpPost]
  18227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18228. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18229. {
  18230. var watch = new Stopwatch();
  18231. watch.Start();
  18232. RefAsync<int> total = 0;
  18233. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18234. .AS("Grp_DelegationInfo")
  18235. .Includes(x => x.InvitingInfos)
  18236. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18237. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18238. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18239. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18240. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18241. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18242. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18243. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18244. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18245. infos.ForEach(x =>
  18246. {
  18247. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18248. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18249. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18250. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18251. });
  18252. watch.Stop();
  18253. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18254. }
  18255. #endregion
  18256. #region 报批行程
  18257. /// <summary>
  18258. /// 报批行程初始化
  18259. /// </summary>
  18260. /// <param name="dto"></param>
  18261. /// <returns></returns>
  18262. [HttpPost]
  18263. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18264. {
  18265. const int chiNumber = 5;
  18266. var jw = JsonView(false);
  18267. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18268. var group = groupList.First();
  18269. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18270. group = groupList.First(x => x.Id == diid);
  18271. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18272. .Where(x => x.DiId == diid && x.IsDel == 0)
  18273. .ToArray();
  18274. var count = 1;
  18275. foreach (var item in blackCodeList)
  18276. {
  18277. if (string.IsNullOrWhiteSpace(item.Title))
  18278. {
  18279. item.Title = "未设置名称数据" + count;
  18280. }
  18281. count++;
  18282. };
  18283. if (group == null)
  18284. {
  18285. jw.Msg = "暂无团组!";
  18286. return Ok(jw);
  18287. }
  18288. var data = new
  18289. {
  18290. groupList = groupList.Select(x => new
  18291. {
  18292. x.TeamName,
  18293. x.Id
  18294. }),
  18295. content = new ArrayList(),
  18296. groupInfo = new
  18297. {
  18298. group.VisitDays,
  18299. group.TourCode,
  18300. group.VisitPNumber,
  18301. group.TeamName,
  18302. group.Id,
  18303. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18304. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18305. },
  18306. blackCodeList = blackCodeList.Select(x => new
  18307. {
  18308. x.Title,
  18309. x.Id
  18310. }),
  18311. FileTempList = new ArrayList()
  18312. {
  18313. new { Index = 1,FileName = "旧模板" },
  18314. new { Index = 2,FileName = "省外办" },
  18315. new { Index = 3,FileName = "市外办" },
  18316. }
  18317. };
  18318. var resultArr = new ArrayList();
  18319. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18320. #region 默认不生成行程
  18321. //if (content.Count == 0)
  18322. //{
  18323. // var stay = "-";
  18324. // var cityPath = "-";
  18325. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18326. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18327. // .ToList();
  18328. // //添加城市路径以及住宿地
  18329. // //黑屏代码数据
  18330. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18331. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18332. // {
  18333. // jw = JsonView(true, "黑屏代码有误!", data);
  18334. // return Ok(jw);
  18335. // }
  18336. // data = data with
  18337. // {
  18338. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18339. // {
  18340. // x.Title,
  18341. // x.Id,
  18342. // }).ToArray())
  18343. // };
  18344. // foreach (DataRow row in dtBlack.Rows)
  18345. // {
  18346. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18347. // {
  18348. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18349. // return Ok(jw);
  18350. // }
  18351. // }
  18352. // //黑屏代码获取时间区间
  18353. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18354. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18355. // _sqlSugar.BeginTran();
  18356. // for (int i = 0; i < timeArr.Count; i++)
  18357. // {
  18358. // stay = "-";
  18359. // cityPath = "-";
  18360. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18361. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18362. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18363. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18364. // if (tbSelect.Length > 0)
  18365. // {
  18366. // List<string> threeCodeStr = new List<string>();
  18367. // foreach (var item in tbSelect)
  18368. // {
  18369. // var threeCode = item["Three"].ToString() ?? "";
  18370. // if (threeCode.Length == 6)
  18371. // {
  18372. // var start = threeCode.Substring(0, 3);
  18373. // var end = threeCode.Substring(3, 3);
  18374. // if (threeCodeStr.Count == 0)
  18375. // {
  18376. // threeCodeStr.Add(start);
  18377. // threeCodeStr.Add(end);
  18378. // }
  18379. // else
  18380. // {
  18381. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18382. // {
  18383. // threeCodeStr.Add(end);
  18384. // }
  18385. // else
  18386. // {
  18387. // threeCodeStr.Add(start);
  18388. // threeCodeStr.Add(end);
  18389. // }
  18390. // }
  18391. // }
  18392. // }
  18393. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18394. // var last = threeCodeStr.Last();
  18395. // foreach (var item in threeCodeStr)
  18396. // {
  18397. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18398. // if (item.Equals(last))
  18399. // {
  18400. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18401. // }
  18402. // }
  18403. // cityPath = cityPath.Trim('-');
  18404. // }
  18405. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18406. // appro.Diid = diid ?? -1;
  18407. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18408. // appro.Id = thisId;
  18409. // appro.CreateUserId = dto.UserId;
  18410. // appro.CreateTime = DateTime.Now;
  18411. // content.Add(appro);
  18412. // }
  18413. // _sqlSugar.CommitTran();
  18414. //}
  18415. #endregion
  18416. foreach (var x in content)
  18417. {
  18418. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18419. if (chiList.Count < chiNumber)
  18420. {
  18421. for (int i = chiList.Count; i < chiNumber; i++)
  18422. {
  18423. chiList.Add(new Grp_ApprovalTravelDetails());
  18424. }
  18425. }
  18426. resultArr.Add(new
  18427. {
  18428. x.Id,
  18429. x.Date,
  18430. x.Diid,
  18431. chiList = chiList.Select(x1 => new
  18432. {
  18433. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18434. x1.Details,
  18435. x1.ParentId,
  18436. x1.Id
  18437. })
  18438. });
  18439. }
  18440. data = data with
  18441. {
  18442. content = resultArr,
  18443. };
  18444. jw = JsonView(true, "获取成功!", data);
  18445. return Ok(jw);
  18446. }
  18447. /// <summary>
  18448. /// 报批行程删除
  18449. /// </summary>
  18450. /// <param name="dto"></param>
  18451. /// <returns></returns>
  18452. [HttpPost]
  18453. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18454. {
  18455. var jw = JsonView(false);
  18456. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18457. if (group == null)
  18458. {
  18459. jw.Msg = "团组参数有误!";
  18460. return Ok(jw);
  18461. }
  18462. try
  18463. {
  18464. _sqlSugar.BeginTran();
  18465. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18466. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18467. {
  18468. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18469. DeleteUserId = dto.uesrId,
  18470. IsDel = 1
  18471. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18472. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18473. {
  18474. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18475. DeleteUserId = dto.uesrId,
  18476. IsDel = 1
  18477. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18478. _sqlSugar.CommitTran();
  18479. jw = JsonView(true, "删除成功");
  18480. }
  18481. catch (Exception ex)
  18482. {
  18483. jw = JsonView(false, ex.Message);
  18484. }
  18485. return Ok(jw);
  18486. }
  18487. /// <summary>
  18488. /// 报批行程保存
  18489. /// </summary>
  18490. /// <param name="dto"></param>
  18491. /// <returns></returns>
  18492. [HttpPost]
  18493. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18494. {
  18495. var jw = JsonView(false);
  18496. var Find = dto.Arr.Find(x => x.id == 0);
  18497. if (Find != null)
  18498. {
  18499. jw.Msg = "生成的ID为0!";
  18500. return Ok(jw);
  18501. }
  18502. foreach (var item in dto.Arr)
  18503. {
  18504. foreach (var chi in item.chiList)
  18505. {
  18506. if (chi.parentId == 0)
  18507. {
  18508. chi.parentId = item.id;
  18509. }
  18510. }
  18511. }
  18512. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18513. _sqlSugar.BeginTran();
  18514. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18515. {
  18516. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18517. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18518. {
  18519. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18520. DeleteUserId = dto.UserId,
  18521. IsDel = 1
  18522. }).ExecuteCommand();
  18523. }
  18524. try
  18525. {
  18526. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18527. {
  18528. CreateTime = DateTime.Now,
  18529. CreateUserId = dto.UserId,
  18530. Details = x.details,
  18531. ParentId = x.parentId,
  18532. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18533. Remark = "",
  18534. IsDel = 0
  18535. }).ToList()).ExecuteCommand();
  18536. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18537. {
  18538. Id = x.id,
  18539. Details = x.details,
  18540. ParentId = x.parentId,
  18541. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18542. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18543. {
  18544. Details = x.Details,
  18545. ParentId = x.ParentId,
  18546. Time = x.Time
  18547. }).ExecuteCommand();
  18548. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18549. {
  18550. Id = x.id,
  18551. Date = x.date,
  18552. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18553. {
  18554. Date = x.Date
  18555. }).ExecuteCommand();
  18556. _sqlSugar.CommitTran();
  18557. jw = JsonView(true, "保存成功!");
  18558. }
  18559. catch (Exception ex)
  18560. {
  18561. _sqlSugar.RollbackTran();
  18562. jw = JsonView(false, "保存失败!" + ex.Message);
  18563. }
  18564. return Ok(jw);
  18565. }
  18566. /// <summary>
  18567. /// 报批行程生成
  18568. /// </summary>
  18569. /// <param name="dto"></param>
  18570. /// <returns></returns>
  18571. [HttpPost]
  18572. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18573. {
  18574. var jw = JsonView(false);
  18575. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18576. if (group == null)
  18577. {
  18578. jw.Msg = "暂无该团组!";
  18579. return Ok(jw);
  18580. }
  18581. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18582. //黑屏代码数据
  18583. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18584. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18585. {
  18586. jw.Msg = "黑屏代码有误!";
  18587. return Ok(jw);
  18588. }
  18589. foreach (DataRow row in dtBlack.Rows)
  18590. {
  18591. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18592. {
  18593. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18594. return Ok(jw);
  18595. }
  18596. }
  18597. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18598. var resultArr = new ArrayList();
  18599. //if (officialActivitiesArr.Count == 0)
  18600. //{
  18601. // jw.Msg = "暂无公务出访信息!";
  18602. // return Ok(jw);
  18603. //}
  18604. try
  18605. {
  18606. _sqlSugar.BeginTran();
  18607. DeleteApprovalJourney(new
  18608. Domain.Dtos.Groups.DeleteApprovalJourney
  18609. {
  18610. Diid = dto.Diid,
  18611. uesrId = dto.Userid
  18612. });
  18613. var stay = "-";
  18614. var cityPath = "-";
  18615. var arriveCountry = string.Empty;
  18616. //添加城市路径以及住宿地
  18617. //黑屏代码获取时间区间
  18618. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18619. var empty = "【未收入该三字码!请机票同事录入】";
  18620. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18621. #region 配置公务活动时间
  18622. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18623. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18624. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18625. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18626. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18627. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  18628. {
  18629. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  18630. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  18631. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  18632. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  18633. };
  18634. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  18635. {
  18636. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  18637. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  18638. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  18639. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  18640. };
  18641. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  18642. {
  18643. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  18644. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  18645. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  18646. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  18647. };
  18648. #endregion
  18649. var nextDayNum = 0;
  18650. for (int i = 0; i < timeArr.Count; i++)
  18651. {
  18652. stay = "-";
  18653. cityPath = "-";
  18654. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18655. DateTime NewData = DateTime.Parse(timeArr[i]);
  18656. //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();
  18657. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18658. if (nextDayNum > 0)
  18659. {
  18660. nextDayNum--;
  18661. }
  18662. if (tbSelect.Length > 0)
  18663. {
  18664. List<string> threeCodeStr = new List<string>();
  18665. bool isTrade = false;
  18666. string trip = string.Empty;
  18667. foreach (var item in tbSelect)
  18668. {
  18669. if (nextDayNum == 0)
  18670. {
  18671. nextDayNum = Convert.ToInt32(item["Sign"]);
  18672. }
  18673. var airStartTime = item["StartTime"].ToString() ?? "0000";
  18674. var airEndTime = item["EndTime"].ToString() ?? "0000";
  18675. var takeOffTime = DateTime.Parse(timeArr[i]);
  18676. var fallToTime = DateTime.Parse(timeArr[i]);
  18677. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18678. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18679. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18680. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18681. if (nextDayNum > 0)
  18682. {
  18683. fallToTime = fallToTime.AddDays(nextDayNum);
  18684. }
  18685. trip = string.Empty;
  18686. var start = string.Empty;
  18687. var end = string.Empty;
  18688. var threeCode = item["Three"].ToString() ?? "";
  18689. if (threeCode.Length == 6)
  18690. {
  18691. start = threeCode.Substring(0, 3);
  18692. end = threeCode.Substring(3, 3);
  18693. if (threeCodeStr.Count == 0)
  18694. {
  18695. threeCodeStr.Add(start);
  18696. threeCodeStr.Add(end);
  18697. }
  18698. else
  18699. {
  18700. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18701. {
  18702. threeCodeStr.Add(end);
  18703. }
  18704. else
  18705. {
  18706. threeCodeStr.Add(start);
  18707. threeCodeStr.Add(end);
  18708. }
  18709. }
  18710. }
  18711. //处理机票信息
  18712. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18713. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18714. if (start_Object == null)
  18715. {
  18716. start_Object = new Res_ThreeCode()
  18717. {
  18718. AirPort = empty,
  18719. AirPort_En = empty,
  18720. City = empty,
  18721. Country = empty,
  18722. Four = empty,
  18723. Three = empty,
  18724. };
  18725. }
  18726. if (end_Object == null)
  18727. {
  18728. end_Object = new Res_ThreeCode()
  18729. {
  18730. AirPort = empty,
  18731. AirPort_En = empty,
  18732. City = empty,
  18733. Country = empty,
  18734. Four = empty,
  18735. Three = empty,
  18736. };
  18737. }
  18738. //机型判断
  18739. string airModel = item["AirModel"].ToString();
  18740. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18741. string flightTime = item["FlightTime"].ToString();
  18742. flightTime = ParseBlackTime(flightTime);
  18743. //航班号
  18744. string flightcode = item["Fliagtcode"].ToString();
  18745. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18746. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18747. if (aircompany == null)
  18748. {
  18749. aircompany = new Res_AirCompany
  18750. {
  18751. CnName = hsEmpty,
  18752. EnName = hsEmpty,
  18753. ShortCode = hsEmpty,
  18754. };
  18755. }
  18756. //航班前公务安排
  18757. if (tbSelect.First().Equals(item) && i != 0)
  18758. {
  18759. foreach (var takeoff in takeoffTimes)
  18760. {
  18761. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  18762. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  18763. {
  18764. foreach (var addTime in takeoff.Item2)
  18765. {
  18766. chiarr.Add(new Grp_ApprovalTravelDetails
  18767. {
  18768. Time = addTime,
  18769. CreateTime = DateTime.Now,
  18770. CreateUserId = dto.Userid,
  18771. ParentId = 0,
  18772. Details = "公务活动"
  18773. });
  18774. }
  18775. break;
  18776. }
  18777. }
  18778. }
  18779. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18780. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18781. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  18782. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  18783. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18784. if (isTrade)
  18785. {
  18786. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18787. trip += "(转机不出机场)。";
  18788. }
  18789. //else
  18790. //{
  18791. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18792. //}
  18793. chiarr.Add(new Grp_ApprovalTravelDetails
  18794. {
  18795. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18796. CreateTime = DateTime.Now,
  18797. CreateUserId = dto.Userid,
  18798. ParentId = 0,
  18799. Details = trip
  18800. });
  18801. //最后一条到达的时间安排公务
  18802. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  18803. {
  18804. bool isCheckCountry = false;
  18805. if (end_Object.Country != arriveCountry)
  18806. {
  18807. arriveCountry = end_Object.Country;
  18808. isCheckCountry = true;
  18809. }
  18810. if (nextDayNum == 0)
  18811. {
  18812. //需要入境的情况
  18813. if (isCheckCountry)
  18814. {
  18815. foreach (var fallTime in fallTimesCheckCountry)
  18816. {
  18817. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  18818. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  18819. {
  18820. foreach (var addTime in fallTime.Item2)
  18821. {
  18822. chiarr.Add(new Grp_ApprovalTravelDetails
  18823. {
  18824. Time = addTime,
  18825. CreateTime = DateTime.Now,
  18826. CreateUserId = dto.Userid,
  18827. ParentId = 0,
  18828. Details = "公务活动"
  18829. });
  18830. }
  18831. break;
  18832. }
  18833. }
  18834. }
  18835. else
  18836. {
  18837. foreach (var fallTime in fallTimesNotCheckCountry)
  18838. {
  18839. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  18840. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  18841. {
  18842. foreach (var addTime in fallTime.Item2)
  18843. {
  18844. chiarr.Add(new Grp_ApprovalTravelDetails
  18845. {
  18846. Time = addTime,
  18847. CreateTime = DateTime.Now,
  18848. CreateUserId = dto.Userid,
  18849. ParentId = 0,
  18850. Details = "公务活动"
  18851. });
  18852. }
  18853. break;
  18854. }
  18855. }
  18856. }
  18857. }
  18858. }
  18859. }
  18860. //添加乘车语句
  18861. //chiarr.Add(new Grp_ApprovalTravelDetails
  18862. //{
  18863. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18864. // CreateTime = DateTime.Now,
  18865. // CreateUserId = dto.Userid,
  18866. // ParentId = 0,
  18867. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18868. //});
  18869. //if (i != timeArr.Count - 1)
  18870. //{
  18871. // fallToTime = fallToTime.AddHours(2.5);
  18872. // foreach (var item in Times)
  18873. // {
  18874. // //排列公务时间
  18875. // if (fallToTime.Hour < item.Item1)
  18876. // {
  18877. // chiarr.Add(new Grp_ApprovalTravelDetails
  18878. // {
  18879. // Time = $"{item.Item2} - {item.Item3}",
  18880. // CreateTime = DateTime.Now,
  18881. // CreateUserId = dto.Userid,
  18882. // ParentId = 0,
  18883. // Details = "公务活动"
  18884. // });
  18885. // }
  18886. // }
  18887. //}
  18888. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18889. var last = threeCodeStr.Last();
  18890. foreach (var item in threeCodeStr)
  18891. {
  18892. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18893. if (item.Equals(last))
  18894. {
  18895. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18896. }
  18897. }
  18898. cityPath = cityPath.Trim('-');
  18899. }
  18900. else
  18901. {
  18902. foreach (var item in Times)
  18903. {
  18904. chiarr.Add(new Grp_ApprovalTravelDetails
  18905. {
  18906. Time = $"{item.Item2} - {item.Item3}",
  18907. CreateTime = DateTime.Now,
  18908. CreateUserId = dto.Userid,
  18909. ParentId = 0,
  18910. Details = "公务活动"
  18911. });
  18912. }
  18913. }
  18914. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18915. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18916. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  18917. appro.Diid = dto.Diid;
  18918. appro.CreateUserId = dto.Userid;
  18919. appro.CreateTime = DateTime.Now;
  18920. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18921. appro.Id = thisId;
  18922. //foreach (var item in gwinfo)
  18923. //{
  18924. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18925. // chi.Details = "拜访" + item.Client;
  18926. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18927. // {
  18928. // chi.Details += "," + item.ReqSample;
  18929. // }
  18930. // chi.ParentId = thisId;
  18931. // chi.Time = item.Time;
  18932. // chiarr.Add(chi);
  18933. //}
  18934. if (chiarr.Count < 6)
  18935. {
  18936. for (int j = chiarr.Count; j < 6; j++)
  18937. {
  18938. chiarr.Add(new
  18939. Grp_ApprovalTravelDetails());
  18940. }
  18941. }
  18942. resultArr.Add(new
  18943. {
  18944. appro.Id,
  18945. appro.Date,
  18946. appro.Diid,
  18947. chiList = chiarr.Select(x1 => new
  18948. {
  18949. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18950. x1.Details,
  18951. x1.ParentId,
  18952. x1.Id
  18953. })
  18954. });
  18955. }
  18956. _sqlSugar.CommitTran();
  18957. jw = JsonView(true, "生成成功!", resultArr);
  18958. }
  18959. catch (Exception ex)
  18960. {
  18961. jw.Code = 400;
  18962. jw.Msg = "生成失败!" + ex.Message;
  18963. }
  18964. return Ok(jw);
  18965. }
  18966. /// <summary>
  18967. /// 报批行程word导出
  18968. /// </summary>
  18969. /// <param name="dto"></param>
  18970. /// <returns></returns>
  18971. [HttpPost]
  18972. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18973. {
  18974. var jw = JsonView(false);
  18975. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18976. if (group == null)
  18977. {
  18978. jw.Msg = "暂无该团组!";
  18979. return Ok(jw);
  18980. }
  18981. //模板路径
  18982. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  18983. var fileName = string.Empty;
  18984. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  18985. bool bold = false;
  18986. if (dto.FileIndex == 1)
  18987. {
  18988. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18989. }
  18990. else if (dto.FileIndex == 2)
  18991. {
  18992. fileName = "省外办-报批.docx";
  18993. bold = false;
  18994. titleFont = "方正黑体简体";
  18995. timeFont = "Times New Roman";
  18996. contentFont = "方正仿宋_GBK";
  18997. }
  18998. else if (dto.FileIndex == 3)
  18999. {
  19000. fileName = "市外办-报批.docx";
  19001. titleFont = "方正黑体简体";
  19002. timeFont = "Times New Roman";
  19003. contentFont = "方正仿宋简体";
  19004. }
  19005. tempPath = tempPath + fileName;
  19006. //载入模板
  19007. Document doc = new Document(tempPath);
  19008. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19009. //获取所填表格的序数
  19010. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19011. Aspose.Words.Tables.Row titleRowClone = null;
  19012. Aspose.Words.Tables.Row CenterRowClone = null;
  19013. int index = 0;
  19014. int indexChi = 0;
  19015. int SetIndex = 0;
  19016. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  19017. //获取数据,放到datatable
  19018. foreach (var item in ApprovalTravelArr)
  19019. {
  19020. if (index > 0)
  19021. {
  19022. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  19023. tableOne.AppendChild(titleRowClone);
  19024. }
  19025. var textTime = item.Date;
  19026. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  19027. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  19028. SetIndex++;
  19029. if (ChiRep.Count > 0)
  19030. {
  19031. foreach (var itemChi in ChiRep)
  19032. {
  19033. var txtTime = itemChi.Time;
  19034. var txtDetail = itemChi.Details;
  19035. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  19036. {
  19037. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  19038. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19039. //indexChi++;
  19040. //SetIndex++;
  19041. break;
  19042. }
  19043. if (indexChi > 0)
  19044. {
  19045. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19046. tableOne.AppendChild(CenterRowClone);
  19047. }
  19048. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  19049. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  19050. indexChi++;
  19051. SetIndex++;
  19052. }
  19053. }
  19054. //else
  19055. //{
  19056. // if (indexChi > 0)
  19057. // {
  19058. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19059. // tableOne.AppendChild(CenterRowClone);
  19060. // }
  19061. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  19062. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19063. // indexChi++;
  19064. // SetIndex++;
  19065. //}
  19066. index++;
  19067. }
  19068. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  19069. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19070. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19071. jw.Code = 200;
  19072. jw.Msg = "";
  19073. return Ok(jw);
  19074. }
  19075. private string ParseBlackTime(string time)
  19076. {
  19077. // 匹配可能只有分钟的情况
  19078. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  19079. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  19080. if (match.Success)
  19081. {
  19082. string hours = match.Groups[1].Value;
  19083. string minutes = match.Groups[2].Value;
  19084. // 如果小时部分为空,则只显示分钟
  19085. if (string.IsNullOrEmpty(hours))
  19086. {
  19087. return $"{minutes}分钟";
  19088. }
  19089. // 如果分钟部分为空,则只显示小时
  19090. else if (string.IsNullOrEmpty(minutes))
  19091. {
  19092. return $"{hours}小时";
  19093. }
  19094. // 否则显示完整格式
  19095. else
  19096. {
  19097. return $"{hours}小时{minutes}分钟";
  19098. }
  19099. }
  19100. else
  19101. {
  19102. return "未知时长";
  19103. }
  19104. }
  19105. private string intToString(int numberVal)
  19106. {
  19107. string numberval = numberVal.ToString();
  19108. Dictionary<char, string> Number = new Dictionary<char, string>();
  19109. Number.Add('1', "一");
  19110. Number.Add('2', "二");
  19111. Number.Add('3', "三");
  19112. Number.Add('4', "四");
  19113. Number.Add('5', "五");
  19114. Number.Add('6', "六");
  19115. Number.Add('7', "七");
  19116. Number.Add('8', "八");
  19117. Number.Add('9', "九");
  19118. string stringNumberVal = string.Empty;
  19119. for (int i = 0; i < numberval.Length; i++)
  19120. {
  19121. if (i == 0)
  19122. {
  19123. stringNumberVal += Number[numberval[i]];
  19124. }
  19125. else if (i >= 1)
  19126. {
  19127. if (numberval[i] == '0')
  19128. {
  19129. stringNumberVal = "十";
  19130. }
  19131. else
  19132. {
  19133. stringNumberVal += "十" + Number[numberval[i]];
  19134. }
  19135. }
  19136. }
  19137. return stringNumberVal;
  19138. }
  19139. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  19140. {
  19141. //获取table中的某个单元格,从0开始
  19142. Cell lshCell = table.Rows[rows].Cells[cells];
  19143. //将单元格中段落移除
  19144. foreach (Paragraph item in lshCell.Paragraphs)
  19145. {
  19146. lshCell.Paragraphs.Remove(item);
  19147. }
  19148. if (val.Contains("\r\n"))
  19149. {
  19150. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19151. foreach (var item in spArr)
  19152. {
  19153. //新建一个段落
  19154. Paragraph p = new Paragraph(doc);
  19155. var r = new Run(doc, item);
  19156. //设置字体
  19157. if (!string.IsNullOrEmpty(font))
  19158. {
  19159. r.Font.Name = font;
  19160. }
  19161. r.Font.Bold = bold;
  19162. //把设置的值赋给之前新建的段落
  19163. p.AppendChild(r);
  19164. //将此段落加到单元格内
  19165. lshCell.AppendChild(p);
  19166. }
  19167. }
  19168. else
  19169. {
  19170. //新建一个段落
  19171. Paragraph p = new Paragraph(doc);
  19172. var r = new Run(doc, val);
  19173. //设置字体
  19174. if (!string.IsNullOrEmpty(font))
  19175. {
  19176. r.Font.Name = font;
  19177. }
  19178. r.Font.Bold = bold;
  19179. //把设置的值赋给之前新建的段落
  19180. p.AppendChild(r);
  19181. //将此段落加到单元格内
  19182. lshCell.AppendChild(p);
  19183. }
  19184. }
  19185. [HttpPost]
  19186. public async Task<IActionResult> ServerHttp(string paramStr)
  19187. {
  19188. paramStr = paramStr.TrimEnd('\'');
  19189. paramStr = paramStr.TrimStart('\'');
  19190. JsonView jw = JsonView(false);
  19191. JObject param = JObject.Parse(paramStr);
  19192. if (!param.ContainsKey("url"))
  19193. {
  19194. jw.Msg = "url null";
  19195. return Ok(jw);
  19196. }
  19197. string url = param["url"]!.ToString();
  19198. var methon = "get";
  19199. Dictionary<string, string> headValues = null;
  19200. string bodyStr = string.Empty;
  19201. if (param.ContainsKey("methon"))
  19202. {
  19203. methon = param["methon"]!.ToString().ToLower();
  19204. }
  19205. if (param.ContainsKey("header"))
  19206. {
  19207. var header = param["header"]!.ToString();
  19208. JObject headerJobject = JObject.Parse(header);
  19209. headValues = new Dictionary<string, string>();
  19210. foreach (JProperty item in headerJobject.Properties())
  19211. {
  19212. var value = item.Value.ToString();
  19213. var head = item.Path;
  19214. headValues.Add(head, value);
  19215. }
  19216. }
  19217. HttpClient client = new HttpClient();
  19218. string responseString = string.Empty;
  19219. StringContent content = null;
  19220. if (headValues != null)
  19221. {
  19222. foreach (var item in headValues.Keys)
  19223. {
  19224. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19225. {
  19226. if (param.ContainsKey("body"))
  19227. {
  19228. bodyStr = param["body"]!.ToString();
  19229. }
  19230. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19231. }
  19232. else
  19233. {
  19234. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19235. }
  19236. }
  19237. }
  19238. try
  19239. {
  19240. if (methon == "get")
  19241. {
  19242. responseString = await client.GetStringAsync(url);
  19243. }
  19244. else if (methon == "post")
  19245. {
  19246. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19247. {
  19248. Content = content
  19249. };
  19250. var response = await client.SendAsync(request);
  19251. try
  19252. {
  19253. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19254. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19255. {
  19256. using (StreamReader reader = new StreamReader(gzipStream))
  19257. {
  19258. responseString = await reader.ReadToEndAsync();
  19259. }
  19260. }
  19261. }
  19262. catch (Exception)
  19263. {
  19264. responseString = await response.Content.ReadAsStringAsync();
  19265. }
  19266. }
  19267. else
  19268. {
  19269. responseString = "methon error";
  19270. }
  19271. jw = JsonView(true, "success", responseString);
  19272. }
  19273. catch (Exception ex)
  19274. {
  19275. jw.Msg = "error " + ex.Message;
  19276. jw.Data = ex.StackTrace;
  19277. }
  19278. finally
  19279. {
  19280. client.Dispose();
  19281. }
  19282. return Ok(jw);
  19283. }
  19284. #endregion
  19285. #region 团组接待意见调查
  19286. /// <summary>
  19287. /// 团组接待意见调查 - 信息管理
  19288. /// 基础数据(团组)
  19289. /// </summary>
  19290. /// <returns></returns>
  19291. [HttpGet]
  19292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19293. public async Task<IActionResult> OpinionaireInit()
  19294. {
  19295. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19296. .Select(x => new
  19297. {
  19298. x.Id,
  19299. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19300. })
  19301. .OrderByDescending(x => x.Id)
  19302. .ToListAsync();
  19303. return Ok(JsonView(groupData, groupData.Count));
  19304. }
  19305. /// <summary>
  19306. /// 团组接待意见调查 - 信息管理
  19307. /// 列表
  19308. /// </summary>
  19309. /// <param name="groupId"></param>
  19310. /// <returns></returns>
  19311. [HttpGet("{groupId}")]
  19312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19313. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19314. {
  19315. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19316. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19317. .Select(x => new
  19318. {
  19319. x.Id,
  19320. x.TourGuideName,
  19321. x.CityName,
  19322. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19323. x.CreateTime
  19324. })
  19325. .OrderBy(x => x.Id)
  19326. .ToListAsync();
  19327. return Ok(JsonView(data));
  19328. }
  19329. /// <summary>
  19330. /// 团组接待意见调查 - 信息管理
  19331. /// 保存
  19332. /// </summary>
  19333. /// <param name="dto"></param>
  19334. /// <returns></returns>
  19335. [HttpPost]
  19336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19337. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19338. {
  19339. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19340. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19341. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19342. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19343. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19344. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19345. _opinionaireRep.BeginTran();
  19346. if (addData != null && addData.Count > 0)
  19347. {
  19348. foreach (var item in addData)
  19349. {
  19350. item.CreateUserId = currUserInfo.UserId;
  19351. item.DiId = dto.DiId;
  19352. }
  19353. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19354. }
  19355. if (updData != null && updData.Count > 0)
  19356. {
  19357. var upd = await _opinionaireRep._sqlSugar
  19358. .Updateable(updData)
  19359. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19360. .WhereColumns(x => new { x.Id })
  19361. .ExecuteCommandAsync();
  19362. }
  19363. _opinionaireRep.CommitTran();
  19364. return Ok(JsonView("操作成功!"));
  19365. }
  19366. /// <summary>
  19367. /// 团组接待意见调查 - 信息管理
  19368. /// 删除
  19369. /// </summary>
  19370. /// <param name="id"></param>
  19371. /// <returns></returns>
  19372. [HttpDelete("{id}")]
  19373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19374. public async Task<IActionResult> OpinionaireManageDel(int id)
  19375. {
  19376. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19377. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19378. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19379. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19380. if (!del) return Ok(JsonView("操作失败!"));
  19381. return Ok(JsonView("操作成功!"));
  19382. }
  19383. /// <summary>
  19384. /// 团组接待意见调查 - 用户
  19385. /// 列表
  19386. /// </summary>
  19387. /// <param name="diId"></param>
  19388. /// <returns></returns>
  19389. [HttpGet("{diId}")]
  19390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19391. public async Task<IActionResult> OpinionaireUserList(int diId)
  19392. {
  19393. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19394. var sql = string.Format(@"
  19395. SELECT
  19396. o.Id,
  19397. o.DiId,
  19398. di.TeamName AS 'GroupName',
  19399. di.VisitPNumber AS 'PeopleNumber',
  19400. di.ClientName AS 'LeadGroup',
  19401. di.VisitCountry AS 'Travel',
  19402. di.VisitDays AS 'Days',
  19403. o.CityName,
  19404. o.TourGuideName,
  19405. o.Catering,
  19406. o.CateringReason,
  19407. o.Stay,
  19408. o.StayReason,
  19409. o.[Route],
  19410. o.RouteReason,
  19411. o.OfficialActivity,
  19412. o.OfficialActivityReason,
  19413. o.TourGuide,
  19414. o.TourGuideReason,
  19415. o.[Translate],
  19416. o.TranslateReason,
  19417. o.Trip,
  19418. o.TripReason,
  19419. o.ESFileName,
  19420. o.SignatureDate,
  19421. o.Remark
  19422. FROM
  19423. Grp_Opinionaire o
  19424. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19425. WHERE
  19426. o.IsDel = 0
  19427. AND o.DiId = {0}
  19428. ORDER BY
  19429. o.Id ASC", diId);
  19430. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19431. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19432. return Ok(JsonView(data));
  19433. }
  19434. /// <summary>
  19435. /// 团组接待意见调查 - 用户
  19436. /// 保存
  19437. /// </summary>
  19438. /// <param name="dto"></param>
  19439. /// <returns></returns>
  19440. [HttpPost]
  19441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19442. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19443. {
  19444. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19445. foreach (var item in dto)
  19446. {
  19447. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19448. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19449. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19450. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19451. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19452. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19453. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19454. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19455. }
  19456. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19457. if (!Directory.Exists(filePathBase))
  19458. {
  19459. Directory.CreateDirectory(filePathBase);
  19460. }
  19461. #region 上传文件
  19462. var filePaths = new List<string>();
  19463. foreach (var item in dto)
  19464. {
  19465. var file = item.File;
  19466. // 将文件保存到指定位置
  19467. var filePath = Path.Combine(filePathBase, file.FileName);
  19468. using (var stream = new FileStream(filePath, FileMode.Create))
  19469. {
  19470. await file.CopyToAsync(stream);
  19471. }
  19472. //验证文件是否上传成功
  19473. if (!System.IO.File.Exists(filePath))
  19474. {
  19475. foreach (var filePathStr in filePaths)
  19476. {
  19477. System.IO.File.Delete(filePathStr);
  19478. }
  19479. return Ok(JsonView(false, "文件上传失败!"));
  19480. }
  19481. item.ESFileName = file.FileName;
  19482. }
  19483. #endregion
  19484. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19485. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19486. .UpdateColumns(x => new
  19487. {
  19488. x.Catering,
  19489. x.CateringReason,
  19490. x.Stay,
  19491. x.StayReason,
  19492. x.Route,
  19493. x.RouteReason,
  19494. x.OfficialActivity,
  19495. x.OfficialActivityReason,
  19496. x.TourGuide,
  19497. x.TourGuideReason,
  19498. x.Translate,
  19499. x.TranslateReason,
  19500. x.Trip,
  19501. x.TripReason,
  19502. x.ESFileName,
  19503. x.SignatureDate,
  19504. x.Remark
  19505. })
  19506. .WhereColumns(x => new { x.Id })
  19507. .ExecuteCommandAsync();
  19508. if (upd < 1)
  19509. {
  19510. foreach (var filePathStr in filePaths)
  19511. {
  19512. System.IO.File.Delete(filePathStr);
  19513. }
  19514. return Ok(JsonView(false));
  19515. }
  19516. return Ok(JsonView(true));
  19517. }
  19518. #endregion
  19519. #region 团组餐厅相关信息
  19520. /// <summary>
  19521. /// 团组相关餐厅信息
  19522. /// 基础数据(团组)
  19523. /// </summary>
  19524. /// <returns></returns>
  19525. [HttpGet]
  19526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19527. public async Task<IActionResult> RestaurantInit()
  19528. {
  19529. return Ok(await _restaurantRep.InitAsync());
  19530. }
  19531. /// <summary>
  19532. /// 团组相关餐厅信息
  19533. /// Item
  19534. /// </summary>
  19535. /// <param name="dto"></param>
  19536. /// <returns></returns>
  19537. [HttpPost]
  19538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19539. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19540. {
  19541. int portType = dto.PortType,
  19542. groupId = dto.GroupId;
  19543. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19544. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19545. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19546. }
  19547. /// <summary>
  19548. /// 团组相关餐厅信息
  19549. /// List
  19550. /// </summary>
  19551. /// <param name="dto"></param>
  19552. /// <returns></returns>
  19553. [HttpPost]
  19554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19555. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19556. {
  19557. int portType = dto.PortType,
  19558. groupId = dto.GroupId;
  19559. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19560. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19561. var sql = string.Format(@" SELECT
  19562. ri.Id,
  19563. ri.GroupId,
  19564. ri.Date,
  19565. ri.StartTime,
  19566. ri.EndTime,
  19567. CASE WHEN ri.Type = 1 THEN '早餐'
  19568. WHEN ri.Type = 2 THEN '午餐'
  19569. WHEN ri.Type = 3 THEN '晚餐'
  19570. ELSE '其他'
  19571. END AS 'Type',
  19572. ri.Name,
  19573. ri.Address,
  19574. ri.Tel,
  19575. ri.Remark,
  19576. ri.CreateTime,
  19577. u.CnName AS CreateUserName
  19578. FROM
  19579. Grp_RestaurantInfo ri
  19580. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19581. WHERE
  19582. ri.IsDel = 0
  19583. AND ri.GroupId = {0}
  19584. ORDER BY
  19585. ri.Date ASC
  19586. ", groupId);
  19587. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19588. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19589. return Ok(JsonView(infos));
  19590. }
  19591. /// <summary>
  19592. /// 团组相关餐厅信息
  19593. /// Info
  19594. /// </summary>
  19595. /// <param name="dto"></param>
  19596. /// <returns></returns>
  19597. [HttpPost]
  19598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19599. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19600. {
  19601. int portType = dto.PortType,
  19602. id = dto.Id;
  19603. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19604. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19605. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19606. }
  19607. /// <summary>
  19608. /// 团组相关餐厅信息
  19609. /// Op
  19610. /// </summary>
  19611. /// <param name="dto"></param>
  19612. /// <returns></returns>
  19613. [HttpPost]
  19614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19615. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19616. {
  19617. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19618. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19619. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19620. return Ok(await _restaurantRep.OpAsync(dto));
  19621. }
  19622. /// <summary>
  19623. /// 团组相关餐厅信息
  19624. /// Del
  19625. /// </summary>
  19626. /// <param name="dto"></param>
  19627. /// <returns></returns>
  19628. [HttpPost]
  19629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19630. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19631. {
  19632. int userId = dto.DeleteUserId;
  19633. var id = dto.Id;
  19634. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19635. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19636. return Ok(await _restaurantRep.DelAsync(dto));
  19637. }
  19638. #endregion
  19639. // /// <summary>
  19640. // ///
  19641. // /// </summary>
  19642. // /// <param name="_dto"></param>
  19643. // /// <returns></returns>
  19644. // [HttpPost]
  19645. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19646. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19647. // {
  19648. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19649. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19650. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19651. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19652. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19653. // dic_psg.Add("客人", 974);
  19654. // dic_psg.Add("司机", 975);
  19655. // dic_psg.Add("导游", 976);
  19656. // dic_psg.Add("公司内部人员", 977);
  19657. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19658. // foreach (var item in list_visa)
  19659. // {
  19660. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19661. // temp.Id = item.Id;
  19662. // temp.DIId = item.DIId;
  19663. // temp.VisaClient = item.VisaClient;
  19664. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19665. // temp.VisaCurrency = item.VisaCurrency;
  19666. // temp.IsThird = item.IsThird;
  19667. // if (dic_psg.ContainsKey(item.PassengerType))
  19668. // {
  19669. // temp.PassengerType = dic_psg[item.PassengerType];
  19670. // }
  19671. // else {
  19672. // temp.PassengerType = -1;
  19673. // }
  19674. // temp.VisaNumber = item.VisaNumber;
  19675. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19676. // temp.CreateUserId = item.Operators;
  19677. // DateTime dt_ct;
  19678. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19679. // if (b_ct)
  19680. // {
  19681. // temp.CreateTime = dt_ct;
  19682. // }
  19683. // else
  19684. // {
  19685. // temp.CreateTime = DateTime.Now;
  19686. // }
  19687. // temp.DeleteTime = "";
  19688. // temp.DeleteUserId = 0;
  19689. // temp.Remark = item.Remark;
  19690. // if (string.IsNullOrEmpty(temp.Remark)) {
  19691. // temp.Remark = "";
  19692. // }
  19693. // temp.IsDel = item.IsDel;
  19694. // temp.VisaDescription = item.VisaAttachment;
  19695. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19696. //([Id]
  19697. // ,[DIId]
  19698. // ,[VisaClient]
  19699. // ,[VisaPrice]
  19700. // ,[VisaCurrency]
  19701. // ,[IsThird]
  19702. // ,[PassengerType]
  19703. // ,[VisaNumber]
  19704. // ,[VisaFreeNumber]
  19705. // ,[CreateUserId]
  19706. // ,[CreateTime]
  19707. // ,[DeleteTime]
  19708. // ,[DeleteUserId]
  19709. // ,[Remark]
  19710. // ,[IsDel]
  19711. // ,[visaDescription])
  19712. // VALUES
  19713. // ({0},{1},'{2}',{3},{4}
  19714. //,{5},{6},{7},{8},{9}
  19715. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19716. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19717. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19718. //);
  19719. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19720. // }
  19721. // return Ok(JsonView(true, "操作成功!"));
  19722. // }
  19723. /// <summary>
  19724. /// 123132123
  19725. /// </summary>
  19726. /// <param name="_dto"></param>
  19727. /// <returns></returns>
  19728. [HttpPost]
  19729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19730. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19731. {
  19732. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19733. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19734. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19735. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19736. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19737. dicDetail.Add(789, 1034);
  19738. dicDetail.Add(790, 1035);
  19739. dicDetail.Add(791, 1036);
  19740. dicDetail.Add(792, 1037);
  19741. dicDetail.Add(793, 1038);
  19742. dicDetail.Add(794, 1039);
  19743. dicDetail.Add(795, 1040);
  19744. dicDetail.Add(796, 1041);
  19745. dicDetail.Add(797, 1042);
  19746. dicDetail.Add(798, 1043);
  19747. dicDetail.Add(801, 1044);
  19748. dicDetail.Add(802, 1045);
  19749. dicDetail.Add(803, 1046);
  19750. Dictionary<int, int> dic = new Dictionary<int, int>();
  19751. dic.Add(806, 1027);
  19752. dic.Add(807, 1028);
  19753. dic.Add(808, 1029);
  19754. dic.Add(809, 1030);
  19755. dic.Add(810, 1031);
  19756. dic.Add(811, 1032);
  19757. dic.Add(812, 1033);
  19758. foreach (var item in list_visa)
  19759. {
  19760. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19761. temp.Coefficient = item.coefficient;
  19762. DateTime dtCrt;
  19763. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19764. if (b1)
  19765. {
  19766. temp.CreateTime = dtCrt;
  19767. }
  19768. else
  19769. {
  19770. temp.CreateTime = DateTime.Now;
  19771. }
  19772. temp.CreateUserId = item.Operators;
  19773. temp.DeleteTime = "";
  19774. temp.DeleteUserId = 0;
  19775. temp.DiId = int.Parse(item.DIID);
  19776. temp.FilePath = item.FilePath;
  19777. temp.IsDel = item.IsDel;
  19778. temp.Price = item.Price;
  19779. temp.PriceCount = 1;
  19780. temp.PriceCurrency = item.Currency;
  19781. int detailId = 0;
  19782. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19783. {
  19784. detailId = dicDetail[item.PriceTypeDetail];
  19785. }
  19786. temp.PriceDetailType = detailId;
  19787. temp.PriceDt = DateTime.Now;
  19788. temp.PriceName = item.PriceName;
  19789. temp.PriceSum = item.Price;
  19790. int tid = 0;
  19791. if (dic.ContainsKey(item.PriceType))
  19792. {
  19793. tid = dic[item.PriceType];
  19794. }
  19795. temp.PriceType = tid;
  19796. temp.Remark = item.Remark;
  19797. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19798. }
  19799. return Ok(JsonView(true, "操作成功!"));
  19800. }
  19801. [HttpPost]
  19802. public IActionResult TimeTest()
  19803. {
  19804. var jw = JsonView(false, "error");
  19805. _sqlSugar.BeginTran();
  19806. try
  19807. {
  19808. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19809. .Select(x => new Crm_NewClientData
  19810. {
  19811. Id = x.Id,
  19812. Client = x.Client,
  19813. Contact = x.Contact,
  19814. Location = x.Location,
  19815. })
  19816. .ToList();
  19817. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19818. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19819. Stopwatch stopwatch = new Stopwatch();
  19820. // 开始计时
  19821. stopwatch.Start();
  19822. foreach (var item in clientList)
  19823. {
  19824. EncryptionProcessor.DecryptProperties(item);
  19825. }
  19826. stopwatch.Stop();
  19827. jw.Code = 200;
  19828. jw.Data = stopwatch.ElapsedMilliseconds;
  19829. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19830. }
  19831. catch (Exception ex)
  19832. {
  19833. jw.Code = 400;
  19834. jw.Msg = ex.Message;
  19835. }
  19836. return Ok(jw);
  19837. }
  19838. }
  19839. }