GroupsController.cs 1.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844
  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("{userId}")]
  382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  383. public async Task<IActionResult> GroupOrderPreInfoList(int userId)
  384. {
  385. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  386. }
  387. /// <summary>
  388. /// 团组前期信息 Init
  389. /// </summary>
  390. /// <returns></returns>
  391. [HttpGet("{userId}")]
  392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  393. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  394. {
  395. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  396. }
  397. /// <summary>
  398. /// 国家数据源
  399. /// </summary>
  400. /// <returns></returns>
  401. [HttpGet]
  402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  403. public async Task<IActionResult> CountryInit()
  404. {
  405. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  406. return Ok(JsonView(countrys));
  407. }
  408. /// <summary>
  409. /// 城市数据源
  410. /// </summary>
  411. /// <returns></returns>
  412. [HttpGet("{countryLabel}")]
  413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  414. public async Task<IActionResult> CityByCountry(string countryLabel)
  415. {
  416. countryLabel=HttpUtility.UrlDecode(countryLabel);
  417. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  418. var citys = Array.Empty<string?>();
  419. if (countryList.Any())
  420. {
  421. var cityDatas = await _sqlSugar
  422. .Queryable<Grp_NationalTravelFee>()
  423. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  424. .ToArrayAsync();
  425. foreach (var item in cityDatas)
  426. {
  427. if (item.City.Contains("城市"))
  428. {
  429. item.City = item.Country + "-所有城市";
  430. }
  431. }
  432. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  433. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  434. }
  435. return Ok(JsonView(citys));
  436. }
  437. /// <summary>
  438. /// 团组前期信息 Info
  439. /// </summary>
  440. /// <param name="id">Id</param>
  441. /// <param name="tempId">Id</param>
  442. /// <returns></returns>
  443. [HttpGet("{id}/{tempId}")]
  444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  445. public async Task<IActionResult> GroupOrderPreInfo(int id,int tempId = 1404)
  446. {
  447. return Ok(await _grpOrderPreInfoRep.InfoAsync(id, tempId));
  448. }
  449. /// <summary>
  450. /// 团组前期信息 Save
  451. /// </summary>
  452. /// <param name="dto">Id</param>
  453. /// <returns></returns>
  454. [HttpPost]
  455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  456. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  457. {
  458. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  459. }
  460. /// <summary>
  461. /// 团组前期信息 文件下载
  462. /// </summary>
  463. /// <param name="id">Id</param>
  464. /// <param name="tempId">Id</param>
  465. /// <returns></returns>
  466. [HttpGet("{id}/{tempId}")]
  467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  468. public async Task<IActionResult> GroupOrderPreInfoFileDownload(int id, int tempId = 1404)
  469. {
  470. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  471. var data = view.Data as GrpOrderPreInfoView;
  472. #region Excel
  473. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  474. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  475. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  476. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  477. var fileNamePrefix = string.Empty;
  478. if (tempId == 1405)
  479. {
  480. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  481. fileNamePrefix = $"{data.Name}_无商邀版";
  482. }
  483. else if (tempId == 1406)
  484. {
  485. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  486. fileNamePrefix = $"{data.Name}_有商邀版";
  487. }
  488. else
  489. {
  490. //tempId == 1404 默认下载
  491. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  492. fileNamePrefix = $"{data.Name}_单接送机";
  493. }
  494. foreach (var item in data.Items)
  495. {
  496. var obj = item.NewValue;
  497. if (obj == null) item.OriginVal = "";
  498. else if (obj.Equals("有") || obj.Equals("无"))
  499. {
  500. item.OriginVal = obj.ToString();
  501. }
  502. else if (obj is object[] objArray)
  503. {
  504. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  505. item.OriginVal = string.Join("、", stringArray);
  506. }
  507. else if (obj is string[] stringArray)
  508. {
  509. item.OriginVal = string.Join("、", stringArray);
  510. } else if (obj.Equals("-"))
  511. {
  512. item.OriginVal = "";
  513. }
  514. }
  515. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  516. fileName = CommonFun.ValidFileName(fileName);
  517. //载入模板
  518. WorkbookDesigner designer = new WorkbookDesigner();
  519. designer.Workbook = new Workbook(tempPath);
  520. if (tempId == 1406)
  521. {
  522. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  523. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  524. for (int i = 1; i <= view2.Length; i++)
  525. {
  526. view2[i - 1].Index = i;
  527. }
  528. designer.SetDataSource("View1", view1);
  529. designer.SetDataSource("View2", view2);
  530. }
  531. else
  532. {
  533. designer.SetDataSource("View", data.Items);
  534. }
  535. designer.Process();
  536. if (!Directory.Exists(savePath))
  537. {
  538. Directory.CreateDirectory(savePath);
  539. }
  540. string serverPath = $"{savePath}{fileName}";
  541. designer.Workbook.Save(serverPath);
  542. string rst = $"{servicePath}{ftpPath}{fileName}";
  543. #endregion
  544. return Ok(JsonView(new { url = rst }));
  545. }
  546. #endregion
  547. #region 团组基本信息
  548. /// <summary>
  549. /// 接团信息列表
  550. /// </summary>
  551. /// <param name="dto">团组列表请求dto</param>
  552. /// <returns></returns>
  553. [HttpPost]
  554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  555. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  556. {
  557. var groupData = await _groupRepository.GetGroupList(dto);
  558. if (groupData.Code != 0)
  559. {
  560. return Ok(JsonView(false, groupData.Msg));
  561. }
  562. return Ok(JsonView(groupData.Data));
  563. }
  564. /// <summary>
  565. /// 分页查询团组列表
  566. /// </summary>
  567. /// <param name="dto"></param>
  568. /// <returns></returns>
  569. [HttpPost]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  572. {
  573. var watch = new Stopwatch();
  574. watch.Start();
  575. RefAsync<int> total = 0;
  576. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  577. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  578. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  579. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  580. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  581. .Distinct()
  582. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  583. watch.Stop();
  584. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  585. }
  586. /// <summary>
  587. /// 接团信息列表 Page Init
  588. /// </summary>
  589. /// <returns></returns>
  590. [HttpPost]
  591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  592. public async Task<IActionResult> PostGroupPageListInit()
  593. {
  594. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  595. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  596. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  597. var _view = new
  598. {
  599. depData = depDatas,
  600. rankData = rankDatas
  601. };
  602. return Ok(JsonView(true, "查询成功!", _view));
  603. }
  604. /// <summary>
  605. /// 接团信息列表 Page
  606. /// </summary>
  607. /// <param name="dto">团组列表请求dto</param>
  608. /// <returns></returns>
  609. [HttpPost]
  610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  611. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  612. {
  613. #region 参数验证
  614. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  615. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  616. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  617. #region 页面操作权限验证
  618. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  619. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  620. #endregion
  621. #endregion
  622. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  623. {
  624. string sqlWhere = string.Empty;
  625. if (dto.IsSure == 0) //未完成
  626. {
  627. sqlWhere += string.Format(@" And IsSure = 0");
  628. }
  629. else if (dto.IsSure == 1) //已完成
  630. {
  631. sqlWhere += string.Format(@" And IsSure = 1");
  632. }
  633. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  634. {
  635. string tj = dto.SearchCriteria;
  636. 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}%')",
  637. tj, tj, tj, tj, tj);
  638. }
  639. if (int.TryParse(dto.Rank, out int rankId))
  640. {
  641. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  642. }
  643. string sqlWhere1 = string.Empty;
  644. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  645. {
  646. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  647. }
  648. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  649. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  650. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  651. JietuanOperator,IsSure,CreateTime,IsBid
  652. From (
  653. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  654. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  655. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  656. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  657. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  658. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  659. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  660. From Grp_DelegationInfo gdi
  661. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  662. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  663. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  664. Where gdi.IsDel = 0 {0}
  665. ) temp {1}", sqlWhere, sqlWhere1);
  666. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  667. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  668. var _view = new
  669. {
  670. PageFuncAuth = pageFunAuthView,
  671. Data = _DelegationList
  672. };
  673. return Ok(JsonView(true, "查询成功!", _view, total));
  674. }
  675. else
  676. {
  677. return Ok(JsonView(false, "查询失败"));
  678. }
  679. }
  680. /// <summary>
  681. /// 团组列表
  682. /// </summary>
  683. /// <returns></returns>
  684. [HttpPost]
  685. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  686. {
  687. #region 参数验证
  688. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  689. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  690. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  691. #region 页面操作权限验证
  692. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  693. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  694. #endregion
  695. #endregion
  696. if (dto.PortType != 1 && dto.PortType != 2)
  697. {
  698. return Ok(JsonView(false, "查询失败!"));
  699. }
  700. string orderbyStr = "order by gdi.CreateTime Desc";
  701. string sqlWhere = string.Empty;
  702. if (dto.IsSure == 0) //未完成
  703. {
  704. sqlWhere += string.Format(@" And IsSure = 0");
  705. }
  706. else if (dto.IsSure == 1) //已完成
  707. {
  708. sqlWhere += string.Format(@" And IsSure = 1");
  709. }
  710. //团组类型
  711. if (dto.TeamDid > 0)
  712. {
  713. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  714. }
  715. //团组名称
  716. if (!string.IsNullOrEmpty(dto.TeamName))
  717. {
  718. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  719. }
  720. //客户名称
  721. if (!string.IsNullOrEmpty(dto.ClientName))
  722. {
  723. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  724. }
  725. //客户单位
  726. if (!string.IsNullOrEmpty(dto.ClientUnit))
  727. {
  728. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  729. }
  730. //出访时间
  731. if (!string.IsNullOrEmpty(dto.visitDataTime))
  732. {
  733. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  734. orderbyStr = "order by gdi.VisitDate";
  735. }
  736. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  737. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  738. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  739. JietuanOperator,IsSure,CreateTime
  740. From (
  741. Select row_number() over({0}) as Row_Number,
  742. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  743. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  744. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  745. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  746. From Grp_DelegationInfo gdi
  747. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  748. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  749. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  750. Where gdi.IsDel = 0 {1}
  751. ) temp ", orderbyStr, sqlWhere);
  752. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  753. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  754. #region 处理所属部门
  755. /*
  756. * 1.sq 和 gyy 等显示 市场部
  757. * 2.王鸽和主管及张总还有管理员号统一国交部
  758. * 2-1. 4 管理员 ,21 张海麟
  759. */
  760. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  761. List<int> userIds1 = new List<int>() { 4, 21 };
  762. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  763. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  764. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  765. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  766. .ToList();
  767. foreach (var item in _DelegationList)
  768. {
  769. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  770. }
  771. #endregion
  772. var _view = new
  773. {
  774. PageFuncAuth = pageFunAuthView,
  775. Data = _DelegationList
  776. };
  777. return Ok(JsonView(true, "查询成功!", _view, total));
  778. }
  779. /// <summary>
  780. /// 接团信息详情
  781. /// </summary>
  782. /// <param name="dto">团组info请求dto</param>
  783. /// <returns></returns>
  784. [HttpPost]
  785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  786. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  787. {
  788. var groupData = await _groupRepository.GetGroupInfo(dto);
  789. if (groupData.Code != 0)
  790. {
  791. return Ok(JsonView(false, groupData.Msg));
  792. }
  793. return Ok(JsonView(groupData.Data));
  794. }
  795. /// <summary>
  796. /// 接团信息 编辑添加
  797. /// 基础信息数据源
  798. /// </summary>
  799. /// <param name="dto"></param>
  800. /// <returns></returns>
  801. [HttpPost]
  802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  803. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  804. {
  805. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  806. if (groupData.Code != 0)
  807. {
  808. return Ok(JsonView(false, groupData.Msg));
  809. }
  810. return Ok(JsonView(groupData.Data));
  811. }
  812. /// <summary>
  813. /// 接团信息 操作(增改)
  814. /// </summary>
  815. /// <param name="dto"></param>
  816. /// <returns></returns>
  817. [HttpPost]
  818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  819. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  820. {
  821. // 创建 Stopwatch 实例
  822. Stopwatch stopwatch = Stopwatch.StartNew();
  823. decimal ffrPrice = 0.00M;
  824. DateTime? visitDt = null;
  825. if (dto.Status == 2)
  826. {
  827. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  828. if (groupInfo != null)
  829. {
  830. ffrPrice = groupInfo.PaymentMoney;
  831. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  832. }
  833. }
  834. var groupData = await _groupRepository.GroupOperation(dto);
  835. if (groupData.Code != 0)
  836. {
  837. return Ok(JsonView(false, groupData.Msg));
  838. }
  839. int diId = 0;
  840. try
  841. {
  842. //添加时 默认加入团组汇率
  843. if (dto.Status == 1) //添加
  844. {
  845. diId = groupData.Data;
  846. //添加默认币种
  847. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  848. //默认分配权限
  849. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  850. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  851. var _managerIds = new List<int>() { 22, 32, 21 };
  852. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  853. if (userIds.Count > 0)
  854. {
  855. userIds.Add(208);
  856. //创建团组管控
  857. GroupStepForDelegation.CreateWorkStep(diId);
  858. //发送消息
  859. string groupName = dto.TeamName;
  860. string createGroupUser = string.Empty;
  861. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  862. if (userInfo != null) createGroupUser = userInfo.CnName;
  863. string title = $"系统通知";
  864. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  865. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  866. }
  867. //默认创建倒推表
  868. await _invertedListRep._Create(dto.UserId, diId);
  869. }
  870. else if (dto.Status == 2)
  871. {
  872. diId = dto.Id;
  873. }
  874. #region 签证人员团组时间通知
  875. #region 计算出访起止时间
  876. var startTime = new DateTime();
  877. var endTime = new DateTime();
  878. if (DateTime.TryParse(dto.VisitDate, out startTime))
  879. {
  880. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  881. }
  882. #endregion
  883. #endregion
  884. #region 团组操作默认添加/修改收款账单
  885. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  886. {
  887. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  888. .Where(x => x.IsDel == 0 &&
  889. x.Diid == diId &&
  890. x.Remark.Equals("预付款")
  891. )
  892. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  893. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  894. .FirstAsync();
  895. ffrInfo = new Fin_ForeignReceivables()
  896. {
  897. Diid = diId,
  898. PriceName = dto.ClientUnit,
  899. Price = dto.PaymentMoney,
  900. Count = 1,
  901. Unit = $"元",
  902. ItemSumPrice = dto.PaymentMoney,
  903. Rate = 1.0000M,
  904. Currency = 836,
  905. AddingWay = 0,
  906. CreateUserId = dto.UserId,
  907. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  908. Remark = $"预付款"
  909. };
  910. if (ffrInfo == null) //Add
  911. {
  912. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  913. }
  914. else //修改
  915. {
  916. await _sqlSugar.Updateable(ffrInfo)
  917. .UpdateColumns(x => new
  918. {
  919. x.PriceName,
  920. x.Price,
  921. x.ItemSumPrice,
  922. x.CreateTime,
  923. x.CreateUserId
  924. })
  925. .WhereColumns(x => x.Id)
  926. .ExecuteCommandAsync();
  927. }
  928. }
  929. #endregion
  930. if (diId > 0)
  931. {
  932. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  933. }
  934. // 停止计时
  935. stopwatch.Stop();
  936. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  937. }
  938. catch (Exception ex)
  939. {
  940. // 停止计时
  941. stopwatch.Stop();
  942. Logs("[response]" + JsonConvert.SerializeObject(dto));
  943. Logs(ex.Message);
  944. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  945. }
  946. // 停止计时
  947. stopwatch.Stop();
  948. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  949. }
  950. /// <summary>
  951. /// 接团流程操作(增改)
  952. /// 安卓端使用 建团时添加客户名单
  953. /// </summary>
  954. /// <param name="dto"></param>
  955. /// <returns></returns>
  956. [HttpPost]
  957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  958. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  959. {
  960. #region 参数验证
  961. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  962. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  963. #region 页面操作权限验证
  964. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  965. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  966. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  967. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  968. #endregion
  969. #endregion
  970. try
  971. {
  972. //_sqlSugar.BeginTran();
  973. decimal ffrPrice = 0.00M;
  974. DateTime? visitDt = null;
  975. if (dto.Status == 2)
  976. {
  977. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  978. if (groupInfo != null)
  979. {
  980. ffrPrice = groupInfo.PaymentMoney;
  981. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  982. }
  983. }
  984. var _dto = new GroupOperationDto();
  985. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  986. var groupData = await _groupRepository.GroupOperation(_dto);
  987. if (groupData.Code != 0)
  988. {
  989. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  990. }
  991. int diId = 0;
  992. //添加时 默认加入团组汇率
  993. if (dto.Status == 1) //添加
  994. {
  995. diId = groupData.Data;
  996. //添加默认币种
  997. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  998. //默认分配权限
  999. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1000. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1001. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1002. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1003. if (userIds.Count > 0)
  1004. {
  1005. userIds.Add(208);
  1006. //创建团组管控
  1007. GroupStepForDelegation.CreateWorkStep(diId);
  1008. //发送消息
  1009. string groupName = dto.TeamName;
  1010. string createGroupUser = string.Empty;
  1011. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1012. if (userInfo != null) createGroupUser = userInfo.CnName;
  1013. string title = $"系统通知";
  1014. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1015. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1016. }
  1017. #region 应用推送
  1018. try
  1019. {
  1020. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1021. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1022. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1023. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1024. {
  1025. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1026. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1027. }
  1028. }
  1029. catch (Exception ex)
  1030. {
  1031. }
  1032. #endregion
  1033. //默认创建倒推表
  1034. await _invertedListRep._Create(dto.UserId, diId);
  1035. }
  1036. if (dto.Status == 2)
  1037. {
  1038. diId = dto.Id;
  1039. if (diId == 0)
  1040. {
  1041. //_sqlSugar.RollbackTran();
  1042. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1043. }
  1044. }
  1045. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1046. if (viewData.Code != 0)
  1047. {
  1048. //_sqlSugar.RollbackTran();
  1049. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1050. }
  1051. #region 团组操作默认添加/修改收款账单
  1052. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1053. {
  1054. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1055. .Where(x => x.IsDel == 0 &&
  1056. x.Diid == diId &&
  1057. x.Remark.Equals("预付款")
  1058. )
  1059. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1060. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1061. .FirstAsync();
  1062. ffrInfo = new Fin_ForeignReceivables()
  1063. {
  1064. Diid = diId,
  1065. PriceName = dto.ClientUnit,
  1066. Price = dto.PaymentMoney,
  1067. Count = 1,
  1068. Unit = $"元",
  1069. ItemSumPrice = dto.PaymentMoney,
  1070. Rate = 1.0000M,
  1071. Currency = 836,
  1072. AddingWay = 0,
  1073. CreateUserId = dto.UserId,
  1074. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1075. Remark = $"预付款"
  1076. };
  1077. if (ffrInfo == null) //Add
  1078. {
  1079. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1080. }
  1081. else //修改
  1082. {
  1083. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1084. .UpdateColumns(x => new
  1085. {
  1086. x.PriceName,
  1087. x.Price,
  1088. x.ItemSumPrice,
  1089. x.CreateTime,
  1090. x.CreateUserId
  1091. })
  1092. .WhereColumns(x => x.Id)
  1093. .ExecuteCommandAsync();
  1094. }
  1095. }
  1096. #endregion
  1097. #region 签证人员团组时间通知
  1098. #region 计算出访起止时间
  1099. var startTime = new DateTime();
  1100. var endTime = new DateTime();
  1101. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1102. {
  1103. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1104. }
  1105. #endregion
  1106. if (diId > 0)
  1107. {
  1108. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1109. }
  1110. #endregion
  1111. //_sqlSugar.CommitTran();
  1112. return Ok(JsonView(true, "添加成功"));
  1113. }
  1114. catch (Exception ex)
  1115. {
  1116. _sqlSugar.RollbackTran();
  1117. return Ok(JsonView(false, ex.Message));
  1118. }
  1119. }
  1120. /// <summary>
  1121. /// 接团流程操作(增改)
  1122. /// 安卓端使用 建团时添加客户名单
  1123. /// </summary>
  1124. /// <param name="dto"></param>
  1125. /// <returns></returns>
  1126. [HttpPost]
  1127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1128. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1129. {
  1130. #region 参数验证
  1131. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1132. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1133. #region 页面操作权限验证
  1134. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1135. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1136. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1137. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1138. #endregion
  1139. #endregion
  1140. _sqlSugar.BeginTran();
  1141. decimal ffrPrice = 0.00M;
  1142. DateTime? visitDt = null;
  1143. if (dto.Status == 2)
  1144. {
  1145. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1146. if (groupInfo != null)
  1147. {
  1148. ffrPrice = groupInfo.PaymentMoney;
  1149. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1150. }
  1151. }
  1152. var _dto = new GroupOperationDto();
  1153. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1154. var groupData = await _groupRepository.GroupOperation(_dto);
  1155. if (groupData.Code != 0)
  1156. {
  1157. _sqlSugar.RollbackTran();
  1158. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1159. }
  1160. try
  1161. {
  1162. int diId = 0;
  1163. //添加时 默认加入团组汇率
  1164. if (dto.Status == 1) //添加
  1165. {
  1166. diId = groupData.Data;
  1167. //添加默认币种
  1168. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1169. //默认分配权限
  1170. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1171. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1172. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1173. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1174. if (userIds.Count > 0)
  1175. {
  1176. userIds.Add(208);
  1177. //创建团组管控
  1178. GroupStepForDelegation.CreateWorkStep(diId);
  1179. //发送消息
  1180. string groupName = dto.TeamName;
  1181. string createGroupUser = string.Empty;
  1182. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1183. if (userInfo != null) createGroupUser = userInfo.CnName;
  1184. string title = $"系统通知";
  1185. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1186. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1187. }
  1188. #region 应用推送
  1189. try
  1190. {
  1191. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1192. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1193. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1194. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1195. {
  1196. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1197. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1198. }
  1199. }
  1200. catch (Exception ex)
  1201. {
  1202. _sqlSugar.CommitTran();
  1203. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1204. }
  1205. #endregion
  1206. //默认创建倒推表
  1207. await _invertedListRep._Create(dto.UserId, diId);
  1208. }
  1209. else if (dto.Status == 2)
  1210. {
  1211. diId = dto.Id;
  1212. if (diId == 0)
  1213. {
  1214. _sqlSugar.RollbackTran();
  1215. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1216. }
  1217. }
  1218. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1219. if (viewData.Code != 0)
  1220. {
  1221. _sqlSugar.RollbackTran();
  1222. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1223. }
  1224. #region 团组操作默认添加/修改收款账单
  1225. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1226. {
  1227. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1228. .Where(x => x.IsDel == 0 &&
  1229. x.Diid == diId &&
  1230. x.Remark.Equals("预付款")
  1231. )
  1232. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1233. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1234. .FirstAsync();
  1235. ffrInfo = new Fin_ForeignReceivables()
  1236. {
  1237. Diid = diId,
  1238. PriceName = dto.ClientUnit,
  1239. Price = dto.PaymentMoney,
  1240. Count = 1,
  1241. Unit = $"元",
  1242. ItemSumPrice = dto.PaymentMoney,
  1243. Rate = 1.0000M,
  1244. Currency = 836,
  1245. AddingWay = 0,
  1246. CreateUserId = dto.UserId,
  1247. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1248. Remark = $"预付款"
  1249. };
  1250. if (ffrInfo == null) //Add
  1251. {
  1252. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1253. }
  1254. else //修改
  1255. {
  1256. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1257. .UpdateColumns(x => new
  1258. {
  1259. x.PriceName,
  1260. x.Price,
  1261. x.ItemSumPrice,
  1262. x.CreateTime,
  1263. x.CreateUserId
  1264. })
  1265. .WhereColumns(x => x.Id)
  1266. .ExecuteCommandAsync();
  1267. }
  1268. }
  1269. #endregion
  1270. #region 签证人员团组时间通知
  1271. #region 计算出访起止时间
  1272. var startTime = new DateTime();
  1273. var endTime = new DateTime();
  1274. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1275. {
  1276. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1277. }
  1278. #endregion
  1279. if (diId > 0)
  1280. {
  1281. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1282. }
  1283. #endregion
  1284. _sqlSugar.CommitTran();
  1285. return Ok(JsonView(true));
  1286. }
  1287. catch (Exception ex)
  1288. {
  1289. _sqlSugar.RollbackTran();
  1290. return Ok(JsonView(false, ex.Message));
  1291. }
  1292. }
  1293. /// <summary>
  1294. /// 接团信息 操作(删除)
  1295. /// </summary>
  1296. /// <param name="dto"></param>
  1297. /// <returns></returns>
  1298. [HttpPost]
  1299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1300. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1301. {
  1302. var diId = dto.Id;
  1303. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1304. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1305. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1306. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1307. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1308. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1309. #endregion
  1310. var groupData = await _groupRepository.GroupDel(dto);
  1311. if (groupData.Code != 0)
  1312. {
  1313. return Ok(JsonView(false, groupData.Msg));
  1314. }
  1315. return Ok(JsonView(true));
  1316. }
  1317. /// <summary>
  1318. /// 获取团组销售报价号
  1319. /// 团组添加时 使用
  1320. /// </summary>
  1321. /// <returns></returns>
  1322. [HttpPost]
  1323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1324. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1325. {
  1326. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1327. if (groupData.Code != 0)
  1328. {
  1329. return Ok(JsonView(false, groupData.Msg));
  1330. }
  1331. object salesQuoteNo = new
  1332. {
  1333. SalesQuoteNo = groupData.Data
  1334. };
  1335. return Ok(JsonView(salesQuoteNo));
  1336. }
  1337. /// <summary>
  1338. /// 设置确认出团
  1339. /// </summary>
  1340. /// <param name="dto"></param>
  1341. /// <returns></returns>
  1342. [HttpPost]
  1343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1344. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1345. {
  1346. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1347. if (groupData.Code != 0)
  1348. {
  1349. return Ok(JsonView(false, groupData.Msg));
  1350. }
  1351. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1352. #region OA消息推送
  1353. try
  1354. {
  1355. string groupName = groupInfo.TeamName;
  1356. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1357. string title = $"系统通知";
  1358. string content = $"团组[{groupName}]已确认出团!";
  1359. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1360. }
  1361. catch (Exception ex)
  1362. {
  1363. }
  1364. #endregion
  1365. #region 应用推送
  1366. try
  1367. {
  1368. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1369. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1370. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1371. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1372. {
  1373. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1374. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1375. }
  1376. }
  1377. catch (Exception ex)
  1378. {
  1379. }
  1380. #endregion
  1381. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1382. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1383. }
  1384. /// <summary>
  1385. /// 获取团组名称data And 签证国别Data
  1386. /// </summary>
  1387. /// <param name="dto"></param>
  1388. /// <returns></returns>
  1389. [HttpPost]
  1390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1391. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1392. {
  1393. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1394. if (groupData.Code != 0)
  1395. {
  1396. return Ok(JsonView(false, groupData.Msg));
  1397. }
  1398. return Ok(JsonView(groupData.Data));
  1399. }
  1400. /// <summary>
  1401. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1402. /// </summary>
  1403. /// <returns></returns>
  1404. [HttpPost]
  1405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1406. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1407. {
  1408. try
  1409. {
  1410. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1411. if (groupData.Code != 0)
  1412. {
  1413. return Ok(JsonView(false, groupData.Msg));
  1414. }
  1415. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1416. }
  1417. catch (Exception ex)
  1418. {
  1419. return Ok(JsonView(false, "程序错误!"));
  1420. throw;
  1421. }
  1422. }
  1423. /// <summary>
  1424. /// 团组清单 Excel
  1425. /// </summary>
  1426. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1427. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1428. /// <returns></returns>
  1429. [HttpGet]
  1430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1431. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1432. {
  1433. DateTime _beginDt, _endDt;
  1434. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1435. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1436. if (!beginBool && !endBool)
  1437. {
  1438. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1439. }
  1440. string sql = string.Format(@"
  1441. SELECT
  1442. ROW_NUMBER,
  1443. Id,
  1444. SalesQuoteNo,
  1445. TourCode,
  1446. TeamTypeId,
  1447. TeamType,
  1448. TeamLevId,
  1449. TeamLev,
  1450. TeamName,
  1451. ClientName,
  1452. ClientUnit,
  1453. VisitDate,
  1454. VisitDays,
  1455. VisitPNumber,
  1456. JietuanOperatorId,
  1457. JietuanOperator,
  1458. IsSure,
  1459. CreateUserName,
  1460. IsBid
  1461. FROM
  1462. (
  1463. SELECT
  1464. ROW_NUMBER() OVER(
  1465. ORDER BY
  1466. gdi.CreateTime Desc
  1467. ) AS ROW_NUMBER,
  1468. gdi.Id,
  1469. SalesQuoteNo,
  1470. TourCode,
  1471. ssd.Id TeamTypeId,
  1472. ssd.Name TeamType,
  1473. ssd1.Id TeamLevId,
  1474. ssd1.Name TeamLev,
  1475. TeamName,
  1476. ClientName,
  1477. ClientUnit,
  1478. VisitDate,
  1479. VisitDays,
  1480. VisitPNumber,
  1481. JietuanOperator JietuanOperatorId,
  1482. su.CnName JietuanOperator,
  1483. IsSure,
  1484. gdi.CreateTime,
  1485. su1.CnName As CreateUserName,
  1486. gdi.IsBid
  1487. FROM
  1488. Grp_DelegationInfo gdi
  1489. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1490. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1491. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1492. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1493. WHERE
  1494. gdi.IsDel = 0
  1495. AND gdi.IsBid = 0
  1496. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1497. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1498. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1499. #region 处理所属部门
  1500. /*
  1501. * 1.sq 和 gyy 等显示 市场部
  1502. * 2.王鸽和主管及张总还有管理员号统一国交部
  1503. * 2-1. 4 管理员 ,21 张海麟
  1504. */
  1505. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1506. List<int> userIds1 = new List<int>() { 4, 21 };
  1507. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1508. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1509. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1510. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1511. .ToListAsync();
  1512. var droupIds = groupList.Select(it => it.Id).ToList();
  1513. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1514. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1515. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1516. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1517. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1518. {
  1519. DiId = tcl.DiId,
  1520. LastName = dc.LastName,
  1521. FirstName = dc.FirstName,
  1522. Sex = dc.Sex,
  1523. Birthday = dc.BirthDay,
  1524. Company = cc.CompanyFullName,
  1525. Job = dc.Job,
  1526. CreateTime = tcl.CreateTime,
  1527. })
  1528. .ToList();
  1529. foreach (var item in groupList)
  1530. {
  1531. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1532. string groupFirstName = "";
  1533. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1534. if (currDatas.Any())
  1535. {
  1536. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1537. }
  1538. item.GroupFirst = groupFirstName;
  1539. }
  1540. #endregion
  1541. #region Excel
  1542. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1543. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1544. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1545. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1546. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1547. //载入模板
  1548. WorkbookDesigner designer = new WorkbookDesigner();
  1549. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1550. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1551. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1552. dt.TableName = "GroupList";
  1553. designer.SetDataSource(dt);
  1554. designer.Process();
  1555. if (!Directory.Exists(savePath))
  1556. {
  1557. Directory.CreateDirectory(savePath);
  1558. }
  1559. string serverPath = $"{savePath}{fileName}";
  1560. designer.Workbook.Save(serverPath);
  1561. string rst = $"{servicePath}{ftpPath}{fileName}";
  1562. #endregion
  1563. return Ok(JsonView(true, "操作成功!", rst));
  1564. }
  1565. #endregion
  1566. #region 团组&签证
  1567. /// <summary>
  1568. /// 根据团组Id获取签证客户信息List
  1569. /// </summary>
  1570. /// <param name="dto">请求dto</param>
  1571. /// <returns></returns>
  1572. [HttpPost]
  1573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1574. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1575. {
  1576. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1577. if (groupData.Code != 0)
  1578. {
  1579. return Ok(JsonView(false, groupData.Msg));
  1580. }
  1581. return Ok(JsonView(groupData.Data));
  1582. }
  1583. /// <summary>
  1584. /// IOS获取团组签证拍照上传进度01(团组列表)
  1585. /// </summary>
  1586. /// <param name="dto">请求dto</param>
  1587. /// <returns></returns>
  1588. [HttpPost]
  1589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1590. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1591. {
  1592. if (dto == null)
  1593. {
  1594. return Ok(JsonView(false, "参数为空"));
  1595. }
  1596. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1597. return Ok(JsonView(visaList));
  1598. }
  1599. /// <summary>
  1600. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1601. /// </summary>
  1602. /// <returns></returns>
  1603. [HttpPost]
  1604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1605. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1606. {
  1607. if (dto == null)
  1608. {
  1609. return Ok(JsonView(false, "请求错误:"));
  1610. }
  1611. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1612. return Ok(JsonView(list));
  1613. }
  1614. /// <summary>
  1615. /// IOS获取团组签证拍照上传进度03(相册)
  1616. /// </summary>
  1617. /// <returns></returns>
  1618. [HttpPost]
  1619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1620. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1621. {
  1622. if (dto == null)
  1623. {
  1624. return Ok(JsonView(false, "请求错误:"));
  1625. }
  1626. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1627. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1628. list.ForEach(s => s.url = url);
  1629. return Ok(JsonView(list));
  1630. }
  1631. /// <summary>
  1632. /// IOS获取团组签证拍照上传进度04(图片上传)
  1633. /// </summary>
  1634. /// <param name="dto"></param>
  1635. /// <returns></returns>
  1636. [HttpPost]
  1637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1638. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1639. {
  1640. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1641. //if (!string.IsNullOrEmpty(result))
  1642. //{
  1643. //}
  1644. //else {
  1645. // return Ok(JsonView(false, "上传失败"));
  1646. //}
  1647. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1648. int sucNum = 0;
  1649. try
  1650. {
  1651. foreach (var item in dto.base64DataList)
  1652. {
  1653. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1654. string result = DecodeBase64ToImage(item, imageName);
  1655. if (!string.IsNullOrEmpty(result))
  1656. {
  1657. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1658. pic.CreateUserId = dto.CreateUserId;
  1659. pic.PicName = imageName;
  1660. pic.PicPath = result;
  1661. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1662. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1663. if (insertResult > 0)
  1664. {
  1665. sucNum++;
  1666. }
  1667. }
  1668. }
  1669. }
  1670. catch (Exception ex)
  1671. {
  1672. return Ok(JsonView(false, ex.Message));
  1673. }
  1674. string msg = string.Format(@"成功上传{0}张", sucNum);
  1675. return Ok(JsonView(true, msg));
  1676. }
  1677. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1678. {
  1679. string filename = "";//声明一个string类型的相对路径
  1680. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1681. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1682. try//会有异常抛出,try,catch一下
  1683. {
  1684. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1685. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1686. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1687. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1688. //文件名称
  1689. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1690. //上传的文件的路径
  1691. string filePath = "";
  1692. if (!Directory.Exists(fileDir))
  1693. {
  1694. Directory.CreateDirectory(fileDir);
  1695. }
  1696. //上传的文件的路径
  1697. filePath = fileDir + filename;
  1698. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1699. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1700. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1701. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1702. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1703. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1704. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1705. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1706. bitmap.Dispose();
  1707. }
  1708. catch (Exception e)
  1709. {
  1710. string massage = e.Message;
  1711. Logs("IOS图片上传Error:" + massage);
  1712. //filename = e.Message;
  1713. }
  1714. return filename;//返回相对路径
  1715. }
  1716. /// <summary>
  1717. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1718. /// </summary>
  1719. /// <param name="dto"></param>
  1720. /// <returns></returns>
  1721. [HttpPost]
  1722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1723. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1724. {
  1725. if (dto == null)
  1726. {
  1727. return Ok(JsonView(false, "请求错误:"));
  1728. }
  1729. string msg = "参数错误";
  1730. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1731. {
  1732. try
  1733. {
  1734. //_delegationVisaRep.BeginTran();
  1735. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1736. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1737. .Where(s => s.Id == dto.visaProgressCustomerId)
  1738. .ExecuteCommandAsync();
  1739. if (updCount > 0 && dto.publishCode == 1)
  1740. {
  1741. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1742. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1743. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1744. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1745. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1746. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1747. if (groupData == null)
  1748. {
  1749. _delegationVisaRep.RollbackTran();
  1750. }
  1751. string title = string.Format(@"[签证进度更新]");
  1752. string content = string.Format(@"测试文本");
  1753. bool rst = await _message.AddMsg(new MessageDto()
  1754. {
  1755. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1756. IssuerId = dto.publisher,
  1757. Title = title,
  1758. Content = content,
  1759. ReleaseTime = DateTime.Now,
  1760. UIdList = new List<int> {
  1761. 234
  1762. }
  1763. });
  1764. if (rst)
  1765. {
  1766. return Ok(JsonView(true, "发送通知成功"));
  1767. }
  1768. }
  1769. //_delegationVisaRep.CommitTran();
  1770. }
  1771. catch (Exception)
  1772. {
  1773. //_delegationVisaRep.RollbackTran();
  1774. }
  1775. }
  1776. return Ok(JsonView(true, msg));
  1777. }
  1778. #endregion
  1779. #region 团组任务分配
  1780. /// <summary>
  1781. /// 团组任务分配初始化
  1782. /// </summary>
  1783. /// <returns></returns>
  1784. [HttpPost]
  1785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1786. public async Task<IActionResult> GetTaskAssignmen()
  1787. {
  1788. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1789. if (groupData.Code != 0)
  1790. {
  1791. return Ok(JsonView(false, groupData.Msg));
  1792. }
  1793. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1794. }
  1795. /// <summary>
  1796. /// 团组任务分配查询
  1797. /// </summary>
  1798. /// <param name="dto"></param>
  1799. /// <returns></returns>
  1800. [HttpPost]
  1801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1802. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1803. {
  1804. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1805. if (groupData.Code != 0)
  1806. {
  1807. return Ok(JsonView(false, groupData.Msg));
  1808. }
  1809. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1810. }
  1811. /// <summary>
  1812. /// 团组任务分配操作
  1813. /// </summary>
  1814. /// <param name="dto"></param>
  1815. /// <returns></returns>
  1816. [HttpPost]
  1817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1818. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1819. {
  1820. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1821. if (groupData.Code != 0)
  1822. {
  1823. return Ok(JsonView(false, groupData.Msg));
  1824. }
  1825. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1826. }
  1827. /// <summary>
  1828. /// 团组任务分配
  1829. /// 批量分配
  1830. /// 查询团组
  1831. /// </summary>
  1832. /// <param name="dto"></param>
  1833. /// <returns></returns>
  1834. [HttpPost]
  1835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1836. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1837. {
  1838. //参数验证
  1839. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1840. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1841. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1842. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1843. }
  1844. /// <summary>
  1845. /// 团组任务分配
  1846. /// 批量分配
  1847. /// </summary>
  1848. /// <param name="dto"></param>
  1849. /// <returns></returns>
  1850. [HttpPost]
  1851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1852. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1853. {
  1854. //参数验证
  1855. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1856. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1857. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1858. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1859. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1860. }
  1861. #endregion
  1862. #region 团组费用审核
  1863. /// <summary>
  1864. /// 费用审核
  1865. /// 团组列表 Page
  1866. /// </summary>
  1867. /// <param name="_dto">团组列表请求dto</param>
  1868. /// <returns></returns>
  1869. [HttpPost]
  1870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1871. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1872. {
  1873. #region 参数验证
  1874. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1875. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1876. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1877. #region 页面操作权限验证
  1878. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1879. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1880. #endregion
  1881. #endregion
  1882. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1883. {
  1884. string sqlWhere = string.Empty;
  1885. if (_dto.IsSure == 0) //未完成
  1886. {
  1887. sqlWhere += string.Format(@" And IsSure = 0");
  1888. }
  1889. else if (_dto.IsSure == 1) //已完成
  1890. {
  1891. sqlWhere += string.Format(@" And IsSure = 1");
  1892. }
  1893. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1894. {
  1895. string tj = _dto.SearchCriteria;
  1896. 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}%')",
  1897. tj, tj, tj, tj, tj);
  1898. }
  1899. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1900. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1901. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1902. From (
  1903. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1904. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1905. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1906. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1907. From Grp_DelegationInfo gdi
  1908. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1909. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1910. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1911. Where gdi.IsDel = 0 {0}
  1912. ) temp ", sqlWhere);
  1913. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1914. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1915. var _view = new
  1916. {
  1917. PageFuncAuth = pageFunAuthView,
  1918. Data = _DelegationList
  1919. };
  1920. return Ok(JsonView(true, "查询成功!", _view, total));
  1921. }
  1922. else
  1923. {
  1924. return Ok(JsonView(false, "查询失败"));
  1925. }
  1926. }
  1927. /// <summary>
  1928. /// 获取团组费用审核
  1929. /// </summary>
  1930. /// <param name="_dto"></param>
  1931. /// <returns></returns>
  1932. [HttpPost]
  1933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1934. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1935. {
  1936. try
  1937. {
  1938. #region 参数验证
  1939. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1940. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1941. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1942. #region 页面操作权限验证
  1943. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1944. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1945. #endregion
  1946. #endregion
  1947. var _view = new Grp_CreditCardPaymentView();
  1948. var clientNameList = getSimplClientList(_dto.DiId);
  1949. #region 费用清单
  1950. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1951. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1952. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1953. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1954. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1955. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1956. /*
  1957. * 76://酒店预订
  1958. */
  1959. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1960. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1961. /*
  1962. * 79://车/导游地接
  1963. */
  1964. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1965. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1966. /*
  1967. * 80: //签证
  1968. */
  1969. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1970. /*
  1971. *81: //邀请/公务活动
  1972. */
  1973. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1974. /*
  1975. * 82: //团组客户保险
  1976. */
  1977. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1978. /*
  1979. * Lable = 85 机票预订
  1980. */
  1981. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1982. /*
  1983. * 85 机票预定
  1984. */
  1985. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1986. /*
  1987. * 98 其他款项
  1988. */
  1989. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1990. /*
  1991. * 285:收款退还
  1992. */
  1993. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1994. /*
  1995. * 1015: //超支费用
  1996. */
  1997. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1998. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1999. /*
  2000. * 币种信息
  2001. */
  2002. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2003. /*
  2004. * 车/导游地接 费用类型
  2005. */
  2006. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2007. /*
  2008. * 车/导游地接 费用类型
  2009. */
  2010. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2011. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2012. /*
  2013. * 用户信息
  2014. */
  2015. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2016. /*
  2017. * 费用模块
  2018. */
  2019. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2020. string priceModule = string.Empty;
  2021. if (sdPriceName != null)
  2022. {
  2023. priceModule = sdPriceName.Name;
  2024. }
  2025. /*
  2026. * 成本信息
  2027. */
  2028. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2029. decimal _groupRate = 0.0000M;
  2030. string _groupCurrencyCode = "-";
  2031. if (groupCost != null)
  2032. {
  2033. _groupRate = groupCost.Rate;
  2034. if (int.TryParse(groupCost.Currency, out int _currency))
  2035. {
  2036. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2037. }
  2038. else _groupCurrencyCode = groupCost.Currency;
  2039. }
  2040. string costContentSql = $"Select * From Grp_GroupCost";
  2041. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2042. //处理日期为空的天数
  2043. for (int i = 0; i < groupCostDetails.Count; i++)
  2044. if (i != 0)
  2045. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2046. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2047. /*
  2048. * 处理详情数据
  2049. */
  2050. foreach (var entity in entityList)
  2051. {
  2052. var _detail = new Grp_CreditCardPaymentDetailView();
  2053. _detail.Id = entity.Id;
  2054. _detail.PriceName = priceModule;
  2055. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2056. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2057. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2058. //处理金额
  2059. if (entity.CTable == 1015)
  2060. {
  2061. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2062. if (czInfo != null)
  2063. {
  2064. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2065. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2066. }
  2067. }
  2068. /*
  2069. * 应付款金额
  2070. */
  2071. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2072. string PaymentCurrency_WaitPay = "Unknown";
  2073. string hotelCurrncyCode = "Unknown";
  2074. string hotelCurrncyName = "Unknown";
  2075. if (sdPaymentCurrency_WaitPay != null)
  2076. {
  2077. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2078. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2079. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2080. if (hotelCurrncyCode.Equals("CNY"))
  2081. {
  2082. entity.DayRate = 1.0000M;
  2083. }
  2084. }
  2085. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2086. /*
  2087. * 此次付款金额
  2088. */
  2089. decimal CurrPayStr = 0.00M,
  2090. OriginalCurrPay = 0.00M;
  2091. if (entity.PayPercentage == 0)
  2092. {
  2093. if (entity.PayThenMoney != 0)
  2094. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2095. }
  2096. else
  2097. {
  2098. if (entity.PayMoney != 0)
  2099. {
  2100. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2101. }
  2102. }
  2103. //if (_dto.Label == 79)
  2104. //{
  2105. // string original = string.Empty;
  2106. // if (hotelCurrncyCode.Equals("CNY"))
  2107. // {
  2108. // OriginalCurrPay = CurrPayStr;
  2109. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2110. // }
  2111. // else
  2112. // {
  2113. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2114. // //760 EUR(7600.00 CNY)
  2115. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2116. // }
  2117. //}
  2118. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2119. string original = string.Empty;
  2120. if (hotelCurrncyCode.Equals("CNY"))
  2121. {
  2122. OriginalCurrPay = CurrPayStr;
  2123. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2124. }
  2125. else
  2126. {
  2127. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2128. //760 EUR(7600.00 CNY)
  2129. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2130. }
  2131. /*
  2132. * 剩余尾款
  2133. */
  2134. decimal BalanceStr = 0;
  2135. if (CurrPayStr != 0)
  2136. {
  2137. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2138. BalanceStr = 0;
  2139. else
  2140. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2141. }
  2142. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2143. /*
  2144. * Bus名称
  2145. */
  2146. _detail.BusName = "待增加";
  2147. /*
  2148. *费用所属
  2149. */
  2150. switch (entity.CTable)
  2151. {
  2152. case 76://酒店预订
  2153. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2154. if (hotelReservations != null)
  2155. {
  2156. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2157. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2158. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2159. string roomFeeStr = "", roomFeestr1 = "";
  2160. //是否比较房型价格
  2161. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2162. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2163. roomFeeStr += $"<br/>";
  2164. var roomTotal = 0.00M;
  2165. if (hotelReservations.SingleRoomPrice > 0)
  2166. {
  2167. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2168. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2169. //__isSingle = true;
  2170. roomTotal += fee;
  2171. }
  2172. if (hotelReservations.DoubleRoomPrice > 0)
  2173. {
  2174. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2175. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2176. // __isDouble = true;
  2177. roomTotal += fee;
  2178. }
  2179. if (hotelReservations.SuiteRoomPrice > 0)
  2180. {
  2181. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2182. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2183. //__isSuite = true;
  2184. roomTotal += fee;
  2185. }
  2186. if (hotelReservations.OtherRoomPrice > 0)
  2187. {
  2188. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2189. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2190. //__isOther = true;
  2191. roomTotal += fee;
  2192. }
  2193. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2194. else roomFeeStr += " 0.00 * 0";
  2195. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2196. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2197. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2198. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2199. /*
  2200. * 费用类型
  2201. * 1:房费
  2202. * 2:早餐
  2203. * 3:地税
  2204. * 4:城市税
  2205. * </summary>
  2206. */
  2207. //地税
  2208. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2209. if (governmentRentData != null)
  2210. {
  2211. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2212. governmentRentFee = governmentRentData.Price;
  2213. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2214. if (governmentRentCurrData != null)
  2215. {
  2216. governmentRentCode = governmentRentCurrData.Name;
  2217. governmentRentName = $"({governmentRentCurrData.Remark})";
  2218. }
  2219. }
  2220. //城市税
  2221. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2222. if (cityTaxData != null)
  2223. {
  2224. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2225. cityTaxFee = cityTaxData.Price;
  2226. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2227. if (cityTaxCurrData != null)
  2228. {
  2229. cityTaxCode = cityTaxCurrData.Name;
  2230. cityTaxName = $"({cityTaxCurrData.Remark})";
  2231. }
  2232. }
  2233. //酒店早餐
  2234. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2235. if (breakfastData != null)
  2236. {
  2237. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2238. breakfastFee = breakfastData.Price;
  2239. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2240. if (breakfastCurrData != null)
  2241. {
  2242. breakfastCode = breakfastCurrData.Name;
  2243. breakfastName = $"({breakfastCurrData.Remark})";
  2244. }
  2245. }
  2246. //房间费用
  2247. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2248. if (roomData != null)
  2249. {
  2250. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2251. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2252. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2253. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2254. roomFee = roomData.Price;
  2255. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2256. if (roomCurrData != null)
  2257. {
  2258. roomCode = roomCurrData.Name;
  2259. roomName = $"({roomCurrData.Remark})";
  2260. }
  2261. }
  2262. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2263. string hotelCostStr = "";
  2264. decimal hotelCsotTotal = 0.00M;
  2265. if (groupCost != null)
  2266. {
  2267. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2268. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2269. }
  2270. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2271. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2272. string hotelCost_day = "";
  2273. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2274. foreach (var item in hotelCostDetails1)
  2275. {
  2276. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2277. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2278. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2279. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2280. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2281. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2282. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2283. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2284. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2285. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2286. hotelCost_day += @$"<br/>";
  2287. }
  2288. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2289. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2290. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2291. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2292. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2293. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2294. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2295. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2296. $"房间说明: {hotelReservations.Remark} <br/>" +
  2297. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2298. $"{hotelBreakfastStr}" +
  2299. $"{hotelGovernmentRentStr}" +
  2300. $"{hotelCityTaxStr}";
  2301. _detail.PriceNameContent = hotelReservations.HotelName;
  2302. }
  2303. break;
  2304. case 79://车/导游地接
  2305. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2306. if (touristGuideGroundReservations != null)
  2307. {
  2308. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2309. {
  2310. _detail.BusName = touristGuideGroundReservations.BusName;
  2311. }
  2312. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2313. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2314. //if (isInt)
  2315. //{
  2316. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2317. // if (cityInfo != null)
  2318. // {
  2319. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2320. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2321. // if (carFeeItem != null)
  2322. // {
  2323. // nameContent += $@"({carFeeItem.Name})";
  2324. // }
  2325. // _detail.PriceNameContent = nameContent;
  2326. // }
  2327. //}
  2328. //else
  2329. //{
  2330. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2331. //}
  2332. var touristGuideGroundReservationsContents =
  2333. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2334. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2335. foreach (var item in touristGuideGroundReservationsContents)
  2336. {
  2337. string typeName = "Unknown";
  2338. string carCurrencyCode = "Unknown";
  2339. string carCurrencyName = "Unknown";
  2340. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2341. if (carTypeData != null) typeName = carTypeData.Name;
  2342. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2343. if (currencyData != null)
  2344. {
  2345. carCurrencyCode = currencyData.Name;
  2346. carCurrencyName = currencyData.Remark;
  2347. }
  2348. //op、成本 币种是否一致
  2349. bool IsCurrencyAgreement = false;
  2350. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2351. string opCostStr = string.Empty;
  2352. decimal opCostTypePrice = 0.00M;
  2353. #region 处理成本各项费用
  2354. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2355. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2356. if (opCost.Count > 0)
  2357. {
  2358. switch (item.SId)
  2359. {
  2360. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2361. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2362. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2363. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2364. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2365. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2366. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2367. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2368. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2369. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2370. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2371. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2372. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2373. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2374. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2375. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2376. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2377. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2378. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2379. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2380. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2381. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2382. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2383. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2384. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2385. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2386. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2387. }
  2388. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2389. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2390. }
  2391. #endregion
  2392. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2393. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2394. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2395. $"{opTypeStr} {opCostStr}<br/>" +
  2396. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2397. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2398. }
  2399. _detail.PriceMsgContent = priceMsg;
  2400. }
  2401. break;
  2402. case 80: //签证
  2403. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2404. if (visaInfo != null)
  2405. {
  2406. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2407. _detail.PriceNameContent = visaInfo.VisaDescription;
  2408. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2409. }
  2410. break;
  2411. case 81: //邀请/公务活动
  2412. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2413. if (_ioa != null)
  2414. {
  2415. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2416. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2417. sendCurrName = "Unknown", //快递费用币种 Name
  2418. sendCurrCode = "Unknown", //快递费用币种 Code
  2419. eventsCurrName = "Unknown", //公务活动费币种 Name
  2420. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2421. translateCurrName = "Unknown", //公务翻译费 Name
  2422. translateCurrCode = "Unknown"; //公务翻译费 Code
  2423. #region 处理费用币种
  2424. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2425. if (inviteCurrData != null)
  2426. {
  2427. inviteCurrName = inviteCurrData.Remark;
  2428. inviteCurrCode = inviteCurrData.Name;
  2429. }
  2430. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2431. if (sendCurrData != null)
  2432. {
  2433. sendCurrName = sendCurrData.Remark;
  2434. sendCurrCode = sendCurrData.Name;
  2435. }
  2436. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2437. if (eventsCurrData != null)
  2438. {
  2439. eventsCurrName = eventsCurrData.Remark;
  2440. eventsCurrCode = eventsCurrData.Name;
  2441. }
  2442. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2443. if (translateCurrData != null)
  2444. {
  2445. translateCurrName = translateCurrData.Remark;
  2446. translateCurrCode = translateCurrData.Name;
  2447. }
  2448. #endregion
  2449. _detail.PriceNameContent = _ioa.InviterArea;
  2450. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2451. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2452. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2453. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2454. $@"备注:" + _ioa.Remark + "<br/>";
  2455. }
  2456. break;
  2457. case 82: //团组客户保险
  2458. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2459. if (customers != null)
  2460. {
  2461. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2462. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2463. }
  2464. break;
  2465. case 85: //机票预订
  2466. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2467. if (jpRes != null)
  2468. {
  2469. string FlightsDescription = jpRes.FlightsDescription;
  2470. string PriceDescription = jpRes.PriceDescription;
  2471. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2472. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2473. }
  2474. break;
  2475. case 98://其他款项
  2476. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2477. if (gdpRes != null)
  2478. {
  2479. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2480. _detail.PriceNameContent = gdpRes.PriceName;
  2481. }
  2482. break;
  2483. case 285://收款退还
  2484. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2485. if (refundAndOtherMoney != null)
  2486. {
  2487. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2488. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2489. }
  2490. break;
  2491. case 751://酒店早餐
  2492. break;
  2493. case 1015://超支费用
  2494. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2495. if (groupExtraCost != null)
  2496. {
  2497. _detail.PriceNameContent = groupExtraCost.PriceName;
  2498. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2499. }
  2500. break;
  2501. default:
  2502. break;
  2503. }
  2504. /*
  2505. * 申请人
  2506. */
  2507. string operatorName = " - ";
  2508. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2509. if (_opUser != null)
  2510. {
  2511. operatorName = _opUser.CnName;
  2512. }
  2513. _detail.OperatorName = operatorName;
  2514. /*
  2515. * 审核人
  2516. */
  2517. string auditOperatorName = "Unknown";
  2518. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2519. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2520. else
  2521. {
  2522. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2523. if (_adUser != null)
  2524. {
  2525. auditOperatorName = _adUser.CnName;
  2526. }
  2527. }
  2528. _detail.AuditOperatorName = auditOperatorName;
  2529. /*
  2530. * 超预算比例
  2531. */
  2532. string overBudgetStr = "";
  2533. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2534. else if (entity.ExceedBudget == 0)
  2535. {
  2536. if (entity.CTable == 76 || entity.CTable == 79)
  2537. {
  2538. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2539. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2540. }
  2541. else
  2542. {
  2543. overBudgetStr = "未超预算";
  2544. }
  2545. }
  2546. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2547. _detail.OverBudget = overBudgetStr;
  2548. decimal auditFee = 0.00M; //已审核金额 人名币
  2549. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2550. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2551. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2552. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2553. {
  2554. auditedFeeOriginal = entity.PayMoney;
  2555. auditFee = CurrPayStr;
  2556. }
  2557. else if (entity.IsAuditGM == 0)
  2558. {
  2559. unAuditFeeCNY = CurrPayStr;
  2560. unAuditFeeOriginal = OriginalCurrPay;
  2561. OriginalCurrPay = 0.00M;
  2562. }
  2563. /*
  2564. * 费用总计
  2565. */
  2566. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2567. {
  2568. CurrencyId = entity.PaymentCurrency,
  2569. CurrencyName = PaymentCurrency_WaitPay,
  2570. AmountPayable = entity.PayMoney,
  2571. ThisPayment = OriginalCurrPay,
  2572. BalancePayment = BalanceStr,
  2573. AuditedFunds = auditFee,
  2574. AuditedFundsOriginal = auditedFeeOriginal,
  2575. UnAuditFundsCNY = unAuditFeeCNY,
  2576. UnAuditFundsOriginal = unAuditFeeOriginal
  2577. });
  2578. _detail.IsAuditGM = entity.IsAuditGM;
  2579. detailList.Add(_detail);
  2580. }
  2581. #endregion
  2582. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2583. /*
  2584. * 下方描述处理
  2585. */
  2586. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2587. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2588. if (ccpCurrencyPrice != null)
  2589. {
  2590. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2591. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2592. }
  2593. else
  2594. {
  2595. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2596. }
  2597. string amountPayableStr = string.Format(@"应付款总金额: ");
  2598. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2599. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2600. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2601. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2602. foreach (var item in nonDuplicat)
  2603. {
  2604. var currencyName = item.CurrencyName;
  2605. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2606. if (strs.Count > 0)
  2607. {
  2608. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2609. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2610. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2611. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2612. //单独处理此次付款金额
  2613. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2614. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2615. //单独处理已审核费用
  2616. //if (item.CurrencyId == 836) //人民币
  2617. //{
  2618. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2619. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2620. //}
  2621. //else
  2622. //{
  2623. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2624. //}
  2625. if (currencyName.Equals("CNY"))
  2626. {
  2627. //已审核费用
  2628. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2629. //未审核费用
  2630. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2631. }
  2632. else
  2633. {
  2634. //已审核费用
  2635. 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"));
  2636. //未审核费用
  2637. 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"));
  2638. }
  2639. }
  2640. }
  2641. _view.TotalStr1 = amountPayableStr[..^1];
  2642. _view.TotalStr2 = thisPaymentStr[..^1];
  2643. _view.TotalStr3 = balancePaymentStr[..^1];
  2644. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2645. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2646. var _view1 = new
  2647. {
  2648. PageFuncAuth = pageFunAuthView,
  2649. Data = _view
  2650. };
  2651. return Ok(JsonView(_view1));
  2652. }
  2653. catch (Exception ex)
  2654. {
  2655. return Ok(JsonView(false, ex.Message));
  2656. }
  2657. }
  2658. /// <summary>
  2659. /// 费用审核
  2660. /// 修改团组费用审核状态
  2661. /// </summary>
  2662. /// <param name="_dto">参数Json字符串</param>
  2663. /// <returns></returns>
  2664. [HttpPost]
  2665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2666. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2667. {
  2668. #region 参数验证
  2669. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2670. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2671. #endregion
  2672. #region 页面操作权限验证
  2673. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2674. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2675. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2676. #endregion
  2677. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2678. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2679. DateTime dtNow = DateTime.Now;
  2680. _groupRepository.BeginTran();
  2681. int rst = 0;
  2682. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2683. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2684. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2685. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2686. List<dynamic> msgDatas = new List<dynamic>();
  2687. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2688. foreach (var item in idList)
  2689. {
  2690. int CreditId = int.Parse(item);
  2691. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2692. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2693. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2694. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2695. .Where(s => s.Id == CreditId)
  2696. .ExecuteCommandAsync();
  2697. if (result < 1)
  2698. {
  2699. rst = -1;
  2700. _groupRepository.RollbackTran();
  2701. return Ok(JsonView(false, "操作失败并回滚!"));
  2702. }
  2703. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2704. if (creditData != null)
  2705. {
  2706. #region 应用通知配置
  2707. try
  2708. {
  2709. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2710. }
  2711. catch (Exception ex)
  2712. {
  2713. }
  2714. #endregion
  2715. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2716. string groupNameStr = string.Empty;
  2717. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2718. if (groupData != null) groupNameStr = groupData.TeamName;
  2719. string creditTypeStr = string.Empty;
  2720. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2721. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2722. string creditCurrency = string.Empty;
  2723. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2724. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2725. if (creditCurrency.Equals("CNY"))
  2726. {
  2727. creditData.DayRate = 1.0000M;
  2728. }
  2729. if (creditData.PayPercentage == 0.00M)
  2730. {
  2731. creditData.PayPercentage = 100M;
  2732. }
  2733. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2734. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2735. string msgContent = "";
  2736. if (creditCurrency.Equals("CNY"))
  2737. {
  2738. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2739. }
  2740. else
  2741. {
  2742. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2743. }
  2744. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2745. }
  2746. }
  2747. if (rst == 0)
  2748. {
  2749. _groupRepository.CommitTran();
  2750. foreach (var item in msgDatas)
  2751. {
  2752. //发送消息
  2753. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2754. }
  2755. #region 应用推送
  2756. try
  2757. {
  2758. foreach (var ccpId in dic_ccp_user.Keys)
  2759. {
  2760. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2761. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2762. }
  2763. }
  2764. catch (Exception)
  2765. {
  2766. }
  2767. #endregion
  2768. return Ok(JsonView(true, "操作成功!"));
  2769. }
  2770. return Ok(JsonView(false, "操作失败!"));
  2771. }
  2772. #endregion
  2773. #region 机票费用录入
  2774. /// <summary>
  2775. /// 机票录入当前登录人可操作团组
  2776. /// </summary>
  2777. /// <param name="dto"></param>
  2778. /// <returns></returns>
  2779. [HttpPost]
  2780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2781. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2782. {
  2783. try
  2784. {
  2785. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2786. if (groupData.Code != 0)
  2787. {
  2788. return Ok(JsonView(false, groupData.Msg));
  2789. }
  2790. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2791. }
  2792. catch (Exception ex)
  2793. {
  2794. return Ok(JsonView(false, "程序错误!"));
  2795. throw;
  2796. }
  2797. }
  2798. /// <summary>
  2799. /// 机票费用录入列表
  2800. /// </summary>
  2801. /// <param name="dto"></param>
  2802. /// <returns></returns>
  2803. [HttpPost]
  2804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2805. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2806. {
  2807. try
  2808. {
  2809. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2810. if (groupData.Code != 0)
  2811. {
  2812. return Ok(JsonView(false, groupData.Msg));
  2813. }
  2814. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2815. }
  2816. catch (Exception ex)
  2817. {
  2818. return Ok(JsonView(false, ex.Message));
  2819. throw;
  2820. }
  2821. }
  2822. /// <summary>
  2823. /// 根据id查询费用录入信息
  2824. /// </summary>
  2825. /// <param name="dto"></param>
  2826. /// <returns></returns>
  2827. [HttpPost]
  2828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2829. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2830. {
  2831. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2832. if (groupData.Code != 0)
  2833. {
  2834. return Ok(JsonView(false, groupData.Msg));
  2835. }
  2836. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2837. }
  2838. /// <summary>
  2839. /// 机票费用录入操作(Status:1.新增,2.修改)
  2840. /// </summary>
  2841. /// <param name="dto"></param>
  2842. /// <returns></returns>
  2843. [HttpPost]
  2844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2845. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2846. {
  2847. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2848. if (groupData.Code != 0)
  2849. {
  2850. return Ok(JsonView(false, groupData.Msg));
  2851. }
  2852. #region 应用推送
  2853. try
  2854. {
  2855. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2856. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2857. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2858. //2024-10-21 新增LZ UID
  2859. var userIds = new List<int>() { 21 };
  2860. string title = $"系统通知";
  2861. string content = "";
  2862. var diId = dto.AirTicketResOpData.DiId;
  2863. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2864. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2865. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2866. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2867. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2868. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2869. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2870. }
  2871. catch (Exception ex)
  2872. {
  2873. }
  2874. #endregion
  2875. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2876. }
  2877. /// <summary>
  2878. /// 根据舱位类型查询接团客户名单信息
  2879. /// </summary>
  2880. /// <param name="dto"></param>
  2881. /// <returns></returns>
  2882. [HttpPost]
  2883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2884. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2885. {
  2886. try
  2887. {
  2888. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2889. if (crm_Groups.Count != 0)
  2890. {
  2891. List<dynamic> Customer = new List<dynamic>();
  2892. foreach (var item in crm_Groups)
  2893. {
  2894. var data = new
  2895. {
  2896. Id = item.Id,
  2897. Pinyin = item.Pinyin,
  2898. Name = item.LastName + item.FirstName
  2899. };
  2900. Customer.Add(data);
  2901. }
  2902. return Ok(JsonView(true, "查询成功!", Customer));
  2903. }
  2904. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2905. }
  2906. catch (Exception ex)
  2907. {
  2908. return Ok(JsonView(false, "程序错误!"));
  2909. throw;
  2910. }
  2911. }
  2912. /// <summary>
  2913. /// 根据团号获取客户信息
  2914. /// </summary>
  2915. /// <param name="dto"></param>
  2916. /// <returns></returns>
  2917. [HttpPost]
  2918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2919. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2920. {
  2921. var jw = JsonView(false);
  2922. if (dto.DIID < 1)
  2923. {
  2924. jw.Msg += "请输入正确的diid";
  2925. return Ok(jw);
  2926. }
  2927. var arr = getSimplClientList(dto.DIID);
  2928. jw = JsonView(true, "获取成功!", arr);
  2929. return Ok(jw);
  2930. }
  2931. private List<SimplClientInfo> getSimplClientList(int diId)
  2932. {
  2933. 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);
  2934. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2935. foreach (var item in arr)
  2936. {
  2937. EncryptionProcessor.DecryptProperties(item);
  2938. }
  2939. return arr;
  2940. }
  2941. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2942. {
  2943. string result = origin;
  2944. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2945. {
  2946. string[] temparr = origin.Split(',');
  2947. string fistrStr = temparr[0];
  2948. int count = temparr.Count();
  2949. int tempId;
  2950. bool success = int.TryParse(fistrStr, out tempId);
  2951. if (success)
  2952. {
  2953. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2954. if (tempInfo != null)
  2955. {
  2956. if (count > 1)
  2957. {
  2958. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2959. }
  2960. else
  2961. {
  2962. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2963. }
  2964. }
  2965. }
  2966. }
  2967. return result;
  2968. }
  2969. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2970. {
  2971. string result = origin;
  2972. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2973. {
  2974. string[] temparr = origin.Split(',');
  2975. result = "";
  2976. foreach (var item in temparr)
  2977. {
  2978. int tempId;
  2979. bool success = int.TryParse(item, out tempId);
  2980. if (success)
  2981. {
  2982. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2983. if (tempInfo != null)
  2984. {
  2985. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2986. }
  2987. }
  2988. }
  2989. }
  2990. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2991. return result;
  2992. }
  2993. /// <summary>
  2994. /// 机票费用录入,删除
  2995. /// </summary>
  2996. /// <param name="dto"></param>
  2997. /// <returns></returns>
  2998. [HttpPost]
  2999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3000. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3001. {
  3002. try
  3003. {
  3004. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3005. if (res)
  3006. {
  3007. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3008. {
  3009. IsDel = 1,
  3010. DeleteUserId = dto.DeleteUserId,
  3011. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3012. }).ExecuteCommandAsync();
  3013. return Ok(JsonView(true, "删除成功!"));
  3014. }
  3015. return Ok(JsonView(false, "删除失败!"));
  3016. }
  3017. catch (Exception ex)
  3018. {
  3019. return Ok(JsonView(false, "程序错误!"));
  3020. throw;
  3021. }
  3022. }
  3023. /// <summary>
  3024. /// 导出机票录入报表
  3025. /// </summary>
  3026. /// <param name="dto"></param>
  3027. /// <returns></returns>
  3028. [HttpPost]
  3029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3030. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3031. {
  3032. try
  3033. {
  3034. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3035. if (groupData.Code != 0)
  3036. {
  3037. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3038. }
  3039. else
  3040. {
  3041. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3042. if (AirTicketReservations.Count != 0)
  3043. {
  3044. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3045. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3046. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3047. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3048. WorkbookDesigner designer = new WorkbookDesigner();
  3049. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3050. decimal countCost = 0;
  3051. foreach (var item in AirTicketReservations)
  3052. {
  3053. #region 处理客人姓名
  3054. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3055. item.ClientName = clientNames;
  3056. #endregion
  3057. if (item.BankType == "其他")
  3058. {
  3059. item.BankNo = "--";
  3060. }
  3061. else
  3062. {
  3063. if (!string.IsNullOrEmpty(item.BankType))
  3064. {
  3065. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3066. }
  3067. }
  3068. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3069. item.Price = System.Decimal.Round(item.Price, 2);
  3070. countCost += Convert.ToDecimal(item.Price);
  3071. }
  3072. designer.SetDataSource("Export", AirTicketReservations);
  3073. designer.SetDataSource("ExportDiCode", diCode);
  3074. designer.SetDataSource("ExportDiName", diName);
  3075. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3076. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3077. designer.Process();
  3078. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3079. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3080. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3081. return Ok(JsonView(true, "成功", url = rst));
  3082. }
  3083. else
  3084. {
  3085. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3086. }
  3087. }
  3088. }
  3089. catch (Exception ex)
  3090. {
  3091. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3092. throw;
  3093. }
  3094. }
  3095. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3096. /// <summary>
  3097. /// 行程单导出
  3098. /// </summary>
  3099. /// <param name="dto"></param>
  3100. /// <returns></returns>
  3101. [HttpPost]
  3102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3103. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3104. {
  3105. try
  3106. {
  3107. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3108. if (groupData.Code != 0)
  3109. {
  3110. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3111. }
  3112. else
  3113. {
  3114. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3115. if (dto.Language == "CN")
  3116. {
  3117. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3118. DocumentBuilder builder = new DocumentBuilder(doc);
  3119. int tableIndex = 0;//表格索引
  3120. //得到文档中的第一个表格
  3121. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3122. foreach (var item in _AirTicketReservations)
  3123. {
  3124. #region 处理固定数据
  3125. string[] FlightsCode = item.FlightsCode.Split('/');
  3126. if (FlightsCode.Length != 0)
  3127. {
  3128. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3129. if (_AirCompany != null)
  3130. {
  3131. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3132. }
  3133. else
  3134. {
  3135. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3136. }
  3137. }
  3138. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3139. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3140. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3141. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3142. string name = "";
  3143. foreach (string clientName in nameArray)
  3144. {
  3145. if (!name.Contains(clientName))
  3146. {
  3147. name += clientName + ",";
  3148. }
  3149. }
  3150. if (!string.IsNullOrWhiteSpace(name))
  3151. {
  3152. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3153. }
  3154. else
  3155. {
  3156. table.Range.Bookmarks["ClientName"].Text = "--";
  3157. }
  3158. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3159. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3160. table.Range.Bookmarks["JointTicket"].Text = "--";
  3161. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3162. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3163. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3164. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3165. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3166. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3167. #endregion
  3168. #region 循环数据处理
  3169. List<AirInfo> airs = new List<AirInfo>();
  3170. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3171. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3172. for (int i = 0; i < FlightsCode.Length; i++)
  3173. {
  3174. AirInfo air = new AirInfo();
  3175. string[] tempstr = DayArray[i]
  3176. .Replace("\r\n", string.Empty)
  3177. .Replace("\\r\\n", string.Empty)
  3178. .TrimStart().TrimEnd()
  3179. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3180. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3181. string starCity = "";
  3182. if (star_Three != null)
  3183. {
  3184. starCity = star_Three.AirPort;
  3185. }
  3186. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3187. string EndCity = "";
  3188. if (End_Three != null)
  3189. {
  3190. EndCity = End_Three.AirPort;
  3191. }
  3192. air.Destination = starCity + "/" + EndCity;
  3193. air.Flight = FlightsCode[i];
  3194. air.SeatingClass = item.CTypeName;
  3195. string dateTime = tempstr[2];
  3196. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3197. air.FlightDate = DateTemp;
  3198. air.DepartureTime = tempstr[5];
  3199. air.LandingTime = tempstr[6];
  3200. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3201. air.TicketStatus = "--";
  3202. air.Luggage = "--";
  3203. air.DepartureTerminal = "--";
  3204. air.LandingTerminal = "--";
  3205. airs.Add(air);
  3206. }
  3207. int row = 13;
  3208. for (int i = 0; i < airs.Count; i++)
  3209. {
  3210. if (airs.Count > 2)
  3211. {
  3212. for (int j = 0; j < airs.Count - 2; j++)
  3213. {
  3214. var CopyRow = table.Rows[12].Clone(true);
  3215. table.Rows.Add(CopyRow);
  3216. }
  3217. }
  3218. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3219. int index = 0;
  3220. foreach (PropertyInfo property in properties)
  3221. {
  3222. string value = property.GetValue(airs[i]).ToString();
  3223. Cell ishcel0 = table.Rows[row].Cells[index];
  3224. Paragraph p = new Paragraph(doc);
  3225. string s = value;
  3226. p.AppendChild(new Run(doc, s));
  3227. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3228. ishcel0.AppendChild(p);
  3229. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3230. index++;
  3231. }
  3232. row++;
  3233. }
  3234. #endregion
  3235. Paragraph lastParagraph = new Paragraph(doc);
  3236. //第一个表格末尾加段落
  3237. table.ParentNode.InsertAfter(lastParagraph, table);
  3238. //复制第一个表格
  3239. Table cloneTable = (Table)table.Clone(true);
  3240. //在文档末尾段落后面加入复制的表格
  3241. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3242. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3243. {
  3244. int rownewsIndex = 13;
  3245. for (int i = 0; i < 2; i++)
  3246. {
  3247. var CopyRow = table.Rows[12].Clone(true);
  3248. table.Rows.RemoveAt(13);
  3249. table.Rows.Add(CopyRow);
  3250. rownewsIndex++;
  3251. }
  3252. }
  3253. else
  3254. {
  3255. table.Rows.RemoveAt(12);
  3256. }
  3257. cloneTable.Rows.RemoveAt(12);
  3258. }
  3259. if (_AirTicketReservations.Count != 0)
  3260. {
  3261. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3262. if (FlightsCode.Length != 0)
  3263. {
  3264. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3265. if (_AirCompany != null)
  3266. {
  3267. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3268. }
  3269. else
  3270. {
  3271. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3272. }
  3273. }
  3274. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3275. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3276. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3277. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3278. string name = "";
  3279. foreach (string clientName in nameArray)
  3280. {
  3281. if (!name.Contains(clientName))
  3282. {
  3283. name += clientName + ",";
  3284. }
  3285. }
  3286. if (!string.IsNullOrWhiteSpace(name))
  3287. {
  3288. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3289. }
  3290. else
  3291. {
  3292. table.Range.Bookmarks["ClientName"].Text = "--";
  3293. }
  3294. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3295. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3296. table.Range.Bookmarks["JointTicket"].Text = "--";
  3297. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3298. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3299. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3300. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3301. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3302. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3303. }
  3304. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3305. //保存合并后的文档
  3306. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3307. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3308. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3309. return Ok(JsonView(true, "成功!", rst));
  3310. }
  3311. else
  3312. {
  3313. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3314. DocumentBuilder builder = new DocumentBuilder(doc);
  3315. int tableIndex = 0;//表格索引
  3316. //得到文档中的第一个表格
  3317. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3318. List<string> texts = new List<string>();
  3319. foreach (var item in _AirTicketReservations)
  3320. {
  3321. string[] FlightsCode = item.FlightsCode.Split('/');
  3322. if (FlightsCode.Length != 0)
  3323. {
  3324. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3325. if (_AirCompany != null)
  3326. {
  3327. if (!transDic.ContainsKey(_AirCompany.CnName))
  3328. {
  3329. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3330. }
  3331. }
  3332. else
  3333. {
  3334. if (!transDic.ContainsKey("--"))
  3335. {
  3336. transDic.Add("--", "--");
  3337. }
  3338. }
  3339. }
  3340. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3341. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3342. string name = "";
  3343. foreach (string clientName in nameArray)
  3344. {
  3345. name += clientName + ",";
  3346. }
  3347. if (!texts.Contains(name))
  3348. {
  3349. texts.Add(name);
  3350. }
  3351. List<AirInfo> airs = new List<AirInfo>();
  3352. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3353. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3354. for (int i = 0; i < FlightsCode.Length; i++)
  3355. {
  3356. AirInfo air = new AirInfo();
  3357. string[] tempstr = DayArray[i]
  3358. .Replace("\r\n", string.Empty)
  3359. .Replace("\\r\\n", string.Empty)
  3360. .TrimStart().TrimEnd()
  3361. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3362. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3363. if (star_Three != null)
  3364. {
  3365. if (!transDic.ContainsKey(star_Three.AirPort))
  3366. {
  3367. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3368. }
  3369. }
  3370. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3371. if (End_Three != null)
  3372. {
  3373. if (!transDic.ContainsKey(End_Three.AirPort))
  3374. {
  3375. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3376. }
  3377. }
  3378. if (!texts.Contains(item.CTypeName))
  3379. {
  3380. texts.Add(item.CTypeName);
  3381. }
  3382. }
  3383. }
  3384. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3385. if (transData.Count > 0)
  3386. {
  3387. foreach (TranslateResult item in transData)
  3388. {
  3389. if (!transDic.ContainsKey(item.Query))
  3390. {
  3391. transDic.Add(item.Query, item.Translation);
  3392. }
  3393. }
  3394. }
  3395. foreach (var item in _AirTicketReservations)
  3396. {
  3397. #region 处理固定数据
  3398. string[] FlightsCode = item.FlightsCode.Split('/');
  3399. if (FlightsCode.Length != 0)
  3400. {
  3401. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3402. if (_AirCompany != null)
  3403. {
  3404. string str = "--";
  3405. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3406. if (!string.IsNullOrEmpty(translateResult))
  3407. {
  3408. str = translateResult;
  3409. str = _airTicketResRep.Processing(str);
  3410. }
  3411. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3412. }
  3413. else
  3414. {
  3415. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3416. }
  3417. }
  3418. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3419. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3420. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3421. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3422. string names = "";
  3423. foreach (string clientName in nameArray)
  3424. {
  3425. names += clientName + ",";
  3426. }
  3427. if (!string.IsNullOrWhiteSpace(names))
  3428. {
  3429. string str = "--";
  3430. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3431. if (!string.IsNullOrEmpty(translateResult))
  3432. {
  3433. str = translateResult;
  3434. str = _airTicketResRep.Processing(str);
  3435. }
  3436. table.Range.Bookmarks["ClientName"].Text = str;
  3437. }
  3438. else
  3439. {
  3440. table.Range.Bookmarks["ClientName"].Text = "--";
  3441. }
  3442. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3443. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3444. table.Range.Bookmarks["JointTicket"].Text = "--";
  3445. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3446. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3447. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3448. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3449. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3450. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3451. #endregion
  3452. #region 循环数据处理
  3453. List<AirInfo> airs = new List<AirInfo>();
  3454. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3455. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3456. for (int i = 0; i < FlightsCode.Length; i++)
  3457. {
  3458. AirInfo air = new AirInfo();
  3459. string[] tempstr = DayArray[i]
  3460. .Replace("\r\n", string.Empty)
  3461. .Replace("\\r\\n", string.Empty)
  3462. .TrimStart().TrimEnd()
  3463. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3464. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3465. string starCity = "";
  3466. if (star_Three != null)
  3467. {
  3468. string str2 = "--";
  3469. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3470. if (!string.IsNullOrEmpty(translateResult2))
  3471. {
  3472. str2 = translateResult2;
  3473. str2 = _airTicketResRep.Processing(str2);
  3474. }
  3475. starCity = str2;
  3476. }
  3477. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3478. string EndCity = "";
  3479. if (End_Three != null)
  3480. {
  3481. string str1 = "--";
  3482. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3483. if (!string.IsNullOrEmpty(translateResult1))
  3484. {
  3485. str1 = translateResult1;
  3486. str1 = _airTicketResRep.Processing(str1);
  3487. }
  3488. EndCity = str1;
  3489. }
  3490. air.Destination = starCity + "/" + EndCity;
  3491. air.Flight = FlightsCode[i];
  3492. string str = "--";
  3493. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3494. if (!string.IsNullOrEmpty(translateResult))
  3495. {
  3496. str = translateResult;
  3497. str = _airTicketResRep.Processing(str);
  3498. }
  3499. air.SeatingClass = str;
  3500. string dateTime = tempstr[2];
  3501. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3502. air.FlightDate = DateTemp;
  3503. air.DepartureTime = tempstr[5];
  3504. air.LandingTime = tempstr[6];
  3505. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3506. air.TicketStatus = "--";
  3507. air.Luggage = "--";
  3508. air.DepartureTerminal = "--";
  3509. air.LandingTerminal = "--";
  3510. airs.Add(air);
  3511. }
  3512. int row = 13;
  3513. for (int i = 0; i < airs.Count; i++)
  3514. {
  3515. if (airs.Count > 2)
  3516. {
  3517. for (int j = 0; j < airs.Count - 2; j++)
  3518. {
  3519. var CopyRow = table.Rows[12].Clone(true);
  3520. table.Rows.Add(CopyRow);
  3521. }
  3522. }
  3523. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3524. int index = 0;
  3525. foreach (PropertyInfo property in properties)
  3526. {
  3527. string value = property.GetValue(airs[i]).ToString();
  3528. Cell ishcel0 = table.Rows[row].Cells[index];
  3529. Paragraph p = new Paragraph(doc);
  3530. string s = value;
  3531. p.AppendChild(new Run(doc, s));
  3532. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3533. ishcel0.AppendChild(p);
  3534. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3535. //ishcel0.CellFormat.VerticalAlignment=
  3536. index++;
  3537. }
  3538. row++;
  3539. }
  3540. #endregion
  3541. Paragraph lastParagraph = new Paragraph(doc);
  3542. //第一个表格末尾加段落
  3543. table.ParentNode.InsertAfter(lastParagraph, table);
  3544. //复制第一个表格
  3545. Table cloneTable = (Table)table.Clone(true);
  3546. //在文档末尾段落后面加入复制的表格
  3547. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3548. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3549. {
  3550. int rownewsIndex = 13;
  3551. for (int i = 0; i < 2; i++)
  3552. {
  3553. var CopyRow = table.Rows[12].Clone(true);
  3554. table.Rows.RemoveAt(13);
  3555. table.Rows.Add(CopyRow);
  3556. rownewsIndex++;
  3557. }
  3558. }
  3559. else
  3560. {
  3561. table.Rows.RemoveAt(12);
  3562. }
  3563. cloneTable.Rows.RemoveAt(12);
  3564. }
  3565. if (_AirTicketReservations.Count != 0)
  3566. {
  3567. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3568. if (FlightsCode.Length != 0)
  3569. {
  3570. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3571. if (_AirCompany != null)
  3572. {
  3573. string str = "--";
  3574. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3575. if (!string.IsNullOrEmpty(translateResult))
  3576. {
  3577. str = translateResult;
  3578. str = _airTicketResRep.Processing(str);
  3579. }
  3580. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3581. }
  3582. else
  3583. {
  3584. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3585. }
  3586. }
  3587. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3588. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3589. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3590. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3591. string names = "";
  3592. foreach (string clientName in nameArray)
  3593. {
  3594. names += clientName + ",";
  3595. }
  3596. if (!string.IsNullOrWhiteSpace(names))
  3597. {
  3598. string str = "--";
  3599. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3600. if (!string.IsNullOrEmpty(translateResult))
  3601. {
  3602. str = translateResult;
  3603. str = _airTicketResRep.Processing(str);
  3604. }
  3605. table.Range.Bookmarks["ClientName"].Text = str;
  3606. }
  3607. else
  3608. {
  3609. table.Range.Bookmarks["ClientName"].Text = "--";
  3610. }
  3611. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3612. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3613. table.Range.Bookmarks["JointTicket"].Text = "--";
  3614. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3615. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3616. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3617. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3618. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3619. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3620. }
  3621. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3622. //保存合并后的文档
  3623. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3624. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3625. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3626. return Ok(JsonView(true, "成功!", rst));
  3627. }
  3628. }
  3629. }
  3630. catch (Exception ex)
  3631. {
  3632. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3633. throw;
  3634. }
  3635. }
  3636. #endregion
  3637. #region 团组增减款项 --> 其他款项
  3638. /// <summary>
  3639. /// 团组增减款项下拉框绑定
  3640. /// </summary>
  3641. /// <param name="dto"></param>
  3642. /// <returns></returns>
  3643. [HttpPost]
  3644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3645. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3646. {
  3647. #region 参数验证
  3648. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3649. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3650. #endregion
  3651. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3652. }
  3653. /// <summary>
  3654. /// 根据团组Id查询团组增减款项
  3655. /// </summary>
  3656. /// <param name="dto"></param>
  3657. /// <returns></returns>
  3658. [HttpPost]
  3659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3660. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3661. {
  3662. #region 参数验证
  3663. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3664. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3665. #endregion
  3666. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3667. }
  3668. /// <summary>
  3669. /// 团组增减款项操作(Status:1.新增,2.修改)
  3670. /// </summary>
  3671. /// <param name="dto"></param>
  3672. /// <returns></returns>
  3673. [HttpPost]
  3674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3675. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3676. {
  3677. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3678. if (groupData.Code != 200)
  3679. {
  3680. return Ok(JsonView(false, groupData.Msg));
  3681. }
  3682. #region 应用推送
  3683. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3684. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3685. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3686. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3687. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3688. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3689. //自动审核
  3690. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3691. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3692. //2024-10-21 新增LZ UID
  3693. var userIds = new List<int>() { 21 };
  3694. string title = $"系统通知";
  3695. string content = "";
  3696. var diId = dto.DiId;
  3697. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3698. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3699. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3700. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3701. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3702. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3703. #endregion
  3704. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3705. }
  3706. /// <summary>
  3707. /// 团组增减款项操作 删除
  3708. /// </summary>
  3709. /// <param name="dto"></param>
  3710. /// <returns></returns>
  3711. [HttpPost]
  3712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3713. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3714. {
  3715. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3716. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3717. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3718. if (res.Code == 0)
  3719. {
  3720. return Ok(JsonView(true, "删除成功!"));
  3721. }
  3722. return Ok(JsonView(false, "删除失败!"));
  3723. }
  3724. /// <summary>
  3725. /// 根据团组增减款项Id查询
  3726. /// </summary>
  3727. /// <param name="dto"></param>
  3728. /// <returns></returns>
  3729. [HttpPost]
  3730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3731. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3732. {
  3733. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3734. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3735. }
  3736. /// <summary>
  3737. /// 查询供应商名称
  3738. /// </summary>
  3739. /// <param name="dto"></param>
  3740. /// <returns></returns>
  3741. [HttpPost]
  3742. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3743. {
  3744. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3745. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3746. ?? new List<Grp_DecreasePayments>();
  3747. dbResult = dbResult.Distinct(new
  3748. ProductComparer()).ToList();
  3749. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3750. {
  3751. x.Id,
  3752. x.SupplierAddress,
  3753. x.SupplierArea,
  3754. x.SupplierContact,
  3755. x.SupplierContactNumber,
  3756. x.SupplierEmail,
  3757. x.SupplierName,
  3758. x.SupplierSocialAccount,
  3759. x.SupplierTypeId,
  3760. }).ToList());
  3761. return Ok(jw);
  3762. }
  3763. /// <summary>
  3764. /// 团组增减款项 OTA匹配
  3765. /// </summary>
  3766. /// <param name="file"></param>
  3767. /// <returns></returns>
  3768. [HttpPost]
  3769. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3770. {
  3771. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3772. string fileName = file.FileName;
  3773. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3774. {
  3775. return Ok(JsonView(false, "请上传Excel文件!"));
  3776. }
  3777. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3778. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3779. if (!Directory.Exists(path))
  3780. {
  3781. Directory.CreateDirectory(path);
  3782. }
  3783. var filePath = @$"{path}/{fileName}";
  3784. //保存文件
  3785. using (FileStream fs = System.IO.File.Create(filePath))
  3786. {
  3787. file.CopyTo(fs);
  3788. fs.Flush();
  3789. }
  3790. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3791. //读取ExcelFile
  3792. DataTable dt = ConvertExcelToDataTable(filePath);
  3793. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3794. dt.TableName = "TB";
  3795. //修改table列名
  3796. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3797. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3798. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3799. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3800. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3801. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3802. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3803. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3804. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3805. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3806. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3807. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3808. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3809. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3810. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3811. var otaOrderNos = new List<string>();
  3812. foreach (DataRow item in dt.Rows)
  3813. {
  3814. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3815. }
  3816. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3817. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3818. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3819. .Select((dp, di) => new
  3820. {
  3821. dp.PriceName,
  3822. dp.OTAOrderNo,
  3823. dp.FeeTotal,
  3824. di.TeamName,
  3825. })
  3826. .ToListAsync();
  3827. foreach (DataRow item in dt.Rows)
  3828. {
  3829. var otaOrderNo = item["OTAOrderNo"].ToString();
  3830. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3831. if (oaData == null) continue;
  3832. item["GroupName"] = oaData.TeamName;
  3833. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3834. }
  3835. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3836. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3837. List<DataTable> datas = new List<DataTable>();
  3838. datas.Add(dt);
  3839. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3840. return Ok(JsonView(true, "操作成功", new { url = url }));
  3841. }
  3842. #region
  3843. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3844. {
  3845. // 创建Workbook对象
  3846. Workbook workbook = new Workbook(excelFilePath);
  3847. // 获取第一个工作表
  3848. Worksheet worksheet = workbook.Worksheets[0];
  3849. // 将工作表转换为DataTable
  3850. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3851. return dataTable;
  3852. }
  3853. #endregion
  3854. #endregion
  3855. #region 文件上传、删除
  3856. /// <summary>
  3857. /// region 文件上传 可以带参数
  3858. /// </summary>
  3859. /// <param name="file"></param>
  3860. /// <returns></returns>
  3861. [HttpPost]
  3862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3863. public async Task<IActionResult> UploadProject(IFormFile file)
  3864. {
  3865. //var TypeName = Request.Headers["TypeName"].ToString();
  3866. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3867. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3868. ////文件名称
  3869. //string projectFileName = file.FileName;
  3870. ////上传的文件的路径
  3871. //string filePath = $"{fileDir}/{projectFileName}";
  3872. //if (TypeName == "A")//A代表团组增减款项
  3873. //{
  3874. // filePath = fileDir + $@"\团组增减款项相关文件";
  3875. // if (!Directory.Exists(filePath))
  3876. // {
  3877. // Directory.CreateDirectory(filePath);
  3878. // }
  3879. // //上传的文件的路径
  3880. // filePath += $@"\{projectFileName}";
  3881. //}
  3882. //else if (TypeName == "B")//B代表商邀相关文件
  3883. //{
  3884. // //上传的文件的路径
  3885. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3886. // if (!Directory.Exists(filePath))
  3887. // {
  3888. // Directory.CreateDirectory(filePath);
  3889. // }
  3890. // //上传的文件的路径
  3891. // filePath = $@"\{projectFileName}";
  3892. //}
  3893. //try
  3894. //{
  3895. // using (FileStream fs = System.IO.File.Create(filePath))
  3896. // {
  3897. // file.CopyTo(fs);
  3898. // fs.Flush();
  3899. // }
  3900. //}
  3901. //catch (Exception ex)
  3902. //{
  3903. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3904. //}
  3905. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3906. try
  3907. {
  3908. var TypeName = Request.Headers["TypeName"].ToString();
  3909. if (file != null)
  3910. {
  3911. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3912. //文件名称
  3913. string projectFileName = file.FileName;
  3914. //上传的文件的路径
  3915. string filePath = $"{fileDir}/{projectFileName}";
  3916. if (TypeName == "A")//A代表团组增减款项
  3917. {
  3918. if (!Directory.Exists(fileDir))
  3919. {
  3920. Directory.CreateDirectory(fileDir);
  3921. }
  3922. //上传的文件的路径
  3923. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3924. }
  3925. else if (TypeName == "B")//B代表商邀相关文件
  3926. {
  3927. if (!Directory.Exists(fileDir))
  3928. {
  3929. Directory.CreateDirectory(fileDir);
  3930. }
  3931. //上传的文件的路径
  3932. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3933. }
  3934. using (FileStream fs = System.IO.File.Create(filePath))
  3935. {
  3936. file.CopyTo(fs);
  3937. fs.Flush();
  3938. }
  3939. return Ok(JsonView(true, "上传成功!", projectFileName));
  3940. }
  3941. else
  3942. {
  3943. return Ok(JsonView(false, "上传失败!"));
  3944. }
  3945. }
  3946. catch (Exception ex)
  3947. {
  3948. return Ok(JsonView(false, "程序错误!"));
  3949. }
  3950. }
  3951. /// <summary>
  3952. /// 删除指定文件
  3953. /// </summary>
  3954. /// <param name="dto"></param>
  3955. /// <returns></returns>
  3956. [HttpPost]
  3957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3958. public async Task<IActionResult> DelFile(DelFileDto dto)
  3959. {
  3960. try
  3961. {
  3962. var TypeName = Request.Headers["TypeName"].ToString();
  3963. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3964. string filePath = "";
  3965. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3966. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3967. int id = 0;
  3968. if (TypeName == "A")
  3969. {
  3970. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3971. // 删除该文件
  3972. System.IO.File.Delete(filePath);
  3973. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3974. .Where(a => a.Id == dto.Id)
  3975. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3976. .ExecuteCommandAsync();
  3977. }
  3978. else if (TypeName == "B")
  3979. {
  3980. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3981. // 删除该文件
  3982. System.IO.File.Delete(filePath);
  3983. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3984. if (info != null)
  3985. {
  3986. string[] files = new string[] { };
  3987. if (!string.IsNullOrEmpty(info.Attachment))
  3988. {
  3989. try
  3990. {
  3991. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3992. }
  3993. catch (Exception)
  3994. {
  3995. files = new List<string>() { info.Attachment }.ToArray();
  3996. }
  3997. }
  3998. if (files.Length > 0)
  3999. {
  4000. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4001. string filePath2 = string.Empty;
  4002. if (files1.Length > 0)
  4003. {
  4004. filePath2 = JsonConvert.SerializeObject(files1);
  4005. }
  4006. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4007. .Where(a => a.Id == dto.Id)
  4008. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4009. .ExecuteCommandAsync();
  4010. }
  4011. }
  4012. }
  4013. if (id != 0)
  4014. {
  4015. return Ok(JsonView(true, "成功!"));
  4016. }
  4017. else
  4018. {
  4019. return Ok(JsonView(false, "失败!"));
  4020. }
  4021. }
  4022. catch (Exception ex)
  4023. {
  4024. return Ok(JsonView(false, "程序错误!"));
  4025. throw;
  4026. }
  4027. }
  4028. /// <summary>
  4029. /// 文件上传多个文件 可以带参数
  4030. /// </summary>
  4031. /// <param name="files"></param>
  4032. /// <returns></returns>
  4033. [HttpPost]
  4034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4035. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4036. {
  4037. try
  4038. {
  4039. var TypeName = Request.Headers["TypeName"].ToString();
  4040. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4041. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4042. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4043. var filePahts = new List<string>();
  4044. foreach (var file in files)
  4045. {
  4046. //文件名称
  4047. string projectFileName = file.FileName;
  4048. //上传的文件的路径
  4049. string filePath = $"{fileDir}/{projectFileName}";
  4050. if (TypeName == "A")//A代表团组增减款项
  4051. {
  4052. if (!Directory.Exists(fileDir))
  4053. {
  4054. Directory.CreateDirectory(fileDir);
  4055. }
  4056. //上传的文件的路径
  4057. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4058. }
  4059. else if (TypeName == "B")//B代表商邀相关文件
  4060. {
  4061. if (!Directory.Exists(fileDir))
  4062. {
  4063. Directory.CreateDirectory(fileDir);
  4064. }
  4065. //上传的文件的路径
  4066. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4067. }
  4068. using (FileStream fs = System.IO.File.Create(filePath))
  4069. {
  4070. file.CopyTo(fs);
  4071. fs.Flush();
  4072. }
  4073. filePahts.Add(projectFileName);
  4074. }
  4075. return Ok(JsonView(true, "上传成功!", filePahts));
  4076. }
  4077. catch (Exception ex)
  4078. {
  4079. return Ok(JsonView(false, "程序错误!"));
  4080. }
  4081. }
  4082. #endregion
  4083. #region 商邀费用录入
  4084. /// <summary>
  4085. /// 根据团组Id查询商邀费用列表
  4086. /// </summary>
  4087. /// <param name="dto"></param>
  4088. /// <returns></returns>
  4089. [HttpPost]
  4090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4091. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4092. {
  4093. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4094. if (groupData.Code != 0)
  4095. {
  4096. return Ok(JsonView(false, groupData.Msg));
  4097. }
  4098. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4099. }
  4100. /// <summary>
  4101. /// 商邀费用列表
  4102. /// 下载文件
  4103. /// </summary>
  4104. /// <param name="id"></param>
  4105. /// <returns></returns>
  4106. [HttpGet("{id}")]
  4107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4108. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4109. {
  4110. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4111. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4112. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4113. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4114. var filePaths = new List<string>();
  4115. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4116. try
  4117. {
  4118. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4119. }
  4120. catch (Exception ex)
  4121. {
  4122. filePaths.Add(info.Attachment);
  4123. }
  4124. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4125. for (int i = 0; i < filePaths.Count; i++)
  4126. {
  4127. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4128. }
  4129. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4130. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4131. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4132. {
  4133. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4134. {
  4135. foreach (string filePath in filePaths)
  4136. {
  4137. if (System.IO.File.Exists(filePath))
  4138. {
  4139. // 获取文件名
  4140. string fileName = Path.GetFileName(filePath);
  4141. // 将文件添加到ZIP归档中
  4142. zipArchive.CreateEntryFromFile(filePath, fileName);
  4143. }
  4144. }
  4145. }
  4146. }
  4147. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4148. }
  4149. /// <summary>
  4150. /// 商邀费用 Info Page 基础数据源
  4151. /// </summary>
  4152. /// <returns></returns>
  4153. [HttpPost]
  4154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4155. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4156. {
  4157. try
  4158. {
  4159. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4160. if (groupData.Code != 0)
  4161. {
  4162. return Ok(JsonView(false, groupData.Msg));
  4163. }
  4164. return Ok(JsonView(true, "操作成功", groupData.Data));
  4165. }
  4166. catch (Exception ex)
  4167. {
  4168. return Ok(JsonView(false, ex.Message));
  4169. throw;
  4170. }
  4171. }
  4172. /// <summary>
  4173. /// 根据商邀费用ID查询C表和商邀费用数据
  4174. /// </summary>
  4175. /// <param name="dto"></param>
  4176. /// <returns></returns>
  4177. [HttpPost]
  4178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4179. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4180. {
  4181. try
  4182. {
  4183. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4184. if (groupData.Code != 0)
  4185. {
  4186. return Ok(JsonView(false, groupData.Msg));
  4187. }
  4188. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4189. }
  4190. catch (Exception ex)
  4191. {
  4192. return Ok(JsonView(false, ex.Message));
  4193. throw;
  4194. }
  4195. }
  4196. /// <summary>
  4197. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4198. /// </summary>
  4199. /// <param name="dto"></param>
  4200. /// <returns></returns>
  4201. [HttpPost]
  4202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4203. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4204. {
  4205. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4206. if (groupData.Code != 0)
  4207. {
  4208. return Ok(JsonView(false, groupData.Msg));
  4209. }
  4210. #region 应用推送
  4211. try
  4212. {
  4213. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4214. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4215. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4216. //2024-10-21 新增LZ UID
  4217. var userIds = new List<int>() { 21 };
  4218. string title = $"系统通知";
  4219. string content = "";
  4220. var diId = dto.DiId;
  4221. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4222. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4223. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4224. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4225. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4226. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4227. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4228. }
  4229. catch (Exception ex)
  4230. {
  4231. }
  4232. #endregion
  4233. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4234. }
  4235. /// <summary>
  4236. /// 商邀删除
  4237. /// </summary>
  4238. /// <param name="dto"></param>
  4239. /// <returns></returns>
  4240. [HttpPost]
  4241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4242. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4243. {
  4244. try
  4245. {
  4246. _sqlSugar.BeginTran();
  4247. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4248. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4249. {
  4250. IsDel = 1,
  4251. DeleteUserId = dto.DeleteUserId,
  4252. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4253. })
  4254. .Where(it => it.Id == dto.Id)
  4255. .ExecuteCommand();
  4256. if (res1 > 0)
  4257. {
  4258. int _diId = 0;
  4259. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4260. if (_ioaInfo != null)
  4261. {
  4262. _diId = _ioaInfo.DiId;
  4263. }
  4264. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4265. .SetColumns(a => new Grp_CreditCardPayment()
  4266. {
  4267. IsDel = 1,
  4268. DeleteUserId = dto.DeleteUserId,
  4269. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4270. })
  4271. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4272. .ExecuteCommand();
  4273. if (res2 > 0)
  4274. {
  4275. _sqlSugar.CommitTran();
  4276. return Ok(JsonView(true, "删除成功!"));
  4277. }
  4278. }
  4279. _sqlSugar.RollbackTran();
  4280. return Ok(JsonView(false, "删除失败"));
  4281. }
  4282. catch (Exception ex)
  4283. {
  4284. _sqlSugar.RollbackTran();
  4285. return Ok(JsonView(false, ex.Message));
  4286. }
  4287. }
  4288. /// <summary>
  4289. /// 团组模块文件上传
  4290. /// </summary>
  4291. /// <param name="dto"></param>
  4292. /// <returns></returns>
  4293. [HttpPost]
  4294. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4295. {
  4296. var jw = JsonView(false);
  4297. long M = 1024 * 1024;
  4298. if (dto.Files == null || dto.Files.Count == 0)
  4299. {
  4300. jw.Msg = "无文件信息!";
  4301. return Ok(jw);
  4302. }
  4303. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4304. {
  4305. jw.Msg = "文件大小超过20M!";
  4306. return Ok(jw);
  4307. }
  4308. //var nameSp = dto.File.FileName.Split(".");
  4309. //if (nameSp.Length < 2)
  4310. //{
  4311. // jw.Msg = "拓展名称有误!";
  4312. // return Ok(jw);
  4313. //}
  4314. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4315. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4316. //{
  4317. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4318. // return Ok(jw);
  4319. //}
  4320. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4321. if (Ctable == null)
  4322. {
  4323. jw.Msg = "Ctable指向有误!";
  4324. return Ok(jw);
  4325. }
  4326. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4327. if (groupInfo == null)
  4328. {
  4329. jw.Msg = "团组信息不存在!";
  4330. return Ok(jw);
  4331. }
  4332. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4333. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4334. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4335. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4336. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4337. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4338. try
  4339. {
  4340. if (!Directory.Exists(fileBase))
  4341. {
  4342. Directory.CreateDirectory(fileBase);
  4343. }
  4344. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4345. foreach (var fileStream in dto.Files)
  4346. {
  4347. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4348. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4349. {
  4350. Cid = dto.Cid,
  4351. CreateTime = DateTime.Now,
  4352. CreateUserId = dto.Userid,
  4353. Ctable = dto.Ctable,
  4354. Diid = dto.Diid,
  4355. IsDel = 0,
  4356. FilePath = saveFilePath,
  4357. FileName = fileStream.FileName
  4358. };
  4359. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4360. {
  4361. fileStream.CopyTo(fs);
  4362. fs.Flush();
  4363. }
  4364. saveArr.Add(file);
  4365. }
  4366. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4367. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4368. jw = JsonView(true, "保存成功!", new
  4369. {
  4370. count = addResult,
  4371. filesName = saveArr.Select(x => x.FileName)
  4372. });
  4373. }
  4374. catch (Exception ex)
  4375. {
  4376. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4377. {
  4378. count = 0,
  4379. filesName = new string[0],
  4380. });
  4381. }
  4382. return Ok(jw);
  4383. }
  4384. /// <summary>
  4385. /// 查询各模块已保存文件
  4386. /// </summary>
  4387. /// <param name="dto"></param>
  4388. /// <returns></returns>
  4389. [HttpPost]
  4390. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4391. {
  4392. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4393. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4394. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4395. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4396. {
  4397. expression = Expressionable.Create<Grp_GroupModelFile>()
  4398. .And(x => visaIds.Contains(x.CreateUserId));
  4399. }
  4400. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4401. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4402. .Where(expression.ToExpression())
  4403. .ToList();
  4404. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4405. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4406. {
  4407. x.FileName,
  4408. x.Id,
  4409. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4410. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4411. })));
  4412. }
  4413. /// <summary>
  4414. /// 下载该团组下的所有文件
  4415. /// </summary>
  4416. /// <param name="dto"></param>
  4417. /// <returns></returns>
  4418. [HttpPost]
  4419. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4420. {
  4421. var jw = JsonView(false);
  4422. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4423. if (groupInfo == null)
  4424. {
  4425. jw.Msg = "团组信息不存在!";
  4426. return Ok(jw);
  4427. }
  4428. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4429. var isModule = Convert.ToBoolean(dto.isModule);
  4430. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4431. IOOperatorHelper io = new IOOperatorHelper();
  4432. if (isModule)
  4433. {
  4434. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4435. foreach (var moduleArr in moduleGroup)
  4436. {
  4437. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4438. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4439. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4440. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4441. foreach (var item in moduleArr)
  4442. {
  4443. if (System.IO.File.Exists(item.FilePath))
  4444. {
  4445. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4446. {
  4447. byte[] bytes = new byte[fileStream.Length];
  4448. fileStream.Read(bytes, 0, bytes.Length);
  4449. fileStream.Close();
  4450. Stream stream = new MemoryStream(bytes);
  4451. chiZips.Add(item.FileName, stream);
  4452. }
  4453. }
  4454. }
  4455. if (chiZips.Count > 0)
  4456. {
  4457. var byts = io.ConvertZipStream(chiZips);
  4458. Stream stream = new MemoryStream(byts);
  4459. Zips.Add(key.Name + "_.zip", stream);
  4460. }
  4461. }
  4462. }
  4463. else
  4464. {
  4465. foreach (var item in dbQuery)
  4466. {
  4467. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4468. {
  4469. byte[] bytes = new byte[fileStream.Length];
  4470. fileStream.Read(bytes, 0, bytes.Length);
  4471. fileStream.Close();
  4472. Stream stream = new MemoryStream(bytes);
  4473. while (Zips.Keys.Contains(item.FileName))
  4474. {
  4475. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4476. }
  4477. Zips.Add(item.FileName, stream);
  4478. }
  4479. }
  4480. }
  4481. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4482. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4483. if (Zips.Count > 0)
  4484. {
  4485. var byts = io.ConvertZipStream(Zips);
  4486. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4487. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4488. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4489. }
  4490. else
  4491. {
  4492. jw.Msg = "暂无生成文件!";
  4493. }
  4494. return Ok(jw);
  4495. }
  4496. /// <summary>
  4497. /// 下载该团组下此模块的所有文件
  4498. /// </summary>
  4499. /// <param name="dto"></param>
  4500. /// <returns></returns>
  4501. [HttpPost]
  4502. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4503. {
  4504. var jw = JsonView(false);
  4505. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4506. if (groupInfo == null)
  4507. {
  4508. jw.Msg = "团组信息不存在!";
  4509. return Ok(jw);
  4510. }
  4511. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4512. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4513. && x.IsDel == 0);
  4514. if (key == null)
  4515. {
  4516. jw.Msg = "Ctable指向错误!";
  4517. return Ok(jw);
  4518. }
  4519. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4520. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4521. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4522. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4523. IOOperatorHelper io = new IOOperatorHelper();
  4524. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4525. foreach (var item in dbQuery)
  4526. {
  4527. if (System.IO.File.Exists(item.FilePath))
  4528. {
  4529. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4530. {
  4531. byte[] bytes = new byte[fileStream.Length];
  4532. fileStream.Read(bytes, 0, bytes.Length);
  4533. fileStream.Close();
  4534. Stream stream = new MemoryStream(bytes);
  4535. while (Zips.Keys.Contains(item.FileName))
  4536. {
  4537. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4538. }
  4539. Zips.Add(item.FileName, stream);
  4540. }
  4541. }
  4542. }
  4543. if (Zips.Count > 0)
  4544. {
  4545. var byts = io.ConvertZipStream(Zips);
  4546. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4547. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4548. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4549. }
  4550. else
  4551. {
  4552. jw.Msg = "暂无生成文件!";
  4553. }
  4554. return Ok(jw);
  4555. }
  4556. /// <summary>
  4557. /// 删除该团组下的指定文件
  4558. /// </summary>
  4559. /// <param name="dto"></param>
  4560. /// <returns></returns>
  4561. [HttpPost]
  4562. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4563. {
  4564. var jw = JsonView(false);
  4565. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4566. if (sing == null)
  4567. {
  4568. jw.Msg = "暂无";
  4569. return Ok(jw);
  4570. }
  4571. if (System.IO.File.Exists(sing.FilePath))
  4572. {
  4573. try
  4574. {
  4575. System.IO.File.Delete(sing.FilePath);
  4576. }
  4577. catch (Exception ex)
  4578. {
  4579. jw.Msg = "删除失败!" + ex.Message;
  4580. return Ok(jw);
  4581. }
  4582. }
  4583. sing.IsDel = 1;
  4584. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4585. sing.DeleteUserId = dto.UserId;
  4586. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4587. jw = JsonView(true, "删除成功!");
  4588. return Ok(jw);
  4589. }
  4590. #endregion
  4591. #region 团组英文资料
  4592. /// <summary>
  4593. /// 查询团组英文所有资料
  4594. /// </summary>
  4595. /// <param name="dto"></param>
  4596. /// <returns></returns>
  4597. [HttpPost]
  4598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4599. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4600. {
  4601. try
  4602. {
  4603. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4604. if (groupData.Code != 0)
  4605. {
  4606. return Ok(JsonView(false, groupData.Msg));
  4607. }
  4608. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4609. }
  4610. catch (Exception ex)
  4611. {
  4612. return Ok(JsonView(false, "程序错误!"));
  4613. throw;
  4614. }
  4615. }
  4616. /// <summary>
  4617. /// 团组英文资料操作(Status:1.新增,2.修改)
  4618. /// </summary>
  4619. /// <param name="dto"></param>
  4620. /// <returns></returns>
  4621. [HttpPost]
  4622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4623. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4624. {
  4625. try
  4626. {
  4627. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4628. if (groupData.Code != 0)
  4629. {
  4630. return Ok(JsonView(false, groupData.Msg));
  4631. }
  4632. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4633. }
  4634. catch (Exception ex)
  4635. {
  4636. return Ok(JsonView(false, "程序错误!"));
  4637. throw;
  4638. }
  4639. }
  4640. /// <summary>
  4641. /// 团组英文资料Id查询数据
  4642. /// </summary>
  4643. /// <param name="dto"></param>
  4644. /// <returns></returns>
  4645. [HttpPost]
  4646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4647. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4648. {
  4649. try
  4650. {
  4651. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4652. if (_DelegationEnData != null)
  4653. {
  4654. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4655. }
  4656. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4657. }
  4658. catch (Exception ex)
  4659. {
  4660. return Ok(JsonView(false, "程序错误!"));
  4661. throw;
  4662. }
  4663. }
  4664. /// <summary>
  4665. /// 团组英文资料删除
  4666. /// </summary>
  4667. /// <param name="dto"></param>
  4668. /// <returns></returns>
  4669. [HttpPost]
  4670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4671. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4672. {
  4673. try
  4674. {
  4675. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4676. if (!res)
  4677. {
  4678. return Ok(JsonView(false, "删除失败"));
  4679. }
  4680. return Ok(JsonView(true, "删除成功!"));
  4681. }
  4682. catch (Exception ex)
  4683. {
  4684. return Ok(JsonView(false, "程序错误!"));
  4685. throw;
  4686. }
  4687. }
  4688. #endregion
  4689. #region 导出邀请函
  4690. /// <summary>
  4691. /// 导出邀请函页面初始化
  4692. /// </summary>
  4693. /// <param name="dto"></param>
  4694. /// <returns></returns>
  4695. [HttpPost]
  4696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4697. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4698. {
  4699. try
  4700. {
  4701. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4702. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4703. if (dto.DiId == 0)
  4704. {
  4705. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4706. }
  4707. else
  4708. {
  4709. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4710. }
  4711. return Ok(JsonView(true, "查询成功!", new
  4712. {
  4713. deleClient = crm_Deles,
  4714. delegations = grp_Delegations
  4715. }));
  4716. }
  4717. catch (Exception ex)
  4718. {
  4719. return Ok(JsonView(false, "程序错误!"));
  4720. throw;
  4721. }
  4722. }
  4723. /// <summary>
  4724. /// 导出邀请函
  4725. /// </summary>
  4726. /// <param name="dto"></param>
  4727. /// <returns></returns>
  4728. [HttpPost]
  4729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4730. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4731. {
  4732. #region 参数验证
  4733. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4734. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4735. #endregion
  4736. try
  4737. {
  4738. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4739. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4740. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4741. From Grp_TourClientList tcl
  4742. Left Join
  4743. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4744. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4745. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4746. From Crm_DeleClient dc
  4747. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4748. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4749. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4750. Where dc.IsDel = 0) temp
  4751. On temp.DcId =tcl.ClientId
  4752. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4753. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4754. List<string> texts = new List<string>();
  4755. if (datas.Count != 0)
  4756. {
  4757. foreach (TourClientListDetailsView item in datas)
  4758. {
  4759. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4760. {
  4761. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4762. }
  4763. else
  4764. {
  4765. string name = item.LastName + item.FirstName;
  4766. texts.Add(name);
  4767. }
  4768. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4769. {
  4770. if (!transDic.ContainsKey(item.Job))
  4771. {
  4772. texts.Add(item.Job);
  4773. }
  4774. }
  4775. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4776. {
  4777. texts.Add(item.CompanyFullName);
  4778. }
  4779. }
  4780. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4781. if (transData.Count > 0)
  4782. {
  4783. foreach (TranslateResult item in transData)
  4784. {
  4785. if (!transDic.ContainsKey(item.Query))
  4786. {
  4787. transDic.Add(item.Query, item.Translation);
  4788. }
  4789. }
  4790. }
  4791. List<GuestList> list = new List<GuestList>();
  4792. foreach (TourClientListDetailsView dele in datas)
  4793. {
  4794. GuestList guestList = new GuestList();
  4795. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4796. {
  4797. guestList.Name = dele.Pinyin;
  4798. }
  4799. else
  4800. {
  4801. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4802. guestList.Name = Name;
  4803. }
  4804. if (dele.Sex == 0)
  4805. {
  4806. guestList.Sex = "Male";
  4807. }
  4808. else if (dele.Sex == 1)
  4809. {
  4810. guestList.Sex = "Female";
  4811. }
  4812. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4813. if (!string.IsNullOrEmpty(dele.Job))
  4814. {
  4815. guestList.Job = dele.Job;
  4816. }
  4817. list.Add(guestList);
  4818. }
  4819. //载入模板
  4820. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4821. DocumentBuilder builder = new DocumentBuilder(doc);
  4822. //获取word里所有表格
  4823. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4824. //获取所填表格的序数
  4825. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4826. var rowStart = tableOne.Rows[0]; //获取第1行
  4827. //循环赋值
  4828. for (int i = 0; i < list.Count; i++)
  4829. {
  4830. builder.MoveToCell(0, i + 1, 0, 0);
  4831. builder.Write(list[i].Name.ToString());
  4832. builder.MoveToCell(0, i + 1, 1, 0);
  4833. builder.Write(list[i].Sex.ToString());
  4834. builder.MoveToCell(0, i + 1, 2, 0);
  4835. builder.Write(list[i].DOB.ToString());
  4836. builder.MoveToCell(0, i + 1, 3, 0);
  4837. builder.Write(list[i].Job.ToString());
  4838. }
  4839. //删除多余行
  4840. while (tableOne.Rows.Count > list.Count + 1)
  4841. {
  4842. tableOne.Rows.RemoveAt(list.Count + 1);
  4843. }
  4844. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4845. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4846. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4847. doc.Save(filePath);
  4848. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4849. return Ok(JsonView(true, "操作成功!", Url));
  4850. }
  4851. else
  4852. {
  4853. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4854. }
  4855. }
  4856. catch (Exception ex)
  4857. {
  4858. return Ok(JsonView(false, ex.Message));
  4859. throw;
  4860. }
  4861. }
  4862. #endregion
  4863. #region 团组经理模块 出入境费用
  4864. /// <summary>
  4865. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4866. /// </summary>
  4867. /// <returns></returns>
  4868. [HttpPost]
  4869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4870. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4871. {
  4872. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4873. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4874. //SetDataInfoView
  4875. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4876. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4877. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4878. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4879. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4880. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4881. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4882. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4883. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4884. return Ok(JsonView(true, "查询成功!", new
  4885. {
  4886. GroupNameData = groupNameData.Data,
  4887. CurrencyData = _CurrencyData,
  4888. WordTypeData = _WordTypeData,
  4889. ExcelTypeData = _ExcelTypeData,
  4890. CurrencyInit = _currencyInfos,
  4891. ViewPermissionData = viewPermissionData
  4892. }));
  4893. }
  4894. /// <summary>
  4895. /// 团组模块 - 出入境费用
  4896. /// 实时汇率 tips
  4897. /// 签证费用 tips
  4898. /// 机票费用 tips
  4899. /// </summary>
  4900. /// <returns></returns>
  4901. [HttpPost]
  4902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4903. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4904. {
  4905. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4906. //默认币种显示
  4907. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4908. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4909. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4910. return Ok(JsonView(true, "查询成功!", new
  4911. {
  4912. //GroupNameData = groupNameData.Data,
  4913. visaData = visaData.Data,
  4914. airData = airData.Data,
  4915. reteInfos = reteInfos
  4916. }));
  4917. }
  4918. /// <summary>
  4919. /// 团组模块 - 出入境费用 - Info
  4920. /// </summary>
  4921. /// <returns></returns>
  4922. [HttpPost]
  4923. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4925. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4926. {
  4927. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4928. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4929. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4930. }
  4931. /// <summary>
  4932. /// 团组模块 - 出入境费用 - 设置view权限
  4933. /// </summary>
  4934. /// <returns></returns>
  4935. [HttpPost]
  4936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4937. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4938. {
  4939. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4940. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4941. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4942. var permissions = new List<Grp_EnterExitCostPermission>();
  4943. foreach (var userId in dto.UserIds)
  4944. {
  4945. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4946. }
  4947. if (permissions.Any())
  4948. {
  4949. _sqlSugar.BeginTran();
  4950. try
  4951. {
  4952. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4953. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4954. if (result < 1)
  4955. {
  4956. _sqlSugar.RollbackTran();
  4957. return Ok(JsonView(false));
  4958. }
  4959. }
  4960. catch (Exception ex)
  4961. {
  4962. _sqlSugar.RollbackTran();
  4963. return Ok(JsonView(false, ex.Message));
  4964. }
  4965. _sqlSugar.CommitTran();
  4966. return Ok(JsonView(true));
  4967. }
  4968. return Ok(JsonView(false));
  4969. }
  4970. /// <summary>
  4971. /// 团组模块 - 出入境费用 - Add And Update
  4972. /// </summary>
  4973. /// <returns></returns>
  4974. [HttpPost]
  4975. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4977. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4978. {
  4979. try
  4980. {
  4981. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4982. if (dto.DayOtherPriceData.Any())
  4983. {
  4984. var inserList = dto.DayOtherPriceData
  4985. .Where(x => x.Id == 0)
  4986. .Select(x => new Grp_DayOtherPrice
  4987. {
  4988. Cost = x.Cost,
  4989. Id = x.Id,
  4990. CreateTime = DateTime.Now,
  4991. CreateUserId = dto.UserId,
  4992. Currency = x.Currency,
  4993. Diid = x.DiId,
  4994. Index = x.Index,
  4995. IsDel = 0,
  4996. SetDataId = x.SetDataId,
  4997. SubTotal = x.SubTotal,
  4998. Remark = x.Remark
  4999. })
  5000. .ToList();
  5001. var updateList = dto.DayOtherPriceData
  5002. .Where(x => x.Id != 0)
  5003. .Select(x => new Grp_DayOtherPrice
  5004. {
  5005. Cost = x.Cost,
  5006. Id = x.Id,
  5007. CreateTime = DateTime.Now,
  5008. CreateUserId = dto.UserId,
  5009. Currency = x.Currency,
  5010. Diid = x.DiId,
  5011. Index = x.Index,
  5012. IsDel = 0,
  5013. SetDataId = x.SetDataId,
  5014. SubTotal = x.SubTotal,
  5015. Remark = x.Remark
  5016. })
  5017. .ToList();
  5018. //添加
  5019. _sqlSugar.BeginTran();
  5020. if (inserList.Any())
  5021. {
  5022. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5023. }
  5024. if (updateList.Any())
  5025. {
  5026. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5027. }
  5028. _sqlSugar.CommitTran();
  5029. }
  5030. if (data.Code != 0)
  5031. {
  5032. return Ok(JsonView(false, data.Msg));
  5033. }
  5034. //生成默认文件pdf并且通知人员
  5035. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5036. {
  5037. DiId = dto.DiId,
  5038. ExportType = 1,
  5039. SubTypeId = 1005
  5040. }, "pdf");
  5041. //发送通知
  5042. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5043. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5044. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5045. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5046. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5047. //汇率信息记录
  5048. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5049. return Ok(JsonView(true, data.Msg, data.Data));
  5050. }
  5051. catch (Exception ex)
  5052. {
  5053. return Ok(JsonView(false, ex.Message));
  5054. }
  5055. }
  5056. /// <summary>
  5057. /// 团组模块 - 出入境费用 - Confirm 费用
  5058. /// </summary>
  5059. /// <returns></returns>
  5060. [HttpPost]
  5061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5062. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5063. {
  5064. //TODO:测试完毕需把对应的用户ID更改
  5065. //1、数据表添加字段
  5066. //2、更改字段接口()
  5067. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5068. //3、确认成功 给财务发送消息
  5069. if (_view.Code == 200)
  5070. {
  5071. if (dto.Type == 1)
  5072. {
  5073. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5074. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5075. }
  5076. }
  5077. return Ok(_view);
  5078. }
  5079. /// <summary>
  5080. /// 团组模块 - 出入境费用 - File download
  5081. /// </summary>
  5082. /// <param name="dto"></param>
  5083. /// <returns></returns>
  5084. [HttpPost]
  5085. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5087. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5088. {
  5089. try
  5090. {
  5091. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5092. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5093. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5094. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5095. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5096. 3 团组成员名单 1 团组成员名单", ""));
  5097. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5098. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5099. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5100. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5101. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5102. //数据源
  5103. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5104. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5105. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5106. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5107. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5108. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5109. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5110. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5111. .Select((x, a, b) => new
  5112. {
  5113. x.Index,
  5114. itemName = a.Name,
  5115. CurrencyStr = b.Name,
  5116. x.Cost,
  5117. x.SubTotal,
  5118. x.Remark
  5119. })
  5120. .OrderBy((x) => x.Index)
  5121. .ToList(); //其他款项费用
  5122. var peiceItemCurrencys = new List<string>();
  5123. if (_DayAndCosts.Any())
  5124. {
  5125. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5126. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5127. }
  5128. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5129. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5130. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5131. {
  5132. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5133. }
  5134. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5135. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5136. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5137. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5138. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5139. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5140. .Select((tcl, dc, cc) => new ClientInfo
  5141. {
  5142. LastName = dc.LastName,
  5143. FirstName = dc.FirstName,
  5144. Sex = dc.Sex,
  5145. Birthday = dc.BirthDay,
  5146. Company = cc.CompanyFullName,
  5147. Job = dc.Job
  5148. })
  5149. .ToList();
  5150. foreach (var item in DeleClientList)
  5151. {
  5152. EncryptionProcessor.DecryptProperties(item);
  5153. }
  5154. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5155. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5156. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5157. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5158. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5159. if (dto.ExportType == 1) //明细表
  5160. {
  5161. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5162. {
  5163. //获取模板
  5164. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5165. //载入模板
  5166. Document doc = new Document(tempPath);
  5167. DocumentBuilder builder = new DocumentBuilder(doc);
  5168. //利用键值对存放数据
  5169. Dictionary<string, string> dic = new Dictionary<string, string>();
  5170. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5171. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5172. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5173. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5174. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5175. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5176. //境内费用(其他费用)
  5177. if (_EnterExitCosts.ChoiceOne == 1)
  5178. {
  5179. string row1_1 = "";
  5180. if (_EnterExitCosts.Visa > 0)
  5181. {
  5182. //insidePayTotal += _EnterExitCosts.Visa;
  5183. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5184. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5185. {
  5186. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5187. }
  5188. }
  5189. string row1_2 = "";
  5190. if (_EnterExitCosts.YiMiao > 0)
  5191. {
  5192. //insidePayTotal += _EnterExitCosts.YiMiao;
  5193. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5194. }
  5195. if (_EnterExitCosts.HeSuan > 0)
  5196. {
  5197. //insidePayTotal += _EnterExitCosts.HeSuan;
  5198. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5199. }
  5200. if (_EnterExitCosts.Service > 0)
  5201. {
  5202. //insidePayTotal += _EnterExitCosts.Service;
  5203. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5204. }
  5205. string row1_3 = "";
  5206. if (_EnterExitCosts.Safe > 0)
  5207. {
  5208. //insidePayTotal += _EnterExitCosts.Safe;
  5209. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5210. }
  5211. if (_EnterExitCosts.Ticket > 0)
  5212. {
  5213. //insidePayTotal += _EnterExitCosts.Ticket;
  5214. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5215. }
  5216. string row1 = "";
  5217. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5218. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5219. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5220. row1 += $"备注:{_EnterExitCosts.Remark}";
  5221. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5222. dic.Add("Row1Str", row1);
  5223. }
  5224. string airTotalStr = string.Empty,
  5225. airPriceStr = string.Empty;
  5226. //经济舱
  5227. if (_EnterExitCosts.SumJJC == 1)
  5228. {
  5229. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5230. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5231. }
  5232. //公务舱
  5233. if (_EnterExitCosts.SumGWC == 1)
  5234. {
  5235. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5236. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5237. }
  5238. //头等舱
  5239. if (_EnterExitCosts.SumTDC == 1)
  5240. {
  5241. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5242. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5243. }
  5244. //汇率描述
  5245. string rateStr = "";
  5246. if (peiceItemCurrencyInfos.Any())
  5247. {
  5248. rateStr = "\r\n汇率描述:";
  5249. foreach (var item in peiceItemCurrencyInfos)
  5250. {
  5251. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5252. }
  5253. }
  5254. string twoItemRemark = "备注:";
  5255. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5256. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5257. dic.Add("AirTotalStr", airTotalStr);
  5258. dic.Add("AirPriceStr", airPriceStr);
  5259. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5260. dic.Add("TwoItemRemark", twoItemRemark);
  5261. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5262. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5263. int table1Row = 0,
  5264. table2Row = 0,
  5265. table3Row = 0,
  5266. table4Row = 0,
  5267. table5Row = 0;
  5268. //住宿费
  5269. if (_EnterExitCosts.ChoiceThree == 1)
  5270. {
  5271. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5272. table1Row = dac1.Count;
  5273. #region 填充word表格内容
  5274. for (int i = 0; i < dac1.Count; i++)
  5275. {
  5276. Grp_DayAndCost dac = dac1[i];
  5277. if (dac == null) continue;
  5278. builder.MoveToCell(0, i, 0, 0);
  5279. builder.Write("第" + dac.Days.ToString() + "晚:");
  5280. builder.MoveToCell(0, i, 1, 0);
  5281. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5282. //builder.Write(dac.Place == null ? "" : dac.Place);
  5283. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5284. builder.MoveToCell(0, i, 2, 0);
  5285. builder.Write("费用标准:");
  5286. string curr = "";
  5287. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5288. if (currData != null)
  5289. {
  5290. curr = currData.Name;
  5291. }
  5292. builder.MoveToCell(0, i, 3, 0);
  5293. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5294. builder.MoveToCell(0, i, 4, 0);
  5295. builder.Write("费用小计:");
  5296. builder.MoveToCell(0, i, 5, 0);
  5297. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5298. }
  5299. #endregion
  5300. }
  5301. else dic.Add("SubZS", "0.00");
  5302. //删除多余行
  5303. while (table1.Rows.Count > table1Row)
  5304. {
  5305. table1.Rows.RemoveAt(table1Row);
  5306. }
  5307. //伙食费
  5308. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5309. if (_EnterExitCosts.ChoiceFour == 1)
  5310. {
  5311. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5312. table2Row = dac2.Count;
  5313. #region 填充word表格内容
  5314. for (int i = 0; i < dac2.Count; i++)
  5315. {
  5316. Grp_DayAndCost dac = dac2[i];
  5317. if (dac == null) continue;
  5318. builder.MoveToCell(1, i, 0, 0);
  5319. builder.Write("第" + dac.Days.ToString() + "天:");
  5320. builder.MoveToCell(1, i, 1, 0);
  5321. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5322. builder.MoveToCell(1, i, 2, 0);
  5323. builder.Write("费用标准:");
  5324. string curr = "";
  5325. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5326. if (currData != null)
  5327. {
  5328. curr = currData.Name;
  5329. }
  5330. builder.MoveToCell(1, i, 3, 0);
  5331. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5332. builder.MoveToCell(1, i, 4, 0);
  5333. builder.Write("费用小计:");
  5334. builder.MoveToCell(1, i, 5, 0);
  5335. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5336. }
  5337. #endregion
  5338. }
  5339. else dic.Add("SubHS", "0.00");
  5340. //删除多余行
  5341. while (table2.Rows.Count > table2Row)
  5342. {
  5343. table2.Rows.RemoveAt(table2Row);
  5344. }
  5345. //公杂费
  5346. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5347. if (_EnterExitCosts.ChoiceFive == 1)
  5348. {
  5349. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5350. table3Row = dac3.Count;
  5351. #region 填充word表格内容
  5352. for (int i = 0; i < dac3.Count; i++)
  5353. {
  5354. Grp_DayAndCost dac = dac3[i];
  5355. if (dac == null) continue;
  5356. builder.MoveToCell(2, i, 0, 0);
  5357. builder.Write("第" + dac.Days.ToString() + "天:");
  5358. builder.MoveToCell(2, i, 1, 0);
  5359. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5360. builder.MoveToCell(2, i, 2, 0);
  5361. builder.Write("费用标准:");
  5362. string curr = "";
  5363. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5364. if (currData != null)
  5365. {
  5366. curr = currData.Name;
  5367. }
  5368. builder.MoveToCell(2, i, 3, 0);
  5369. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5370. builder.MoveToCell(2, i, 4, 0);
  5371. builder.Write("费用小计:");
  5372. builder.MoveToCell(2, i, 5, 0);
  5373. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5374. }
  5375. //删除多余行
  5376. while (table3.Rows.Count > table3Row)
  5377. {
  5378. table3.Rows.RemoveAt(table3Row);
  5379. }
  5380. #endregion
  5381. }
  5382. else dic.Add("SubGZF", "0.00");
  5383. //删除多余行
  5384. while (table3.Rows.Count > table3Row)
  5385. {
  5386. table3.Rows.RemoveAt(table3Row);
  5387. }
  5388. //培训费
  5389. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5390. if (_EnterExitCosts.ChoiceSix == 1)
  5391. {
  5392. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5393. dic.Add("SubPX", pxStr);
  5394. table4Row = dac4.Count;
  5395. #region 填充word表格内容
  5396. for (int i = 0; i < dac4.Count; i++)
  5397. {
  5398. Grp_DayAndCost dac = dac4[i];
  5399. if (dac == null) continue;
  5400. builder.MoveToCell(3, i, 0, 0);
  5401. builder.Write("第" + dac.Days.ToString() + "天:");
  5402. builder.MoveToCell(3, i, 1, 0);
  5403. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5404. builder.MoveToCell(3, i, 2, 0);
  5405. builder.Write("费用标准:");
  5406. string curr = "";
  5407. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5408. if (currData != null)
  5409. {
  5410. curr = currData.Name;
  5411. }
  5412. builder.MoveToCell(3, i, 3, 0);
  5413. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5414. builder.MoveToCell(3, i, 4, 0);
  5415. builder.Write("费用小计:");
  5416. builder.MoveToCell(3, i, 5, 0);
  5417. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5418. }
  5419. #endregion
  5420. }
  5421. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5422. //删除多余行
  5423. while (table4.Rows.Count > table4Row)
  5424. {
  5425. table4.Rows.RemoveAt(table4Row);
  5426. }
  5427. //其他费用
  5428. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5429. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5430. {
  5431. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5432. dic.Add("titleQi", qtStr);
  5433. table5Row = dac5.Count;
  5434. #region 填充word表格内容
  5435. for (int i = 0; i < dac5.Count; i++)
  5436. {
  5437. var dac = dac5[i];
  5438. if (dac == null) continue;
  5439. builder.MoveToCell(4, i, 0, 0);
  5440. builder.Write("第" + dac.Index.ToString() + "项:");
  5441. builder.MoveToCell(4, i, 1, 0);
  5442. builder.Write(dac.itemName);
  5443. builder.MoveToCell(4, i, 2, 0);
  5444. builder.Write("费用标准:");
  5445. builder.MoveToCell(4, i, 3, 0);
  5446. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5447. builder.MoveToCell(4, i, 4, 0);
  5448. builder.Write("费用小计:");
  5449. builder.MoveToCell(4, i, 5, 0);
  5450. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5451. builder.MoveToCell(4, i, 6, 0);
  5452. builder.Write("备注:");
  5453. builder.MoveToCell(4, i, 7, 0);
  5454. builder.Write(dac.Remark);
  5455. }
  5456. #endregion
  5457. }
  5458. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5459. //删除多余行
  5460. while (table5.Rows.Count > table5Row)
  5461. {
  5462. table5.Rows.RemoveAt(table5Row);
  5463. }
  5464. //加上其他费用
  5465. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5466. decimal subJJC = 0.00M,
  5467. subGWC = 0.00M,
  5468. subTDC = 0.00M;
  5469. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5470. string totalLabel = string.Format("全部费用总计:");
  5471. //经济舱
  5472. if (_EnterExitCosts.SumJJC == 1)
  5473. {
  5474. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5475. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5476. }
  5477. //公务舱
  5478. if (_EnterExitCosts.SumGWC == 1) {
  5479. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5480. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5481. }
  5482. //头等舱
  5483. if (_EnterExitCosts.SumTDC == 1)
  5484. {
  5485. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5486. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5487. }
  5488. //TotalLabel
  5489. dic.Add("TotalLabel", totalLabel);
  5490. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5491. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5492. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5493. #region 填充word模板书签内容
  5494. foreach (var key in dic.Keys)
  5495. {
  5496. Bookmark bookmark = doc.Range.Bookmarks[key];
  5497. if (bookmark != null)
  5498. {
  5499. builder.MoveToBookmark(key);
  5500. builder.Write(dic[key]);
  5501. }
  5502. }
  5503. #endregion
  5504. #region 设置页眉
  5505. string userLabel = string.Empty;
  5506. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5507. if (currUserInfo != null)
  5508. {
  5509. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5510. if (userInfo != null)
  5511. {
  5512. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5513. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5514. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5515. }
  5516. }
  5517. //设置页脚
  5518. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5519. #endregion
  5520. //文件名
  5521. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5522. AsposeHelper.removewatermark_v2180();
  5523. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5524. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5525. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5526. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5527. }
  5528. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5529. {
  5530. //获取模板
  5531. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5532. //载入模板
  5533. Document doc = new Document(tempPath);
  5534. DocumentBuilder builder = new DocumentBuilder(doc);
  5535. Dictionary<string, string> dic = new Dictionary<string, string>();
  5536. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5537. {
  5538. List<string> list = new List<string>();
  5539. try
  5540. {
  5541. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5542. foreach (var item in spilitArr)
  5543. {
  5544. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5545. var depCode = spDotandEmpty[2].Substring(0, 3);
  5546. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5547. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5548. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5549. list.Add(depName);
  5550. list.Add(arrName);
  5551. }
  5552. list = list.Distinct().ToList();
  5553. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5554. }
  5555. catch (Exception)
  5556. {
  5557. dic.Add("ReturnCode", "行程录入不正确!");
  5558. }
  5559. }
  5560. else
  5561. {
  5562. dic.Add("ReturnCode", "未录入行程!");
  5563. }
  5564. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5565. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5566. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5567. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5568. {
  5569. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5570. dic.Add("Day", sp.Days.ToString());
  5571. }
  5572. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5573. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5574. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5575. //dic.Add("Names", Names);
  5576. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5577. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5578. decimal dac1totalPrice = 0.00M;
  5579. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5580. foreach (var dac in dac1)
  5581. {
  5582. if (dac.SubTotal == 0.00M)
  5583. {
  5584. continue;
  5585. }
  5586. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5587. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5588. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5589. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5590. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5591. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5592. builder.Write(currency);//币种
  5593. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5594. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5595. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5596. builder.Write("");//人数
  5597. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5598. builder.Write("");//天数
  5599. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5600. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5601. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5602. decimal rate = 0.00M;
  5603. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5604. builder.Write(rate.ToString("#0.0000"));//汇率
  5605. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5606. decimal rbmPrice = dac.SubTotal;
  5607. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5608. accommodationStartIndex++;
  5609. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5610. }
  5611. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5612. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5613. {
  5614. table1.Rows.RemoveAt(i - 1);
  5615. foodandotherStartIndex--;
  5616. }
  5617. if (dac2.Count == dac3.Count)//国家 币种 金额
  5618. {
  5619. for (int i = 0; i < dac2.Count; i++)
  5620. {
  5621. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5622. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5623. }
  5624. }
  5625. decimal dac2totalPrice = 0.00M;
  5626. foreach (var dac in dac2)
  5627. {
  5628. if (dac.SubTotal == 0)
  5629. {
  5630. continue;
  5631. }
  5632. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5633. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5634. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5635. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5636. builder.Write(currency);//币种
  5637. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5638. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5639. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5640. builder.Write("");//人数
  5641. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5642. builder.Write("");//天数
  5643. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5644. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5645. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5646. decimal rate = 0.00M;
  5647. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5648. builder.Write(rate.ToString("#0.0000"));//汇率
  5649. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5650. decimal rbmPrice = dac.SubTotal;
  5651. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5652. foodandotherStartIndex++;
  5653. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5654. }
  5655. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5656. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5657. {
  5658. table1.Rows.RemoveAt(i - 1);
  5659. }
  5660. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5661. string otherFeeStr = "";
  5662. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5663. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5664. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5665. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5666. foreach (var otherInfo in dac5)
  5667. {
  5668. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5669. }
  5670. #endregion
  5671. if (otherFeeStr.Length > 0)
  5672. {
  5673. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5674. otherFeeStr = $"({otherFeeStr})";
  5675. dic.Add("OtherFeeStr", otherFeeStr);
  5676. }
  5677. //总计
  5678. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5679. //国际旅费
  5680. string outsideAir = string.Empty;
  5681. string allPriceAir = string.Empty;
  5682. if (_EnterExitCosts.SumJJC == 1)
  5683. {
  5684. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5685. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5686. }
  5687. if (_EnterExitCosts.SumGWC == 1)
  5688. {
  5689. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5690. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5691. }
  5692. if (_EnterExitCosts.SumTDC == 1)
  5693. {
  5694. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5695. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5696. }
  5697. dic.Add("InTravelPrice", $"({outsideAir})");
  5698. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5699. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5700. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5701. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5702. foreach (var key in dic.Keys)
  5703. {
  5704. builder.MoveToBookmark(key);
  5705. builder.Write(dic[key]);
  5706. }
  5707. //模板文件名
  5708. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5709. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5710. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5711. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5712. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5713. }
  5714. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5715. {
  5716. //获取模板
  5717. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5718. //载入模板
  5719. WorkbookDesigner designer = new WorkbookDesigner();
  5720. designer.Workbook = new Workbook(tempPath);
  5721. Dictionary<string, string> dic = new Dictionary<string, string>();
  5722. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5723. {
  5724. List<string> list = new List<string>();
  5725. try
  5726. {
  5727. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5728. foreach (var item in spilitArr)
  5729. {
  5730. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5731. var depCode = spDotandEmpty[2].Substring(0, 3);
  5732. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5733. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5734. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5735. list.Add(depName);
  5736. list.Add(arrName);
  5737. }
  5738. list = list.Distinct().ToList();
  5739. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5740. }
  5741. catch (Exception)
  5742. {
  5743. dic.Add("ReturnCode", "行程录入不正确!");
  5744. }
  5745. }
  5746. else
  5747. {
  5748. dic.Add("ReturnCode", "未录入行程!");
  5749. }
  5750. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5751. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5752. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5753. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5754. {
  5755. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5756. dic.Add("Day", sp.Days.ToString());
  5757. }
  5758. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5759. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5760. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5761. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5762. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5763. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5764. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5765. designer.SetDataSource("Name", Names);
  5766. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5767. designer.SetDataSource("Day", dic["Day"] + "天");
  5768. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5769. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5770. int startIndex = 10;
  5771. const int startIndexcopy = 10;
  5772. if (dac2.Count == dac3.Count)//国家 币种 金额
  5773. {
  5774. for (int i = 0; i < dac2.Count; i++)
  5775. {
  5776. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5777. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5778. }
  5779. }
  5780. DataTable dtdac1 = new DataTable();
  5781. List<string> place = new List<string>();
  5782. dtdac1.Columns.AddRange(new DataColumn[] {
  5783. new DataColumn(){ ColumnName = "city"},
  5784. new DataColumn(){ ColumnName = "curr"},
  5785. new DataColumn(){ ColumnName = "criterion"},
  5786. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5787. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5788. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5789. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5790. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5791. });
  5792. DataTable dtdac2 = new DataTable();
  5793. dtdac2.Columns.AddRange(new DataColumn[] {
  5794. new DataColumn(){ ColumnName = "city"},
  5795. new DataColumn(){ ColumnName = "curr"},
  5796. new DataColumn(){ ColumnName = "criterion"},
  5797. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5798. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5799. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5800. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5801. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5802. });
  5803. dtdac1.TableName = "tb1";
  5804. dtdac2.TableName = "tb2";
  5805. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5806. foreach (var item in dac1)
  5807. {
  5808. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5809. if (place.Contains(item.Place))
  5810. {
  5811. continue;
  5812. }
  5813. DataRow row = dtdac1.NewRow();
  5814. row["city"] = item.Place;
  5815. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5816. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5817. row["curr"] = currency;
  5818. row["rate"] = rate.ToString("#0.0000");
  5819. row["criterion"] = item.Cost.ToString("#0.00");
  5820. row["number"] = 1;
  5821. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5822. //row["costRMB"] = rbmPrice;
  5823. dtdac1.Rows.Add(row);
  5824. place.Add(item.Place);
  5825. }
  5826. place = new List<string>();
  5827. foreach (var item in dac2)
  5828. {
  5829. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5830. if (place.Contains(item.Place))
  5831. {
  5832. continue;
  5833. }
  5834. DataRow row = dtdac2.NewRow();
  5835. row["city"] = item.Place;
  5836. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5837. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5838. row["curr"] = currency;
  5839. row["rate"] = rate.ToString("#0.0000");
  5840. row["criterion"] = item.Cost.ToString("#0.00");
  5841. row["number"] = 1;
  5842. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5843. //row["cost"] = item.SubTotal;
  5844. //row["costRMB"] = rbmPrice;
  5845. dtdac2.Rows.Add(row);
  5846. place.Add(item.Place);
  5847. //dac2totalPrice += rbmPrice;
  5848. }
  5849. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5850. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5851. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5852. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5853. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5854. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5855. string cell4Str1 = string.Empty;
  5856. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5857. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5858. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5859. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5860. string cellStr = $" 5.其他费用(";
  5861. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5862. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5863. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5864. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5865. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5866. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5867. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5868. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5869. foreach (var otherInfo in dac5)
  5870. {
  5871. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5872. }
  5873. #endregion
  5874. if (cellStr.Length > 8)
  5875. {
  5876. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5877. }
  5878. cellStr += ")";
  5879. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5880. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5881. decimal pxFee = dac4.Sum(it => it.Cost);
  5882. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5883. string celllastStr1 = "";
  5884. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5885. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5886. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5887. celllastStr1 += $",国际旅费 元";
  5888. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5889. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5890. designer.SetDataSource("cell4Str", cell4Str);
  5891. designer.SetDataSource("cellStr", cellStr);
  5892. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5893. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5894. designer.SetDataSource("celllastStr", celllastStr);
  5895. Workbook wb = designer.Workbook;
  5896. var sheet = wb.Worksheets[0];
  5897. //绑定datatable数据集
  5898. designer.SetDataSource(dtdac1);
  5899. designer.SetDataSource(dtdac2);
  5900. designer.Process();
  5901. var rowStart = dtdac1.Rows.Count;
  5902. while (rowStart > 0)
  5903. {
  5904. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5905. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5906. startIndex++;
  5907. rowStart--;
  5908. }
  5909. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5910. startIndex += 1; //总计行
  5911. rowStart = dtdac2.Rows.Count;
  5912. while (rowStart > 0)
  5913. {
  5914. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5915. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5916. startIndex++;
  5917. rowStart--;
  5918. }
  5919. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5920. wb.CalculateFormula(true);
  5921. //模板文件名
  5922. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5923. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5924. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5925. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5926. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5927. }
  5928. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5929. {
  5930. //获取模板
  5931. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5932. //载入模板
  5933. Document doc = new Document(tempPath);
  5934. DocumentBuilder builder = new DocumentBuilder(doc);
  5935. Dictionary<string, string> dic = new Dictionary<string, string>();
  5936. dic.Add("GroupName", _DelegationInfo.TeamName);
  5937. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5938. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5939. string missionLeaderJob = "";//负责人job
  5940. //int groupNumber = 0; //团人数
  5941. if (DeleClientList.Count > 0)
  5942. {
  5943. missionLeader = DeleClientList[0]?.Name ?? "";
  5944. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5945. }
  5946. dic.Add("MissionLeader", missionLeader); //团负责人
  5947. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5948. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5949. #region MyRegion
  5950. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5951. //{
  5952. // List<string> list = new List<string>();
  5953. // try
  5954. // {
  5955. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5956. // foreach (var item in spilitArr)
  5957. // {
  5958. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5959. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5960. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5961. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5962. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5963. // list.Add(depName);
  5964. // list.Add(arrName);
  5965. // }
  5966. // list = list.Distinct().ToList();
  5967. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5968. // }
  5969. // catch (Exception)
  5970. // {
  5971. // dic.Add("ReturnCode", "行程录入不正确!");
  5972. // }
  5973. //}
  5974. //else
  5975. //{
  5976. // dic.Add("ReturnCode", "未录入行程!");
  5977. //}
  5978. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5979. dic.Add("ReturnCode", string.Join("、", countrys));
  5980. #endregion
  5981. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5982. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5983. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5984. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5985. //{
  5986. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5987. // dic.Add("Day", sp.Days.ToString());
  5988. //}
  5989. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5990. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5991. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5992. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5993. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5994. //培训人员名单
  5995. int cultivateRowIndex = 7;
  5996. foreach (var item in DeleClientList)
  5997. {
  5998. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5999. builder.Write(item.Name);
  6000. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6001. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6002. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6003. string birthDay = "";
  6004. if (item.Birthday != null)
  6005. {
  6006. DateTime dt = Convert.ToDateTime(item.Birthday);
  6007. birthDay = $"{dt.Year}.{dt.Month}";
  6008. }
  6009. builder.Write(birthDay);
  6010. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6011. builder.Write(item.Company);
  6012. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6013. builder.Write(item.Job);
  6014. cultivateRowIndex++;
  6015. }
  6016. //删除多余行
  6017. //cultivateRowIndex -= 2;
  6018. int delRows = 10 + 7 - cultivateRowIndex;
  6019. if (delRows > 0)
  6020. {
  6021. for (int i = 0; i < delRows; i++)
  6022. {
  6023. table1.Rows.RemoveAt(cultivateRowIndex);
  6024. //cultivateRowIndex++;
  6025. }
  6026. }
  6027. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6028. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6029. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6030. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6031. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6032. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6033. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6034. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6035. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6036. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6037. //其他费用
  6038. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6039. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6040. //其他费用合计
  6041. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6042. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6043. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6044. //公务舱合计
  6045. //国际旅费
  6046. //string outsideJJ = "";
  6047. //string allPriceJJ = "";
  6048. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6049. {
  6050. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6051. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6052. }
  6053. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6054. {
  6055. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6056. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6057. }
  6058. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6059. {
  6060. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6061. dic.Add("AirFeeTotal", airFeeTotalStr);
  6062. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6063. dic.Add("FeeTotal", feeTotalStr);
  6064. }
  6065. foreach (var key in dic.Keys)
  6066. {
  6067. builder.MoveToBookmark(key);
  6068. builder.Write(dic[key]);
  6069. }
  6070. //模板文件名
  6071. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6072. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6073. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6074. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6075. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6076. }
  6077. }
  6078. else if (dto.ExportType == 2) //表格
  6079. {
  6080. //利用键值对存放数据
  6081. Dictionary<string, string> dic = new Dictionary<string, string>();
  6082. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6083. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6084. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6085. dic.Add("Day", sp.Days.ToString());
  6086. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6087. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6088. {
  6089. //获取模板
  6090. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6091. //载入模板
  6092. Document doc = new Document(tempPath);
  6093. DocumentBuilder builder = new DocumentBuilder(doc);
  6094. dic.Add("TeamName", _DelegationInfo.TeamName);
  6095. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6096. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6097. string missionLeaderName = "",
  6098. missionLeaderJob = "";
  6099. if (DeleClientList.Count > 0)
  6100. {
  6101. missionLeaderName = DeleClientList[0].Name;
  6102. missionLeaderJob = DeleClientList[0].Job;
  6103. }
  6104. dic.Add("MissionLeaderName", missionLeaderName);
  6105. dic.Add("MissionLeaderJob", missionLeaderJob);
  6106. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6107. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6108. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6109. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6110. int rowCount = 10;//总人数行
  6111. int startRowIndex = 7; //起始行
  6112. for (int i = 0; i < DeleClientList.Count; i++)
  6113. {
  6114. builder.MoveToCell(0, startRowIndex, 0, 0);
  6115. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6116. builder.MoveToCell(0, startRowIndex, 1, 0);
  6117. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6118. builder.Write(sex);//性别
  6119. builder.MoveToCell(0, startRowIndex, 2, 0);
  6120. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6121. builder.MoveToCell(0, startRowIndex, 3, 0);
  6122. builder.Write(DeleClientList[i].Company);//工作单位
  6123. builder.MoveToCell(0, startRowIndex, 4, 0);
  6124. builder.Write(DeleClientList[i].Job);//职务及级别
  6125. builder.MoveToCell(0, startRowIndex, 5, 0);
  6126. builder.Write("");//人员属性
  6127. builder.MoveToCell(0, startRowIndex, 6, 0);
  6128. builder.Write("");//上次出国时间
  6129. startRowIndex++;
  6130. }
  6131. int nullRow = rowCount - DeleClientList.Count;//空行
  6132. for (int i = 0; i < nullRow; i++)
  6133. {
  6134. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6135. }
  6136. foreach (var key in dic.Keys)
  6137. {
  6138. builder.MoveToBookmark(key);
  6139. builder.Write(dic[key]);
  6140. }
  6141. //模板文件名
  6142. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6143. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6144. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6145. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6146. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6147. }
  6148. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6149. {
  6150. //获取模板
  6151. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6152. //载入模板
  6153. Document doc = new Document(tempPath);
  6154. DocumentBuilder builder = new DocumentBuilder(doc);
  6155. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6156. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6157. dic.Add("Names", Names);
  6158. int accommodationRows = 12;
  6159. //int foodandotherRows = 12;
  6160. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6161. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6162. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6163. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6164. int accommodationStartIndex = 6;
  6165. decimal dac1totalPrice = 0.00M;
  6166. foreach (var dac in dac1)
  6167. {
  6168. if (dac.SubTotal == 0)
  6169. {
  6170. continue;
  6171. }
  6172. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6173. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6174. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6175. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6176. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6177. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6178. builder.Write(currency);//币种
  6179. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6180. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6181. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6182. builder.Write("");//人数
  6183. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6184. builder.Write("");//天数
  6185. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6186. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6187. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6188. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6189. builder.Write(rate.ToString("#0.0000"));//汇率
  6190. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6191. decimal rbmPrice = rate * dac.SubTotal;
  6192. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6193. accommodationStartIndex++;
  6194. dac1totalPrice += rbmPrice;
  6195. }
  6196. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6197. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6198. builder.Write("小计");
  6199. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6200. builder.Write(dac1totalPrice.ToString("#0.00"));
  6201. accommodationStartIndex++;
  6202. int nullRow = accommodationRows - dac1.Count;
  6203. //删除空行
  6204. //if (nullRow > 0)
  6205. //{
  6206. // int rowIndex = accommodationStartIndex;
  6207. // for (int i = 0; i < nullRow; i++)
  6208. // {
  6209. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6210. // row.Remove();
  6211. // rowIndex++;
  6212. // }
  6213. //}
  6214. if (dac2.Count == dac3.Count)//国家 币种 金额
  6215. {
  6216. for (int i = 0; i < dac2.Count; i++)
  6217. {
  6218. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6219. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6220. }
  6221. }
  6222. int foodandotherStartIndex = 19;//
  6223. decimal dac2totalPrice = 0.00M;
  6224. foreach (var dac in dac2)
  6225. {
  6226. if (dac.SubTotal == 0)
  6227. {
  6228. continue;
  6229. }
  6230. //foodandotherStartIndex = 12;
  6231. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6232. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6233. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6234. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6235. builder.Write(currency);//币种
  6236. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6237. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6238. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6239. builder.Write("");//人数
  6240. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6241. builder.Write("");//天数
  6242. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6243. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6244. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6245. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6246. builder.Write(rate.ToString("#0.0000"));//汇率
  6247. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6248. decimal rbmPrice = rate * dac.SubTotal;
  6249. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6250. foodandotherStartIndex++;
  6251. dac2totalPrice += rbmPrice;
  6252. }
  6253. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6254. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6255. //删除空行
  6256. //if (dac2.Count < foodandotherRows)
  6257. //{
  6258. // while (table2.Rows.Count > dac2.Count)
  6259. // {
  6260. // table2.Rows.RemoveAt(dac2.Count);
  6261. // }
  6262. //}
  6263. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6264. string otherFeeStr = "";
  6265. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6266. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6267. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6268. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6269. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6270. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6271. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6272. foreach (var otherInfo in dac5)
  6273. {
  6274. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6275. }
  6276. #endregion
  6277. if (otherFeeStr.Length > 0)
  6278. {
  6279. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6280. otherFeeStr = $"({otherFeeStr})";
  6281. dic.Add("OtherFeeStr", otherFeeStr);
  6282. }
  6283. foreach (var key in dic.Keys)
  6284. {
  6285. builder.MoveToBookmark(key);
  6286. builder.Write(dic[key]);
  6287. }
  6288. //模板文件名
  6289. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6290. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6291. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6292. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6293. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6294. }
  6295. }
  6296. else if (dto.ExportType == 3)
  6297. {
  6298. if (dto.SubTypeId == 1) //团组成员名单
  6299. {
  6300. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6301. //获取模板
  6302. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6303. //载入模板
  6304. Document doc = new Document(tempPath);
  6305. DocumentBuilder builder = new DocumentBuilder(doc);
  6306. //获取word里所有表格
  6307. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6308. //获取所填表格的序数
  6309. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6310. var rowStart = tableOne.Rows[0]; //获取第1行
  6311. //循环赋值
  6312. for (int i = 0; i < DeleClientList.Count; i++)
  6313. {
  6314. builder.MoveToCell(0, i + 1, 0, 0);
  6315. builder.Write(DeleClientList[i].Name);
  6316. builder.MoveToCell(0, i + 1, 1, 0);
  6317. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6318. builder.Write(sex);
  6319. builder.MoveToCell(0, i + 1, 2, 0);
  6320. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6321. builder.MoveToCell(0, i + 1, 3, 0);
  6322. builder.Write(DeleClientList[i].Company);
  6323. builder.MoveToCell(0, i + 1, 4, 0);
  6324. builder.Write(DeleClientList[i].Job);
  6325. }
  6326. //删除多余行
  6327. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6328. {
  6329. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6330. }
  6331. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6332. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6333. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6334. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6335. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6336. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6337. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6338. }
  6339. }
  6340. return Ok(JsonView(400, "操作失败!", ""));
  6341. }
  6342. catch (Exception ex)
  6343. {
  6344. return Ok(JsonView(400, ex.Message, ""));
  6345. }
  6346. }
  6347. /// <summary>
  6348. /// 获取三公费用标准city
  6349. /// </summary>
  6350. /// <param name="placeData"></param>
  6351. /// <param name="nationalTravelFeeId"></param>
  6352. /// <returns></returns>
  6353. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6354. {
  6355. string _city = string.Empty;
  6356. if (placeData.Count < 1) return _city;
  6357. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6358. if (data == null) return _city;
  6359. string country = data.Country;
  6360. string city = data.City;
  6361. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6362. else _city = city;
  6363. return _city;
  6364. }
  6365. /// <summary>
  6366. /// 团组模块 - 出入境费用 - 明细表导出
  6367. /// </summary>
  6368. /// <returns></returns>
  6369. [HttpPost]
  6370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6371. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6372. {
  6373. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6374. if (data.Code != 0)
  6375. {
  6376. return Ok(JsonView(false, data.Msg));
  6377. }
  6378. return Ok(JsonView(true, data.Msg, data.Data));
  6379. }
  6380. /// <summary>
  6381. /// 团组模块 - 出入境费用 - 一键清空
  6382. /// </summary>
  6383. /// <returns></returns>
  6384. [HttpPost]
  6385. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6387. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6388. {
  6389. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6390. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6391. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6392. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6393. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6394. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6395. .SetColumns(x => new Grp_DayOtherPrice
  6396. {
  6397. IsDel = 1,
  6398. DeleteUserId = dto.UserId,
  6399. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6400. })
  6401. .ExecuteCommandAsync();
  6402. if (_view.Code == 0)
  6403. {
  6404. return Ok(JsonView(true, "操作成功"));
  6405. }
  6406. return Ok(JsonView(false, "操作失败"));
  6407. }
  6408. /// <summary>
  6409. /// 团组模块 - 出入境费用 - 子项删除
  6410. /// </summary>
  6411. /// <returns></returns>
  6412. [HttpPost]
  6413. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6415. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6416. {
  6417. try
  6418. {
  6419. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6420. if (data.Code != 0)
  6421. {
  6422. return Ok(JsonView(false, data.Msg));
  6423. }
  6424. return Ok(JsonView(true, "操作成功!", data.Data));
  6425. }
  6426. catch (Exception ex)
  6427. {
  6428. return Ok(JsonView(false, ex.Message));
  6429. }
  6430. }
  6431. /// <summary>
  6432. /// 删除三公其他费用
  6433. /// </summary>
  6434. /// <param name="dto"></param>
  6435. /// <returns></returns>
  6436. [HttpPost]
  6437. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6438. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6439. {
  6440. var jw = JsonView(false, "删除失败!");
  6441. var data = new Grp_DayOtherPrice()
  6442. {
  6443. Id = dto.Id,
  6444. IsDel = 1,
  6445. DeleteUserId = dto.DeleteUserId,
  6446. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6447. };
  6448. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6449. if (del > 0)
  6450. {
  6451. jw.Code = 200;
  6452. jw.Msg = "删除成功!";
  6453. }
  6454. return Ok(jw);
  6455. }
  6456. /// <summary>
  6457. /// 团组模块 - 出入境国家费用标准 List
  6458. /// </summary>
  6459. /// <returns></returns>
  6460. [HttpPost]
  6461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6462. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6463. {
  6464. try
  6465. {
  6466. Stopwatch sw = new Stopwatch();
  6467. sw.Start();
  6468. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6469. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6470. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6471. Where gntf.Isdel = 0");
  6472. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6473. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6474. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6475. //foreach (var item in nationalTravel)
  6476. //{
  6477. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6478. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6479. // if (otherData != null)
  6480. // {
  6481. // cityData.Remove(otherData);
  6482. // cityData.Add(otherData);
  6483. // }
  6484. // nationalTravelFeeData1.Add(new
  6485. // {
  6486. // Country = item.Country,
  6487. // CityData = cityData
  6488. // });
  6489. //}
  6490. sw.Stop();
  6491. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6492. }
  6493. catch (Exception ex)
  6494. {
  6495. return Ok(JsonView(false, ex.Message));
  6496. throw;
  6497. }
  6498. }
  6499. /// <summary>
  6500. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6501. /// </summary>
  6502. /// <returns></returns>
  6503. [HttpPost]
  6504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6505. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6506. {
  6507. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6508. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6509. List<string> countryData = new List<string>();
  6510. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6511. countryData = countryData.Distinct().ToList();
  6512. List<dynamic> dataSource = new List<dynamic>();
  6513. foreach (var item in countryData)
  6514. {
  6515. var cityData1 = new List<string>();
  6516. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6517. var countryData2 = new
  6518. {
  6519. CountryName = item,
  6520. CityData = cityData1
  6521. };
  6522. dataSource.Add(countryData2);
  6523. }
  6524. return Ok(JsonView(true, "查询成功!", dataSource));
  6525. }
  6526. /// <summary>
  6527. /// 团组模块 - 出入境国家费用标准 Page List
  6528. /// </summary>
  6529. /// <returns></returns>
  6530. [HttpPost]
  6531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6532. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6533. {
  6534. int portId = dto.PortType;
  6535. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6536. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6537. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6538. string whereSql = string.Empty;
  6539. if (!string.IsNullOrEmpty(dto.Country))
  6540. {
  6541. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6542. }
  6543. if (!string.IsNullOrEmpty(dto.City))
  6544. {
  6545. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6546. }
  6547. string pageSql = string.Format(@"Select * From (
  6548. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6549. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6550. From Grp_NationalTravelFee gntf
  6551. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6552. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6553. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6554. RefAsync<int> total = 0;
  6555. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6556. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6557. }
  6558. /// <summary>
  6559. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6560. /// </summary>
  6561. /// <returns></returns>
  6562. [HttpPost]
  6563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6564. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6565. {
  6566. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6567. int portId = dto.PortType;
  6568. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6569. string whereSql = string.Empty;
  6570. if (!string.IsNullOrEmpty(dto.Country))
  6571. {
  6572. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6573. }
  6574. if (!string.IsNullOrEmpty(dto.City))
  6575. {
  6576. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6577. }
  6578. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6579. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6580. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6581. From Grp_NationalTravelFee gntf
  6582. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6583. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6584. Where gntf.Isdel = 0 {0} ", whereSql);
  6585. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6586. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6587. }
  6588. /// <summary>
  6589. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6590. /// </summary>
  6591. /// <returns></returns>
  6592. [HttpPost]
  6593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6594. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6595. {
  6596. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6597. if (data.Code != 0)
  6598. {
  6599. return Ok(JsonView(false, data.Msg));
  6600. }
  6601. return Ok(JsonView(true, "操作成功!", data.Data));
  6602. }
  6603. /// <summary>
  6604. /// 团组模块 - 出入境国家费用标准 - Del
  6605. /// </summary>
  6606. /// <returns></returns>
  6607. [HttpPost]
  6608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6609. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6610. {
  6611. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6612. {
  6613. Id = dto.Id,
  6614. DeleteUserId = dto.DeleteUserId,
  6615. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6616. IsDel = 1
  6617. };
  6618. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6619. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6620. .WhereColumns(it => new { it.Id })
  6621. .ExecuteCommandAsync();
  6622. if (delStatus <= 0)
  6623. {
  6624. return Ok(JsonView(false, "删除失败!"));
  6625. }
  6626. return Ok(JsonView(true, "操作成功!"));
  6627. }
  6628. /// <summary>
  6629. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6630. /// 注:Get 请求Headers 加 Token
  6631. /// </summary>
  6632. /// <param name="groupId"></param>
  6633. /// <returns></returns>
  6634. [HttpGet("{groupId}")]
  6635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6636. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6637. {
  6638. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6639. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6640. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6641. data.ForEach(x =>
  6642. {
  6643. x.CreateUserId = _currUserInfo.UserId;
  6644. });
  6645. if (data.Any())
  6646. {
  6647. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6648. if (add > 0)
  6649. {
  6650. return Ok(JsonView(true, "操作成功!"));
  6651. }
  6652. }
  6653. return Ok(JsonView(false, "未操作!"));
  6654. }
  6655. #endregion
  6656. #region 团组经理模块 出入境费用-草稿
  6657. /// <summary>
  6658. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6659. /// </summary>
  6660. /// <returns></returns>
  6661. [HttpPost]
  6662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6663. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6664. {
  6665. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6666. .Where(x => x.IsDel == 0)
  6667. .OrderByDescending(x => x.CreateTime)
  6668. .Select(x => new { x.Id, x.DraftName })
  6669. .ToListAsync();
  6670. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6671. //SetDataInfoView
  6672. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6673. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6674. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6675. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6676. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6677. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6678. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6679. //默认币种显示
  6680. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6681. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6682. return Ok(JsonView(true, "查询成功!", new
  6683. {
  6684. DraftNameDatas = draftNameDatas,
  6685. CurrencyData = _CurrencyData,
  6686. WordTypeData = _WordTypeData,
  6687. ExcelTypeData = _ExcelTypeData,
  6688. CurrencyInit = _currencyInfos,
  6689. ViewPermissionData = viewPermissionData
  6690. }));
  6691. }
  6692. /// <summary>
  6693. /// 团组模块 - 出入境费用-草稿
  6694. /// 实时汇率 tips
  6695. /// 机票费用 tips
  6696. /// </summary>
  6697. /// <returns></returns>
  6698. [HttpPost]
  6699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6700. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6701. {
  6702. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6703. return Ok(JsonView(true, "查询成功!", new
  6704. {
  6705. //GroupNameData = groupNameData.Data,
  6706. //visaData = visaData.Data,
  6707. //airData = airData.Data,
  6708. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6709. }));
  6710. }
  6711. /// <summary>
  6712. /// 团组模块 - 出入境费用-草稿
  6713. /// 签证费用 tips
  6714. /// </summary>
  6715. /// <returns></returns>
  6716. [HttpPost]
  6717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6718. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6719. {
  6720. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6721. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6722. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6723. .Select(x => x.NationalTravelFeeId)
  6724. .Distinct()
  6725. .ToListAsync();
  6726. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6727. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6728. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6729. .Select(x => x.Country)
  6730. .Distinct()
  6731. .ToArrayAsync();
  6732. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6733. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6734. return Ok(JsonView(true, "查询成功!", new
  6735. {
  6736. totalAmt = totalAmt,
  6737. remark = remark
  6738. }));
  6739. }
  6740. /// <summary>
  6741. /// 团组模块 - 出入境费用-草稿 - Info
  6742. /// </summary>
  6743. /// <returns></returns>
  6744. [HttpPost]
  6745. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6747. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6748. {
  6749. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6750. }
  6751. /// <summary>
  6752. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6753. /// </summary>
  6754. /// <returns></returns>
  6755. [HttpPost]
  6756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6757. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6758. {
  6759. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6760. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6761. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6762. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6763. foreach (var userId in dto.UserIds)
  6764. {
  6765. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6766. }
  6767. if (permissions.Any())
  6768. {
  6769. _sqlSugar.BeginTran();
  6770. try
  6771. {
  6772. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6773. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6774. if (result < 1)
  6775. {
  6776. _sqlSugar.RollbackTran();
  6777. return Ok(JsonView(false));
  6778. }
  6779. }
  6780. catch (Exception ex)
  6781. {
  6782. _sqlSugar.RollbackTran();
  6783. return Ok(JsonView(false, ex.Message));
  6784. }
  6785. _sqlSugar.CommitTran();
  6786. return Ok(JsonView(true));
  6787. }
  6788. return Ok(JsonView(false));
  6789. }
  6790. /// <summary>
  6791. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6792. /// </summary>
  6793. /// <returns></returns>
  6794. [HttpPost]
  6795. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6797. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6798. {
  6799. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6800. if (data.Code != 0)
  6801. {
  6802. return Ok(JsonView(false, data.Msg));
  6803. }
  6804. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6805. //汇率信息记录
  6806. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6807. return Ok(JsonView(true, data.Msg, data.Data));
  6808. }
  6809. /// <summary>
  6810. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6811. /// </summary>
  6812. /// <param name="dto"></param>
  6813. /// <returns></returns>
  6814. [HttpPost]
  6815. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6817. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6818. {
  6819. try
  6820. {
  6821. var id = dto.Id;
  6822. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6823. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6824. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6825. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6826. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6827. 3 团组成员名单 1 团组成员名单", ""));
  6828. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6829. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6830. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6831. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6832. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6833. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6834. //数据源
  6835. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6836. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6837. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6838. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6839. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6840. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6841. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6842. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6843. .Select((x, a, b) => new
  6844. {
  6845. x.Index,
  6846. itemName = a.Name,
  6847. CurrencyStr = b.Name,
  6848. x.Cost,
  6849. x.SubTotal,
  6850. x.Remark
  6851. })
  6852. .OrderBy((x) => x.Index)
  6853. .ToList(); //其他款项费用
  6854. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6855. var peiceItemCurrencys = new List<string>();
  6856. if (_DayAndCosts.Any())
  6857. {
  6858. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6859. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6860. }
  6861. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6862. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6863. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6864. {
  6865. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6866. }
  6867. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6868. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6869. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6870. if (dto.ExportType == 1) //明细表
  6871. {
  6872. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6873. {
  6874. //获取模板
  6875. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6876. //载入模板
  6877. Document doc = new Document(tempPath);
  6878. DocumentBuilder builder = new DocumentBuilder(doc);
  6879. //利用键值对存放数据
  6880. Dictionary<string, string> dic = new Dictionary<string, string>();
  6881. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6882. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6883. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6884. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6885. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6886. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6887. //境内费用(其他费用)
  6888. if (_EnterExitCosts.ChoiceOne == 1)
  6889. {
  6890. string row1_1 = "";
  6891. if (_EnterExitCosts.Visa > 0)
  6892. {
  6893. //insidePayTotal += _EnterExitCosts.Visa;
  6894. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6895. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6896. {
  6897. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6898. }
  6899. }
  6900. string row1_2 = "";
  6901. if (_EnterExitCosts.YiMiao > 0)
  6902. {
  6903. //insidePayTotal += _EnterExitCosts.YiMiao;
  6904. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6905. }
  6906. if (_EnterExitCosts.HeSuan > 0)
  6907. {
  6908. //insidePayTotal += _EnterExitCosts.HeSuan;
  6909. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6910. }
  6911. if (_EnterExitCosts.Service > 0)
  6912. {
  6913. //insidePayTotal += _EnterExitCosts.Service;
  6914. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6915. }
  6916. string row1_3 = "";
  6917. if (_EnterExitCosts.Safe > 0)
  6918. {
  6919. //insidePayTotal += _EnterExitCosts.Safe;
  6920. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6921. }
  6922. if (_EnterExitCosts.Ticket > 0)
  6923. {
  6924. //insidePayTotal += _EnterExitCosts.Ticket;
  6925. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6926. }
  6927. string row1 = "";
  6928. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6929. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6930. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6931. row1 += $"备注:{_EnterExitCosts.Remark}";
  6932. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6933. dic.Add("Row1Str", row1);
  6934. }
  6935. string airTotalStr = string.Empty,
  6936. airPriceStr = string.Empty;
  6937. //经济舱
  6938. if (_EnterExitCosts.SumJJC == 1)
  6939. {
  6940. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6941. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6942. }
  6943. //公务舱
  6944. if (_EnterExitCosts.SumGWC == 1)
  6945. {
  6946. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6947. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6948. }
  6949. //头等舱
  6950. if (_EnterExitCosts.SumTDC == 1)
  6951. {
  6952. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6953. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6954. }
  6955. //汇率描述
  6956. string rateStr = "";
  6957. if (peiceItemCurrencyInfos.Any())
  6958. {
  6959. rateStr = "\r\n汇率描述:";
  6960. foreach (var item in peiceItemCurrencyInfos)
  6961. {
  6962. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6963. }
  6964. }
  6965. string twoItemRemark = "备注:";
  6966. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6967. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6968. dic.Add("AirTotalStr", airTotalStr);
  6969. dic.Add("AirPriceStr", airPriceStr);
  6970. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6971. dic.Add("TwoItemRemark", twoItemRemark);
  6972. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6973. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6974. int table1Row = 0,
  6975. table2Row = 0,
  6976. table3Row = 0,
  6977. table4Row = 0,
  6978. table5Row = 0;
  6979. //住宿费
  6980. if (_EnterExitCosts.ChoiceThree == 1)
  6981. {
  6982. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6983. table1Row = dac1.Count;
  6984. #region 填充word表格内容
  6985. for (int i = 0; i < dac1.Count; i++)
  6986. {
  6987. var dac = dac1[i];
  6988. if (dac == null) continue;
  6989. builder.MoveToCell(0, i, 0, 0);
  6990. builder.Write("第" + dac.Days.ToString() + "晚:");
  6991. builder.MoveToCell(0, i, 1, 0);
  6992. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6993. //builder.Write(dac.Place == null ? "" : dac.Place);
  6994. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6995. builder.MoveToCell(0, i, 2, 0);
  6996. builder.Write("费用标准:");
  6997. string curr = "";
  6998. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6999. if (currData != null)
  7000. {
  7001. curr = currData.Name;
  7002. }
  7003. builder.MoveToCell(0, i, 3, 0);
  7004. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7005. builder.MoveToCell(0, i, 4, 0);
  7006. builder.Write("费用小计:");
  7007. builder.MoveToCell(0, i, 5, 0);
  7008. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7009. }
  7010. #endregion
  7011. }
  7012. else dic.Add("SubZS", "0.00");
  7013. //删除多余行
  7014. while (table1.Rows.Count > table1Row)
  7015. {
  7016. table1.Rows.RemoveAt(table1Row);
  7017. }
  7018. //伙食费
  7019. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7020. if (_EnterExitCosts.ChoiceFour == 1)
  7021. {
  7022. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7023. table2Row = dac2.Count;
  7024. #region 填充word表格内容
  7025. for (int i = 0; i < dac2.Count; i++)
  7026. {
  7027. var dac = dac2[i];
  7028. if (dac == null) continue;
  7029. builder.MoveToCell(1, i, 0, 0);
  7030. builder.Write("第" + dac.Days.ToString() + "天:");
  7031. builder.MoveToCell(1, i, 1, 0);
  7032. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7033. builder.MoveToCell(1, i, 2, 0);
  7034. builder.Write("费用标准:");
  7035. string curr = "";
  7036. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7037. if (currData != null)
  7038. {
  7039. curr = currData.Name;
  7040. }
  7041. builder.MoveToCell(1, i, 3, 0);
  7042. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7043. builder.MoveToCell(1, i, 4, 0);
  7044. builder.Write("费用小计:");
  7045. builder.MoveToCell(1, i, 5, 0);
  7046. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7047. }
  7048. #endregion
  7049. }
  7050. else dic.Add("SubHS", "0.00");
  7051. //删除多余行
  7052. while (table2.Rows.Count > table2Row)
  7053. {
  7054. table2.Rows.RemoveAt(table2Row);
  7055. }
  7056. //公杂费
  7057. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7058. if (_EnterExitCosts.ChoiceFive == 1)
  7059. {
  7060. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7061. table3Row = dac3.Count;
  7062. #region 填充word表格内容
  7063. for (int i = 0; i < dac3.Count; i++)
  7064. {
  7065. var dac = dac3[i];
  7066. if (dac == null) continue;
  7067. builder.MoveToCell(2, i, 0, 0);
  7068. builder.Write("第" + dac.Days.ToString() + "天:");
  7069. builder.MoveToCell(2, i, 1, 0);
  7070. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7071. builder.MoveToCell(2, i, 2, 0);
  7072. builder.Write("费用标准:");
  7073. string curr = "";
  7074. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7075. if (currData != null)
  7076. {
  7077. curr = currData.Name;
  7078. }
  7079. builder.MoveToCell(2, i, 3, 0);
  7080. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7081. builder.MoveToCell(2, i, 4, 0);
  7082. builder.Write("费用小计:");
  7083. builder.MoveToCell(2, i, 5, 0);
  7084. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7085. }
  7086. //删除多余行
  7087. while (table3.Rows.Count > table3Row)
  7088. {
  7089. table3.Rows.RemoveAt(table3Row);
  7090. }
  7091. #endregion
  7092. }
  7093. else dic.Add("SubGZF", "0.00");
  7094. //删除多余行
  7095. while (table3.Rows.Count > table3Row)
  7096. {
  7097. table3.Rows.RemoveAt(table3Row);
  7098. }
  7099. //培训费
  7100. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7101. if (_EnterExitCosts.ChoiceSix == 1)
  7102. {
  7103. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7104. dic.Add("SubPX", pxStr);
  7105. table4Row = dac4.Count;
  7106. #region 填充word表格内容
  7107. for (int i = 0; i < dac4.Count; i++)
  7108. {
  7109. var dac = dac4[i];
  7110. if (dac == null) continue;
  7111. builder.MoveToCell(3, i, 0, 0);
  7112. builder.Write("第" + dac.Days.ToString() + "天:");
  7113. builder.MoveToCell(3, i, 1, 0);
  7114. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7115. builder.MoveToCell(3, i, 2, 0);
  7116. builder.Write("费用标准:");
  7117. string curr = "";
  7118. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7119. if (currData != null)
  7120. {
  7121. curr = currData.Name;
  7122. }
  7123. builder.MoveToCell(3, i, 3, 0);
  7124. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7125. builder.MoveToCell(3, i, 4, 0);
  7126. builder.Write("费用小计:");
  7127. builder.MoveToCell(3, i, 5, 0);
  7128. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7129. }
  7130. #endregion
  7131. }
  7132. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7133. //删除多余行
  7134. while (table4.Rows.Count > table4Row)
  7135. {
  7136. table4.Rows.RemoveAt(table4Row);
  7137. }
  7138. //其他费用
  7139. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7140. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7141. {
  7142. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7143. dic.Add("titleQi", qtStr);
  7144. table5Row = dac5.Count;
  7145. #region 填充word表格内容
  7146. for (int i = 0; i < dac5.Count; i++)
  7147. {
  7148. var dac = dac5[i];
  7149. if (dac == null) continue;
  7150. builder.MoveToCell(4, i, 0, 0);
  7151. builder.Write("第" + dac.Index.ToString() + "项:");
  7152. builder.MoveToCell(4, i, 1, 0);
  7153. builder.Write(dac.itemName);
  7154. builder.MoveToCell(4, i, 2, 0);
  7155. builder.Write("费用标准:");
  7156. builder.MoveToCell(4, i, 3, 0);
  7157. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7158. builder.MoveToCell(4, i, 4, 0);
  7159. builder.Write("费用小计:");
  7160. builder.MoveToCell(4, i, 5, 0);
  7161. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7162. builder.MoveToCell(4, i, 6, 0);
  7163. builder.Write("备注:");
  7164. builder.MoveToCell(4, i, 7, 0);
  7165. builder.Write(dac.Remark);
  7166. }
  7167. #endregion
  7168. }
  7169. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7170. //删除多余行
  7171. while (table5.Rows.Count > table5Row)
  7172. {
  7173. table5.Rows.RemoveAt(table5Row);
  7174. }
  7175. //加上其他费用
  7176. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7177. decimal subJJC = 0.00M,
  7178. subGWC = 0.00M,
  7179. subTDC = 0.00M;
  7180. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7181. string totalLabel = string.Format("全部费用总计:");
  7182. //经济舱
  7183. if (_EnterExitCosts.SumJJC == 1)
  7184. {
  7185. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7186. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7187. }
  7188. //公务舱
  7189. if (_EnterExitCosts.SumGWC == 1)
  7190. {
  7191. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7192. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7193. }
  7194. //头等舱
  7195. if (_EnterExitCosts.SumTDC == 1)
  7196. {
  7197. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7198. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7199. }
  7200. //TotalLabel
  7201. dic.Add("TotalLabel", totalLabel);
  7202. #region 填充word模板书签内容
  7203. foreach (var key in dic.Keys)
  7204. {
  7205. Bookmark bookmark = doc.Range.Bookmarks[key];
  7206. if (bookmark != null)
  7207. {
  7208. builder.MoveToBookmark(key);
  7209. builder.Write(dic[key]);
  7210. }
  7211. }
  7212. #endregion
  7213. //文件名
  7214. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7215. strFileName = CommonFun.ValidFileName(strFileName);
  7216. AsposeHelper.removewatermark_v2180();
  7217. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7218. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7219. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7220. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7221. }
  7222. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7223. {
  7224. //获取模板
  7225. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7226. //载入模板
  7227. Document doc = new Document(tempPath);
  7228. DocumentBuilder builder = new DocumentBuilder(doc);
  7229. Dictionary<string, string> dic = new Dictionary<string, string>();
  7230. string returnCodeLabel = string.Empty;
  7231. if (nationalTravelFeeData.Any())
  7232. {
  7233. List<string> list = new List<string>();
  7234. foreach (var item in nationalTravelFeeData)
  7235. {
  7236. list.Add($"{item.Country}({item.City})");
  7237. }
  7238. list = list.Distinct().ToList();
  7239. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7240. }
  7241. var countryLabel = string.Empty;
  7242. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7243. if (countryData.Any())
  7244. {
  7245. countryLabel = string.Join("、", countryData);
  7246. }
  7247. dic.Add("ReturnCodeAir", returnCodeLabel);
  7248. dic.Add("VisitStartDate", "-");
  7249. dic.Add("VisitEndDate", "-");
  7250. dic.Add("Day", "-");
  7251. dic.Add("VisitCountry", countryLabel);
  7252. dic.Add("ClientUnit", "-");
  7253. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7254. //dic.Add("Names", Names);
  7255. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7256. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7257. decimal dac1totalPrice = 0.00M;
  7258. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7259. foreach (var dac in dac1)
  7260. {
  7261. if (dac.SubTotal == 0.00M)
  7262. {
  7263. continue;
  7264. }
  7265. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7266. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7267. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7268. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7269. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7270. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7271. builder.Write(currency);//币种
  7272. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7273. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7274. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7275. builder.Write("");//人数
  7276. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7277. builder.Write("");//天数
  7278. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7279. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7280. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7281. decimal rate = 0.00M;
  7282. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7283. builder.Write(rate.ToString("#0.0000"));//汇率
  7284. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7285. decimal rbmPrice = dac.SubTotal;
  7286. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7287. accommodationStartIndex++;
  7288. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7289. }
  7290. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7291. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7292. {
  7293. table1.Rows.RemoveAt(i - 1);
  7294. foodandotherStartIndex--;
  7295. }
  7296. if (dac2.Count == dac3.Count)//国家 币种 金额
  7297. {
  7298. for (int i = 0; i < dac2.Count; i++)
  7299. {
  7300. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7301. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7302. }
  7303. }
  7304. decimal dac2totalPrice = 0.00M;
  7305. foreach (var dac in dac2)
  7306. {
  7307. if (dac.SubTotal == 0)
  7308. {
  7309. continue;
  7310. }
  7311. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7312. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7313. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7314. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7315. builder.Write(currency);//币种
  7316. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7317. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7318. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7319. builder.Write("");//人数
  7320. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7321. builder.Write("");//天数
  7322. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7323. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7324. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7325. decimal rate = 0.00M;
  7326. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7327. builder.Write(rate.ToString("#0.0000"));//汇率
  7328. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7329. decimal rbmPrice = dac.SubTotal;
  7330. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7331. foodandotherStartIndex++;
  7332. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7333. }
  7334. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7335. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7336. {
  7337. table1.Rows.RemoveAt(i - 1);
  7338. }
  7339. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7340. string otherFeeStr = "";
  7341. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7342. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7343. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7344. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7345. foreach (var otherInfo in dac5)
  7346. {
  7347. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7348. }
  7349. #endregion
  7350. if (otherFeeStr.Length > 0)
  7351. {
  7352. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7353. otherFeeStr = $"({otherFeeStr})";
  7354. dic.Add("OtherFeeStr", otherFeeStr);
  7355. }
  7356. //总计
  7357. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7358. //国际旅费
  7359. string outsideAir = string.Empty;
  7360. string allPriceAir = string.Empty;
  7361. if (_EnterExitCosts.SumJJC == 1)
  7362. {
  7363. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7364. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7365. }
  7366. if (_EnterExitCosts.SumGWC == 1)
  7367. {
  7368. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7369. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7370. }
  7371. if (_EnterExitCosts.SumTDC == 1)
  7372. {
  7373. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7374. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7375. }
  7376. dic.Add("InTravelPrice", $"({outsideAir})");
  7377. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7378. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7379. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7380. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7381. foreach (var key in dic.Keys)
  7382. {
  7383. builder.MoveToBookmark(key);
  7384. builder.Write(dic[key]);
  7385. }
  7386. //模板文件名
  7387. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7388. strFileName = CommonFun.ValidFileName(strFileName);
  7389. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7390. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7391. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7392. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7393. }
  7394. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7395. {
  7396. //获取模板
  7397. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7398. //载入模板
  7399. WorkbookDesigner designer = new WorkbookDesigner();
  7400. designer.Workbook = new Workbook(tempPath);
  7401. Dictionary<string, string> dic = new Dictionary<string, string>();
  7402. string returnCodeLabel = string.Empty;
  7403. if (nationalTravelFeeData.Any())
  7404. {
  7405. List<string> list = new List<string>();
  7406. foreach (var item in nationalTravelFeeData)
  7407. {
  7408. list.Add($"{item.Country}({item.City})");
  7409. }
  7410. list = list.Distinct().ToList();
  7411. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7412. }
  7413. var countryLabel = string.Empty;
  7414. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7415. if (countryData.Any())
  7416. {
  7417. countryLabel = string.Join("、", countryData);
  7418. }
  7419. dic.Add("ReturnCodeAir", returnCodeLabel);
  7420. dic.Add("VisitStartDate", "-");
  7421. dic.Add("VisitEndDate", "-");
  7422. dic.Add("Day", "0");
  7423. dic.Add("VisitCountry", countryLabel);
  7424. dic.Add("ClientUnit", "-");
  7425. designer.SetDataSource("ClientUnit", "-");
  7426. designer.SetDataSource("VisitCountry", countryLabel);
  7427. designer.SetDataSource("Group", "-");
  7428. designer.SetDataSource("ClientUnitTitle", "-");
  7429. designer.SetDataSource("Name", "-");
  7430. designer.SetDataSource("VisitStartDate", "-");
  7431. designer.SetDataSource("Day", "0");
  7432. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7433. designer.SetDataSource("ReturnCodeAir", "-");
  7434. int startIndex = 10;
  7435. const int startIndexcopy = 10;
  7436. if (dac2.Count == dac3.Count)//国家 币种 金额
  7437. {
  7438. for (int i = 0; i < dac2.Count; i++)
  7439. {
  7440. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7441. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7442. }
  7443. }
  7444. DataTable dtdac1 = new DataTable();
  7445. List<string> place = new List<string>();
  7446. dtdac1.Columns.AddRange(new DataColumn[] {
  7447. new DataColumn(){ ColumnName = "city"},
  7448. new DataColumn(){ ColumnName = "curr"},
  7449. new DataColumn(){ ColumnName = "criterion"},
  7450. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7451. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7452. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7453. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7454. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7455. });
  7456. DataTable dtdac2 = new DataTable();
  7457. dtdac2.Columns.AddRange(new DataColumn[] {
  7458. new DataColumn(){ ColumnName = "city"},
  7459. new DataColumn(){ ColumnName = "curr"},
  7460. new DataColumn(){ ColumnName = "criterion"},
  7461. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7462. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7463. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7464. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7465. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7466. });
  7467. dtdac1.TableName = "tb1";
  7468. dtdac2.TableName = "tb2";
  7469. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7470. foreach (var item in dac1)
  7471. {
  7472. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7473. if (place.Contains(item.Place))
  7474. {
  7475. continue;
  7476. }
  7477. DataRow row = dtdac1.NewRow();
  7478. row["city"] = item.Place;
  7479. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7480. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7481. row["curr"] = currency;
  7482. row["rate"] = rate.ToString("#0.0000");
  7483. row["criterion"] = item.Cost.ToString("#0.00");
  7484. row["number"] = 1;
  7485. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7486. //row["costRMB"] = rbmPrice;
  7487. dtdac1.Rows.Add(row);
  7488. place.Add(item.Place);
  7489. }
  7490. place = new List<string>();
  7491. foreach (var item in dac2)
  7492. {
  7493. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7494. if (place.Contains(item.Place))
  7495. {
  7496. continue;
  7497. }
  7498. DataRow row = dtdac2.NewRow();
  7499. row["city"] = item.Place;
  7500. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7501. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7502. row["curr"] = currency;
  7503. row["rate"] = rate.ToString("#0.0000");
  7504. row["criterion"] = item.Cost.ToString("#0.00");
  7505. row["number"] = 1;
  7506. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7507. //row["cost"] = item.SubTotal;
  7508. //row["costRMB"] = rbmPrice;
  7509. dtdac2.Rows.Add(row);
  7510. place.Add(item.Place);
  7511. //dac2totalPrice += rbmPrice;
  7512. }
  7513. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7514. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7515. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7516. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7517. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7518. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7519. string cell4Str1 = string.Empty;
  7520. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7521. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7522. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7523. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7524. string cellStr = $" 5.其他费用(";
  7525. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7526. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7527. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7528. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7529. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7530. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7531. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7532. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7533. foreach (var otherInfo in dac5)
  7534. {
  7535. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7536. }
  7537. #endregion
  7538. if (cellStr.Length > 8)
  7539. {
  7540. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7541. }
  7542. cellStr += ")";
  7543. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7544. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7545. decimal pxFee = dac4.Sum(it => it.Cost);
  7546. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7547. string celllastStr1 = "";
  7548. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7549. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7550. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7551. celllastStr1 += $",国际旅费 元";
  7552. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7553. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7554. designer.SetDataSource("cell4Str", cell4Str);
  7555. designer.SetDataSource("cellStr", cellStr);
  7556. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7557. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7558. designer.SetDataSource("celllastStr", celllastStr);
  7559. Workbook wb = designer.Workbook;
  7560. var sheet = wb.Worksheets[0];
  7561. //绑定datatable数据集
  7562. designer.SetDataSource(dtdac1);
  7563. designer.SetDataSource(dtdac2);
  7564. designer.Process();
  7565. var rowStart = dtdac1.Rows.Count;
  7566. while (rowStart > 0)
  7567. {
  7568. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7569. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7570. startIndex++;
  7571. rowStart--;
  7572. }
  7573. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7574. startIndex += 1; //总计行
  7575. rowStart = dtdac2.Rows.Count;
  7576. while (rowStart > 0)
  7577. {
  7578. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7579. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7580. startIndex++;
  7581. rowStart--;
  7582. }
  7583. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7584. wb.CalculateFormula(true);
  7585. //模板文件名
  7586. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7587. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7588. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7589. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7590. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7591. }
  7592. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7593. {
  7594. //获取模板
  7595. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7596. //载入模板
  7597. Document doc = new Document(tempPath);
  7598. DocumentBuilder builder = new DocumentBuilder(doc);
  7599. Dictionary<string, string> dic = new Dictionary<string, string>();
  7600. dic.Add("GroupName", "-");
  7601. dic.Add("ClientUnit", "-");
  7602. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7603. //string missionLeaderJob = "";//负责人job
  7604. //int groupNumber = 0; //团人数
  7605. dic.Add("MissionLeader", "-"); //团负责人
  7606. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7607. dic.Add("GroupNumber", "0"); //团人数
  7608. dic.Add("Day", "0");
  7609. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7610. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7611. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7612. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7613. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7614. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7615. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7616. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7617. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7618. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7619. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7620. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7621. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7622. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7623. //其他费用
  7624. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7625. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7626. //其他费用合计
  7627. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7628. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7629. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7630. //公务舱合计
  7631. //国际旅费
  7632. //string outsideJJ = "";
  7633. //string allPriceJJ = "";
  7634. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7635. {
  7636. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7637. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7638. }
  7639. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7640. {
  7641. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7642. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7643. }
  7644. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7645. {
  7646. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7647. dic.Add("AirFeeTotal", airFeeTotalStr);
  7648. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7649. dic.Add("FeeTotal", feeTotalStr);
  7650. }
  7651. foreach (var key in dic.Keys)
  7652. {
  7653. builder.MoveToBookmark(key);
  7654. builder.Write(dic[key]);
  7655. }
  7656. //模板文件名
  7657. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7658. strFileName = CommonFun.ValidFileName(strFileName);
  7659. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7660. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7661. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7662. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7663. }
  7664. }
  7665. else if (dto.ExportType == 2) //表格
  7666. {
  7667. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7668. }
  7669. else if (dto.ExportType == 3)
  7670. {
  7671. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7672. }
  7673. return Ok(JsonView(400, "只可导出明细表!", ""));
  7674. }
  7675. catch (Exception ex)
  7676. {
  7677. return Ok(JsonView(400, ex.Message, ""));
  7678. }
  7679. }
  7680. /// <summary>
  7681. /// 获取三公费用标准city
  7682. /// </summary>
  7683. /// <param name="placeData"></param>
  7684. /// <param name="nationalTravelFeeId"></param>
  7685. /// <returns></returns>
  7686. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7687. {
  7688. string _city = string.Empty;
  7689. if (!placeData.Any()) return _city;
  7690. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7691. if (data == null) return _city;
  7692. string country = data.Country;
  7693. string city = data.City;
  7694. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7695. else _city = city;
  7696. return _city;
  7697. }
  7698. /// <summary>
  7699. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7700. /// </summary>
  7701. /// <returns></returns>
  7702. [HttpPost]
  7703. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7705. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7706. {
  7707. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7708. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7709. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7710. if (_view.Code == 0)
  7711. {
  7712. return Ok(JsonView(true, "操作成功"));
  7713. }
  7714. return Ok(JsonView(false, "操作失败"));
  7715. }
  7716. /// <summary>
  7717. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7718. /// </summary>
  7719. /// <returns></returns>
  7720. [HttpPost]
  7721. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7723. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7724. {
  7725. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7726. if (data.Code != 0)
  7727. {
  7728. return Ok(JsonView(false, data.Msg));
  7729. }
  7730. return Ok(JsonView(true, "操作成功!", data.Data));
  7731. }
  7732. /// <summary>
  7733. /// 三公其他费用草稿 删除
  7734. /// </summary>
  7735. /// <param name="dto"></param>
  7736. /// <returns></returns>
  7737. [HttpPost]
  7738. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7739. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7740. {
  7741. var jw = JsonView(false, "删除失败!");
  7742. var data = new Grp_DayOtherPriceDraft()
  7743. {
  7744. Id = dto.Id,
  7745. IsDel = 1,
  7746. DeleteUserId = dto.DeleteUserId,
  7747. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7748. };
  7749. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7750. if (del > 0)
  7751. {
  7752. jw.Code = 200;
  7753. jw.Msg = "删除成功!";
  7754. }
  7755. return Ok(jw);
  7756. }
  7757. /// <summary>
  7758. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7759. /// </summary>
  7760. /// <returns></returns>
  7761. [HttpPost]
  7762. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7763. {
  7764. var jw = JsonView(false);
  7765. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7766. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7767. jw.Code = StatusCodes.Status200OK;
  7768. jw.Msg = "操作成功!";
  7769. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7770. return Ok(jw);
  7771. }
  7772. /// <summary>
  7773. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7774. /// </summary>
  7775. /// <param name="dto"></param>
  7776. /// <returns></returns>
  7777. [HttpPost]
  7778. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7779. {
  7780. int userId = dto.UserId,
  7781. portId = dto.PortType,
  7782. groupId = dto.GroupId,
  7783. draftId = dto.DraftId;
  7784. _portTypeData.Add(1);
  7785. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7786. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7787. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7788. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7789. _sqlSugar.BeginTran();
  7790. try
  7791. {
  7792. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7793. if (draftDatas == null)
  7794. {
  7795. _sqlSugar.RollbackTran();
  7796. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7797. }
  7798. //验证可覆盖已有数据 两边创建人需为同一人;
  7799. int draftCreateUserId = draftDatas.CreateUserId,
  7800. formalCreateUserId = 0;
  7801. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7802. if (formalData != null)
  7803. {
  7804. formalCreateUserId = formalData.CreateUserId;
  7805. if (draftCreateUserId != formalCreateUserId)
  7806. {
  7807. _sqlSugar.RollbackTran();
  7808. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7809. }
  7810. }
  7811. //默认添加查看、编辑权限(创建人、自己)
  7812. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7813. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7814. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7815. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7816. newExterData.DiId = groupId;
  7817. newExterData.CreateUserId = userId;
  7818. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7819. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7820. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7821. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7822. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7823. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7824. //数据如果存在执行删除
  7825. if (enterExitCostInfo != null)
  7826. {
  7827. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7828. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7829. .Where(x => x.Id == enterExitCostInfo.Id)
  7830. .ExecuteCommand();
  7831. _sqlSugar.Updateable<Grp_DayAndCost>()
  7832. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7833. .Where(x => x.DiId == groupId)
  7834. .ExecuteCommand();
  7835. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7836. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7837. .Where(x => x.Diid == groupId)
  7838. .ExecuteCommand();
  7839. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7840. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7841. .Where(x => x.GroupId == groupId)
  7842. .ExecuteCommand();
  7843. }
  7844. //执行insert
  7845. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7846. if (insertId < 1)
  7847. {
  7848. _sqlSugar.RollbackTran();
  7849. return Ok(JsonView(false, "草稿数据导入失败!"));
  7850. }
  7851. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7852. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7853. #region 默认添加权限
  7854. #endregion
  7855. _sqlSugar.CommitTran();
  7856. //执行操作之后
  7857. //生成默认文件pdf并且通知人员
  7858. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7859. {
  7860. DiId = groupId,
  7861. ExportType = 1,
  7862. SubTypeId = 1005
  7863. }, "pdf");
  7864. //发送通知
  7865. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7866. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7867. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7868. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7869. //汇率信息记录
  7870. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7871. return Ok(JsonView(true));
  7872. }
  7873. catch (Exception ex)
  7874. {
  7875. _sqlSugar.RollbackTran();
  7876. return Ok(JsonView(false, ex.Message));
  7877. }
  7878. }
  7879. #endregion
  7880. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7881. /// <summary>
  7882. /// 获取币种基础数据(含逻辑处理)
  7883. /// </summary>
  7884. /// <returns></returns>
  7885. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7886. {
  7887. return await GeneralMethod.EnterExitCostInitRate();
  7888. }
  7889. /// <summary>
  7890. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7891. /// </summary>
  7892. /// <returns></returns>
  7893. [HttpPost]
  7894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7895. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7896. {
  7897. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7898. //SetDataInfoView
  7899. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7900. var fileTypes = new List<EecSetDataInfoView>();
  7901. var wordTypeData = dataSource.Where(it => it.STid == 72).Select(x => new EecSetDataInfoView() {
  7902. ParentId = 1,
  7903. Id = x.Id,
  7904. Name = x.Name
  7905. }) .ToList(); //三公费用-Word明细类型
  7906. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  7907. var excelTypeData = dataSource.Where(it => it.STid == 73)
  7908. .Select(x => new EecSetDataInfoView()
  7909. {
  7910. ParentId = 2,
  7911. Id = x.Id,
  7912. Name = x.Name
  7913. }).ToList(); //三公费用-Excel明细类型
  7914. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  7915. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  7916. fileTypes.Add(groupNameList);
  7917. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  7918. //默认币种显示
  7919. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7920. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7921. return Ok(JsonView(true, "查询成功!", new
  7922. {
  7923. FileTypeData = fileTypes,
  7924. CurrencyInit = _currencyInfos,
  7925. viewPermissionData = viewPermissionData
  7926. }));
  7927. }
  7928. /// <summary>
  7929. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7930. /// </summary>
  7931. /// <returns></returns>
  7932. [HttpPost]
  7933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7934. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7935. {
  7936. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7937. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7938. RefAsync<int> total = 0;
  7939. int diId = 0;
  7940. var status = int.TryParse(dto.GroupName, out diId);
  7941. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  7942. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7943. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7944. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7945. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7946. .OrderByDescending(x => x.VisitStartDate)
  7947. .Select(x => new EnterExitCostMobileGroupView()
  7948. {
  7949. Id = x.Id,
  7950. GroupName = x.TeamName,
  7951. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  7952. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  7953. })
  7954. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7955. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  7956. {
  7957. foreach (var item in data)
  7958. {
  7959. item.IsView = true;
  7960. }
  7961. }
  7962. return Ok(JsonView(true, "查询成功!", data, total));
  7963. }
  7964. /// <summary>
  7965. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7966. /// </summary>
  7967. /// <returns></returns>
  7968. [HttpPost]
  7969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7970. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7971. {
  7972. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7973. RefAsync<int> total = 0;
  7974. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7975. .Where(x => x.IsDel == 0 && x.STid == 66)
  7976. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7977. .Select(x => new
  7978. {
  7979. id = x.Id,
  7980. name = x.Name,
  7981. remark = x.Remark,
  7982. })
  7983. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7984. return Ok(JsonView(true, "查询成功!", data, total));
  7985. }
  7986. /// <summary>
  7987. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7988. /// </summary>
  7989. /// <returns></returns>
  7990. [HttpPost]
  7991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7992. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7993. {
  7994. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7995. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7996. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7997. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7998. var groupOtherRateData = groupRateData.TeamRates;
  7999. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8000. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8001. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8002. groupOtherRateData = groupOtherRateData
  8003. .Select(x => new TeamRateDescAddCurrencyIdView
  8004. {
  8005. CurrencyId = x.CurrencyId,
  8006. CurrencyName = x.CurrencyName,
  8007. CurrencyCode = x.CurrencyCode,
  8008. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8009. }).ToList();
  8010. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8011. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8012. }
  8013. /// <summary>
  8014. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8015. /// </summary>
  8016. /// <returns></returns>
  8017. [HttpPost]
  8018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8019. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8020. {
  8021. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8022. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8023. var tipsData = new List<int>() { 1, 2, 3 };
  8024. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8025. if (dto.TipsType == 1)
  8026. {
  8027. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8028. }
  8029. else if (dto.TipsType == 2)
  8030. {
  8031. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8032. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8033. }
  8034. else if (dto.TipsType == 3)
  8035. {
  8036. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8037. return Ok(JsonView(true, "查询成功!", airData.Data));
  8038. }
  8039. return Ok(JsonView(false));
  8040. }
  8041. /// <summary>
  8042. /// 团组模块 - 出入境国家费用标准-移动端 List
  8043. /// </summary>
  8044. /// <returns></returns>
  8045. [HttpPost]
  8046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8047. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8048. {
  8049. Stopwatch sw = new Stopwatch();
  8050. sw.Start();
  8051. RefAsync<int> total = 0;
  8052. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8053. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8054. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8055. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8056. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8057. .Select((ntf, sd, u) => new
  8058. {
  8059. Id = ntf.Id,
  8060. Area = $"{ntf.Country}-{ntf.City}",
  8061. Currency = ntf.Currency,
  8062. CurrencyCode = sd.Name,
  8063. CurrencyName = sd.Remark,
  8064. RoomCost = ntf.RoomCost,
  8065. FoodCost = ntf.FoodCost,
  8066. PublicCost = ntf.PublicCost,
  8067. LastUpdateUserId = ntf.LastUpdateUserId,
  8068. LastUpdateUserName = u.CnName,
  8069. LastUpdateTime = ntf.LastUpdateTime,
  8070. })
  8071. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8072. sw.Stop();
  8073. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8074. }
  8075. /// <summary>
  8076. /// 团组模块 - 出入境费用-移动端 - Info
  8077. /// </summary>
  8078. /// <returns></returns>
  8079. [HttpPost]
  8080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8081. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8082. {
  8083. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8084. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8085. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8086. return Ok(data);
  8087. }
  8088. /// <summary>
  8089. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8090. /// </summary>
  8091. /// <returns></returns>
  8092. [HttpPost]
  8093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8094. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8095. {
  8096. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8097. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8098. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8099. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8100. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8101. mobileInfo.DiId = dto.DiId;
  8102. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8103. if (eecInfo == null) return Ok(mobileInfo);
  8104. //验证查看权限
  8105. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8106. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8107. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8108. mobileInfo.IsAssignPerm = isSet;
  8109. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8110. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8111. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8112. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8113. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8114. {
  8115. SubId = dac.Id,
  8116. DiId = dac.DiId,
  8117. Type = dac.Type,
  8118. Days = dac.Days,
  8119. NationalTravelFeeId = dac.NationalTravelFeeId,
  8120. Arae = $"{ntf.Country}-{ntf.City}",
  8121. Cost = dac.Cost,
  8122. Currency = dac.Currency,
  8123. CurrencyName = sd.Name,
  8124. SubTotal = dac.SubTotal,
  8125. })
  8126. .ToList();
  8127. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8128. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8129. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8130. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8131. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8132. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8133. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8134. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8135. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8136. //其他款项
  8137. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8138. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8139. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8140. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8141. .OrderBy((dop, sd1, sd2) => dop.Index)
  8142. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8143. {
  8144. SubId = dop.Id,
  8145. DiId = dop.Diid,
  8146. Index = dop.Index,
  8147. SetDataId = dop.SetDataId,
  8148. SetDataName = sd1.Name,
  8149. Cost = dop.Cost,
  8150. Currency = dop.Currency,
  8151. CurrencyName = sd2.Remark,
  8152. SubTotal = dop.SubTotal,
  8153. Remark = dop.Remark,
  8154. })
  8155. .ToArray();
  8156. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8157. return Ok(mobileInfo);
  8158. }
  8159. /// <summary>
  8160. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8161. /// </summary>
  8162. /// <returns></returns>
  8163. [HttpPost]
  8164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8165. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8166. {
  8167. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8168. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8169. //验证查看权限
  8170. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8171. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8172. var userIds = await _sqlSugar
  8173. .Queryable<Grp_EnterExitCostPermission>()
  8174. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8175. .Select(x => x.UserId)
  8176. .ToArrayAsync();
  8177. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8178. var perUsersView = new List<dynamic>();
  8179. foreach (var item in perUsers)
  8180. {
  8181. bool isView1 = false;
  8182. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8183. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8184. }
  8185. return Ok(JsonView(perUsersView));
  8186. }
  8187. /// <summary>
  8188. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8189. /// </summary>
  8190. /// <returns></returns>
  8191. [HttpPost]
  8192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8193. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8194. {
  8195. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8196. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8197. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8198. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8199. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8200. //验证查看权限
  8201. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8202. //if (!isView) return Ok(JsonView(false, msg));
  8203. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8204. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8205. var subType = dto.SubType;
  8206. if (subType == 1) //1:境内费用
  8207. {
  8208. var oneData = new ChoiceOneMobileSubInfoView()
  8209. {
  8210. Id = eecInfo.Id,
  8211. ChoiceOne = eecInfo.ChoiceOne,
  8212. ChoiceOneTotalCost = eecInfo.InsidePay,
  8213. Visa = eecInfo.Visa,
  8214. VisaRemark = eecInfo.VisaRemark,
  8215. YiMiao = eecInfo.YiMiao,
  8216. HeSuan = eecInfo.HeSuan,
  8217. Service = eecInfo.Service,
  8218. Ticket = eecInfo.Ticket,
  8219. Safe = eecInfo.Safe,
  8220. FirstItemRemark = eecInfo.FirstItemRemark
  8221. };
  8222. return Ok(JsonView(oneData));
  8223. }
  8224. else if (subType == 2) //2:国际旅费
  8225. {
  8226. var twoData = new ChoiceTwoMobileSubInfoView()
  8227. {
  8228. Id = eecInfo.Id,
  8229. ChoiceTwoJJ = eecInfo.SumJJC,
  8230. OutsideJJPay = eecInfo.OutsideJJPay,
  8231. ChoiceTwoGW = eecInfo.SumGWC,
  8232. OutsideGWPay = eecInfo.OutsideGWPay,
  8233. ChoiceTwoTD = eecInfo.SumTDC,
  8234. OutsideTDPay = eecInfo.OutsideTDPay,
  8235. AirJJ = eecInfo.AirJJ,
  8236. AirGW = eecInfo.AirGW,
  8237. AirTD = eecInfo.AirTD,
  8238. CityTranffic = eecInfo.CityTranffic,
  8239. TwoItemRemark = eecInfo.TwoItemRemark
  8240. };
  8241. return Ok(JsonView(twoData));
  8242. }
  8243. else if (subType == 3) //3:住宿费
  8244. {
  8245. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8246. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8247. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8248. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8249. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8250. {
  8251. SubId = dac.Id,
  8252. DiId = dac.DiId,
  8253. Type = dac.Type,
  8254. Days = dac.Days,
  8255. NationalTravelFeeId = dac.NationalTravelFeeId,
  8256. Arae = $"{ntf.Country}-{ntf.City}",
  8257. Cost = dac.Cost,
  8258. Currency = dac.Currency,
  8259. CurrencyName = sd.Name,
  8260. SubTotal = dac.SubTotal,
  8261. })
  8262. .ToArray();
  8263. var data = new ChoiceMobileSubInfo3To6View()
  8264. {
  8265. ParentId = eecInfo.Id,
  8266. Choice = eecInfo.ChoiceThree,
  8267. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8268. Details = dayAndCostDatas
  8269. };
  8270. return Ok(JsonView(data));
  8271. }
  8272. else if (subType == 4) //4:伙食费
  8273. {
  8274. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8275. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8276. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8277. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8278. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8279. {
  8280. SubId = dac.Id,
  8281. DiId = dac.DiId,
  8282. Type = dac.Type,
  8283. Days = dac.Days,
  8284. NationalTravelFeeId = dac.NationalTravelFeeId,
  8285. Arae = $"{ntf.Country}-{ntf.City}",
  8286. Cost = dac.Cost,
  8287. Currency = dac.Currency,
  8288. CurrencyName = sd.Name,
  8289. SubTotal = dac.SubTotal,
  8290. })
  8291. .ToArray();
  8292. var data = new ChoiceMobileSubInfo3To6View()
  8293. {
  8294. ParentId = eecInfo.Id,
  8295. Choice = eecInfo.ChoiceFour,
  8296. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8297. Details = dayAndCostDatas
  8298. };
  8299. return Ok(JsonView(data));
  8300. }
  8301. else if (subType == 5) //5:公杂费
  8302. {
  8303. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8304. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8305. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8306. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8307. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8308. {
  8309. SubId = dac.Id,
  8310. DiId = dac.DiId,
  8311. Type = dac.Type,
  8312. Days = dac.Days,
  8313. NationalTravelFeeId = dac.NationalTravelFeeId,
  8314. Arae = $"{ntf.Country}-{ntf.City}",
  8315. Cost = dac.Cost,
  8316. Currency = dac.Currency,
  8317. CurrencyName = sd.Name,
  8318. SubTotal = dac.SubTotal,
  8319. })
  8320. .ToArray();
  8321. var data = new ChoiceMobileSubInfo3To6View()
  8322. {
  8323. ParentId = eecInfo.Id,
  8324. Choice = eecInfo.ChoiceFive,
  8325. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8326. Details = dayAndCostDatas
  8327. };
  8328. return Ok(JsonView(data));
  8329. }
  8330. else if (subType == 6) //6:培训费
  8331. {
  8332. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8333. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8334. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8335. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8336. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8337. {
  8338. SubId = dac.Id,
  8339. DiId = dac.DiId,
  8340. Type = dac.Type,
  8341. Days = dac.Days,
  8342. NationalTravelFeeId = dac.NationalTravelFeeId,
  8343. Arae = $"{ntf.Country}-{ntf.City}",
  8344. Cost = dac.Cost,
  8345. Currency = dac.Currency,
  8346. CurrencyName = sd.Name,
  8347. SubTotal = dac.SubTotal,
  8348. })
  8349. .ToArray();
  8350. var data = new ChoiceMobileSubInfo3To6View()
  8351. {
  8352. ParentId = eecInfo.Id,
  8353. Choice = eecInfo.ChoiceSix,
  8354. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8355. Details = dayAndCostDatas
  8356. };
  8357. return Ok(JsonView(data));
  8358. }
  8359. else if (subType == 7) //7:其他
  8360. {
  8361. //其他款项
  8362. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8363. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8364. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8365. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8366. .OrderBy((dop, sd1, sd2) => dop.Index)
  8367. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8368. {
  8369. SubId = dop.Id,
  8370. DiId = dop.Diid,
  8371. Index = dop.Index,
  8372. SetDataId = dop.SetDataId,
  8373. SetDataName = sd1.Name,
  8374. Cost = dop.Cost,
  8375. Currency = dop.Currency,
  8376. CurrencyName = sd2.Name,
  8377. SubTotal = dop.SubTotal,
  8378. Remark = dop.Remark,
  8379. })
  8380. .ToArray();
  8381. var data = new ChoiceSevenMobileSubInfoView()
  8382. {
  8383. ParentId = eecInfo.Id,
  8384. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8385. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8386. Details = otherData
  8387. };
  8388. return Ok(JsonView(data));
  8389. }
  8390. return Ok(JsonView(false));
  8391. }
  8392. #region op
  8393. /// <summary>
  8394. /// 移动端更新费用消息通知
  8395. /// </summary>
  8396. /// <param name="diid"></param>
  8397. /// <param name="id"></param>
  8398. /// <param name="currUserId"></param>
  8399. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8400. {
  8401. try
  8402. {
  8403. ////生成默认文件pdf并且通知人员
  8404. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8405. //{
  8406. // DiId = diid,
  8407. // ExportType = 1,
  8408. // SubTypeId = 1005
  8409. //}, "pdf");
  8410. ////发送通知
  8411. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8412. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8413. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8414. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8415. ////汇率信息记录
  8416. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8417. }
  8418. catch (Exception ex)
  8419. {
  8420. //记录日志
  8421. throw;
  8422. }
  8423. }
  8424. /// <summary>
  8425. /// 验证出入境费用数据是否存在
  8426. /// 不存在添加
  8427. /// </summary>
  8428. /// <param name="diId"></param>
  8429. /// <param name="currUserId"></param>
  8430. /// <returns></returns>
  8431. /// <exception cref="CustomException"></exception>
  8432. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8433. {
  8434. var parentId = 0;
  8435. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8436. if (info != null)
  8437. {
  8438. parentId = info.Id;
  8439. }
  8440. else
  8441. {
  8442. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8443. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8444. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8445. parentId = addId;
  8446. }
  8447. return parentId;
  8448. }
  8449. /// <summary>
  8450. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8451. /// </summary>
  8452. /// <returns></returns>
  8453. [HttpPost]
  8454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8455. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8456. {
  8457. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8458. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8459. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8460. //验证编辑权限
  8461. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8462. //if (!isEdit) return Ok(JsonView(false, msg));
  8463. var permissions = new List<Grp_EnterExitCostPermission>();
  8464. foreach (var userId in dto.UserIds)
  8465. {
  8466. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8467. }
  8468. if (permissions.Any())
  8469. {
  8470. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8471. {
  8472. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8473. }
  8474. _sqlSugar.BeginTran();
  8475. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8476. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8477. if (result < 1)
  8478. {
  8479. _sqlSugar.RollbackTran();
  8480. return Ok(JsonView(false));
  8481. }
  8482. _sqlSugar.CommitTran();
  8483. return Ok(JsonView(true));
  8484. }
  8485. return Ok(JsonView(false));
  8486. }
  8487. /// <summary>
  8488. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8489. /// </summary>
  8490. /// <returns></returns>
  8491. [HttpPost]
  8492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8493. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8494. {
  8495. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8496. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8497. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8498. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8499. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8500. int id = dto.Id;
  8501. if (id <= 0) //add
  8502. {
  8503. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8504. if (add < 1) return Ok(JsonView(false));
  8505. id = add;
  8506. }
  8507. else //update
  8508. {
  8509. ////验证编辑权限
  8510. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8511. //if (!isEdit) return Ok(JsonView(false, msg));
  8512. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8513. if (upd < 1) return Ok(JsonView(false));
  8514. }
  8515. #region 汇率变更时更改币种相关费用
  8516. var opDayCosts = new List<Grp_DayAndCost>();
  8517. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8518. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8519. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8520. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8521. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8522. .Select((dac, sd) => new
  8523. {
  8524. dac.Id,
  8525. dac.DiId,
  8526. CurrencyCode = sd.Name,
  8527. dac.Cost
  8528. })
  8529. .ToList();
  8530. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8531. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8532. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8533. .Select((dop, sd) => new
  8534. {
  8535. dop.Id,
  8536. dop.Diid,
  8537. CurrencyCode = sd.Name,
  8538. dop.Cost
  8539. })
  8540. .ToList();
  8541. if (dayCosts.Count > 0)
  8542. {
  8543. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8544. foreach (var dc in new_dayCosts)
  8545. {
  8546. var thisCurrency = dc.Key.ToUpper();
  8547. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8548. if (thisRate == 0.00M) continue;
  8549. foreach (var dcSub in dc)
  8550. {
  8551. opDayCosts.Add(new Grp_DayAndCost()
  8552. {
  8553. Id = dcSub.Id,
  8554. DiId = dcSub.DiId,
  8555. Cost = dcSub.Cost,
  8556. SubTotal = dcSub.Cost * thisRate,
  8557. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8558. });
  8559. }
  8560. }
  8561. if (opDayCosts.Count > 0)
  8562. {
  8563. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8564. }
  8565. }
  8566. if (dayOtherCosts.Count > 0)
  8567. {
  8568. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8569. foreach (var dc in new_dayOtherCosts)
  8570. {
  8571. var thisCurrency = dc.Key.ToUpper();
  8572. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8573. if (thisRate == 0.00M) continue;
  8574. foreach (var dcSub in dc)
  8575. {
  8576. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8577. {
  8578. Id = dcSub.Id,
  8579. Diid = dcSub.Diid,
  8580. Cost = dcSub.Cost,
  8581. SubTotal = dcSub.Cost * thisRate,
  8582. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8583. });
  8584. }
  8585. }
  8586. if (opDayOtherCosts.Count > 0)
  8587. {
  8588. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8589. }
  8590. }
  8591. #endregion
  8592. //消息通知
  8593. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8594. //汇率信息记录
  8595. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8596. return Ok(JsonView(new { parentId = id }));
  8597. }
  8598. /// <summary>
  8599. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8600. /// </summary>
  8601. /// <returns></returns>
  8602. [HttpPost]
  8603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8604. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8605. {
  8606. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8607. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8608. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8609. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8610. int id = dto.Id;
  8611. if (id <= 0) //add
  8612. {
  8613. checkboxInfo.CreateUserId = dto.CurrUserId;
  8614. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8615. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8616. if (add < 1) return Ok(JsonView(false));
  8617. }
  8618. else //update
  8619. {
  8620. ////验证编辑权限
  8621. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8622. //if (!isEdit) return Ok(JsonView(false, msg));
  8623. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8624. .UpdateColumns(x => new
  8625. {
  8626. x.ChoiceOne,
  8627. x.ChoiceTwo,
  8628. x.SumJJC,
  8629. x.SumGWC,
  8630. x.SumTDC,
  8631. x.ChoiceThree,
  8632. x.ChoiceFour,
  8633. x.ChoiceFive,
  8634. x.ChoiceSix,
  8635. x.OtherExpenses_Checked
  8636. })
  8637. .Where(x => x.Id == id)
  8638. .ExecuteCommandAsync();
  8639. if (upd < 1) return Ok(JsonView(false));
  8640. }
  8641. return Ok(JsonView(new { parentId = id }));
  8642. }
  8643. /// <summary>
  8644. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8645. /// </summary>
  8646. /// <returns></returns>
  8647. [HttpPost]
  8648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8649. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8650. {
  8651. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8652. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8653. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8654. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8655. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8656. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8657. var checkboxInfo = new Grp_EnterExitCost()
  8658. {
  8659. Id = id,
  8660. DiId = diId,
  8661. CreateUserId = currUserId
  8662. };
  8663. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8664. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8665. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8666. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8667. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8668. if (id <= 0) //add
  8669. {
  8670. checkboxInfo.CreateUserId = dto.CurrUserId;
  8671. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8672. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8673. if (add < 1) return Ok(JsonView(false));
  8674. }
  8675. else //update
  8676. {
  8677. ////验证编辑权限
  8678. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8679. //if (!isEdit) return Ok(JsonView(false, msg));
  8680. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8681. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8682. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8683. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8684. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8685. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8686. .Where(x => x.Id == id)
  8687. .ExecuteCommandAsync();
  8688. if (upd < 1) return Ok(JsonView(false));
  8689. }
  8690. return Ok(JsonView(new { parentId = id }));
  8691. }
  8692. /// <summary>
  8693. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8694. /// </summary>
  8695. /// <returns></returns>
  8696. [HttpPost]
  8697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8698. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8699. {
  8700. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8701. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8702. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8703. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8704. info.FirstItemRemark = dto.FirstItemRemark;
  8705. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8706. int id = dto.Id;
  8707. if (id <= 0) //add
  8708. {
  8709. info.CreateUserId = dto.CurrUserId;
  8710. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8711. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8712. if (add < 1) return Ok(JsonView(false));
  8713. id = add;
  8714. }
  8715. else //update
  8716. {
  8717. ////验证编辑权限
  8718. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8719. //if (!isEdit) return Ok(JsonView(false, msg));
  8720. var upd = await _sqlSugar.Updateable(info)
  8721. .UpdateColumns(x => new
  8722. {
  8723. x.ChoiceOne,
  8724. x.InsidePay,
  8725. x.VisaRemark,
  8726. x.Visa,
  8727. x.Service,
  8728. x.Safe,
  8729. x.Ticket,
  8730. x.HeSuan,
  8731. x.YiMiao,
  8732. x.FirstItemRemark
  8733. })
  8734. .Where(x => x.Id == id)
  8735. .ExecuteCommandAsync();
  8736. if (upd < 1) return Ok(JsonView(false));
  8737. }
  8738. //消息通知
  8739. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8740. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8741. }
  8742. /// <summary>
  8743. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8744. /// </summary>
  8745. /// <returns></returns>
  8746. [HttpPost]
  8747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8748. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8749. {
  8750. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8751. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8752. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8753. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8754. info.OutsideJJPay = dto.OutsideJJPay;
  8755. info.OutsideGWPay = dto.OutsideGWPay;
  8756. info.OutsideTDPay = dto.OutsideTDPay;
  8757. info.AirJJ = dto.AirJJ;
  8758. info.AirGW = dto.AirGW;
  8759. info.AirTD = dto.AirTD;
  8760. info.CityTranffic = dto.CityTranffic;
  8761. info.TwoItemRemark = dto.TwoItemRemark;
  8762. info.SumJJC = dto.ChoiceTwoJJ;
  8763. info.SumGWC = dto.ChoiceTwoGW;
  8764. info.SumTDC = dto.ChoiceTwoTD;
  8765. int id = dto.Id;
  8766. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8767. if (id <= 0) //add
  8768. {
  8769. info.CreateUserId = dto.CurrUserId;
  8770. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8771. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8772. if (addId <= 0) return Ok(JsonView(false));
  8773. id = addId;
  8774. }
  8775. else //update
  8776. {
  8777. ////验证编辑权限
  8778. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8779. //if (!isEdit) return Ok(JsonView(false, msg));
  8780. var upd = await _sqlSugar.Updateable(info)
  8781. .UpdateColumns(x => new
  8782. {
  8783. x.SumJJC,
  8784. x.OutsideJJPay,
  8785. x.SumGWC,
  8786. x.OutsideGWPay,
  8787. x.SumTDC,
  8788. x.OutsideTDPay,
  8789. x.AirJJ,
  8790. x.AirGW,
  8791. x.AirTD,
  8792. x.CityTranffic,
  8793. x.TwoItemRemark
  8794. })
  8795. .Where(x => x.Id == id)
  8796. .ExecuteCommandAsync();
  8797. if (upd < 1) return Ok(JsonView(false));
  8798. }
  8799. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8800. gwcItemTotal = info.AirGW + info.CityTranffic;
  8801. tdcItemTotal = info.AirTD + info.CityTranffic;
  8802. //消息通知
  8803. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8804. return Ok(JsonView(new
  8805. {
  8806. parentId = id,
  8807. choiceTwoJJ = dto.ChoiceTwoJJ,
  8808. jjcItemTotal = jjcItemTotal,
  8809. choiceTwoGW = dto.ChoiceTwoGW,
  8810. gwcItemTotal = gwcItemTotal,
  8811. choiceTwoTD = dto.ChoiceTwoTD,
  8812. tdcItemTotal = tdcItemTotal
  8813. }));
  8814. }
  8815. /// <summary>
  8816. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8817. /// </summary>
  8818. /// <returns></returns>
  8819. [HttpPost]
  8820. [ApiExplorerSettings(IgnoreApi = true)]
  8821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8822. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8823. {
  8824. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8825. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8826. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8827. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8828. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8829. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8830. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8831. var infos = infos1.Select(x => new Grp_DayAndCost
  8832. {
  8833. Id = x.Id,
  8834. DiId = dto.DiId,
  8835. Type = dto.FeeType,
  8836. Days = x.Days,
  8837. NationalTravelFeeId = x.NationalTravelFeeId,
  8838. Cost = x.Cost,
  8839. Currency = x.Currency,
  8840. SubTotal = x.SubTotal,
  8841. CreateUserId = dto.CurrUserId
  8842. })
  8843. .ToList();
  8844. var adds = infos.Where(x => x.Id <= 0).ToList();
  8845. var upds = infos.Where(x => x.Id > 0).ToList();
  8846. if (adds.Count > 0)
  8847. {
  8848. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8849. if (add < 1) return Ok(JsonView(false));
  8850. }
  8851. if (upds.Count > 0)
  8852. {
  8853. var upd = await _sqlSugar.Updateable(adds)
  8854. .UpdateColumns(x => new
  8855. {
  8856. x.Days,
  8857. x.NationalTravelFeeId,
  8858. x.Cost,
  8859. x.Currency,
  8860. x.SubTotal
  8861. })
  8862. .WhereColumns(x => new { x.Id })
  8863. .ExecuteCommandAsync();
  8864. if (upd < 1) return Ok(JsonView(false));
  8865. }
  8866. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8867. //消息通知
  8868. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8869. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8870. return Ok(JsonView(new { itemTotal = itemTotal }));
  8871. }
  8872. /// <summary>
  8873. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8874. /// </summary>
  8875. /// <returns></returns>
  8876. [HttpPost]
  8877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8878. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8879. {
  8880. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8881. int subId = dto.SubId, feeType = dto.FeeType;
  8882. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8883. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8884. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8885. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8886. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8887. subInfo.Id = subId;
  8888. subInfo.DiId = dto.DiId;
  8889. if (feeType == 3) subInfo.Type = 1;
  8890. else if (feeType == 4) subInfo.Type = 2;
  8891. else if (feeType == 5) subInfo.Type = 3;
  8892. else if (feeType == 6) subInfo.Type = 4;
  8893. subInfo.CreateUserId = dto.CurrUserId;
  8894. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8895. if (parentId < 1) return Ok(JsonView(false));
  8896. //子表op
  8897. if (subId < 1)
  8898. {
  8899. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8900. if (subAdd < 1) return Ok(JsonView(false));
  8901. }
  8902. else
  8903. {
  8904. ////验证编辑权限
  8905. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8906. //if (!isEdit) return Ok(JsonView(false, msg));
  8907. var subUpd = await _sqlSugar.Updateable(subInfo)
  8908. .UpdateColumns(x => new
  8909. {
  8910. x.Days,
  8911. x.NationalTravelFeeId,
  8912. x.Cost,
  8913. x.Currency,
  8914. x.SubTotal
  8915. })
  8916. .WhereColumns(x => new { x.Id })
  8917. .ExecuteCommandAsync();
  8918. if (subUpd < 1) return Ok(JsonView(false));
  8919. }
  8920. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8921. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8922. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8923. }
  8924. /// <summary>
  8925. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8926. /// </summary>
  8927. /// <returns></returns>
  8928. [HttpPost]
  8929. [ApiExplorerSettings(IgnoreApi = true)]
  8930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8931. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8932. {
  8933. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8934. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8935. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8936. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8937. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8938. {
  8939. Id = x.Id,
  8940. Diid = dto.DiId,
  8941. SetDataId = x.SetDataId,
  8942. Index = x.Index,
  8943. Cost = x.Cost,
  8944. Currency = x.Currency,
  8945. SubTotal = x.SubTotal,
  8946. CreateUserId = dto.CurrUserId,
  8947. Remark = x.Remark
  8948. }).ToList();
  8949. var adds = infos.Where(x => x.Id <= 0).ToList();
  8950. var upds = infos.Where(x => x.Id > 0).ToList();
  8951. if (adds.Count > 0)
  8952. {
  8953. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8954. if (add < 1) return Ok(JsonView(false));
  8955. }
  8956. if (upds.Count > 0)
  8957. {
  8958. var upd = await _sqlSugar.Updateable(adds)
  8959. .UpdateColumns(x => new
  8960. {
  8961. x.Index,
  8962. x.SetDataId,
  8963. x.Cost,
  8964. x.Currency,
  8965. x.SubTotal,
  8966. x.Remark
  8967. })
  8968. .WhereColumns(x => new { x.Id })
  8969. .ExecuteCommandAsync();
  8970. if (upd < 1) return Ok(JsonView(false));
  8971. }
  8972. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8973. //消息通知
  8974. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8975. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8976. return Ok(JsonView(new { itemTotal = itemTotal }));
  8977. }
  8978. /// <summary>
  8979. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8980. /// </summary>
  8981. /// <returns></returns>
  8982. [HttpPost]
  8983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8984. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8985. {
  8986. int subId = dto.SubId;
  8987. int diId = dto.Diid;
  8988. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8989. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8990. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8991. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8992. subInfo.Id = subId;
  8993. subInfo.Diid = dto.Diid;
  8994. subInfo.CreateUserId = dto.CurrUserId;
  8995. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8996. if (parentId < 1) return Ok(JsonView(false));
  8997. #region 子表op
  8998. if (subId < 1)//add
  8999. {
  9000. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9001. if (subAdd < 1) return Ok(JsonView(false));
  9002. }
  9003. else //upd
  9004. {
  9005. ////验证编辑权限
  9006. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9007. //if (!isEdit) return Ok(JsonView(false, msg));
  9008. var subUpd = await _sqlSugar.Updateable(subInfo)
  9009. .UpdateColumns(x => new
  9010. {
  9011. x.Index,
  9012. x.SetDataId,
  9013. x.Cost,
  9014. x.Currency,
  9015. x.SubTotal,
  9016. x.Remark
  9017. })
  9018. .WhereColumns(x => new { x.Id })
  9019. .ExecuteCommandAsync();
  9020. if (subUpd < 1) return Ok(JsonView(false));
  9021. }
  9022. #endregion
  9023. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9024. //消息通知
  9025. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9026. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9027. }
  9028. /// <summary>
  9029. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9030. /// </summary>
  9031. /// <returns></returns>
  9032. [HttpPost]
  9033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9034. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9035. {
  9036. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9037. if (data.Code != 0)
  9038. {
  9039. return Ok(JsonView(false, data.Msg));
  9040. }
  9041. return Ok(JsonView(true, "操作成功!", data.Data));
  9042. }
  9043. /// <summary>
  9044. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9045. /// </summary>
  9046. /// <param name="dto"></param>
  9047. /// <returns></returns>
  9048. [HttpPost]
  9049. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9050. {
  9051. var data = new Grp_DayOtherPrice()
  9052. {
  9053. Id = dto.Id,
  9054. IsDel = 1,
  9055. DeleteUserId = dto.DeleteUserId,
  9056. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9057. };
  9058. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9059. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9060. return Ok(JsonView(false, "删除失败!"));
  9061. }
  9062. #endregion
  9063. #endregion
  9064. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9065. /// <summary>
  9066. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9067. /// </summary>
  9068. /// <returns></returns>
  9069. [HttpPost]
  9070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9071. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9072. {
  9073. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9074. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9075. RefAsync<int> total = 0;
  9076. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9077. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9078. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9079. .Select(x => new
  9080. {
  9081. Id = x.Id,
  9082. DraftName = x.DraftName,
  9083. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9084. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9085. .Any()
  9086. })
  9087. .OrderByDescending(x => x.Id)
  9088. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9089. return Ok(JsonView(true, "查询成功!", data, total));
  9090. }
  9091. /// <summary>
  9092. /// 出入境费用-草稿 移动端
  9093. /// 获取币种基础数据(含逻辑处理)
  9094. /// </summary>
  9095. /// <returns></returns>
  9096. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9097. {
  9098. return await GeneralMethod.EnterExitCostInitRate();
  9099. }
  9100. /// <summary>
  9101. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9102. /// </summary>
  9103. /// <returns></returns>
  9104. [HttpPost]
  9105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9106. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9107. {
  9108. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9109. //SetDataInfoView
  9110. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9111. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9112. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9113. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9114. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9115. //默认币种显示
  9116. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9117. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9118. return Ok(JsonView(true, "查询成功!", new
  9119. {
  9120. WordTypeData = _WordTypeData,
  9121. ExcelTypeData = _ExcelTypeData,
  9122. CurrencyInit = _currencyInfos,
  9123. viewPermissionData = viewPermissionData
  9124. }));
  9125. }
  9126. /// <summary>
  9127. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9128. /// </summary>
  9129. /// <returns></returns>
  9130. [HttpPost]
  9131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9132. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9133. {
  9134. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9135. RefAsync<int> total = 0;
  9136. int diId = 0;
  9137. var status = int.TryParse(dto.GroupName, out diId);
  9138. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9139. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9140. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9141. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9142. .OrderByDescending(x => x.VisitStartDate)
  9143. .Select(x => new
  9144. {
  9145. Id = x.Id,
  9146. GroupName = x.TeamName
  9147. })
  9148. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9149. return Ok(JsonView(true, "查询成功!", data, total));
  9150. }
  9151. /// <summary>
  9152. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9153. /// </summary>
  9154. /// <returns></returns>
  9155. [HttpPost]
  9156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9157. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9158. {
  9159. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9160. RefAsync<int> total = 0;
  9161. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9162. .Where(x => x.IsDel == 0 && x.STid == 66)
  9163. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9164. .Select(x => new
  9165. {
  9166. id = x.Id,
  9167. name = x.Name,
  9168. remark = x.Remark,
  9169. })
  9170. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9171. return Ok(JsonView(true, "查询成功!", data, total));
  9172. }
  9173. /// <summary>
  9174. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9175. /// </summary>
  9176. /// <returns></returns>
  9177. [HttpPost]
  9178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9179. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9180. {
  9181. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9182. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9183. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  9184. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9185. var groupOtherRateData = groupRateData.TeamRates;
  9186. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9187. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9188. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9189. groupOtherRateData = groupOtherRateData
  9190. .Select(x => new TeamRateDescAddCurrencyIdView
  9191. {
  9192. CurrencyId = x.CurrencyId,
  9193. CurrencyName = x.CurrencyName,
  9194. CurrencyCode = x.CurrencyCode,
  9195. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9196. }).ToList();
  9197. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9198. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9199. }
  9200. /// <summary>
  9201. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9202. /// </summary>
  9203. /// <returns></returns>
  9204. [HttpPost]
  9205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9206. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9207. {
  9208. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9209. var tipsData = new List<int>() { 1, 2, 3 };
  9210. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9211. if (dto.TipsType == 1)
  9212. {
  9213. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9214. }
  9215. else if (dto.TipsType == 2)
  9216. {
  9217. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9218. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9219. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9220. .Select(x => x.NationalTravelFeeId)
  9221. .Distinct()
  9222. .ToListAsync();
  9223. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9224. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9225. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9226. .Select(x => x.Country)
  9227. .Distinct()
  9228. .ToArrayAsync();
  9229. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9230. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9231. return Ok(JsonView(true, "查询成功!", new
  9232. {
  9233. totalAmt = totalAmt,
  9234. remark = remark
  9235. }));
  9236. }
  9237. else if (dto.TipsType == 3)
  9238. {
  9239. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9240. }
  9241. return Ok(JsonView(false));
  9242. }
  9243. /// <summary>
  9244. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9245. /// </summary>
  9246. /// <returns></returns>
  9247. [HttpPost]
  9248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9249. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9250. {
  9251. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9252. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9253. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9254. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9255. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9256. var info = new Grp_EnterExitCostDraft() {
  9257. DraftName = dto.DraftName,
  9258. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9259. CreateUserId = dto.CurrUserId
  9260. };
  9261. _sqlSugar.BeginTran();
  9262. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9263. if (draftId < 1) {
  9264. _sqlSugar.RollbackTran();
  9265. return Ok(JsonView(false, "草稿创建失败!"));
  9266. }
  9267. //添加默认权限
  9268. await _enterExitCostDraftRep.InitPerm(draftId,dto.CurrUserId);
  9269. _sqlSugar.CommitTran();
  9270. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9271. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9272. mobileInfo.Id = draftId;
  9273. mobileInfo.DraftName = dto.DraftName;
  9274. mobileInfo.Currencys = rateInfos;
  9275. mobileInfo.IsAssignPerm = assignPerm;
  9276. return Ok(JsonView(mobileInfo));
  9277. }
  9278. /// <summary>
  9279. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9280. /// </summary>
  9281. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9282. /// <summary>
  9283. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9284. /// </summary>
  9285. /// <returns></returns>
  9286. [HttpPost]
  9287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9288. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9289. {
  9290. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9291. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9292. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9293. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9294. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9295. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9296. //验证查看编辑权限
  9297. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9298. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9299. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9300. mobileInfo.IsAssignPerm = assignPerm;
  9301. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9302. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9303. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9304. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9305. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9306. {
  9307. ParentId = dac.ParentId,
  9308. SubId = dac.Id,
  9309. Type = dac.Type,
  9310. Days = dac.Days,
  9311. NationalTravelFeeId = dac.NationalTravelFeeId,
  9312. Arae = $"{ntf.Country}-{ntf.City}",
  9313. Cost = dac.Cost,
  9314. Currency = dac.Currency,
  9315. CurrencyName = sd.Name,
  9316. SubTotal = dac.SubTotal,
  9317. })
  9318. .ToList();
  9319. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9320. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9321. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9322. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9323. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9324. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9325. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9326. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9327. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9328. //其他款项
  9329. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9330. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9331. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9332. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9333. .OrderBy((dop, sd1, sd2) => dop.Index)
  9334. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9335. {
  9336. ParentId = dop.ParentId,
  9337. SubId = dop.Id,
  9338. Index = dop.Index,
  9339. SetDataId = dop.SetDataId,
  9340. SetDataName = sd1.Name,
  9341. Cost = dop.Cost,
  9342. Currency = dop.Currency,
  9343. CurrencyName = sd2.Remark,
  9344. SubTotal = dop.SubTotal,
  9345. Remark = dop.Remark,
  9346. })
  9347. .ToArray();
  9348. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9349. return Ok(mobileInfo);
  9350. }
  9351. /// <summary>
  9352. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9353. /// </summary>
  9354. /// <returns></returns>
  9355. [HttpPost]
  9356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9357. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9358. {
  9359. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9360. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9361. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9362. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9363. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9364. //验证查看编辑权限
  9365. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9366. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9367. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9368. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9369. var subType = dto.SubType;
  9370. if (subType == 1) //1:境内费用
  9371. {
  9372. var oneData = new ChoiceOneMobileSubInfoView()
  9373. {
  9374. Id = eecInfo.Id,
  9375. ChoiceOne = eecInfo.ChoiceOne,
  9376. ChoiceOneTotalCost = eecInfo.InsidePay,
  9377. Visa = eecInfo.Visa,
  9378. VisaRemark = eecInfo.VisaRemark,
  9379. YiMiao = eecInfo.YiMiao,
  9380. HeSuan = eecInfo.HeSuan,
  9381. Service = eecInfo.Service,
  9382. Ticket = eecInfo.Ticket,
  9383. Safe = eecInfo.Safe,
  9384. FirstItemRemark = eecInfo.FirstItemRemark
  9385. };
  9386. return Ok(JsonView(oneData));
  9387. }
  9388. else if (subType == 2) //2:国际旅费
  9389. {
  9390. var twoData = new ChoiceTwoMobileSubInfoView()
  9391. {
  9392. Id = eecInfo.Id,
  9393. ChoiceTwoJJ = eecInfo.SumJJC,
  9394. OutsideJJPay = eecInfo.OutsideJJPay,
  9395. ChoiceTwoGW = eecInfo.SumGWC,
  9396. OutsideGWPay = eecInfo.OutsideGWPay,
  9397. ChoiceTwoTD = eecInfo.SumTDC,
  9398. OutsideTDPay = eecInfo.OutsideTDPay,
  9399. AirJJ = eecInfo.AirJJ,
  9400. AirGW = eecInfo.AirGW,
  9401. AirTD = eecInfo.AirTD,
  9402. CityTranffic = eecInfo.CityTranffic,
  9403. TwoItemRemark = eecInfo.TwoItemRemark
  9404. };
  9405. return Ok(JsonView(twoData));
  9406. }
  9407. else if (subType == 3) //3:住宿费
  9408. {
  9409. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9410. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9411. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9412. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9413. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9414. {
  9415. ParentId = dac.ParentId,
  9416. SubId = dac.Id,
  9417. Type = dac.Type,
  9418. Days = dac.Days,
  9419. NationalTravelFeeId = dac.NationalTravelFeeId,
  9420. Arae = $"{ntf.Country}-{ntf.City}",
  9421. Cost = dac.Cost,
  9422. Currency = dac.Currency,
  9423. CurrencyName = sd.Name,
  9424. SubTotal = dac.SubTotal,
  9425. })
  9426. .ToArray();
  9427. var data = new ChoiceDraftMobileSubInfo3To6View()
  9428. {
  9429. ParentId = eecInfo.Id,
  9430. Choice = eecInfo.ChoiceThree,
  9431. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9432. Details = dayAndCostDatas
  9433. };
  9434. return Ok(JsonView(data));
  9435. }
  9436. else if (subType == 4) //4:伙食费
  9437. {
  9438. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9439. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9440. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9441. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9442. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9443. {
  9444. ParentId = dac.ParentId,
  9445. SubId = dac.Id,
  9446. Type = dac.Type,
  9447. Days = dac.Days,
  9448. NationalTravelFeeId = dac.NationalTravelFeeId,
  9449. Arae = $"{ntf.Country}-{ntf.City}",
  9450. Cost = dac.Cost,
  9451. Currency = dac.Currency,
  9452. CurrencyName = sd.Name,
  9453. SubTotal = dac.SubTotal,
  9454. })
  9455. .ToArray();
  9456. var data = new ChoiceDraftMobileSubInfo3To6View()
  9457. {
  9458. ParentId = eecInfo.Id,
  9459. Choice = eecInfo.ChoiceFour,
  9460. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9461. Details = dayAndCostDatas
  9462. };
  9463. return Ok(JsonView(data));
  9464. }
  9465. else if (subType == 5) //5:公杂费
  9466. {
  9467. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9468. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9469. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9470. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9471. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9472. {
  9473. ParentId = dac.ParentId,
  9474. SubId = dac.Id,
  9475. Type = dac.Type,
  9476. Days = dac.Days,
  9477. NationalTravelFeeId = dac.NationalTravelFeeId,
  9478. Arae = $"{ntf.Country}-{ntf.City}",
  9479. Cost = dac.Cost,
  9480. Currency = dac.Currency,
  9481. CurrencyName = sd.Name,
  9482. SubTotal = dac.SubTotal,
  9483. })
  9484. .ToArray();
  9485. var data = new ChoiceDraftMobileSubInfo3To6View()
  9486. {
  9487. ParentId = eecInfo.Id,
  9488. Choice = eecInfo.ChoiceFive,
  9489. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9490. Details = dayAndCostDatas
  9491. };
  9492. return Ok(JsonView(data));
  9493. }
  9494. else if (subType == 6) //6:培训费
  9495. {
  9496. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9497. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9498. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9499. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9500. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9501. {
  9502. ParentId = dac.ParentId,
  9503. SubId = dac.Id,
  9504. Type = dac.Type,
  9505. Days = dac.Days,
  9506. NationalTravelFeeId = dac.NationalTravelFeeId,
  9507. Arae = $"{ntf.Country}-{ntf.City}",
  9508. Cost = dac.Cost,
  9509. Currency = dac.Currency,
  9510. CurrencyName = sd.Name,
  9511. SubTotal = dac.SubTotal,
  9512. })
  9513. .ToArray();
  9514. var data = new ChoiceDraftMobileSubInfo3To6View()
  9515. {
  9516. ParentId = eecInfo.Id,
  9517. Choice = eecInfo.ChoiceSix,
  9518. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9519. Details = dayAndCostDatas
  9520. };
  9521. return Ok(JsonView(data));
  9522. }
  9523. else if (subType == 7) //7:其他
  9524. {
  9525. //其他款项
  9526. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9527. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9528. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9529. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9530. .OrderBy((dop, sd1, sd2) => dop.Index)
  9531. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9532. {
  9533. ParentId = dop.ParentId,
  9534. SubId = dop.Id,
  9535. Index = dop.Index,
  9536. SetDataId = dop.SetDataId,
  9537. SetDataName = sd1.Name,
  9538. Cost = dop.Cost,
  9539. Currency = dop.Currency,
  9540. CurrencyName = sd2.Name,
  9541. SubTotal = dop.SubTotal,
  9542. Remark = dop.Remark,
  9543. })
  9544. .ToArray();
  9545. var data = new ChoiceSevenDraftMobileSubInfoView()
  9546. {
  9547. ParentId = eecInfo.Id,
  9548. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9549. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9550. Details = otherData
  9551. };
  9552. return Ok(JsonView(data));
  9553. }
  9554. return Ok(JsonView(false));
  9555. }
  9556. #region op
  9557. /// <summary>
  9558. /// 移动端更新费用消息通知
  9559. /// </summary>
  9560. /// <param name="draftId"></param>
  9561. /// <param name="id"></param>
  9562. /// <param name="currUserId"></param>
  9563. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9564. {
  9565. try
  9566. {
  9567. ////生成默认文件pdf并且通知人员
  9568. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9569. //{
  9570. // DiId = draftId,
  9571. // ExportType = 1,
  9572. // SubTypeId = 1005
  9573. //}, "pdf");
  9574. ////发送通知
  9575. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9576. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9577. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9578. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9579. ////汇率信息记录
  9580. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9581. }
  9582. catch (Exception ex)
  9583. {
  9584. //记录日志
  9585. throw;
  9586. }
  9587. }
  9588. /// <summary>
  9589. /// 验证出入境费用数据是否存在
  9590. /// 不存在添加
  9591. /// </summary>
  9592. /// <param name="draftId"></param>
  9593. /// <param name="currUserId"></param>
  9594. /// <returns></returns>
  9595. /// <exception cref="CustomException"></exception>
  9596. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9597. {
  9598. var parentId = 0;
  9599. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9600. if (info != null) parentId = info.Id;
  9601. else
  9602. {
  9603. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9604. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9605. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9606. parentId = addId;
  9607. }
  9608. return parentId;
  9609. }
  9610. /// <summary>
  9611. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  9612. /// </summary>
  9613. /// <returns></returns>
  9614. [HttpPost]
  9615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9616. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  9617. {
  9618. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9619. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9620. //验证查看权限
  9621. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9622. if (!isView) return Ok(JsonView(false, _viewPermStr));
  9623. var userIds = await _sqlSugar
  9624. .Queryable<Grp_EnterExitCostDraftPermission>()
  9625. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  9626. .Select(x => x.UserId)
  9627. .ToArrayAsync();
  9628. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9629. var perUsersView = new List<dynamic>();
  9630. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  9631. var viewPermissionData = new List<PermissionViewUserview>();
  9632. if (feeBasePerm.Any())
  9633. {
  9634. foreach (var item in feeBasePerm)
  9635. {
  9636. if (item.Users.Any())
  9637. {
  9638. viewPermissionData.AddRange(item.Users);
  9639. }
  9640. }
  9641. }
  9642. foreach (var item in perUsers)
  9643. {
  9644. bool isView1 = false;
  9645. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9646. else if (viewPermissionData.Any(x => x.Id ==dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  9647. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9648. }
  9649. return Ok(JsonView(perUsersView));
  9650. }
  9651. /// <summary>
  9652. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9653. /// </summary>
  9654. /// <returns></returns>
  9655. [HttpPost]
  9656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9657. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9658. {
  9659. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9660. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9661. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9662. //验证查看编辑权限
  9663. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9664. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9665. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  9666. foreach (var userId in dto.UserIds)
  9667. {
  9668. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9669. }
  9670. if (permissions.Any())
  9671. {
  9672. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9673. {
  9674. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9675. }
  9676. _sqlSugar.BeginTran();
  9677. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9678. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9679. if (result < 1)
  9680. {
  9681. _sqlSugar.RollbackTran();
  9682. return Ok(JsonView(false));
  9683. }
  9684. _sqlSugar.CommitTran();
  9685. return Ok(JsonView(true));
  9686. }
  9687. return Ok(JsonView(false));
  9688. }
  9689. /// <summary>
  9690. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9691. /// </summary>
  9692. /// <returns></returns>
  9693. [HttpPost]
  9694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9695. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9696. {
  9697. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9698. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9699. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9700. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9701. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9702. int id = dto.DraftId;
  9703. if (id <= 0) //add
  9704. {
  9705. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9706. if (add < 1) return Ok(JsonView(false));
  9707. id = add;
  9708. }
  9709. else //update
  9710. {
  9711. //验证查看编辑权限
  9712. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9713. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9714. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9715. if (upd < 1) return Ok(JsonView(false));
  9716. }
  9717. #region 汇率变更时更改币种相关费用
  9718. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9719. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9720. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9721. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9722. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9723. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9724. .Select((dac, sd) => new
  9725. {
  9726. dac.Id,
  9727. dac.ParentId,
  9728. CurrencyCode = sd.Name,
  9729. dac.Cost
  9730. })
  9731. .ToList();
  9732. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9733. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9734. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9735. .Select((dop, sd) => new
  9736. {
  9737. dop.Id,
  9738. dop.ParentId,
  9739. CurrencyCode = sd.Name,
  9740. dop.Cost
  9741. })
  9742. .ToList();
  9743. if (dayCosts.Count > 0)
  9744. {
  9745. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9746. foreach (var dc in new_dayCosts)
  9747. {
  9748. var thisCurrency = dc.Key.ToUpper();
  9749. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9750. if (thisRate == 0.00M) continue;
  9751. foreach (var dcSub in dc)
  9752. {
  9753. opDayCosts.Add(new Grp_DayAndCostDraft()
  9754. {
  9755. Id = dcSub.Id,
  9756. ParentId = dcSub.ParentId,
  9757. Cost = dcSub.Cost,
  9758. SubTotal = dcSub.Cost * thisRate,
  9759. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9760. });
  9761. }
  9762. }
  9763. if (opDayCosts.Count > 0)
  9764. {
  9765. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9766. }
  9767. }
  9768. if (dayOtherCosts.Count > 0)
  9769. {
  9770. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9771. foreach (var dc in new_dayOtherCosts)
  9772. {
  9773. var thisCurrency = dc.Key.ToUpper();
  9774. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9775. if (thisRate == 0.00M) continue;
  9776. foreach (var dcSub in dc)
  9777. {
  9778. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9779. {
  9780. Id = dcSub.Id,
  9781. ParentId = dcSub.ParentId,
  9782. Cost = dcSub.Cost,
  9783. SubTotal = dcSub.Cost * thisRate,
  9784. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9785. });
  9786. }
  9787. }
  9788. if (opDayOtherCosts.Count > 0)
  9789. {
  9790. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9791. }
  9792. }
  9793. #endregion
  9794. ////消息通知
  9795. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9796. ////汇率信息记录
  9797. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9798. return Ok(JsonView(new { parentId = id }));
  9799. }
  9800. /// <summary>
  9801. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9802. /// </summary>
  9803. /// <returns></returns>
  9804. [HttpPost]
  9805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9806. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9807. {
  9808. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9809. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9810. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9811. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9812. int id = dto.DraftId;
  9813. if (id <= 0) //add
  9814. {
  9815. checkboxInfo.CreateUserId = dto.CurrUserId;
  9816. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9817. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9818. if (add < 1) return Ok(JsonView(false));
  9819. }
  9820. else //update
  9821. {
  9822. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9823. .UpdateColumns(x => new
  9824. {
  9825. x.ChoiceOne,
  9826. x.ChoiceTwo,
  9827. x.SumJJC,
  9828. x.SumGWC,
  9829. x.SumTDC,
  9830. x.ChoiceThree,
  9831. x.ChoiceFour,
  9832. x.ChoiceFive,
  9833. x.ChoiceSix,
  9834. x.OtherExpenses_Checked
  9835. })
  9836. .Where(x => x.Id == id)
  9837. .ExecuteCommandAsync();
  9838. if (upd < 1) return Ok(JsonView(false));
  9839. }
  9840. return Ok(JsonView(new { parentId = id }));
  9841. }
  9842. /// <summary>
  9843. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9844. /// </summary>
  9845. /// <returns></returns>
  9846. [HttpPost]
  9847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9848. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9849. {
  9850. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9851. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9852. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9853. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9854. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9855. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9856. var checkboxInfo = new Grp_EnterExitCostDraft()
  9857. {
  9858. Id = draftId,
  9859. CreateUserId = currUserId
  9860. };
  9861. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9862. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9863. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9864. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9865. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9866. if (draftId <= 0) //add
  9867. {
  9868. checkboxInfo.CreateUserId = dto.CurrUserId;
  9869. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9870. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9871. if (add < 1) return Ok(JsonView(false));
  9872. }
  9873. else //update
  9874. {
  9875. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9876. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9877. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9878. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9879. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9880. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9881. .Where(x => x.Id == draftId)
  9882. .ExecuteCommandAsync();
  9883. if (upd < 1) return Ok(JsonView(false));
  9884. }
  9885. return Ok(JsonView(new { parentId = draftId }));
  9886. }
  9887. /// <summary>
  9888. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9889. /// </summary>
  9890. /// <returns></returns>
  9891. [HttpPost]
  9892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9893. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9894. {
  9895. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9896. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9897. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9898. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9899. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9900. info.FirstItemRemark = dto.FirstItemRemark;
  9901. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9902. if (id <= 0) //add
  9903. {
  9904. info.CreateUserId = dto.CurrUserId;
  9905. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9906. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9907. if (add < 1) return Ok(JsonView(false));
  9908. id = add;
  9909. }
  9910. else //update
  9911. {
  9912. var upd = await _sqlSugar.Updateable(info)
  9913. .UpdateColumns(x => new
  9914. {
  9915. x.ChoiceOne,
  9916. x.InsidePay,
  9917. x.VisaRemark,
  9918. x.Visa,
  9919. x.Service,
  9920. x.Safe,
  9921. x.Ticket,
  9922. x.HeSuan,
  9923. x.YiMiao,
  9924. x.FirstItemRemark
  9925. })
  9926. .Where(x => x.Id == id)
  9927. .ExecuteCommandAsync();
  9928. if (upd < 1) return Ok(JsonView(false));
  9929. }
  9930. ////消息通知
  9931. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9932. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9933. }
  9934. /// <summary>
  9935. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9936. /// </summary>
  9937. /// <returns></returns>
  9938. [HttpPost]
  9939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9940. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9941. {
  9942. int id = dto.DraftId;
  9943. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9944. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9945. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9946. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9947. info.OutsideJJPay = dto.OutsideJJPay;
  9948. info.OutsideGWPay = dto.OutsideGWPay;
  9949. info.OutsideTDPay = dto.OutsideTDPay;
  9950. info.AirJJ = dto.AirJJ;
  9951. info.AirGW = dto.AirGW;
  9952. info.AirTD = dto.AirTD;
  9953. info.CityTranffic = dto.CityTranffic;
  9954. info.TwoItemRemark = dto.TwoItemRemark;
  9955. info.SumJJC = dto.ChoiceTwoJJ;
  9956. info.SumGWC = dto.ChoiceTwoGW;
  9957. info.SumTDC = dto.ChoiceTwoTD;
  9958. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9959. if (id <= 0) //add
  9960. {
  9961. info.CreateUserId = dto.CurrUserId;
  9962. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9963. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9964. if (addId <= 0) return Ok(JsonView(false));
  9965. id = addId;
  9966. }
  9967. else //update
  9968. {
  9969. var upd = await _sqlSugar.Updateable(info)
  9970. .UpdateColumns(x => new
  9971. {
  9972. x.SumJJC,
  9973. x.OutsideJJPay,
  9974. x.SumGWC,
  9975. x.OutsideGWPay,
  9976. x.SumTDC,
  9977. x.OutsideTDPay,
  9978. x.AirJJ,
  9979. x.AirGW,
  9980. x.AirTD,
  9981. x.CityTranffic,
  9982. x.TwoItemRemark
  9983. })
  9984. .Where(x => x.Id == id)
  9985. .ExecuteCommandAsync();
  9986. if (upd < 1) return Ok(JsonView(false));
  9987. }
  9988. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9989. gwcItemTotal = info.AirGW + info.CityTranffic;
  9990. tdcItemTotal = info.AirTD + info.CityTranffic;
  9991. ////消息通知
  9992. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9993. return Ok(JsonView(new
  9994. {
  9995. parentId = id,
  9996. choiceTwoJJ = dto.ChoiceTwoJJ,
  9997. jjcItemTotal = jjcItemTotal,
  9998. choiceTwoGW = dto.ChoiceTwoGW,
  9999. gwcItemTotal = gwcItemTotal,
  10000. choiceTwoTD = dto.ChoiceTwoTD,
  10001. tdcItemTotal = tdcItemTotal
  10002. }));
  10003. }
  10004. /// <summary>
  10005. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10006. /// </summary>
  10007. /// <returns></returns>
  10008. [HttpPost]
  10009. [ApiExplorerSettings(IgnoreApi = true)]
  10010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10011. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10012. {
  10013. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10014. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10015. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10016. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10017. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10018. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10019. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10020. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10021. {
  10022. Id = x.Id,
  10023. ParentId = dto.DraftId,
  10024. Type = dto.FeeType,
  10025. Days = x.Days,
  10026. NationalTravelFeeId = x.NationalTravelFeeId,
  10027. Cost = x.Cost,
  10028. Currency = x.Currency,
  10029. SubTotal = x.SubTotal,
  10030. CreateUserId = dto.CurrUserId
  10031. })
  10032. .ToList();
  10033. var adds = infos.Where(x => x.Id <= 0).ToList();
  10034. var upds = infos.Where(x => x.Id > 0).ToList();
  10035. if (adds.Count > 0)
  10036. {
  10037. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10038. if (add < 1) return Ok(JsonView(false));
  10039. }
  10040. if (upds.Count > 0)
  10041. {
  10042. var upd = await _sqlSugar.Updateable(adds)
  10043. .UpdateColumns(x => new
  10044. {
  10045. x.Days,
  10046. x.NationalTravelFeeId,
  10047. x.Cost,
  10048. x.Currency,
  10049. x.SubTotal
  10050. })
  10051. .WhereColumns(x => new { x.Id })
  10052. .ExecuteCommandAsync();
  10053. if (upd < 1) return Ok(JsonView(false));
  10054. }
  10055. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10056. ////消息通知
  10057. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10058. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10059. return Ok(JsonView(new { itemTotal = itemTotal }));
  10060. }
  10061. /// <summary>
  10062. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10063. /// </summary>
  10064. /// <returns></returns>
  10065. [HttpPost]
  10066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10067. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10068. {
  10069. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10070. int subId = dto.SubId, feeType = dto.FeeType;
  10071. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10072. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10073. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10074. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10075. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10076. subInfo.Id = subId;
  10077. subInfo.ParentId = dto.DraftId;
  10078. if (feeType == 3) subInfo.Type = 1;
  10079. else if (feeType == 4) subInfo.Type = 2;
  10080. else if (feeType == 5) subInfo.Type = 3;
  10081. else if (feeType == 6) subInfo.Type = 4;
  10082. subInfo.CreateUserId = dto.CurrUserId;
  10083. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10084. if (parentId < 1) return Ok(JsonView(false));
  10085. //子表op
  10086. if (subId < 1)
  10087. {
  10088. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10089. if (subAdd < 1) return Ok(JsonView(false));
  10090. }
  10091. else
  10092. {
  10093. var subUpd = await _sqlSugar.Updateable(subInfo)
  10094. .UpdateColumns(x => new
  10095. {
  10096. x.Days,
  10097. x.NationalTravelFeeId,
  10098. x.Cost,
  10099. x.Currency,
  10100. x.SubTotal
  10101. })
  10102. .WhereColumns(x => new { x.Id })
  10103. .ExecuteCommandAsync();
  10104. if (subUpd < 1) return Ok(JsonView(false));
  10105. }
  10106. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10107. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10108. }
  10109. /// <summary>
  10110. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10111. /// </summary>
  10112. /// <returns></returns>
  10113. [HttpPost]
  10114. [ApiExplorerSettings(IgnoreApi = true)]
  10115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10116. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10117. {
  10118. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10119. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10120. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10121. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10122. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10123. {
  10124. Id = x.Id,
  10125. ParentId = dto.DraftId,
  10126. SetDataId = x.SetDataId,
  10127. Index = x.Index,
  10128. Cost = x.Cost,
  10129. Currency = x.Currency,
  10130. SubTotal = x.SubTotal,
  10131. CreateUserId = dto.CurrUserId,
  10132. Remark = x.Remark
  10133. }).ToList();
  10134. var adds = infos.Where(x => x.Id <= 0).ToList();
  10135. var upds = infos.Where(x => x.Id > 0).ToList();
  10136. if (adds.Count > 0)
  10137. {
  10138. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10139. if (add < 1) return Ok(JsonView(false));
  10140. }
  10141. if (upds.Count > 0)
  10142. {
  10143. var upd = await _sqlSugar.Updateable(adds)
  10144. .UpdateColumns(x => new
  10145. {
  10146. x.Index,
  10147. x.SetDataId,
  10148. x.Cost,
  10149. x.Currency,
  10150. x.SubTotal,
  10151. x.Remark
  10152. })
  10153. .WhereColumns(x => new { x.Id })
  10154. .ExecuteCommandAsync();
  10155. if (upd < 1) return Ok(JsonView(false));
  10156. }
  10157. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10158. //消息通知
  10159. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10160. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10161. return Ok(JsonView(new { itemTotal = itemTotal }));
  10162. }
  10163. /// <summary>
  10164. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10165. /// </summary>
  10166. /// <returns></returns>
  10167. [HttpPost]
  10168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10169. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10170. {
  10171. int subId = dto.SubId, id = dto.DraftId;
  10172. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10173. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10174. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10175. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10176. subInfo.Id = subId;
  10177. subInfo.ParentId = id;
  10178. subInfo.CreateUserId = dto.CurrUserId;
  10179. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10180. if (parentId < 1) return Ok(JsonView(false));
  10181. #region 子表op
  10182. if (subId < 1)//add
  10183. {
  10184. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10185. if (subAdd < 1) return Ok(JsonView(false));
  10186. }
  10187. else //upd
  10188. {
  10189. var subUpd = await _sqlSugar.Updateable(subInfo)
  10190. .UpdateColumns(x => new
  10191. {
  10192. x.Index,
  10193. x.SetDataId,
  10194. x.Cost,
  10195. x.Currency,
  10196. x.SubTotal,
  10197. x.Remark
  10198. })
  10199. .WhereColumns(x => new { x.Id })
  10200. .ExecuteCommandAsync();
  10201. if (subUpd < 1) return Ok(JsonView(false));
  10202. }
  10203. #endregion
  10204. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10205. ////消息通知
  10206. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10207. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10208. }
  10209. /// <summary>
  10210. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10211. /// </summary>
  10212. /// <returns></returns>
  10213. [HttpPost]
  10214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10215. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10216. {
  10217. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10218. if (data.Code != 0)
  10219. {
  10220. return Ok(JsonView(false, data.Msg));
  10221. }
  10222. return Ok(JsonView(true, "操作成功!", data.Data));
  10223. }
  10224. /// <summary>
  10225. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10226. /// </summary>
  10227. /// <param name="dto"></param>
  10228. /// <returns></returns>
  10229. [HttpPost]
  10230. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10231. {
  10232. var data = new Grp_DayOtherPriceDraft()
  10233. {
  10234. Id = dto.Id,
  10235. IsDel = 1,
  10236. DeleteUserId = dto.DeleteUserId,
  10237. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10238. };
  10239. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10240. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10241. return Ok(JsonView(false, "删除失败!"));
  10242. }
  10243. #endregion
  10244. #endregion
  10245. #region 团组经理模块 出入境费用报价表
  10246. /// <summary>
  10247. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10248. /// </summary>
  10249. /// <returns></returns>
  10250. [HttpPost]
  10251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10252. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10253. {
  10254. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10255. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10256. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10257. initRates.Insert(0, cnyInfo);
  10258. liveRates.Insert(0, cnyInfo);
  10259. return Ok(JsonView(true, "查询成功!", new
  10260. {
  10261. InitRates = initRates,
  10262. LiveRates = liveRates
  10263. }));
  10264. }
  10265. /// <summary>
  10266. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10267. /// </summary>
  10268. /// <returns></returns>
  10269. [HttpPost]
  10270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10271. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10272. {
  10273. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10274. }
  10275. /// <summary>
  10276. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10277. /// </summary>
  10278. /// <returns></returns>
  10279. [HttpPost]
  10280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10281. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10282. {
  10283. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10284. }
  10285. /// <summary>
  10286. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10287. /// </summary>
  10288. /// <returns></returns>
  10289. [HttpPost]
  10290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10291. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10292. {
  10293. int groupId = dto.DiId,
  10294. currUserId = dto.CurrUserId;
  10295. if (groupId < 1) return Ok(JsonView(false,"请传入有效的GroupId;"));
  10296. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10297. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10298. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10299. var infoView = info.Data as EnterExitCostInfoView;
  10300. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10301. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10302. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10303. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10304. var eecRates = infoView.Currencys;
  10305. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10306. int pplNum = 1;
  10307. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10308. var views = new List<QuoteSubItemInfo>();
  10309. #region 数据填充
  10310. var intTravelCosts = new List<QuoteSubItemInfo>();
  10311. #region 机票费用 1354
  10312. int intTravelIndex = 1;
  10313. if (infoView.SumJJC == 1)
  10314. {
  10315. intTravelCosts.Add(new QuoteSubItemInfo
  10316. {
  10317. ItemId = 1354,
  10318. Index = intTravelIndex,
  10319. FeeName = "经济舱",
  10320. UnitPrice = infoView.AirJJ,
  10321. Currency = "CNY",
  10322. Quantity = 1,
  10323. PplNum = 1,
  10324. TotalAmt = infoView.AirJJ,
  10325. Remark = "",
  10326. });
  10327. intTravelIndex++;
  10328. }
  10329. if (infoView.SumGWC == 1)
  10330. {
  10331. intTravelCosts.Add(new QuoteSubItemInfo
  10332. {
  10333. ItemId = 1354,
  10334. Index = intTravelIndex,
  10335. FeeName = "公务舱",
  10336. UnitPrice = infoView.AirGW,
  10337. Currency = "CNY",
  10338. Quantity = 1,
  10339. PplNum = 1,
  10340. TotalAmt = infoView.AirGW,
  10341. Remark = "",
  10342. });
  10343. intTravelIndex++;
  10344. }
  10345. if (infoView.SumTDC == 1)
  10346. {
  10347. intTravelCosts.Add(new QuoteSubItemInfo
  10348. {
  10349. ItemId = 1354,
  10350. Index = intTravelIndex,
  10351. FeeName = "头等舱",
  10352. UnitPrice = infoView.AirTD,
  10353. Currency = "CNY",
  10354. Quantity = 1,
  10355. PplNum = 1,
  10356. TotalAmt = infoView.AirTD,
  10357. Remark = "",
  10358. });
  10359. intTravelIndex++;
  10360. }
  10361. intTravelCosts.Add(new QuoteSubItemInfo
  10362. {
  10363. ItemId = 1354,
  10364. Index = intTravelIndex,
  10365. FeeName = "城市间交通费用",
  10366. UnitPrice = infoView.CityTranffic,
  10367. Currency = "CNY",
  10368. Quantity = 1,
  10369. PplNum = pplNum,
  10370. TotalAmt = infoView.CityTranffic * pplNum,
  10371. Remark = "",
  10372. });
  10373. views.AddRange(intTravelCosts);
  10374. #endregion
  10375. var accomCosts = new List<QuoteSubItemInfo>();
  10376. #region 住宿费 1355
  10377. if (infoView.QuarterageData.Any())
  10378. {
  10379. int accomIndex = 1;
  10380. int accomItemTypeId = 1355;
  10381. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10382. foreach (var item in groupData)
  10383. {
  10384. string feeName = string.Empty;
  10385. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10386. if (countryInfo != null)
  10387. {
  10388. feeName = countryInfo.Country;
  10389. var city = countryInfo.City;
  10390. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10391. {
  10392. feeName += $"-{city}";
  10393. }
  10394. }
  10395. var hotelInfo = item.FirstOrDefault();
  10396. if (hotelInfo == null) continue;
  10397. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10398. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10399. int quantity = item.ToList().Count;
  10400. accomCosts.Add(new QuoteSubItemInfo
  10401. {
  10402. ItemId = accomItemTypeId,
  10403. Index = accomIndex,
  10404. FeeName = feeName,
  10405. UnitPrice = hotelInfo.Cost,
  10406. Currency = thisCurrency,
  10407. Quantity = quantity,
  10408. PplNum = pplNum,
  10409. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10410. Remark = "",
  10411. });
  10412. accomIndex++;
  10413. }
  10414. views.AddRange(accomCosts);
  10415. }
  10416. #endregion
  10417. var mealCosts = new List<QuoteSubItemInfo>();
  10418. #region 餐饮费 1356
  10419. if (infoView.BoardWagesData.Any())
  10420. {
  10421. var mealIndex = 1;
  10422. int mealItemTypeId = 1356;
  10423. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10424. foreach (var item in groupData)
  10425. {
  10426. string feeName = string.Empty;
  10427. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10428. if (countryInfo != null)
  10429. {
  10430. feeName = countryInfo.Country;
  10431. var city = countryInfo.City;
  10432. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10433. {
  10434. feeName += $"-{city}";
  10435. }
  10436. }
  10437. var mealInfo = item.FirstOrDefault();
  10438. if (mealInfo == null) continue;
  10439. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10440. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10441. int quantity = item.ToList().Count;
  10442. mealCosts.Add(new QuoteSubItemInfo
  10443. {
  10444. ItemId = mealItemTypeId,
  10445. Index = mealIndex,
  10446. FeeName = feeName,
  10447. UnitPrice = mealInfo.Cost,
  10448. Currency = thisCurrency,
  10449. Quantity = quantity,
  10450. PplNum = pplNum,
  10451. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10452. Remark = "",
  10453. });
  10454. mealIndex++;
  10455. }
  10456. views.AddRange(mealCosts);
  10457. }
  10458. #endregion
  10459. var miscCosts = new List<QuoteSubItemInfo>();
  10460. #region 公杂费 1364
  10461. if (infoView.MiscellaneousFeeData.Any())
  10462. {
  10463. var miscIndex = 1;
  10464. int miscItemTypeId = 1364;
  10465. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10466. foreach (var item in groupData)
  10467. {
  10468. string feeName = string.Empty;
  10469. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10470. if (countryInfo != null)
  10471. {
  10472. feeName = countryInfo.Country;
  10473. var city = countryInfo.City;
  10474. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10475. {
  10476. feeName += $"-{city}";
  10477. }
  10478. }
  10479. var miscInfo = item.FirstOrDefault();
  10480. if (miscInfo == null) continue;
  10481. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10482. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10483. int quantity = item.ToList().Count;
  10484. mealCosts.Add(new QuoteSubItemInfo
  10485. {
  10486. ItemId = miscItemTypeId,
  10487. Index = miscIndex,
  10488. FeeName = feeName,
  10489. UnitPrice = miscInfo.Cost,
  10490. Currency = thisCurrency,
  10491. Quantity = quantity,
  10492. PplNum = pplNum,
  10493. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10494. Remark = "",
  10495. });
  10496. miscIndex++;
  10497. }
  10498. views.AddRange(mealCosts);
  10499. }
  10500. #endregion
  10501. #region 签证+保险 1362
  10502. int visaInsIndex = 1;
  10503. int visaInsItemTypeId = 1362;
  10504. if (infoView.Visa > 0)
  10505. {
  10506. views.Add(new QuoteSubItemInfo() {
  10507. ItemId = visaInsItemTypeId,
  10508. Index = visaInsIndex,
  10509. FeeName = $"签证",
  10510. UnitPrice = infoView.Visa,
  10511. Currency = $"CNY",
  10512. Quantity = 1,
  10513. PplNum = pplNum,
  10514. TotalAmt = infoView.Visa * pplNum,
  10515. Remark = "",
  10516. });
  10517. visaInsIndex++;
  10518. }
  10519. if (infoView.Safe > 0)
  10520. {
  10521. views.Add(new QuoteSubItemInfo()
  10522. {
  10523. ItemId = visaInsItemTypeId,
  10524. Index = visaInsIndex,
  10525. FeeName = $"保险",
  10526. UnitPrice = infoView.Safe,
  10527. Currency = $"CNY",
  10528. Quantity = 1,
  10529. PplNum = pplNum,
  10530. TotalAmt = infoView.Safe * pplNum,
  10531. Remark = "",
  10532. });
  10533. }
  10534. #endregion
  10535. #region 服务费 1363
  10536. int serviceFeeIndex = 1;
  10537. int serviceFeeItemTypeId = 1363;
  10538. if (infoView.Service > 0)
  10539. {
  10540. views.Add(new QuoteSubItemInfo()
  10541. {
  10542. ItemId = serviceFeeItemTypeId,
  10543. Index = serviceFeeIndex,
  10544. FeeName = $"服务费",
  10545. UnitPrice = infoView.Service,
  10546. Currency = $"CNY",
  10547. Quantity = 1,
  10548. PplNum = pplNum,
  10549. TotalAmt = infoView.Service * pplNum,
  10550. Remark = "",
  10551. });
  10552. }
  10553. #endregion
  10554. #endregion
  10555. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10556. result.Rates = eecRates.ToArray();
  10557. if (result.FeeItems.Any())
  10558. {
  10559. result.FeeItems.Select(x =>
  10560. {
  10561. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10562. if (feeInfos.Any()) x.Infos = feeInfos;
  10563. return x;
  10564. }
  10565. )
  10566. .OrderBy(x => x.Index)
  10567. .ToList();
  10568. }
  10569. return Ok(JsonView(result));
  10570. }
  10571. /// <summary>
  10572. /// 团组模块 - 出入境费用报价表 - Info
  10573. /// </summary>
  10574. /// <returns></returns>
  10575. [HttpPost]
  10576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10577. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10578. {
  10579. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10580. if (!info.Rates.Any())
  10581. {
  10582. var rates = await GeneralMethod.EnterExitCostInitRate();
  10583. info.Rates = rates.ToArray();
  10584. }
  10585. return Ok(JsonView(info));
  10586. }
  10587. /// <summary>
  10588. /// 团组模块 - 出入境费用报价表 - OP
  10589. /// </summary>
  10590. /// <returns></returns>
  10591. [HttpPost]
  10592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10593. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10594. {
  10595. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10596. }
  10597. /// <summary>
  10598. /// 团组模块 - 出入境费用报价表 - 删除 项
  10599. /// </summary>
  10600. /// <returns></returns>
  10601. [HttpPost]
  10602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10603. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10604. {
  10605. if (dto.Id < 1) return Ok(JsonView(false,MsgTips.Id));
  10606. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10607. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10608. }
  10609. /// <summary>
  10610. /// 团组模块 - 出入境费用报价表 - 导出
  10611. /// </summary>
  10612. /// <returns></returns>
  10613. [HttpPost]
  10614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10615. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10616. {
  10617. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10618. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10619. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id= dto.Id });
  10620. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10621. var rates = info.Rates;
  10622. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10623. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10624. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10625. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10626. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10627. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10628. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10629. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10630. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10631. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10632. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10633. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10634. //获取模板
  10635. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10636. var designer = new WorkbookDesigner();
  10637. designer.Workbook = new Workbook(tempPath);
  10638. designer.SetDataSource("QuoteName", info.Name);
  10639. designer.SetDataSource("CompanyTitle", "公司名称");
  10640. designer.SetDataSource("CompanyLabel", "");
  10641. #region 国际旅费
  10642. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10643. if (intTravelCosts.Infos.Any())
  10644. {
  10645. var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
  10646. string label = string.Empty;
  10647. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10648. if (infos.Any())
  10649. {
  10650. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10651. }
  10652. foreach (var item in intTravelCosts.Infos)
  10653. {
  10654. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10655. }
  10656. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10657. designer.SetDataSource("IntTravelLabel", label);
  10658. }
  10659. #endregion
  10660. #region 住宿费
  10661. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10662. if (accomCosts.Infos.Any())
  10663. {
  10664. string currencyName = string.Empty;
  10665. decimal rate = 1.0000M;
  10666. string label = "全程五星酒店,每人1间房\r\n";
  10667. foreach (var item in accomCosts.Infos)
  10668. {
  10669. string hotelName = string.Empty;
  10670. if (item.FeeName.Contains("-"))
  10671. {
  10672. var feeName = item.FeeName.Split('-');
  10673. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10674. }
  10675. else hotelName = $"\r\n{item.FeeName}:";
  10676. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10677. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10678. rate = rateInfo?.Rate ?? 1.0000M;
  10679. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10680. }
  10681. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10682. designer.SetDataSource("AccomLabel", label);
  10683. }
  10684. #endregion
  10685. #region 餐饮费
  10686. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  10687. if (mealCosts.Infos.Any())
  10688. {
  10689. string currencyName = string.Empty;
  10690. decimal rate = 1.0000M;
  10691. string label = "全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n";
  10692. foreach (var item in mealCosts.Infos)
  10693. {
  10694. string name = string.Empty;
  10695. if (item.FeeName.Contains("-"))
  10696. {
  10697. var feeName = item.FeeName.Split('-');
  10698. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10699. }
  10700. else name = $"\r\n{item.FeeName}:";
  10701. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10702. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10703. rate = rateInfo?.Rate ?? 1.0000M;
  10704. label += $"{name}{item.UnitPrice.TruncDecimals(2)}{currencyName}/天*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10705. }
  10706. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元\r\n({currencyName}汇率:{rate.TruncDecimals(4)})";
  10707. designer.SetDataSource("MealLabel", label);
  10708. }
  10709. #endregion
  10710. #region 车辆安排
  10711. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  10712. if (vehArranges.Infos.Any())
  10713. {
  10714. string currencyName = string.Empty;
  10715. decimal rate = 1.0000M;
  10716. string label = $"";
  10717. foreach (var item in vehArranges.Infos)
  10718. {
  10719. label += $"{item.Remark}\r\n\r\n{item.FeeName}\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元";
  10720. }
  10721. designer.SetDataSource("VehArrangeLabel", label);
  10722. }
  10723. #endregion
  10724. #region 邀请函发放对象
  10725. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  10726. #endregion
  10727. designer.Process();
  10728. //文件名
  10729. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10730. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10731. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10732. return Ok(JsonView(true, "成功", url));
  10733. }
  10734. #endregion
  10735. #region 签证费用录入
  10736. /// <summary>
  10737. /// 根据diid查询签证费用列表
  10738. /// </summary>
  10739. /// <param name="dto"></param>
  10740. /// <returns></returns>
  10741. [HttpPost]
  10742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10743. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10744. {
  10745. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10746. if (groupData.Code != 0)
  10747. {
  10748. return Ok(JsonView(false, groupData.Msg));
  10749. }
  10750. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10751. }
  10752. /// <summary>
  10753. /// 根据签证费用Id查询单条数据及c表数据
  10754. /// </summary>
  10755. /// <param name="dto"></param>
  10756. /// <returns></returns>
  10757. [HttpPost]
  10758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10759. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10760. {
  10761. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10762. if (groupData.Code != 0)
  10763. {
  10764. return Ok(JsonView(false, groupData.Msg));
  10765. }
  10766. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10767. }
  10768. /// <summary>
  10769. /// 签证费用删除
  10770. /// </summary>
  10771. /// <param name="dto"></param>
  10772. /// <returns></returns>
  10773. [HttpPost]
  10774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10775. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10776. {
  10777. _sqlSugar.BeginTran();
  10778. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10779. if (!res)
  10780. {
  10781. _sqlSugar.RollbackTran();
  10782. return Ok(JsonView(false, "删除失败"));
  10783. }
  10784. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10785. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10786. .SetColumns(a => new Grp_CreditCardPayment()
  10787. {
  10788. IsDel = 1,
  10789. DeleteUserId = dto.DeleteUserId,
  10790. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10791. })
  10792. .ExecuteCommand();
  10793. if (resSub < 1)
  10794. {
  10795. _sqlSugar.RollbackTran();
  10796. return Ok(JsonView(false, "删除失败"));
  10797. }
  10798. _sqlSugar.CommitTran();
  10799. return Ok(JsonView(true, "删除成功!"));
  10800. }
  10801. /// <summary>
  10802. /// 签证费用录入下拉框初始化
  10803. /// </summary>
  10804. /// <returns></returns>
  10805. [HttpPost]
  10806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10807. public async Task<IActionResult> VisaPriceAddSelect()
  10808. {
  10809. //支付方式
  10810. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10811. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10812. //币种
  10813. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10814. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10815. //乘客类型
  10816. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10817. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10818. //卡类型
  10819. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10820. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10821. //代办费类型
  10822. var agencyFeeTypeData = new List<dynamic>() {
  10823. new { id = 0 , Text = "未选择" },
  10824. new { id = 1 , Text = "小公务" },
  10825. new { id = 2 , Text = "大公务" },
  10826. };
  10827. //签证费用标准国家Data
  10828. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10829. var data = new
  10830. {
  10831. Payment = _Payment,
  10832. CurrencyList = _CurrencyList,
  10833. PassengerType = _PassengerType,
  10834. BankCard = _BankCard,
  10835. AgencyFeeType = agencyFeeTypeData,
  10836. CountryFeeData = visaCountryFeeData
  10837. };
  10838. return Ok(JsonView(true, "查询成功!", data));
  10839. }
  10840. /// <summary>
  10841. /// 签证费用录入操作(Status:1.新增,2.修改)
  10842. /// </summary>
  10843. /// <param name="dto"></param>
  10844. /// <returns></returns>
  10845. [HttpPost]
  10846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10847. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10848. {
  10849. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10850. if (groupData.Code != 0)
  10851. {
  10852. return Ok(JsonView(false, groupData.Msg));
  10853. }
  10854. #region 应用推送
  10855. try
  10856. {
  10857. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10858. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10859. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10860. //2024-10-21 新增LZ UID
  10861. var userIds = new List<int>() { 21 };
  10862. string title = $"系统通知";
  10863. string content = "";
  10864. var diId = dto.DiId;
  10865. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10866. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10867. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10868. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10869. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10870. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10871. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10872. }
  10873. catch (Exception ex)
  10874. {
  10875. }
  10876. #endregion
  10877. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10878. }
  10879. #endregion
  10880. #region 签证提成录入
  10881. /// <summary>
  10882. /// 签证提成录入
  10883. /// 基础数据
  10884. /// </summary>
  10885. /// <returns></returns>
  10886. [HttpGet]
  10887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10888. public async Task<IActionResult> VisaCommissionInit()
  10889. {
  10890. return Ok(await _visaCommissionRep.Init());
  10891. }
  10892. /// <summary>
  10893. /// 签证提成录入
  10894. /// Item
  10895. /// </summary>
  10896. /// <param name="_dto"></param>
  10897. /// <returns></returns>
  10898. [HttpPost]
  10899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10900. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10901. {
  10902. var validator = new VisaCommissionItemDtoValidator();
  10903. var validatorRes = await validator.ValidateAsync(_dto);
  10904. if (!validatorRes.IsValid)
  10905. {
  10906. StringBuilder sb = new StringBuilder();
  10907. foreach (var item in validatorRes.Errors)
  10908. {
  10909. sb.AppendLine(item.ErrorMessage);
  10910. }
  10911. return Ok(JsonView(false, sb.ToString()));
  10912. }
  10913. return Ok(await _visaCommissionRep.Item(_dto));
  10914. }
  10915. /// <summary>
  10916. /// 签证提成录入
  10917. /// Save
  10918. /// </summary>
  10919. /// <param name="_dto"></param>
  10920. /// <returns></returns>
  10921. [HttpPost]
  10922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10923. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10924. {
  10925. //参数验证
  10926. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10927. foreach (var item in _dto.Items)
  10928. {
  10929. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10930. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10931. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10932. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10933. }
  10934. return Ok(await _visaCommissionRep.Save(_dto));
  10935. }
  10936. /// <summary>
  10937. /// 签证提成录入
  10938. /// Create
  10939. /// </summary>
  10940. /// <param name="_dto"></param>
  10941. /// <returns></returns>
  10942. [HttpPost]
  10943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10944. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10945. {
  10946. var validator = new VisaCommissionCreateDtoValidator();
  10947. var validatorRes = await validator.ValidateAsync(_dto);
  10948. if (!validatorRes.IsValid)
  10949. {
  10950. StringBuilder sb = new StringBuilder();
  10951. foreach (var item in validatorRes.Errors)
  10952. {
  10953. sb.AppendLine(item.ErrorMessage);
  10954. }
  10955. return Ok(JsonView(false, sb.ToString()));
  10956. }
  10957. return Ok(await _visaCommissionRep.Create(_dto));
  10958. }
  10959. /// <summary>
  10960. /// 签证提成录入
  10961. /// Put(编辑)
  10962. /// </summary>
  10963. /// <param name="id"></param>
  10964. /// <param name="_dto"></param>
  10965. /// <returns></returns>
  10966. [HttpPut]
  10967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10968. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10969. {
  10970. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10971. var validator = new VisaCommissionCreateDtoValidator();
  10972. var validatorRes = await validator.ValidateAsync(_dto);
  10973. if (!validatorRes.IsValid)
  10974. {
  10975. StringBuilder sb = new StringBuilder();
  10976. foreach (var item in validatorRes.Errors)
  10977. {
  10978. sb.AppendLine(item.ErrorMessage);
  10979. }
  10980. return Ok(JsonView(false, sb.ToString()));
  10981. }
  10982. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10983. }
  10984. /// <summary>
  10985. /// 签证提成录入
  10986. /// Del
  10987. /// </summary>
  10988. /// <param name="id"></param>
  10989. /// <param name="currUserId"></param>
  10990. /// <returns></returns>
  10991. [HttpPost]
  10992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10993. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10994. {
  10995. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10996. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10997. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10998. }
  10999. #endregion
  11000. #region op费用录入
  11001. /// <summary>
  11002. /// 根据diid查询op费用列表
  11003. /// </summary>
  11004. /// <param name="dto"></param>
  11005. /// <returns></returns>
  11006. [HttpPost]
  11007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11008. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  11009. {
  11010. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  11011. if (groupData.Code != 0)
  11012. {
  11013. return Ok(JsonView(false, groupData.Msg));
  11014. }
  11015. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11016. }
  11017. /// <summary>
  11018. /// 根据op费用Id查询单条数据及c表数据
  11019. /// </summary>
  11020. /// <param name="dto"></param>
  11021. /// <returns></returns>
  11022. [HttpPost]
  11023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11024. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11025. {
  11026. try
  11027. {
  11028. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11029. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11030. var data = new
  11031. {
  11032. CarTouristGuideGround = _groupData,
  11033. CreditCardPayment = _creditCardPayment
  11034. };
  11035. return Ok(JsonView(true, "查询成功!", data));
  11036. }
  11037. catch (Exception ex)
  11038. {
  11039. return Ok(JsonView(false, "程序错误!"));
  11040. }
  11041. }
  11042. /// <summary>
  11043. /// op费用删除
  11044. /// </summary>
  11045. /// <param name="dto"></param>
  11046. /// <returns></returns>
  11047. [HttpPost]
  11048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11049. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11050. {
  11051. try
  11052. {
  11053. _sqlSugar.BeginTran();
  11054. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11055. if (!res)
  11056. {
  11057. return Ok(JsonView(false, "删除失败"));
  11058. }
  11059. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11060. {
  11061. IsDel = 1,
  11062. DeleteUserId = dto.DeleteUserId,
  11063. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11064. }).ExecuteCommandAsync();
  11065. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11066. {
  11067. IsDel = 1,
  11068. DeleteUserId = dto.DeleteUserId,
  11069. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11070. }).ExecuteCommandAsync();
  11071. #region 删除超支相关数据
  11072. //删除导入的超支数据
  11073. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11074. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11075. {
  11076. IsDel = 1,
  11077. DeleteUserId = dto.DeleteUserId,
  11078. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11079. }).ExecuteCommand();
  11080. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11081. {
  11082. IsDel = 1,
  11083. DeleteUserId = dto.DeleteUserId,
  11084. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11085. }).ExecuteCommand();
  11086. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11087. {
  11088. IsDel = 1,
  11089. DeleteUserId = dto.DeleteUserId,
  11090. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11091. }).ExecuteCommand();
  11092. #endregion
  11093. _sqlSugar.CommitTran();
  11094. return Ok(JsonView(true, "删除成功!"));
  11095. }
  11096. catch (Exception ex)
  11097. {
  11098. _sqlSugar.RollbackTran();
  11099. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11100. }
  11101. }
  11102. /// <summary>
  11103. /// op费用录入操作(Status:1.新增,2.修改)
  11104. /// </summary>
  11105. /// <param name="dto"></param>
  11106. /// <returns></returns>
  11107. [HttpPost]
  11108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11109. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11110. {
  11111. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11112. if (groupData.Code != 0)
  11113. {
  11114. return Ok(JsonView(false, groupData.Msg));
  11115. }
  11116. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11117. }
  11118. /// <summary>
  11119. /// 填写费用详细页面初始化绑定
  11120. /// </summary>
  11121. /// <param name="dto"></param>
  11122. /// <returns></returns>
  11123. [HttpPost]
  11124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11125. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11126. {
  11127. try
  11128. {
  11129. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11130. if (groupData.Code != 0)
  11131. {
  11132. return Ok(JsonView(false, groupData.Msg));
  11133. }
  11134. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11135. }
  11136. catch (Exception ex)
  11137. {
  11138. return Ok(JsonView(false, ex.Message));
  11139. }
  11140. }
  11141. /// <summary>
  11142. /// 根据op费用Id查询详细数据
  11143. /// </summary>
  11144. /// <param name="dto"></param>
  11145. /// <returns></returns>
  11146. [HttpPost]
  11147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11148. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11149. {
  11150. try
  11151. {
  11152. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11153. if (groupData.Code != 0)
  11154. {
  11155. return Ok(JsonView(false, groupData.Msg));
  11156. }
  11157. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11158. }
  11159. catch (Exception ex)
  11160. {
  11161. return Ok(JsonView(false, ex.Message));
  11162. }
  11163. }
  11164. /// <summary>
  11165. /// OP费用录入填写详情
  11166. /// </summary>
  11167. /// <param name="dto"></param>
  11168. /// <returns></returns>
  11169. [HttpPost]
  11170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11171. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11172. {
  11173. try
  11174. {
  11175. #region 参数校验
  11176. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11177. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11178. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11179. #endregion
  11180. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11181. if (groupData.Code != 0)
  11182. {
  11183. return Ok(JsonView(false, groupData.Msg));
  11184. }
  11185. //自动审核
  11186. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11187. #region 应用推送
  11188. try
  11189. {
  11190. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11191. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11192. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11193. //2024-10-21 新增LZ UID
  11194. var userIds = new List<int>() { 21 };
  11195. string title = $"系统通知";
  11196. var diId = dto.DiId;
  11197. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11198. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11199. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11200. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11201. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11202. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11203. }
  11204. catch (Exception ex)
  11205. {
  11206. }
  11207. #endregion
  11208. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11209. }
  11210. catch (Exception ex)
  11211. {
  11212. return Ok(JsonView(false, ex.Message));
  11213. }
  11214. }
  11215. /// <summary>
  11216. /// 获取三公详细所有城市
  11217. /// </summary>
  11218. /// <returns></returns>
  11219. [HttpGet]
  11220. public IActionResult OpCarCityResult()
  11221. {
  11222. var jw = JsonView(false);
  11223. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11224. {
  11225. x.Id,
  11226. x.Country,
  11227. x.City,
  11228. }).ToList();
  11229. if (data.Count > 0)
  11230. {
  11231. jw = JsonView(true, "获取成功!", data);
  11232. }
  11233. else
  11234. {
  11235. jw.Msg = "城市数据为空!";
  11236. jw.Data = new string[0];
  11237. }
  11238. return Ok(jw);
  11239. }
  11240. /// <summary>
  11241. /// 导出地接费用明细
  11242. /// </summary>
  11243. /// <param name="dto"></param>
  11244. /// <returns></returns>
  11245. [HttpPost]
  11246. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11247. {
  11248. var jw = JsonView(false);
  11249. if (dto.Diid < 1)
  11250. {
  11251. jw.Msg = "请输入正确的diid!";
  11252. return Ok(jw);
  11253. }
  11254. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11255. if (group == null)
  11256. {
  11257. jw.Msg = "未找到团组信息!";
  11258. return Ok(jw);
  11259. }
  11260. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11261. if (localGuideArr.Count == 0)
  11262. {
  11263. jw.Msg = "该团组暂无地接信息!";
  11264. return Ok(jw);
  11265. }
  11266. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11267. var overspendSoure = new Dictionary<int, int>
  11268. {
  11269. { 91, 982 }, //车
  11270. { 92 , 1059} ,//导游
  11271. { 994 , 1073}, //翻译
  11272. { 988 , 1074 }, //早餐
  11273. { 93 , 1075 }, //午餐
  11274. { 989 , 1076 }, //晚餐
  11275. };
  11276. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11277. foreach (var groupArr in localGroup)
  11278. {
  11279. var keyValue = groupArr.Key;
  11280. if (int.TryParse(keyValue, out int cityid))
  11281. {
  11282. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11283. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11284. }
  11285. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11286. foreach (var item in groupArr)
  11287. {
  11288. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11289. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11290. new Grp_CarTouristGuideGroundReservationsContentExtend
  11291. {
  11292. Count = a.Count,
  11293. CreateTime = a.CreateTime,
  11294. CreateUserId = a.CreateUserId,
  11295. CTGGRId = a.CTGGRId,
  11296. Currency = a.Currency,
  11297. DatePrice = a.DatePrice,
  11298. DeleteTime = a.DeleteTime,
  11299. DeleteUserId = a.DeleteUserId,
  11300. DiId = a.DiId,
  11301. Id = a.Id,
  11302. IsDel = a.IsDel,
  11303. Price = a.Price,
  11304. PriceContent = a.PriceContent,
  11305. Remark = a.Remark,
  11306. SId = a.SId,
  11307. SidName = b.Name,
  11308. Units = a.Units,
  11309. }
  11310. ).ToList();
  11311. if (content.Count > 0)
  11312. {
  11313. contentArr.Add(content);
  11314. }
  11315. }
  11316. //open excel
  11317. //set excel
  11318. //save excel
  11319. try
  11320. {
  11321. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11322. IWorkbook workbook;
  11323. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11324. {
  11325. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11326. }
  11327. else
  11328. {
  11329. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11330. }
  11331. ISheet sheet = workbook.GetSheetAt(0);
  11332. var rowStartIndex = 2;
  11333. var clounmCount = 10;
  11334. var initStyleRow = sheet.GetRow(2);
  11335. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11336. //var overspendArrDetail =
  11337. var existsId = new List<CarCompare>();
  11338. var lastElem = arr.Last();
  11339. var thisSid = -1;
  11340. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11341. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11342. {
  11343. Name = "未知币种!",
  11344. Remark = "未知币种!",
  11345. };
  11346. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11347. Action cloneRowFn = () =>
  11348. {
  11349. rowStartIndex++;
  11350. var cloneRow = sheet.CreateRow(rowStartIndex);
  11351. // 复制样式
  11352. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11353. {
  11354. ICell sourceCell = initStyleRow.GetCell(i);
  11355. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11356. // 确保单元格存在样式
  11357. if (sourceCell.CellStyle != null)
  11358. {
  11359. targetCell.CellStyle = sourceCell.CellStyle;
  11360. }
  11361. }
  11362. };
  11363. var mergeRow = () =>
  11364. {
  11365. for (int i = 2; i < sheet.LastRowNum; i++)
  11366. {
  11367. var row = sheet.GetRow(i);
  11368. var cellFirst = row.GetCell(0);
  11369. var thisIndex = i + 1;
  11370. while (thisIndex < sheet.LastRowNum)
  11371. {
  11372. var nextRow = sheet.GetRow(thisIndex);
  11373. var nextCellFirst = nextRow.GetCell(0);
  11374. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11375. {
  11376. thisIndex++;
  11377. }
  11378. else
  11379. {
  11380. break;
  11381. }
  11382. }
  11383. thisIndex--;
  11384. if (thisIndex != i)
  11385. {
  11386. //合并row
  11387. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11388. i, // 起始行索引(0-based)
  11389. thisIndex, // 结束行索引(0-based)
  11390. 0, // 起始列索引(0-based)
  11391. 0 // 结束列索引(0-based)
  11392. );
  11393. sheet.AddMergedRegion(cellRangeAddress);
  11394. i = thisIndex;
  11395. }
  11396. }
  11397. };
  11398. var chaoshiNumber = 0;
  11399. var totalNumber = 0.00M;
  11400. string lastStr = "";
  11401. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11402. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11403. {
  11404. b.IsAuditGM,
  11405. x.Id,
  11406. x.Area,
  11407. b.PayPercentage,
  11408. b.PayMoney,
  11409. }).ToList();
  11410. string yesPayment = "", noPayment = "";
  11411. foreach (var item in queryCarArrByCityAndDiid)
  11412. {
  11413. if (item.IsAuditGM == 1)
  11414. {
  11415. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11416. }
  11417. else
  11418. {
  11419. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11420. }
  11421. }
  11422. lastStr = yesPayment + noPayment;
  11423. foreach (var item in arr)
  11424. {
  11425. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11426. {
  11427. if (thisSid != item.SId)
  11428. {
  11429. if (thisSid == -1)
  11430. {
  11431. thisSid = item.SId;
  11432. }
  11433. else
  11434. {
  11435. //合并小计行
  11436. //创建合并区域的实例
  11437. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11438. rowStartIndex, // 起始行索引(0-based)
  11439. rowStartIndex, // 结束行索引(0-based)
  11440. 0, // 起始列索引(0-based)
  11441. 3 // 结束列索引(0-based)
  11442. );
  11443. sheet.AddMergedRegion(cellRangeAddress);
  11444. var CellStyle = workbook.CreateCellStyle();
  11445. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11446. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11447. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11448. for (int i = 0; i <= clounmCount; i++)
  11449. {
  11450. if (i > 6)
  11451. {
  11452. var CellStyle1 = workbook.CreateCellStyle();
  11453. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11454. IFont Font = workbook.CreateFont(); // 创建字体
  11455. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11456. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11457. CellStyle1.SetFont(Font);
  11458. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11459. }
  11460. else
  11461. {
  11462. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11463. }
  11464. }
  11465. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11466. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11467. //超时合计
  11468. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11469. //超时数
  11470. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11471. //超时合计费用
  11472. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11473. thisSid = item.SId;
  11474. cloneRowFn();
  11475. chaoshiNumber = 0;
  11476. totalNumber = 0;
  11477. }
  11478. }
  11479. IRow row = sheet.GetRow(rowStartIndex);
  11480. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11481. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11482. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11483. if (isOpenOverspendSoure)
  11484. {
  11485. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11486. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11487. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11488. }
  11489. for (int i = 0; i <= clounmCount; i++)
  11490. {
  11491. var cell = row.GetCell(i);
  11492. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11493. if (cell == null)
  11494. {
  11495. cell = row.CreateCell(i);
  11496. }
  11497. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11498. fontRed.CloneStyleFrom(cell.CellStyle);
  11499. IFont Font = workbook.CreateFont(); // 创建字体
  11500. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11501. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11502. fontRed.SetFont(Font);
  11503. byte[] rgb = new byte[3] { 255, 242, 204 };
  11504. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11505. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11506. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11507. if (workbook is XSSFWorkbook)
  11508. {
  11509. BackgroundColor255_242_204.FillForegroundColor = 0;
  11510. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11511. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11512. }
  11513. else
  11514. {
  11515. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11516. }
  11517. if (i == 1 || i > 6)
  11518. {
  11519. if (i > 6)
  11520. {
  11521. fontRed.FillForegroundColor = 0;
  11522. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11523. fontRed.FillPattern = FillPattern.SolidForeground;
  11524. }
  11525. cell.CellStyle = fontRed;
  11526. }
  11527. if (i > 2 && i < 7)
  11528. {
  11529. cell.CellStyle = BackgroundColor255_242_204;
  11530. }
  11531. cell.SetCellValue(setCellValue); //写入单元格
  11532. }
  11533. if (overspendSoure.ContainsKey(thisSid))
  11534. {
  11535. var overspendId = overspendSoure[thisSid];
  11536. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11537. }
  11538. cloneRowFn();
  11539. existsId.Add(new CarCompare
  11540. {
  11541. DataPrice = item.DatePrice.ObjToDate(),
  11542. Sid = item.SId
  11543. });
  11544. }
  11545. if (item.Equals(lastElem))
  11546. {
  11547. //合并小计行
  11548. //创建合并区域的实例
  11549. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11550. rowStartIndex, // 起始行索引(0-based)
  11551. rowStartIndex, // 结束行索引(0-based)
  11552. 0, // 起始列索引(0-based)
  11553. 3 // 结束列索引(0-based)
  11554. );
  11555. sheet.AddMergedRegion(cellRangeAddress);
  11556. var CellStyle = workbook.CreateCellStyle();
  11557. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11558. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11559. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11560. for (int i = 0; i <= clounmCount; i++)
  11561. {
  11562. if (i > 6)
  11563. {
  11564. var CellStyle1 = workbook.CreateCellStyle();
  11565. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11566. IFont Font = workbook.CreateFont(); // 创建字体
  11567. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11568. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11569. CellStyle1.SetFont(Font);
  11570. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11571. }
  11572. else
  11573. {
  11574. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11575. }
  11576. }
  11577. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11578. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11579. //超时合计
  11580. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11581. //超时数
  11582. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11583. //超时合计费用
  11584. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11585. cloneRowFn();
  11586. // 创建合并区域的实例
  11587. cellRangeAddress = new CellRangeAddress(
  11588. rowStartIndex, // 起始行索引(0-based)
  11589. rowStartIndex, // 结束行索引(0-based)
  11590. 0, // 起始列索引(0-based)
  11591. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11592. );
  11593. // 添加合并区域
  11594. sheet.AddMergedRegion(cellRangeAddress);
  11595. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11596. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11597. }
  11598. }
  11599. mergeRow();
  11600. // 保存修改后的Excel文件到新文件
  11601. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11602. // new FileStream(newFilePath, FileMode.CreateNew)
  11603. using (var stream = new MemoryStream())
  11604. {
  11605. workbook.Write(stream, true);
  11606. stream.Flush();
  11607. stream.Seek(0, SeekOrigin.Begin);
  11608. MemoryStream memoryStream = new MemoryStream();
  11609. stream.CopyTo(memoryStream);
  11610. memoryStream.Seek(0, SeekOrigin.Begin);
  11611. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11612. }
  11613. workbook.Close();
  11614. workbook.Dispose();
  11615. }
  11616. catch (Exception ex)
  11617. {
  11618. jw.Msg = "出现异常!" + ex.Message;
  11619. return Ok(jw);
  11620. }
  11621. }
  11622. if (Zips.Count > 0)
  11623. {
  11624. IOOperatorHelper io = new IOOperatorHelper();
  11625. var byts = io.ConvertZipStream(Zips);
  11626. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11627. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11628. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11629. }
  11630. else
  11631. {
  11632. jw.Msg = "暂无生成文件!";
  11633. }
  11634. return Ok(jw);
  11635. }
  11636. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11637. {
  11638. string outStr = string.Empty;
  11639. switch (i)
  11640. {
  11641. case 0:
  11642. outStr = arr[0].SidName;
  11643. break;
  11644. case 1:
  11645. outStr = arr[0].DataPriceStr;
  11646. break;
  11647. case 2:
  11648. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11649. break;
  11650. case 4:
  11651. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11652. break;
  11653. case 7:
  11654. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11655. {
  11656. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11657. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11658. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11659. }
  11660. break;
  11661. case 8:
  11662. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11663. {
  11664. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11665. }
  11666. break;
  11667. case 9:
  11668. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11669. {
  11670. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11671. }
  11672. break;
  11673. case 10:
  11674. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11675. {
  11676. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11677. }
  11678. break;
  11679. }
  11680. return outStr;
  11681. }
  11682. #region OP行程单
  11683. /// <summary>
  11684. /// OP行程单初始化
  11685. /// </summary>
  11686. /// <param name="dto"></param>
  11687. /// <returns></returns>
  11688. [HttpPost]
  11689. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11690. {
  11691. var jw = JsonView(false);
  11692. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11693. var group = groupList.First();
  11694. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11695. if (group == null)
  11696. {
  11697. jw.Msg = "暂无团组!";
  11698. return Ok(jw);
  11699. }
  11700. group = groupList.Find(x => x.Id == diid);
  11701. if (group == null)
  11702. {
  11703. jw.Msg = "请输入正确的团组ID!";
  11704. return Ok(jw);
  11705. }
  11706. string city = string.Empty;
  11707. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11708. if (blackCode.Count > 0)
  11709. {
  11710. var black = blackCode.First();
  11711. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11712. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11713. if (blackSp.Length > 0)
  11714. {
  11715. try
  11716. {
  11717. var cityArrCode = new List<string>(20);
  11718. foreach (var item in blackSp)
  11719. {
  11720. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11721. var IndexSelect = itemSp[2];
  11722. var cityArrCodeLength = cityArrCode.Count - 1;
  11723. var startCity = IndexSelect.Substring(0, 3);
  11724. if (cityArrCodeLength > 0)
  11725. {
  11726. var arrEndCity = cityArrCode[cityArrCodeLength];
  11727. if (arrEndCity != startCity)
  11728. {
  11729. cityArrCode.Add(startCity.ToUpper());
  11730. }
  11731. }
  11732. else
  11733. {
  11734. cityArrCode.Add(startCity.ToUpper());
  11735. }
  11736. var endCity = IndexSelect.Substring(3, 3);
  11737. cityArrCode.Add(endCity.ToUpper());
  11738. }
  11739. var cityThree = string.Empty;
  11740. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11741. cityThree = cityThree.TrimEnd(',');
  11742. if (string.IsNullOrWhiteSpace(cityThree))
  11743. {
  11744. throw new
  11745. Exception("error");
  11746. }
  11747. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11748. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11749. foreach (var item in cityArrCode)
  11750. {
  11751. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11752. if (find != null)
  11753. {
  11754. city += find.City + "/";
  11755. }
  11756. else
  11757. {
  11758. city += item + "三字码未收入/";
  11759. }
  11760. }
  11761. city = city.TrimEnd('/');
  11762. }
  11763. catch (Exception e)
  11764. {
  11765. city = "黑屏代码格式不正确!";
  11766. }
  11767. }
  11768. }
  11769. else
  11770. {
  11771. city = "未录入黑屏代码";
  11772. }
  11773. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11774. {
  11775. Date = x.Date,
  11776. Days = x.Days,
  11777. Diffgroup = x.Diffgroup,
  11778. Diid = x.Diid,
  11779. Traffic_First = x.Traffic_First,
  11780. Traffic_Second = x.Traffic_Second,
  11781. Trip = x.Trip,
  11782. WeekDay = x.WeekDay,
  11783. Id = x.Id
  11784. }).ToList();
  11785. jw.Data = new
  11786. {
  11787. groupList = groupList.Select(x => new
  11788. {
  11789. x.Id,
  11790. x.TeamName,
  11791. x.TourCode
  11792. }).ToList(),
  11793. groupInfo = new
  11794. {
  11795. group.VisitDays,
  11796. group.TourCode,
  11797. group.VisitPNumber,
  11798. group.TeamName,
  11799. city
  11800. },
  11801. OpTravelList
  11802. };
  11803. jw.Code = 200;
  11804. jw.Msg = "操作成功!";
  11805. return Ok(jw);
  11806. }
  11807. /// <summary>
  11808. /// 删除团组行程单
  11809. /// </summary>
  11810. /// <returns></returns>
  11811. [HttpPost]
  11812. public IActionResult DelTravel(DelOpTravelDto dto)
  11813. {
  11814. var jw = JsonView(false);
  11815. if (dto.UserId <= 0 || dto.Diid <= 0)
  11816. {
  11817. jw.Msg = "请输入正确的参数!";
  11818. return Ok(jw);
  11819. }
  11820. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11821. .SetColumns(x => new Grp_TravelList
  11822. {
  11823. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11824. DeleteUserId = dto.UserId,
  11825. IsDel = 1,
  11826. }).ExecuteCommand();
  11827. jw = JsonView(true);
  11828. return Ok(jw);
  11829. }
  11830. /// <summary>
  11831. /// 行程单保存
  11832. /// </summary>
  11833. /// <returns></returns>
  11834. [HttpPost]
  11835. public IActionResult TravelSave(TravelSaveDto dto)
  11836. {
  11837. var jw = JsonView(false);
  11838. if (dto.Arr.Count > 0)
  11839. {
  11840. try
  11841. {
  11842. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11843. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11844. .ToList();
  11845. _sqlSugar.BeginTran();
  11846. foreach (var item in dto.Arr)
  11847. {
  11848. if (item.Id == 0)
  11849. {
  11850. throw new Exception("请传入正确的Id");
  11851. }
  11852. //比较上一次的差异
  11853. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11854. if (findTravel != null)
  11855. {
  11856. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11857. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11858. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11859. }
  11860. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11861. .SetColumns(x => new Grp_TravelList
  11862. {
  11863. Trip = item.Trip
  11864. }).ExecuteCommand();
  11865. }
  11866. _sqlSugar.CommitTran();
  11867. jw = JsonView(true);
  11868. }
  11869. catch (Exception ex)
  11870. {
  11871. _sqlSugar.RollbackTran();
  11872. jw.Msg = "程序异常!" + ex.Message;
  11873. }
  11874. }
  11875. else
  11876. {
  11877. jw.Msg = "请传入正确的参数!";
  11878. }
  11879. return Ok(jw);
  11880. }
  11881. private string CheckStr(string original, string changed)
  11882. {
  11883. // 创建diff_match_patch对象
  11884. var dmp = new diff_match_patch();
  11885. // 计算差异
  11886. List<Diff> diffs = dmp.diff_main(original, changed);
  11887. // 清理和合并差异
  11888. dmp.diff_cleanupSemantic(diffs);
  11889. // 使用StringBuilder构建最终的字符串
  11890. StringBuilder finalString = new StringBuilder();
  11891. // 输出差异结果,并构建变动后的字符串
  11892. foreach (Diff diff in diffs)
  11893. {
  11894. switch (diff.operation)
  11895. {
  11896. case Operation.EQUAL:
  11897. // 相等的部分,直接添加到最终字符串
  11898. finalString.Append(diff.text);
  11899. break;
  11900. case Operation.INSERT:
  11901. // 插入的部分,添加标记并添加到最终字符串
  11902. finalString.Append("[++]" + diff.text + "[++]");
  11903. break;
  11904. case Operation.DELETE:
  11905. // 删除的部分,不添加到最终字符串
  11906. //finalString.Append("[++]" + diff.text + "[++]");
  11907. break;
  11908. }
  11909. }
  11910. // 输出变动后的字符串
  11911. return finalString.ToString();
  11912. }
  11913. private class tagContent
  11914. {
  11915. public DateTime Date { get; set; }
  11916. public string StartTag { get; set; }
  11917. public string EndTag { get; set; }
  11918. public string Content { get; set; }
  11919. public static int tagLength { get { return 3; } }
  11920. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11921. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11922. public bool IsFinally { get; set; }
  11923. }
  11924. private List<string> ExtractContentBetweenTags(string input, string tag)
  11925. {
  11926. List<string> results = new List<string>();
  11927. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11928. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11929. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11930. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11931. string[] strValueArr = new string[1];
  11932. foreach (System.Text.RegularExpressions.Match match in matches)
  11933. {
  11934. var strValue = match.Groups[1].Value;
  11935. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11936. }
  11937. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11938. return results;
  11939. }
  11940. /// <summary>
  11941. /// 导出行程单
  11942. /// </summary>
  11943. /// <param name="dto"></param>
  11944. /// <returns></returns>
  11945. [HttpPost]
  11946. public IActionResult ExportTravel(ExportTravelDto dto)
  11947. {
  11948. var jw = JsonView(false);
  11949. jw.Data = "";
  11950. int diid = 0;
  11951. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11952. if (Find == null)
  11953. {
  11954. jw.Msg = "请选择正确的团组!";
  11955. return Ok(jw);
  11956. }
  11957. else
  11958. {
  11959. diid = Find.Id;
  11960. }
  11961. //数据源
  11962. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11963. DataTable dtBlack = null;
  11964. try
  11965. {
  11966. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11967. }
  11968. catch (Exception)
  11969. {
  11970. jw.Msg = "机票黑屏代码有误!";
  11971. return Ok(jw);
  11972. }
  11973. string CityStr = string.Empty;
  11974. if (dtBlack.Rows.Count == 0)
  11975. {
  11976. jw.Msg = "机票黑屏代码有误!";
  11977. return Ok(jw);
  11978. }
  11979. else
  11980. {
  11981. foreach (DataRow row in dtBlack.Rows)
  11982. {
  11983. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11984. {
  11985. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11986. return Ok(jw);
  11987. }
  11988. }
  11989. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11990. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11991. }
  11992. // 指定的文字
  11993. var targetTextDic = new Dictionary<string, List<string>>();
  11994. //创建数据源Table
  11995. DataTable dtSource = new DataTable();
  11996. dtSource.Columns.Add("Days", typeof(string));
  11997. dtSource.Columns.Add("Date", typeof(string));
  11998. dtSource.Columns.Add("Week", typeof(string));
  11999. dtSource.Columns.Add("Traffic", typeof(string));
  12000. dtSource.Columns.Add("Trip", typeof(string));
  12001. //获取数据,放到datatable
  12002. foreach (var item in _travelList)
  12003. {
  12004. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  12005. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  12006. .Replace(tagContent.TagFormat.Item2, string.Empty)
  12007. .Replace("[++]", string.Empty);
  12008. DataRow dr = dtSource.NewRow();
  12009. dr["Days"] = item.Days;
  12010. dr["Date"] = item.Date;
  12011. dr["Week"] = item.WeekDay;
  12012. dr["Traffic"] = item.Traffic_First
  12013. + "\r\n"
  12014. + item.Traffic_Second;
  12015. dr["Trip"] = item.Trip;
  12016. dtSource.Rows.Add(dr);
  12017. }
  12018. Dictionary<string, string> dic = new Dictionary<string, string>();
  12019. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12020. dic.Add("City", CityStr);
  12021. dic.Add("Days", Find.VisitDays.ToString());
  12022. dic.Add("DeleCode", Find.TourCode);
  12023. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12024. //模板路径
  12025. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12026. //载入模板
  12027. Document doc = null;
  12028. DocumentBuilder builder = null;
  12029. try
  12030. {
  12031. //载入模板
  12032. doc = new Document(tempPath);
  12033. builder = new DocumentBuilder(doc);
  12034. }
  12035. catch (Exception)
  12036. {
  12037. jw.Msg = "模板位置不存在!";
  12038. return Ok(jw);
  12039. }
  12040. foreach (var key in dic.Keys)
  12041. {
  12042. Bookmark bookmark = doc.Range.Bookmarks[key];
  12043. if (bookmark != null)
  12044. {
  12045. builder.MoveToBookmark(key);
  12046. builder.Write(dic[key]);
  12047. }
  12048. }
  12049. //获取word里所有表格
  12050. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12051. //获取所填表格的序数
  12052. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12053. try
  12054. {
  12055. //循环赋值
  12056. for (int i = 0; i < dtSource.Rows.Count; i++)
  12057. {
  12058. builder.MoveToCell(0, i + 1, 0, 0);
  12059. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12060. builder.MoveToCell(0, i + 1, 1, 0);
  12061. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12062. builder.MoveToCell(0, i + 1, 2, 0);
  12063. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12064. var trip = dtSource.Rows[i]["Trip"].ToString();
  12065. builder.MoveToCell(0, i + 1, 3, 0);
  12066. builder.Write(trip);
  12067. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12068. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12069. // 获取特定索引的段落
  12070. Paragraph paragraph = (Paragraph)paragraphs[0];
  12071. Run run = paragraph.Runs[0];
  12072. Aspose.Words.Font font = run.Font;
  12073. font.Name = "黑体";
  12074. //设置双休红色
  12075. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12076. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12077. paragraph = (Paragraph)paragraphs[1];
  12078. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12079. {
  12080. run = paragraph.Runs[0];
  12081. font = run.Font;
  12082. font.Color = Color.Red;
  12083. }
  12084. }
  12085. }
  12086. catch (Exception ex)
  12087. {
  12088. }
  12089. //删除多余行
  12090. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12091. {
  12092. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12093. }
  12094. var targetTextList = new List<string>();
  12095. // 遍历文档中的表格
  12096. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12097. {
  12098. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12099. {
  12100. var cellIndex = 0;
  12101. foreach (Cell cell in row.Cells)
  12102. {
  12103. if (cellIndex == 1 && row.Cells.Count == 4)
  12104. {
  12105. foreach (var target in targetTextDic.Keys)
  12106. {
  12107. if (cell.GetText().Contains(target))
  12108. {
  12109. targetTextList = targetTextDic[target];
  12110. break;
  12111. }
  12112. }
  12113. }
  12114. // 遍历单元格中的所有段落
  12115. foreach (Paragraph paragraph in cell.Paragraphs)
  12116. {
  12117. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12118. List<Run> runs = new List<Run>();
  12119. foreach (Run run in paragraph.Runs)
  12120. {
  12121. runs.Add(run);
  12122. }
  12123. foreach (Run run in runs)
  12124. {
  12125. foreach (var targetText in targetTextList)
  12126. {
  12127. // 检查文字是否包含指定文字
  12128. if (run.Text.Contains(targetText))
  12129. {
  12130. // 将包含的部分设置为红色
  12131. HighlightText(run, targetText, Color.Red);
  12132. }
  12133. }
  12134. }
  12135. }
  12136. cellIndex++;
  12137. }
  12138. }
  12139. }
  12140. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12141. if (!Directory.Exists(savePath))
  12142. {
  12143. try
  12144. {
  12145. Directory.CreateDirectory(savePath);
  12146. }
  12147. catch
  12148. {
  12149. }
  12150. }
  12151. string path = savePath + Find.TeamName + "出访日程";
  12152. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12153. try
  12154. {
  12155. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12156. string postfix = ".docx";
  12157. if (dto.IsPDF == 1)
  12158. {
  12159. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12160. postfix = ".pdf";
  12161. }
  12162. doc.Save(path + postfix, saveFormat);
  12163. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12164. }
  12165. catch (Exception)
  12166. {
  12167. jw = JsonView(false);
  12168. }
  12169. return Ok(jw);
  12170. }
  12171. /// <summary>
  12172. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12173. /// </summary>
  12174. /// <param name="num"></param>
  12175. /// <returns></returns>
  12176. string GetNum(string num)
  12177. {
  12178. string str = "";
  12179. switch (num)
  12180. {
  12181. case "1":
  12182. str = "一";
  12183. break;
  12184. case "2":
  12185. str = "二";
  12186. break;
  12187. case "3":
  12188. str = "三";
  12189. break;
  12190. case "4":
  12191. str = "四";
  12192. break;
  12193. case "5":
  12194. str = "五";
  12195. break;
  12196. case "6":
  12197. str = "六";
  12198. break;
  12199. case "7":
  12200. str = "七";
  12201. break;
  12202. case "8":
  12203. str = "八";
  12204. break;
  12205. case "9":
  12206. str = "九";
  12207. break;
  12208. case "10":
  12209. str = "十";
  12210. break;
  12211. case "11":
  12212. str = "十一";
  12213. break;
  12214. case "12":
  12215. str = "十二";
  12216. break;
  12217. case "一":
  12218. str = "1";
  12219. break;
  12220. case "二":
  12221. str = "2";
  12222. break;
  12223. case "三":
  12224. str = "3";
  12225. break;
  12226. case "四":
  12227. str = "4";
  12228. break;
  12229. case "五":
  12230. str = "5";
  12231. break;
  12232. case "六":
  12233. str = "6";
  12234. break;
  12235. case "七":
  12236. str = "7";
  12237. break;
  12238. case "八":
  12239. str = "8";
  12240. break;
  12241. case "九":
  12242. str = "9";
  12243. break;
  12244. case "十":
  12245. str = "10";
  12246. break;
  12247. case "十一":
  12248. str = "11";
  12249. break;
  12250. case "十二":
  12251. str = "12";
  12252. break;
  12253. }
  12254. return str;
  12255. }
  12256. // 高亮包含指定文字的部分
  12257. void HighlightText(Run run, string targetText, Color color)
  12258. {
  12259. string text = run.Text;
  12260. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12261. if (startIndex >= 0)
  12262. {
  12263. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12264. // 前部分
  12265. if (startIndex > 0)
  12266. {
  12267. Run beforeRun = (Run)run.Clone(true);
  12268. beforeRun.Text = text.Substring(0, startIndex);
  12269. parentParagraph.InsertBefore(beforeRun, run);
  12270. }
  12271. // 匹配部分
  12272. Run matchRun = (Run)run.Clone(true);
  12273. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12274. matchRun.Font.Color = color;
  12275. parentParagraph.InsertBefore(matchRun, run);
  12276. // 后部分
  12277. if (startIndex + targetText.Length < text.Length)
  12278. {
  12279. Run afterRun = (Run)run.Clone(true);
  12280. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12281. parentParagraph.InsertBefore(afterRun, run);
  12282. }
  12283. // 删除原始Run
  12284. run.Remove();
  12285. }
  12286. }
  12287. #endregion
  12288. #endregion
  12289. #region 团组成本
  12290. /// <summary>
  12291. /// 团组成本数据初始化
  12292. /// </summary>
  12293. /// <param name="dto"></param>
  12294. /// <returns></returns>
  12295. [HttpPost]
  12296. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12297. {
  12298. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12299. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12300. WHEN COUNT(*) >= 0 THEN 'True'
  12301. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12302. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12303. ").ToList(); //团组列表
  12304. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12305. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12306. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12307. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12308. if (groupinfoValue != null)
  12309. {
  12310. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12311. var spArr = new string[1] { countryArr };
  12312. if (countryArr.Contains("|"))
  12313. {
  12314. spArr = countryArr.Split("|");
  12315. }
  12316. else if (countryArr.Contains("、"))
  12317. {
  12318. spArr = countryArr.Split("、");
  12319. }
  12320. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12321. {
  12322. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12323. if (dbQueryCountry != null)
  12324. {
  12325. visaCountryInfoArr.Add(dbQueryCountry);
  12326. }
  12327. }
  12328. }
  12329. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12330. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12331. var create = _GroupCostRepository.
  12332. CreateGroupCostByBlackCode(dto.Diid);
  12333. if (groupCost.Count == 0 && create.Code == 0)
  12334. {
  12335. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12336. }
  12337. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12338. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12339. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12340. groupCostMap = groupCostMap.Select(x =>
  12341. {
  12342. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12343. {
  12344. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12345. }
  12346. return x;
  12347. }).ToList();
  12348. //GroupCostParameter.Add(new
  12349. // Grp_GroupCostParameter());
  12350. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12351. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12352. return Ok(JsonView(new
  12353. {
  12354. groupList,
  12355. groupInfo,
  12356. groupChecks,
  12357. groupCost = groupCostMap,
  12358. hotelNumber,
  12359. GroupCostParameter = GroupCostParameterMap,
  12360. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12361. {
  12362. x.VisaCountry,
  12363. x.VisaPrice,
  12364. x.Id,
  12365. }).ToList(),
  12366. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12367. blackCodeIsTrue = create.Code == 0 ? true : false,
  12368. hotelIsTrue = hotelIsTrue,
  12369. }));
  12370. }
  12371. /// <summary>
  12372. /// 团组成本信息保存
  12373. /// </summary>
  12374. /// <param name="dto"></param>
  12375. /// <returns></returns>
  12376. [HttpPost]
  12377. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12378. {
  12379. if (dto.Diid <= 0 || dto.Userid <= 0)
  12380. {
  12381. return Ok(JsonView(false));
  12382. }
  12383. JsonView jw = null;
  12384. bool isTrue = false;
  12385. #region 复制团组成本
  12386. //if (dto.Diid == 2581)
  12387. //{
  12388. // dto.Diid = 2599;
  12389. // dto.CheckBoxs.ForEach(x =>
  12390. // {
  12391. // x.Diid = 2599;
  12392. // });
  12393. // dto.GroupCosts.ForEach(x =>
  12394. // {
  12395. // x.Diid = 2599;
  12396. // });
  12397. // dto.CostTypeHotelNumbers.ForEach(x =>
  12398. // {
  12399. // x.Diid = 2599;
  12400. // });
  12401. // dto.GroupCostParameters.ForEach(x =>
  12402. // {
  12403. // x.DiId = 2599;
  12404. // });
  12405. //}
  12406. #endregion
  12407. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12408. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12409. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12410. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12411. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12412. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12413. try
  12414. {
  12415. _sqlSugar.BeginTran();
  12416. isTrue = await _GroupCostRepository.
  12417. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12418. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12419. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12420. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12421. _sqlSugar.CommitTran();
  12422. jw = JsonView(true, "保存成功!", isTrue);
  12423. }
  12424. catch (Exception)
  12425. {
  12426. _sqlSugar.RollbackTran();
  12427. jw = JsonView(false);
  12428. }
  12429. return Ok(jw);
  12430. }
  12431. /// <summary>
  12432. /// 司兼导数据
  12433. /// </summary>
  12434. /// <param name="dto"></param>
  12435. /// <returns></returns>
  12436. [HttpPost]
  12437. public IActionResult GetCarGuides(CarGuidesDto dto)
  12438. {
  12439. JsonView jw = null;
  12440. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12441. jw = JsonView(true, "获取成功!", Data);
  12442. return Ok(jw);
  12443. }
  12444. /// <summary>
  12445. /// 导游数据
  12446. /// </summary>
  12447. /// <param name="dto"></param>
  12448. /// <returns></returns>
  12449. [HttpPost]
  12450. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12451. {
  12452. JsonView jw = null;
  12453. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12454. // 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
  12455. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12456. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12457. jw = JsonView(true, "获取成功!", Data);
  12458. return Ok(jw);
  12459. }
  12460. /// <summary>
  12461. /// 成本车数据
  12462. /// </summary>
  12463. /// <param name="dto"></param>
  12464. /// <returns></returns>
  12465. [HttpPost]
  12466. public IActionResult GetCarInfo(CarGuidesDto dto)
  12467. {
  12468. JsonView jw = null;
  12469. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12470. jw = JsonView(true, "获取成功!", Data);
  12471. return Ok(jw);
  12472. }
  12473. /// <summary>
  12474. /// 景点数据
  12475. /// </summary>
  12476. /// <param name="dto"></param>
  12477. /// <returns></returns>
  12478. [HttpPost]
  12479. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12480. {
  12481. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12482. return Ok(JsonView(true, "获取成功!", Data));
  12483. }
  12484. /// <summary>
  12485. /// 成本通知
  12486. /// </summary>
  12487. /// <param name="dto"></param>
  12488. /// <returns></returns>
  12489. [HttpPost]
  12490. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12491. {
  12492. if (dto.Diid < 0)
  12493. {
  12494. return Ok(JsonView(false));
  12495. }
  12496. JsonView jw = null;
  12497. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12498. if (GroupCostParameter != null)
  12499. {
  12500. int IsShare = 0;
  12501. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12502. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12503. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12504. string msg = string.Empty;
  12505. if (isTrue)
  12506. {
  12507. if (IsShare == 0)
  12508. {
  12509. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12510. }
  12511. else
  12512. {
  12513. #region 企微通知对应岗位用户
  12514. try
  12515. {
  12516. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12517. }
  12518. catch (Exception ex)
  12519. {
  12520. }
  12521. #endregion
  12522. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12523. }
  12524. jw = JsonView(isTrue, msg, new { IsShare });
  12525. }
  12526. else
  12527. {
  12528. msg = "修改失败!";
  12529. jw = JsonView(isTrue, msg);
  12530. }
  12531. }
  12532. else
  12533. {
  12534. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12535. }
  12536. return Ok(jw);
  12537. }
  12538. /// <summary>
  12539. /// 导出报价单
  12540. /// </summary>
  12541. /// <param name="dto"></param>
  12542. /// <returns></returns>
  12543. [HttpPost]
  12544. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12545. {
  12546. if (dto.Diid == 0)
  12547. {
  12548. return Ok(JsonView(false, "请传递团组id"));
  12549. }
  12550. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12551. if (deleInfo.Code != 0)
  12552. {
  12553. return Ok(JsonView(false, "团组信息查询失败!"));
  12554. }
  12555. var di = deleInfo.Data as DelegationInfoWebView;
  12556. if (di != null)
  12557. {
  12558. di.TeamName = di.TeamName.Replace("|", "、");
  12559. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12560. //文件名
  12561. string strFileName = di.TeamName + "-收款账单.doc";
  12562. //获取模板
  12563. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12564. //载入模板
  12565. Document doc = new Document(tmppath);
  12566. decimal TotalPrice = 0.00M;
  12567. string itemStr = string.Empty;
  12568. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12569. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12570. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12571. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12572. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12573. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12574. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12575. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12576. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12577. foreach (var cost in groupCostType)
  12578. {
  12579. var List = cost.ToList();
  12580. if (cost.Key == "A")
  12581. {
  12582. foreach (var ListItem in List)
  12583. {
  12584. if (ListItem.number > 0)
  12585. {
  12586. if (ListItem.code.Contains("TBR"))
  12587. {
  12588. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12589. }
  12590. else
  12591. {
  12592. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12593. }
  12594. TotalPrice += (ListItem.number * ListItem.price);
  12595. }
  12596. }
  12597. }
  12598. else
  12599. {
  12600. itemStr = itemStr.Insert(0, "A段\r\n");
  12601. itemStr += "B段\r\n";
  12602. foreach (var ListItem in List)
  12603. {
  12604. if (ListItem.number > 0)
  12605. {
  12606. if (ListItem.code.Contains("TBR"))
  12607. {
  12608. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12609. }
  12610. else
  12611. {
  12612. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12613. }
  12614. TotalPrice += (ListItem.number * ListItem.price);
  12615. }
  12616. }
  12617. }
  12618. }
  12619. #region 替换Word模板书签内容
  12620. Dictionary<string, string> marks = new Dictionary<string, string>();
  12621. marks.Add("To", di.ClientUnit);//付款方
  12622. marks.Add("ToTel", di.TellPhone);//付款方电话
  12623. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12624. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12625. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12626. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12627. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12628. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12629. marks.Add("PayItemContent", itemStr);//详细信息
  12630. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12631. #endregion
  12632. ////注
  12633. //if (doc.Range.Bookmarks["Attention"] != null)
  12634. //{
  12635. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12636. // mark.Text = frList[0].Attention;
  12637. //}
  12638. foreach (var item in marks.Keys)
  12639. {
  12640. if (doc.Range.Bookmarks[item] != null)
  12641. {
  12642. Bookmark mark = doc.Range.Bookmarks[item];
  12643. mark.Text = marks[item];
  12644. }
  12645. }
  12646. byte[] bytes = null;
  12647. using (MemoryStream stream = new MemoryStream())
  12648. {
  12649. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12650. bytes = stream.ToArray();
  12651. }
  12652. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12653. return Ok(JsonView(true, "", new
  12654. {
  12655. Data = bytes,
  12656. strFileName,
  12657. }));
  12658. }
  12659. else
  12660. {
  12661. return Ok(JsonView(false, "团组信息不存在!"));
  12662. }
  12663. }
  12664. /// <summary>
  12665. /// 导出团组成本
  12666. /// </summary>
  12667. /// <param name="dto"></param>
  12668. /// <returns></returns>
  12669. [HttpPost]
  12670. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12671. {
  12672. var jw = JsonView(false);
  12673. if (dto.Diid == 0)
  12674. {
  12675. return Ok(JsonView(false, "请传递团组id"));
  12676. }
  12677. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12678. if (deleInfo.Code != 0)
  12679. {
  12680. return Ok(JsonView(false, "团组信息查询失败!"));
  12681. }
  12682. var di = deleInfo.Data as DelegationInfoWebView;
  12683. if (di == null)
  12684. {
  12685. return Ok(JsonView(false, "团组信息查询失败!"));
  12686. }
  12687. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12688. WorkbookDesigner designer = new WorkbookDesigner();
  12689. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12690. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12691. for (int i = 0; i < List_GC.Count; i++)
  12692. {
  12693. GroupCost_Excel gc = new GroupCost_Excel();
  12694. gc.Id = List_GC[i].Id;
  12695. gc.Diid = List_GC[i].Diid.ToString();
  12696. gc.DAY = List_GC[i].DAY;
  12697. string week = "";
  12698. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12699. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12700. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12701. gc.ITIN = List_GC[i].ITIN;
  12702. gc.CarType = List_GC[i].CarType;
  12703. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12704. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12705. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12706. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12707. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12708. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12709. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12710. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12711. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12712. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12713. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12714. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12715. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12716. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12717. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12718. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12719. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12720. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12721. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12722. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12723. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12724. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12725. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12726. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12727. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12728. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12729. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12730. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12731. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12732. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12733. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12734. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12735. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12736. List_GC1.Add(gc);
  12737. }
  12738. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12739. dt.TableName = "TB";
  12740. //报表标题等不用dt的值
  12741. designer.SetDataSource("TeamName", dto.title.TeamName);
  12742. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12743. designer.SetDataSource("Tax", dto.title.Tax);
  12744. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12745. designer.SetDataSource("Currency", dto.title.Currency);
  12746. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12747. designer.SetDataSource("Rate", dto.title.Rate);
  12748. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12749. var Aparams = hotels.Find(x => x.Type == "Default");
  12750. if (Aparams == null)
  12751. {
  12752. return Ok(jw);
  12753. }
  12754. //酒店数量
  12755. var txtSGRNumber = Aparams.SGR.ToString();
  12756. var txtTBRNumber = Aparams.TBR.ToString();
  12757. var txtJSESNumber = Aparams.JSES.ToString();
  12758. var txtSUITENumbe = Aparams.SUITE.ToString();
  12759. if (dto.costType == "B")
  12760. {
  12761. Aparams = hotels.Find(x => x.Type == "A");
  12762. var Bparams = hotels.Find(x => x.Type == "B");
  12763. if (Aparams == null || Bparams == null)
  12764. {
  12765. return Ok(jw);
  12766. }
  12767. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12768. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12769. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12770. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12771. }
  12772. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12773. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12774. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12775. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12776. var ws = designer.Workbook.Worksheets[0];
  12777. int Row = List_GC.Count;
  12778. int startIndex = 11;
  12779. int HideRows = 0;
  12780. List<int> hideRowsList = new List<int>();
  12781. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12782. #region A段left数据
  12783. var left = dto.leftInfo.Find(x => x.Type == "A");
  12784. if (left == null)
  12785. {
  12786. return Ok(jw);
  12787. }
  12788. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12789. if (leftBindData != null)
  12790. {
  12791. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12792. designer.SetDataSource("VisaRS", leftBindData.rs);
  12793. designer.SetDataSource("VisaXS", leftBindData.xs);
  12794. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12795. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12796. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12797. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12798. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12799. }
  12800. else
  12801. {
  12802. hideRowsList.Add(Row + startIndex + HideRows);
  12803. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12804. }
  12805. HideRows += 2;
  12806. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12807. if (leftBindData != null)
  12808. {
  12809. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12810. designer.SetDataSource("BXRS", leftBindData.rs);
  12811. designer.SetDataSource("BXXS", leftBindData.xs);
  12812. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12813. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12814. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12815. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12816. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12817. }
  12818. else
  12819. {
  12820. hideRowsList.Add(Row + startIndex + HideRows);
  12821. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12822. }
  12823. HideRows += 2;
  12824. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12825. if (leftBindData != null)
  12826. {
  12827. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12828. designer.SetDataSource("HSRS", leftBindData.rs);
  12829. designer.SetDataSource("HSXS", leftBindData.xs);
  12830. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12831. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12832. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12833. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12834. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12835. }
  12836. else
  12837. {
  12838. hideRowsList.Add(Row + startIndex + HideRows);
  12839. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12840. }
  12841. HideRows += 2;
  12842. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12843. if (leftBindData != null)
  12844. {
  12845. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12846. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12847. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12848. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12849. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12850. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12851. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12852. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12853. }
  12854. else
  12855. {
  12856. hideRowsList.Add(Row + startIndex + HideRows);
  12857. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12858. }
  12859. HideRows += 2;
  12860. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12861. if (leftBindData != null)
  12862. {
  12863. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12864. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12865. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12866. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12867. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12868. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12869. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12870. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12871. }
  12872. else
  12873. {
  12874. hideRowsList.Add(Row + startIndex + HideRows);
  12875. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12876. }
  12877. HideRows += 2;
  12878. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12879. if (leftBindData != null)
  12880. {
  12881. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12882. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12883. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12884. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12885. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12886. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12887. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12888. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12889. }
  12890. else
  12891. {
  12892. hideRowsList.Add(Row + startIndex + HideRows);
  12893. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12894. }
  12895. HideRows += 2;
  12896. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12897. if (leftBindData != null)
  12898. {
  12899. ////TBR
  12900. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12901. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12902. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12903. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12904. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12905. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12906. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12907. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12908. }
  12909. else
  12910. {
  12911. hideRowsList.Add(Row + startIndex + HideRows);
  12912. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12913. }
  12914. HideRows += 2;
  12915. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12916. if (leftBindData != null)
  12917. {
  12918. ////SGR
  12919. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12920. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12921. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12922. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12923. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12924. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12925. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12926. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12927. }
  12928. else
  12929. {
  12930. hideRowsList.Add(Row + startIndex + HideRows);
  12931. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12932. }
  12933. HideRows += 2;
  12934. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12935. if (leftBindData != null)
  12936. {
  12937. ////JS/ES
  12938. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12939. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12940. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12941. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12942. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12943. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12944. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12945. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12946. }
  12947. else
  12948. {
  12949. hideRowsList.Add(Row + startIndex + HideRows);
  12950. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12951. }
  12952. HideRows += 2;
  12953. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12954. if (leftBindData != null)
  12955. {
  12956. ////SUITE
  12957. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12958. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12959. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12960. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12961. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12962. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12963. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12964. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12965. }
  12966. else
  12967. {
  12968. hideRowsList.Add(Row + startIndex + HideRows);
  12969. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12970. }
  12971. HideRows += 2;
  12972. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12973. if (leftBindData != null)
  12974. {
  12975. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12976. designer.SetDataSource("DJRS", leftBindData.rs);
  12977. designer.SetDataSource("DJXS", leftBindData.xs);
  12978. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12979. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12980. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12981. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12982. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12983. }
  12984. else
  12985. {
  12986. hideRowsList.Add(Row + startIndex + HideRows);
  12987. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12988. }
  12989. HideRows += 2;
  12990. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12991. if (leftBindData != null)
  12992. {
  12993. designer.SetDataSource("HCPCB", leftBindData.cb);
  12994. designer.SetDataSource("HCPRS", leftBindData.rs);
  12995. designer.SetDataSource("HCPXS", leftBindData.xs);
  12996. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12997. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12998. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12999. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13000. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13001. }
  13002. else
  13003. {
  13004. hideRowsList.Add(Row + startIndex + HideRows);
  13005. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13006. }
  13007. HideRows += 2;
  13008. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13009. if (leftBindData != null)
  13010. {
  13011. designer.SetDataSource("CPCB", leftBindData.cb);
  13012. designer.SetDataSource("CPRS", leftBindData.rs);
  13013. designer.SetDataSource("CPXS", leftBindData.xs);
  13014. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13015. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13016. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13017. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13018. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13019. }
  13020. else
  13021. {
  13022. hideRowsList.Add(Row + startIndex + HideRows);
  13023. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13024. }
  13025. HideRows += 2;
  13026. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13027. if (leftBindData != null)
  13028. {
  13029. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13030. designer.SetDataSource("GWRS", leftBindData.rs);
  13031. designer.SetDataSource("GWXS", leftBindData.xs);
  13032. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13033. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13034. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13035. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13036. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13037. }
  13038. else
  13039. {
  13040. hideRowsList.Add(Row + startIndex + HideRows);
  13041. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13042. }
  13043. HideRows += 2;
  13044. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13045. if (leftBindData != null)
  13046. {
  13047. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13048. designer.SetDataSource("LYJRS", leftBindData.rs);
  13049. designer.SetDataSource("LYJXS", leftBindData.xs);
  13050. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13051. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13052. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13053. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13054. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13055. }
  13056. else
  13057. {
  13058. hideRowsList.Add(Row + startIndex + HideRows);
  13059. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13060. }
  13061. #endregion
  13062. #region A段Right信息
  13063. var right = dto.rightInfo.Find(x => x.Type == "A");
  13064. if (right == null)
  13065. {
  13066. return Ok(jw);
  13067. }
  13068. HideRows += 4;
  13069. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13070. if (rightBindData != null)
  13071. {
  13072. //经济舱 + 双人间 TBR
  13073. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13074. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13075. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13076. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13077. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13078. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13079. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13080. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13081. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13082. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13083. }
  13084. else
  13085. {
  13086. hideRowsList.Add(Row + startIndex + HideRows);
  13087. }
  13088. HideRows += 2;
  13089. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13090. if (rightBindData != null)
  13091. {
  13092. //经济舱 + 单人间 SGR
  13093. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13094. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13095. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13096. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13097. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13098. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13099. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13100. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13101. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13102. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13103. }
  13104. else
  13105. {
  13106. hideRowsList.Add(Row + startIndex + HideRows);
  13107. }
  13108. HideRows += 2;
  13109. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13110. if (rightBindData != null)
  13111. {
  13112. //公务舱 + 单人间 SGR
  13113. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13114. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13115. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13116. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13117. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13118. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13119. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13120. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13121. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13122. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13123. }
  13124. else
  13125. {
  13126. hideRowsList.Add(Row + startIndex + HideRows);
  13127. }
  13128. HideRows += 2;
  13129. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13130. if (rightBindData != null)
  13131. {
  13132. //公务舱 + 小套房 JSES
  13133. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13134. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13135. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13136. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13137. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13138. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13139. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13140. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13141. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13142. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13143. }
  13144. else
  13145. {
  13146. hideRowsList.Add(Row + startIndex + HideRows);
  13147. }
  13148. HideRows += 2;
  13149. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13150. if (rightBindData != null)
  13151. {
  13152. //公务舱 + 小套房 JSES
  13153. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13154. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13155. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13156. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13157. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13158. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13159. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13160. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13161. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13162. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13163. }
  13164. else
  13165. {
  13166. hideRowsList.Add(Row + startIndex + HideRows);
  13167. }
  13168. HideRows += 2;
  13169. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13170. if (rightBindData != null)
  13171. {
  13172. //经济舱 + 大套房
  13173. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13174. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13175. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13176. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13177. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13178. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13179. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13180. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13181. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13182. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13183. }
  13184. else
  13185. {
  13186. hideRowsList.Add(Row + startIndex + HideRows);
  13187. }
  13188. HideRows += 2;
  13189. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13190. if (rightBindData != null)
  13191. {
  13192. //头等舱 + 小套房 JSES
  13193. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13194. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13195. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13196. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13197. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13198. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13199. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13200. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13201. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13202. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13203. }
  13204. else
  13205. {
  13206. hideRowsList.Add(Row + startIndex + HideRows);
  13207. }
  13208. HideRows += 2;
  13209. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13210. if (rightBindData != null)
  13211. {
  13212. //头等舱 + 大套房
  13213. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13214. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13215. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13216. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13217. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13218. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13219. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13220. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13221. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13222. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13223. }
  13224. else
  13225. {
  13226. hideRowsList.Add(Row + startIndex + HideRows);
  13227. }
  13228. #endregion
  13229. #region B段标题清空
  13230. designer.SetDataSource("CostBDRCB", "");
  13231. designer.SetDataSource("CostBRS", "");
  13232. designer.SetDataSource("CostBXS", "");
  13233. designer.SetDataSource("CostBZCB", "");
  13234. designer.SetDataSource("CostBDRBJ", "");
  13235. designer.SetDataSource("CostBZBJ", "");
  13236. designer.SetDataSource("CostBDRLR", "");
  13237. designer.SetDataSource("CostBZLR", "");
  13238. designer.SetDataSource("CostBDRCBOM", "");
  13239. designer.SetDataSource("CostBRSOM", "");
  13240. designer.SetDataSource("CostBZCBOM", "");
  13241. designer.SetDataSource("CostBDRBJOM", "");
  13242. designer.SetDataSource("CostBZBJOM", "");
  13243. designer.SetDataSource("CostBDRLROM", "");
  13244. designer.SetDataSource("CostBZLROM", "");
  13245. #endregion
  13246. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13247. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13248. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13249. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13250. designer.SetDataSource("DJName", "地接(CNY)");
  13251. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13252. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13253. designer.SetDataSource("GWName", "公务(CNY)");
  13254. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13255. designer.SetDataSource("LYJName", "零用金(CNY)");
  13256. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13257. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13258. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13259. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13260. designer.SetDataSource("BXName", "保险(CNY)");
  13261. designer.SetDataSource("VisaName", "签证(CNY)");
  13262. #region B段基本数据
  13263. if (dto.costType == "B")
  13264. {
  13265. left = dto.leftInfo.Find(x => x.Type == "B");
  13266. if (left == null)
  13267. {
  13268. return Ok(jw);
  13269. }
  13270. #region B段left数据
  13271. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13272. if (leftBindData != null)
  13273. {
  13274. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13275. designer.SetDataSource("BHSRS", leftBindData.rs);
  13276. designer.SetDataSource("BHSXS", leftBindData.xs);
  13277. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13278. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13279. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13280. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13281. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13282. }
  13283. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13284. if (leftBindData != null)
  13285. {
  13286. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13287. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13288. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13289. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13290. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13291. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13292. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13293. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13294. }
  13295. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13296. if (leftBindData != null)
  13297. {
  13298. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13299. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13300. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13301. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13302. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13303. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13304. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13305. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13306. }
  13307. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13308. if (leftBindData != null)
  13309. {
  13310. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13311. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13312. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13313. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13314. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13315. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13316. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13317. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13318. }
  13319. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13320. if (leftBindData != null)
  13321. {
  13322. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13323. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13324. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13325. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13326. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13327. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13328. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13329. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13330. }
  13331. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13332. if (leftBindData != null)
  13333. {
  13334. designer.SetDataSource("BCPCB", leftBindData.cb);
  13335. designer.SetDataSource("BCPRS", leftBindData.rs);
  13336. designer.SetDataSource("BCPXS", leftBindData.xs);
  13337. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13338. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13339. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13340. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13341. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13342. }
  13343. //TBR
  13344. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13345. if (leftBindData != null)
  13346. {
  13347. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13348. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13349. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13350. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13351. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13352. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13353. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13354. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13355. }
  13356. //SGR
  13357. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13358. if (leftBindData != null)
  13359. {
  13360. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13361. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13362. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13363. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13364. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13365. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13366. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13367. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13368. }
  13369. //JS/ES
  13370. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13371. if (leftBindData != null)
  13372. {
  13373. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13374. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13375. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13376. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13377. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13378. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13379. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13380. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13381. }
  13382. //SUITE
  13383. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13384. if (leftBindData != null)
  13385. {
  13386. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13387. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13388. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13389. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13390. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13391. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13392. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13393. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13394. }
  13395. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13396. if (leftBindData != null)
  13397. {
  13398. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13399. designer.SetDataSource("BDJRS", leftBindData.rs);
  13400. designer.SetDataSource("BDJXS", leftBindData.xs);
  13401. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13402. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13403. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13404. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13405. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13406. }
  13407. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13408. if (leftBindData != null)
  13409. {
  13410. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13411. designer.SetDataSource("BGWRS", leftBindData.rs);
  13412. designer.SetDataSource("BGWXS", leftBindData.xs);
  13413. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13414. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13415. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13416. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13417. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13418. }
  13419. #region 优化方案
  13420. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13421. //excelBind.Add("零用金", new {
  13422. //cb="",
  13423. //rs="",
  13424. //xs ="",
  13425. //zcb = "",
  13426. //});
  13427. #endregion
  13428. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13429. if (leftBindData != null)
  13430. {
  13431. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13432. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13433. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13434. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13435. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13436. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13437. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13438. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13439. }
  13440. #endregion
  13441. #region B段Right信息
  13442. right = dto.rightInfo.Find(x => x.Type == "B");
  13443. if (right == null)
  13444. {
  13445. return Ok(jw);
  13446. }
  13447. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13448. if (rightBindData != null)
  13449. {
  13450. //经济舱 + 双人间 TBR
  13451. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13452. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13453. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13454. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13455. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13456. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13457. designer.SetDataSource("BlblJJCTBRZLR", (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("BlblJJCSGRDRCB", rightBindData.cb);
  13467. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13468. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13469. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13470. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13471. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13472. designer.SetDataSource("BlblJJCSGRZLR", (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("公务舱 SGR"));
  13478. if (rightBindData != null)
  13479. {
  13480. //公务舱 + 单人间 SGR
  13481. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13482. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13483. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13484. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13485. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13486. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13487. designer.SetDataSource("BlblGWCSGRZLR", (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("公务舱 JS/ES"));
  13493. if (rightBindData != null)
  13494. {
  13495. //公务舱 + 小套房 JSES
  13496. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13497. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13498. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13499. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13500. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13501. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13502. designer.SetDataSource("BlblGWCJSESZLR", (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. //公务舱 + 小套房 JSES
  13511. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13512. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13513. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13514. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13515. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13516. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13517. designer.SetDataSource("BlblGWCSUITEZLR", (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("经济舱 SUITE"));
  13523. if (rightBindData != null)
  13524. {
  13525. //经济舱 + 大套房
  13526. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13527. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13528. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13529. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13530. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13531. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13532. designer.SetDataSource("BlblJJCSUITEZLR", (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("头等舱 JS/ES"));
  13538. if (rightBindData != null)
  13539. {
  13540. //头等舱 + 小套房 JSES
  13541. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13542. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13543. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13544. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13545. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13546. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13547. designer.SetDataSource("BlblTDCJSESZLR", (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. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13553. if (rightBindData != null)
  13554. {
  13555. //头等舱 + 大套房
  13556. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13557. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13558. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13559. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13560. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13561. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13562. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13563. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13564. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13565. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13566. }
  13567. #endregion
  13568. #region 标题
  13569. designer.SetDataSource("CostBDRCB", "单人成本");
  13570. designer.SetDataSource("CostBRS", "人数");
  13571. designer.SetDataSource("CostBXS", "系数");
  13572. designer.SetDataSource("CostBZCB", "总成本");
  13573. designer.SetDataSource("CostBDRBJ", "单人报价");
  13574. designer.SetDataSource("CostBZBJ", "总报价");
  13575. designer.SetDataSource("CostBDRLR", "单人利润");
  13576. designer.SetDataSource("CostBZLR", "总利润");
  13577. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13578. designer.SetDataSource("CostBRSOM", "人数");
  13579. designer.SetDataSource("CostBZCBOM", "总成本");
  13580. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13581. designer.SetDataSource("CostBZBJOM", "总报价");
  13582. designer.SetDataSource("CostBDRLROM", "单人利润");
  13583. designer.SetDataSource("CostBZLROM", "总利润");
  13584. #endregion
  13585. }
  13586. #endregion
  13587. designer.SetDataSource("TzZCB2", TzZCB2);
  13588. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13589. designer.SetDataSource("TzZLR2", TzZLR2);
  13590. string[] dataSourceKeys = new string[]
  13591. {
  13592. "VF",
  13593. "TGS",
  13594. "TGOF",
  13595. "TGM",
  13596. "TGA",
  13597. "TGTF",
  13598. "TGEF",
  13599. "CFM",
  13600. "CFOF",
  13601. "B",
  13602. "L",
  13603. "D",
  13604. "TBR",
  13605. "SGR",
  13606. "JSES",
  13607. "Suite",
  13608. "TV",
  13609. "1L",
  13610. "IF",
  13611. "EF",
  13612. "BRF",
  13613. "TE",
  13614. "TGT",
  13615. "DRVT",
  13616. "PC",
  13617. "TLF",
  13618. "ECT"
  13619. };
  13620. foreach (var item in dataSourceKeys)
  13621. {
  13622. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13623. if (find != null)
  13624. {
  13625. designer.SetDataSource(item, find.text);
  13626. }
  13627. else
  13628. {
  13629. designer.SetDataSource(item, 0);
  13630. }
  13631. }
  13632. designer.SetDataSource(dt);
  13633. //根据数据源处理生成报表内容
  13634. designer.Process();
  13635. designer.Workbook.Worksheets[0].Name = "清单";
  13636. Worksheet sheet = designer.Workbook.Worksheets[0];
  13637. foreach (var Rowindex in hideRowsList)
  13638. {
  13639. ws.Cells.HideRows(Rowindex, 2);
  13640. }
  13641. byte[] bytes = null;
  13642. string strFileName = di.TeamName + "-团组-成本.xls";
  13643. using (MemoryStream stream = new MemoryStream())
  13644. {
  13645. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13646. bytes = stream.ToArray();
  13647. }
  13648. return Ok(JsonView(true, "", new
  13649. {
  13650. Data = bytes,
  13651. strFileName,
  13652. }));
  13653. }
  13654. /// <summary>
  13655. /// 导出客户报表
  13656. /// </summary>
  13657. /// <returns></returns>
  13658. [HttpPost]
  13659. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13660. {
  13661. var jw = JsonView(false);
  13662. if (dto.Diid == 0)
  13663. {
  13664. return Ok(JsonView(false, "请传递团组id"));
  13665. }
  13666. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13667. if (deleInfo.Code != 0)
  13668. {
  13669. return Ok(JsonView(false, "团组信息查询失败!"));
  13670. }
  13671. var di = deleInfo.Data as DelegationInfoWebView;
  13672. if (di == null)
  13673. {
  13674. return Ok(JsonView(false, "团组信息查询失败!"));
  13675. }
  13676. //文件名
  13677. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13678. //获取模板
  13679. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13680. //载入模板
  13681. Document doc = new Document(tmppath);
  13682. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13683. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13684. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13685. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13686. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13687. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13688. if (AParameter == null)
  13689. {
  13690. return Ok(JsonView(false, "系数不存在!"));
  13691. }
  13692. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13693. , TzAirDesc, TzZCost;
  13694. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13695. = TzAirDesc = TzZCost = string.Empty;
  13696. TzNumber = AParameter.CostTypenumber.ToString();
  13697. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13698. CarGuides1 = dto.CarGuides1;
  13699. Meal = dto.Meal;
  13700. SubsidizedMeals = dto.SubsidizedMeals;
  13701. NightRepair = dto.NightRepair;
  13702. AttractionsTickets = dto.AttractionsTickets;
  13703. MiscellaneousFees = dto.MiscellaneousFees;
  13704. ATip = dto.ATip;
  13705. TzHotelDesc = "";
  13706. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13707. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13708. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13709. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13710. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13711. TzAirDesc = "";
  13712. TzZCost = dto.TzZCost;
  13713. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13714. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13715. var index = 1;
  13716. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13717. foreach (var item in TzHotelDescArr)
  13718. {
  13719. if (AinfoArr != null)
  13720. {
  13721. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13722. if (Ainfo != null)
  13723. {
  13724. if (int.Parse(Ainfo.rs) <= 0)
  13725. {
  13726. continue;
  13727. }
  13728. var hotelText = string.Empty;
  13729. switch (item)
  13730. {
  13731. case "SGR":
  13732. hotelText = "单人间";
  13733. break;
  13734. case "JSES":
  13735. hotelText = "小套房";
  13736. break;
  13737. case "SUITE":
  13738. hotelText = "套房";
  13739. break;
  13740. case "TBR":
  13741. hotelText = "双人间";
  13742. break;
  13743. }
  13744. if (item != "TBR")
  13745. {
  13746. 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";
  13747. }
  13748. else
  13749. {
  13750. 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";
  13751. }
  13752. index++;
  13753. }
  13754. }
  13755. }
  13756. index = 1;
  13757. foreach (var item in TzAirDescArr)
  13758. {
  13759. if (AinfoArr != null)
  13760. {
  13761. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13762. if (Ainfo != null)
  13763. {
  13764. if (int.Parse(Ainfo.rs) <= 0)
  13765. {
  13766. continue;
  13767. }
  13768. 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";
  13769. index++;
  13770. }
  13771. }
  13772. }
  13773. if (dto.costType == "B")
  13774. {
  13775. if (BParameter == null)
  13776. {
  13777. return Ok(JsonView(false, "B段系数不存在!"));
  13778. }
  13779. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13780. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13781. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13782. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13783. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13784. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13785. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13786. foreach (var item in TzHotelDescArr)
  13787. {
  13788. if (AinfoArr != null)
  13789. {
  13790. TzHotelDesc += "B段信息 \r\n";
  13791. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13792. if (Ainfo != null)
  13793. {
  13794. if (int.Parse(Ainfo.rs) <= 0)
  13795. {
  13796. continue;
  13797. }
  13798. var hotelText = string.Empty;
  13799. switch (item)
  13800. {
  13801. case "SGR":
  13802. hotelText = "单人间";
  13803. break;
  13804. case "JSES":
  13805. hotelText = "小套房";
  13806. break;
  13807. case "SUITE":
  13808. hotelText = "套房";
  13809. break;
  13810. case "TBR":
  13811. hotelText = "双人间";
  13812. break;
  13813. }
  13814. if (item != "TBR")
  13815. {
  13816. 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";
  13817. }
  13818. else
  13819. {
  13820. 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";
  13821. }
  13822. index++;
  13823. }
  13824. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13825. }
  13826. }
  13827. index = 1;
  13828. foreach (var item in TzAirDescArr)
  13829. {
  13830. if (AinfoArr != null)
  13831. {
  13832. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13833. if (Ainfo != null)
  13834. {
  13835. if (int.Parse(Ainfo.rs) <= 0)
  13836. {
  13837. continue;
  13838. }
  13839. 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";
  13840. index++;
  13841. }
  13842. }
  13843. }
  13844. }
  13845. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13846. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13847. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13848. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13849. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13850. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13851. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13852. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13853. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13854. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13855. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13856. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13857. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13858. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13859. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13860. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13861. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13862. DickeyValue.Add("TzZCost", TzZCost);
  13863. foreach (var key in DickeyValue.Keys)
  13864. {
  13865. if (doc.Range.Bookmarks[key] != null)
  13866. {
  13867. Bookmark mark = doc.Range.Bookmarks[key];
  13868. mark.Text = DickeyValue[key];
  13869. }
  13870. }
  13871. byte[] bytes = null;
  13872. string strFileName = di.TeamName + "-客户报价.doc";
  13873. using (MemoryStream stream = new MemoryStream())
  13874. {
  13875. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13876. bytes = stream.ToArray();
  13877. }
  13878. return Ok(JsonView(true, "", new
  13879. {
  13880. Data = bytes,
  13881. strFileName,
  13882. }));
  13883. }
  13884. /// <summary>
  13885. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13886. /// </summary>
  13887. /// <param name="dto"></param>
  13888. /// <returns></returns>
  13889. [HttpPost]
  13890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13891. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13892. {
  13893. try
  13894. {
  13895. #region 参数验证
  13896. if (dto.DiId < 0)
  13897. {
  13898. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13899. }
  13900. List<int> cTableIds = new List<int>() {
  13901. 76 ,//酒店预订
  13902. 77 ,//行程
  13903. 79 ,//车/导游地接
  13904. 80 ,//签证
  13905. 81 ,//邀请/公务活
  13906. 82 ,//团组客户保险
  13907. 85 ,//机票预订
  13908. 98 ,//其他款项
  13909. 285 ,//收款退还
  13910. 751 ,//酒店早餐
  13911. 1015 // 超支费用
  13912. };
  13913. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13914. {
  13915. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13916. }
  13917. #endregion
  13918. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13919. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13920. if (_GroupCostParameters.Count <= 0)
  13921. {
  13922. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13923. }
  13924. if (_GroupCostParameters[0].IsShare == 0)
  13925. {
  13926. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13927. }
  13928. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13929. //处理date为空问题
  13930. if (_GroupCosts.Count > 0)
  13931. {
  13932. for (int i = 0; i < _GroupCosts.Count; i++)
  13933. {
  13934. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13935. {
  13936. if (i > 0)
  13937. {
  13938. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13939. }
  13940. }
  13941. }
  13942. }
  13943. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13944. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13945. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13946. string currCode = "";
  13947. #region currCode 验证
  13948. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13949. if (isInt)
  13950. {
  13951. var currData = currDatas.Find(it => it.Id == intCurrency);
  13952. if (currData != null)
  13953. {
  13954. currCode = currData.Name;
  13955. }
  13956. }
  13957. else
  13958. {
  13959. currCode = _GroupCostParameters[0].Currency.Trim();
  13960. }
  13961. #endregion
  13962. //op,酒店单段模式存储
  13963. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13964. {
  13965. CurrencyCode = currCode,
  13966. Rate = _GroupCostParameters[0].Rate,
  13967. CostType = _GroupCostParameters[0].CostType,
  13968. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13969. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13970. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13971. };
  13972. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13973. if (_GroupCostParameters.Count == 2)
  13974. {
  13975. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13976. }
  13977. foreach (var item in _GroupCostParameters)
  13978. {
  13979. decimal _rate = 1;
  13980. decimal _rate1 = item.Rate;
  13981. decimal _scale = 1;
  13982. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13983. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13984. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13985. //if (userInfo != null)
  13986. //{
  13987. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13988. // {
  13989. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13990. // {
  13991. // _scale = 1.00M;
  13992. // }
  13993. // }
  13994. //}
  13995. #endregion
  13996. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13997. {
  13998. CurrencyCode = currCode,
  13999. Rate = _rate1,
  14000. CostType = item.CostType,
  14001. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  14002. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  14003. CostTypeNumber = item.CostTypenumber
  14004. };
  14005. if (_GroupCostParameters.Count > 1)
  14006. {
  14007. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  14008. }
  14009. else
  14010. {
  14011. modulePromptInfo.CostTypeNumber = item.LYJRS;
  14012. }
  14013. if (dto.CTable == 79)//
  14014. {
  14015. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14016. modulePromptInfo.TotalCost = item.DJCB;
  14017. }
  14018. List<string> costTypes = new List<string>() { "A", "B" };
  14019. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14020. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14021. if (_GroupCostsDuplicates.Count() == 1)
  14022. {
  14023. _GroupCostsTypeData = _GroupCosts;
  14024. }
  14025. else
  14026. {
  14027. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14028. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14029. }
  14030. /*
  14031. * 76 酒店预订
  14032. * 77 行程
  14033. * 79 车/导游地接
  14034. * 80 签证
  14035. * 81 邀请/公务活动
  14036. * 82 团组客户保险
  14037. * 85 机票预订
  14038. * 98 其他款项
  14039. * 285 收款退还
  14040. * 751 酒店早餐
  14041. * 1015 超支费用
  14042. */
  14043. switch (dto.CTable)
  14044. {
  14045. case 76: // 酒店预订
  14046. _ModuleSubPromptInfo.AddRange(
  14047. _GroupCostsTypeData.Select(it => new
  14048. {
  14049. it.DAY,
  14050. it.Date,
  14051. it.ACCON,
  14052. it.ITIN,
  14053. it.SGR,
  14054. it.TBR,
  14055. it.JS_ES,
  14056. it.Suite
  14057. })
  14058. );
  14059. break;
  14060. case 79: // 车/导游地接
  14061. _ModuleSubPromptInfo.AddRange(
  14062. _GroupCostsTypeData.Select(it => new
  14063. {
  14064. Date = it.Date, //日期
  14065. CarFee = it.CarCost * _rate * _scale, //车费用
  14066. CarType = it.CarType, //车型
  14067. DriverFee = it.CFS * _rate * _scale, //司机工资
  14068. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14069. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14070. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14071. GuideFee = it.TGS * _rate * _scale, //导游费用
  14072. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14073. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14074. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14075. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14076. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14077. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14078. Breakfast = it.B * _rate * _scale, //早餐费
  14079. Lunch = it.L * _rate * _scale, //午餐费
  14080. Dinner = it.D * _rate * _scale, //晚餐费
  14081. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14082. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14083. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14084. TicketFee = it.EF * _rate * _scale, //门票费
  14085. TicketRemark = it.EFR, //门票费描述
  14086. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14087. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14088. SpentCash = it.PC * _rate * _scale, //零用金
  14089. LeadersFee = it.TLF * _rate * _scale, //领队费
  14090. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14091. })
  14092. );
  14093. break;
  14094. case 85: // 机票
  14095. List<dynamic> datas = new List<dynamic>();
  14096. datas.Add(
  14097. new
  14098. {
  14099. AirType = "经济舱",
  14100. AirNum = item.JJCRS,
  14101. AirDRCB = item.JJCCB,
  14102. AirZCB = (item.JJCRS * item.JJCCB)
  14103. }
  14104. );
  14105. datas.Add(
  14106. new
  14107. {
  14108. AirType = "公务舱",
  14109. AirNum = item.GWCRS,
  14110. AirDRCB = item.GWCCB,
  14111. AirZCB = (item.GWCRS * item.GWCCB)
  14112. }
  14113. );
  14114. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14115. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14116. modulePromptInfo.Data = new
  14117. {
  14118. airFeeData = datas,
  14119. airInitData = initDatas
  14120. };
  14121. _ModulePromptInfos.Add(modulePromptInfo);
  14122. break;
  14123. default:
  14124. break;
  14125. }
  14126. }
  14127. if (dto.CTable != 85)
  14128. {
  14129. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14130. _ModulePromptInfos.Add(_ModulePromptInfo);
  14131. }
  14132. _view.ModulePromptInfos = _ModulePromptInfos;
  14133. return Ok(JsonView(true, "操作成功!", _view));
  14134. }
  14135. catch (Exception ex)
  14136. {
  14137. return Ok(JsonView(false, ex.Message));
  14138. }
  14139. }
  14140. /// <summary>
  14141. /// 根据黑屏代码重新生成行程
  14142. /// </summary>
  14143. /// <param name="dto"></param>
  14144. /// <returns></returns>
  14145. [HttpPost]
  14146. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14147. {
  14148. var jw = JsonView(false);
  14149. var Create = _GroupCostRepository.
  14150. CreateGroupCostByBlackCode(dto.Diid);
  14151. jw.Msg = Create.Msg;
  14152. if (Create.Code == 0)
  14153. {
  14154. jw.Code = 200;
  14155. jw.Data = new
  14156. {
  14157. groupCost = Create.Data,
  14158. blackCodeIsTrue = true
  14159. };
  14160. }
  14161. else
  14162. {
  14163. jw.Code = 400;
  14164. jw.Data = new
  14165. {
  14166. groupCost = Create.Data,
  14167. blackCodeIsTrue = false,
  14168. };
  14169. }
  14170. return Ok(jw);
  14171. }
  14172. /// <summary>
  14173. /// 成本获取OP历史车费用
  14174. /// </summary>
  14175. /// <param name="dto"></param>
  14176. /// <returns></returns>
  14177. [HttpPost]
  14178. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14179. {
  14180. var jw = JsonView(false);
  14181. try
  14182. {
  14183. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14184. //获取现有所有车的数据
  14185. if (!dto.Param.IsNullOrWhiteSpace())
  14186. {
  14187. string sql = $@"
  14188. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14189. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14190. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14191. 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
  14192. AND gctggr.ServiceEndTime is not NULL
  14193. ORDER by gctggrc.id DESC
  14194. ";
  14195. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14196. var numeberResult = await Task.Run(() =>
  14197. {
  14198. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14199. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14200. return numberArr;
  14201. });
  14202. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14203. foreach (var item in numeberResult)
  14204. {
  14205. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14206. {
  14207. Country = "数据异常!",
  14208. City = string.Empty,
  14209. };
  14210. item.Area = find.Country + " " + find.City;
  14211. }
  14212. dbResult.AddRange(numeberResult);
  14213. if (dto.Param.Contains("、"))
  14214. {
  14215. var sp = dto.Param.Split("、");
  14216. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14217. .Where(x =>
  14218. {
  14219. return System.Array.Exists(sp, e =>
  14220. {
  14221. bool where = false;
  14222. if (x.Area != null)
  14223. {
  14224. where = x.Area.Contains(e);
  14225. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14226. {
  14227. return false;
  14228. }
  14229. }
  14230. if (x.PriceName != null && !where)
  14231. {
  14232. where = x.PriceName.Contains(e);
  14233. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14234. {
  14235. return false;
  14236. }
  14237. }
  14238. return where;
  14239. });
  14240. }).ToList();
  14241. }
  14242. else
  14243. {
  14244. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14245. .Where(x =>
  14246. {
  14247. bool where = false;
  14248. if (x.Area != null)
  14249. {
  14250. where = x.Area.Contains(dto.Param);
  14251. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14252. {
  14253. return false;
  14254. }
  14255. }
  14256. if (x.PriceName != null && !where)
  14257. {
  14258. where = x.PriceName.Contains(dto.Param);
  14259. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14260. {
  14261. return false;
  14262. }
  14263. }
  14264. return where;
  14265. }
  14266. )
  14267. .ToList();
  14268. }
  14269. }
  14270. var view = dbResult.Select(x =>
  14271. {
  14272. decimal dp = 0.00M;
  14273. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14274. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14275. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14276. {
  14277. if (startB && endB)
  14278. {
  14279. var timesp = endD.Subtract(startD);
  14280. if ((timesp.Days + 1) != 0)
  14281. {
  14282. dp = x.Price / (timesp.Days + 1);
  14283. }
  14284. }
  14285. }
  14286. else
  14287. {
  14288. dp = x.Price;
  14289. }
  14290. return new
  14291. {
  14292. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14293. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14294. x.Area,
  14295. x.id,
  14296. price = x.Price.ToString("F2"),
  14297. x.PriceName,
  14298. x.PriceContent,
  14299. x.TeamName,
  14300. x.DatePrice,
  14301. dayPrice = dp.ToString("F2"),
  14302. };
  14303. }).OrderByDescending(x => x.id).ToList();
  14304. jw = JsonView(true, "获取成功!", view);
  14305. }
  14306. catch (Exception e)
  14307. {
  14308. jw = JsonView(false, e.Message);
  14309. }
  14310. return Ok(jw);
  14311. }
  14312. #endregion
  14313. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14314. /// <summary>
  14315. /// 酒店预订
  14316. /// 酒店费用列表 根据团组Id查询
  14317. /// </summary>
  14318. /// <param name="_dto"></param>
  14319. /// <returns></returns>
  14320. [HttpPost]
  14321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14322. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14323. {
  14324. #region 参数验证
  14325. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14326. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14327. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14328. #region 团组操作权限验证 76 酒店预定模块
  14329. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14330. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14331. #endregion
  14332. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14333. #region 页面操作权限验证
  14334. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14335. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14336. #endregion
  14337. #endregion
  14338. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14339. }
  14340. /// <summary>
  14341. /// 酒店预订
  14342. /// 基础数据
  14343. /// </summary>
  14344. /// <param name="_dto"></param>
  14345. /// <returns></returns>
  14346. [HttpPost]
  14347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14348. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14349. {
  14350. #region 参数验证
  14351. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14352. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14353. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14354. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14355. #region 页面操作权限验证
  14356. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14357. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14358. #endregion
  14359. #region 团组操作权限验证 76 酒店预定模块
  14360. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14361. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14362. #endregion
  14363. #endregion
  14364. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14365. }
  14366. /// <summary>
  14367. /// 酒店预订
  14368. /// 创建 入住卷号码
  14369. /// </summary>
  14370. /// <param name="_dto"></param>
  14371. /// <returns></returns>
  14372. [HttpPost]
  14373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14374. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14375. {
  14376. #region 参数验证
  14377. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14378. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14379. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14380. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14381. #region 页面操作权限验证
  14382. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14383. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14384. #endregion
  14385. #region 团组操作权限验证 76 酒店预定模块
  14386. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14387. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14388. #endregion
  14389. #endregion
  14390. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14391. if (data.Code != 0)
  14392. {
  14393. return Ok(JsonView(false, data.Msg));
  14394. }
  14395. return Ok(JsonView(true, data.Msg, data.Data));
  14396. }
  14397. /// <summary>
  14398. /// 酒店预订
  14399. /// 详情
  14400. /// </summary>
  14401. /// <param name="_dto"></param>
  14402. /// <returns></returns>
  14403. [HttpPost]
  14404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14405. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14406. {
  14407. #region 参数验证
  14408. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14409. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14410. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14411. #region 团组操作权限验证 76 酒店预定模块
  14412. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14413. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14414. #endregion
  14415. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14416. #region 页面操作权限验证
  14417. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14418. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14419. #endregion
  14420. #endregion
  14421. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14422. }
  14423. /// <summary>
  14424. /// 酒店预订
  14425. /// Add Or Edit
  14426. /// </summary>
  14427. /// <param name="_dto"></param>
  14428. /// <returns></returns>
  14429. [HttpPost]
  14430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14431. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14432. {
  14433. #region 参数验证
  14434. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14435. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14436. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14437. #region 团组操作权限验证 76 酒店预定模块
  14438. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14439. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14440. #endregion
  14441. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14442. #region 页面操作权限验证
  14443. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14444. if (_dto.Id == 0) // Add
  14445. {
  14446. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14447. }
  14448. else if (_dto.Id > 1) // Edit
  14449. {
  14450. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14451. }
  14452. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14453. #endregion
  14454. #endregion
  14455. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14456. if (_view.Code != 200)
  14457. {
  14458. return Ok(_view);
  14459. }
  14460. #region 成本无酒店价格数据进入超支
  14461. _sqlSugar.BeginTran();
  14462. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14463. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14464. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14465. for (int i = 0; i < groupCost.Count; i++)
  14466. {
  14467. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14468. {
  14469. groupCost[i].Date = groupCost[i - 1].Date;
  14470. }
  14471. }
  14472. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14473. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14474. List<Fin_GroupExtraCostDto_OP>();
  14475. if (start_Bool && end_Bool)
  14476. {
  14477. while (start_Time < end_Time)
  14478. {
  14479. foreach (var item in groupCost_Grp)
  14480. {
  14481. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14482. {
  14483. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14484. {
  14485. extraCostList.Add(new
  14486. Fin_GroupExtraCostDto_OP
  14487. {
  14488. Area = _dto.AreaId,
  14489. coefficient = 1.5M,
  14490. createUser = _dto.UserId,
  14491. currency = _dto.CardPriceCurrency,
  14492. diId = _dto.DiId,
  14493. ManagerConfirm = 0,
  14494. SupervisorConfirm = 0,
  14495. SYsupervisorConfirm = 0,
  14496. editType = 1,
  14497. PortType = 1,
  14498. price = _dto.CardPrice,
  14499. PriceCount = 1,
  14500. priceType = 1027,
  14501. priceDetailType = 1044,
  14502. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14503. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14504. });
  14505. }
  14506. }
  14507. }
  14508. start_Time = start_Time.AddDays(1);
  14509. }
  14510. }
  14511. if (extraCostList.Any())
  14512. {
  14513. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14514. }
  14515. _sqlSugar.CommitTran();
  14516. #endregion
  14517. #region 应用推送
  14518. try
  14519. {
  14520. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14521. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14522. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14523. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14524. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14525. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14526. var diId = _dto.DiId;
  14527. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14528. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14529. #region 操作记录
  14530. var opInfo = new Crm_TableOperationRecord()
  14531. {
  14532. TableName = "Grp_HotelReservations",
  14533. PortType = _dto.PortType,
  14534. DataId = hotelId,
  14535. CreateUserId = _dto.UserId
  14536. };
  14537. //var opStatus = OperationEnum.NoOperation;
  14538. if (_dto.Id < 1) //添加操作
  14539. {
  14540. opInfo.OperationItem = OperationEnum.Add;
  14541. }
  14542. else if (_dto.Id > 0)
  14543. {
  14544. opInfo.OperationItem = OperationEnum.Edit;
  14545. }
  14546. string opRemark = string.Empty;
  14547. if (ccpInfo != null)
  14548. {
  14549. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14550. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14551. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14552. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14553. }
  14554. opInfo.Remark = opRemark;
  14555. await _tableorRep.AddAsync(opInfo);
  14556. #endregion
  14557. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14558. //2024-10-21 新增LZ UID
  14559. var userIds = new List<int>() { 21 };
  14560. string title = $"费用审核";
  14561. string content = "";
  14562. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14563. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14564. try
  14565. {
  14566. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14567. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14568. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14569. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14570. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14571. }
  14572. catch (Exception ex)
  14573. {
  14574. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14575. }
  14576. }
  14577. catch (Exception ex)
  14578. {
  14579. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14580. }
  14581. try
  14582. {
  14583. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14584. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14585. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14586. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14587. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14588. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14589. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14590. //自动审核
  14591. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14592. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14593. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14594. //2024-10-21 新增LZ UID
  14595. var userIds = new List<int>() { 21 };
  14596. string title = $"系统通知";
  14597. var diId = _dto.DiId;
  14598. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14599. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14600. string content = "";
  14601. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14602. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14603. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14604. }
  14605. catch (Exception ex)
  14606. {
  14607. }
  14608. #endregion
  14609. return Ok(_view);
  14610. }
  14611. /// <summary>
  14612. /// 酒店自动审核测试
  14613. /// Add Or Edit
  14614. /// </summary>
  14615. /// <param name="diid"></param>
  14616. /// <param name="dataId"></param>
  14617. /// <returns></returns>
  14618. [HttpPost]
  14619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14620. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14621. {
  14622. #region 应用推送
  14623. try
  14624. {
  14625. //自动审核
  14626. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14627. }
  14628. catch (Exception ex)
  14629. {
  14630. return Ok(JsonView(false, "操作失败"));
  14631. }
  14632. #endregion
  14633. return Ok(JsonView(false, "操作成功"));
  14634. }
  14635. /// <summary>
  14636. /// 酒店预订
  14637. /// Del
  14638. /// </summary>
  14639. /// <param name="_dto"></param>
  14640. /// <returns></returns>
  14641. [HttpPost]
  14642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14643. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14644. {
  14645. #region 参数验证
  14646. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14647. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14648. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14649. #region 团组操作权限验证 76 酒店预定模块
  14650. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14651. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14652. #endregion
  14653. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14654. #region 页面操作权限验证
  14655. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14656. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14657. #endregion
  14658. #endregion
  14659. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14660. #region 操作记录
  14661. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14662. {
  14663. TableName = "Grp_HotelReservations",
  14664. PortType = _dto.PortType,
  14665. OperationItem = OperationEnum.Del,
  14666. DataId = _dto.Id,
  14667. CreateUserId = _dto.UserId
  14668. });
  14669. #endregion
  14670. return Ok(data);
  14671. }
  14672. /// <summary>
  14673. /// 酒店预订
  14674. /// 生成VOUCHER
  14675. /// 2024.05.06 之前版本
  14676. /// </summary>
  14677. /// <param name="_dto"></param>
  14678. /// <returns></returns>
  14679. [HttpPost]
  14680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14681. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14682. {
  14683. try
  14684. {
  14685. #region 参数验证
  14686. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14687. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14688. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14689. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14690. #region 团组操作权限验证 76 酒店预定模块
  14691. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14692. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14693. #endregion
  14694. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14695. #region 页面操作权限验证
  14696. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14697. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14698. #endregion
  14699. #endregion
  14700. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14701. //判断数据是否完整
  14702. if (hr != null)
  14703. {
  14704. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14705. {
  14706. string strFileName = "HotelStatement/";
  14707. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14708. if (dele != null)
  14709. strFileName += dele.TourCode;
  14710. //载入模板
  14711. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14712. Document doc = new Document(sss);
  14713. DocumentBuilder builder = new DocumentBuilder(doc);
  14714. #region 替换Word模板书签内容
  14715. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14716. //入住卷预定号码
  14717. if (doc.Range.Bookmarks["VNO"] != null)
  14718. {
  14719. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14720. mark.Text = hr.CheckNumber;
  14721. }
  14722. //酒店时间
  14723. if (doc.Range.Bookmarks["Date"] != null)
  14724. {
  14725. Bookmark mark = doc.Range.Bookmarks["Date"];
  14726. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14727. }
  14728. //团号
  14729. if (doc.Range.Bookmarks["TNo"] != null)
  14730. {
  14731. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14732. mark.Text = dele.TourCode;
  14733. }
  14734. //预定号码
  14735. if (doc.Range.Bookmarks["BookingId"] != null)
  14736. {
  14737. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14738. mark.Text = hr.ReservationsNo;
  14739. }
  14740. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14741. {
  14742. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14743. mark.Text = hr.DetermineNo;
  14744. }
  14745. //酒店城市
  14746. if (doc.Range.Bookmarks["City"] != null)
  14747. {
  14748. Bookmark mark = doc.Range.Bookmarks["City"];
  14749. mark.Text = hr.City;
  14750. }
  14751. //酒店名称
  14752. if (doc.Range.Bookmarks["HName"] != null)
  14753. {
  14754. Bookmark mark = doc.Range.Bookmarks["HName"];
  14755. mark.Text = hr.HotelName;
  14756. }
  14757. //酒店地址
  14758. if (doc.Range.Bookmarks["Address"] != null)
  14759. {
  14760. Bookmark mark = doc.Range.Bookmarks["Address"];
  14761. mark.Text = hr.HotelAddress;
  14762. }
  14763. //酒店电话
  14764. if (doc.Range.Bookmarks["Tel"] != null)
  14765. {
  14766. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14767. mark.Text = hr.HotelTel;
  14768. }
  14769. //酒店传真
  14770. if (doc.Range.Bookmarks["Fax"] != null)
  14771. {
  14772. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14773. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14774. {
  14775. mark.Text = hr.HotelFax;
  14776. }
  14777. }
  14778. //入住时间
  14779. if (doc.Range.Bookmarks["CIn"] != null)
  14780. {
  14781. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14782. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14783. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14784. }
  14785. //退房时间
  14786. if (doc.Range.Bookmarks["COut"] != null)
  14787. {
  14788. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14789. Bookmark mark = doc.Range.Bookmarks["COut"];
  14790. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14791. }
  14792. //客户名称
  14793. if (doc.Range.Bookmarks["GName"] != null)
  14794. {
  14795. string guestName = "";
  14796. string[] clients = new string[] { };
  14797. if (hr.GuestName.Contains(","))
  14798. {
  14799. clients = hr.GuestName.Split(",");
  14800. }
  14801. else
  14802. {
  14803. clients = new string[] { hr.GuestName };
  14804. }
  14805. List<int> clientIds_int = new List<int>();
  14806. if (clients.Length > 0)
  14807. {
  14808. foreach (var item in clients)
  14809. {
  14810. if (item.IsNumeric())
  14811. {
  14812. clientIds_int.Add(int.Parse(item));
  14813. }
  14814. }
  14815. }
  14816. if (clientIds_int.Count > 0)
  14817. {
  14818. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14819. foreach (var client in _clientDatas)
  14820. {
  14821. //男
  14822. if (client.Sex == 0) guestName += $"Mr.";
  14823. //女
  14824. else if (client.Sex == 1) guestName += $"Ms.";
  14825. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14826. {
  14827. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14828. }
  14829. //guestName += $"{client.Pinyin},";
  14830. }
  14831. if (guestName.Length > 0)
  14832. {
  14833. guestName = guestName.Substring(0, guestName.Length - 1);
  14834. }
  14835. }
  14836. else
  14837. {
  14838. guestName = hr.GuestName;
  14839. }
  14840. Bookmark mark = doc.Range.Bookmarks["GName"];
  14841. mark.Text = guestName;
  14842. }
  14843. //房间介绍
  14844. if (doc.Range.Bookmarks["ROOM"] != null)
  14845. {
  14846. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14847. mark.Text = hr.RoomExplanation;
  14848. }
  14849. //报价描述
  14850. if (doc.Range.Bookmarks["NOTE"] != null)
  14851. {
  14852. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14853. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14854. if (ss != null)
  14855. mark.Text = ss.Name;
  14856. }
  14857. //入住时间
  14858. if (doc.Range.Bookmarks["CheckIn"] != null)
  14859. {
  14860. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14861. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14862. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14863. }
  14864. //退房时间
  14865. if (doc.Range.Bookmarks["CheckOut"] != null)
  14866. {
  14867. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14868. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14869. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14870. }
  14871. //日期
  14872. if (doc.Range.Bookmarks["DT"] != null)
  14873. {
  14874. Bookmark mark = doc.Range.Bookmarks["DT"];
  14875. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14876. }
  14877. //名称
  14878. if (doc.Range.Bookmarks["VName"] != null)
  14879. {
  14880. Bookmark mark = doc.Range.Bookmarks["VName"];
  14881. mark.Text = hr.HotelName;
  14882. }
  14883. //号码
  14884. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14885. {
  14886. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14887. mark.Text = hr.CheckNumber;
  14888. }
  14889. #endregion
  14890. strFileName += "VOUCHER.doc";
  14891. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14892. doc.Save(fileDir);
  14893. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14894. return Ok(JsonView(true, "操作成功!", Url));
  14895. }
  14896. else
  14897. {
  14898. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14899. }
  14900. }
  14901. else
  14902. {
  14903. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14904. }
  14905. }
  14906. catch (Exception ex)
  14907. {
  14908. return Ok(JsonView(false, ex.Message));
  14909. }
  14910. }
  14911. /// <summary>
  14912. /// 酒店预订
  14913. /// 生成VOUCHER
  14914. /// 2024.05.06 之后版本
  14915. /// </summary>
  14916. /// <param name="_dto"></param>
  14917. /// <returns></returns>
  14918. [HttpPost]
  14919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14920. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14921. {
  14922. #region 参数验证
  14923. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14924. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14925. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14926. #region 团组操作权限验证 76 酒店预定模块
  14927. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14928. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14929. #endregion
  14930. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14931. #region 页面操作权限验证
  14932. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14933. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14934. #endregion
  14935. #endregion
  14936. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14937. //判断数据是否完整
  14938. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14939. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14940. string strFileName = "HotelStatement/";
  14941. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14942. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14943. #region 数据处理
  14944. List<int> guestIds = new List<int>();
  14945. //int index = 0;
  14946. foreach (var item in hrDtas)
  14947. {
  14948. if (item.GuestName.Contains(","))
  14949. {
  14950. string[] guestIdArr = item.GuestName.Split(',');
  14951. foreach (var guestIdStr in guestIdArr)
  14952. {
  14953. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14954. if (guestBool)
  14955. {
  14956. guestIds.Add(guestId);
  14957. }
  14958. }
  14959. }
  14960. else guestNames += item.GuestName;
  14961. var voucherInfo = new HotelVoucherInfoView()
  14962. {
  14963. HotelName = item.HotelName,
  14964. CheckInDate = item.CheckInDate,
  14965. CheckOutDate = item.CheckOutDate,
  14966. ConfirmationNumber = item.DetermineNo.Trim(),
  14967. RoomType = item.RoomExplanation
  14968. };
  14969. vouchers.Add(voucherInfo);
  14970. }
  14971. if (guestIds.Count > 0)
  14972. {
  14973. guestIds = guestIds.Distinct().ToList();
  14974. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14975. if (guestDatas.Count > 0)
  14976. {
  14977. guestNames = "";
  14978. foreach (var guest in guestDatas)
  14979. {
  14980. string guestName = "";
  14981. if (guest.Sex == 0) guestName += @"MR.";
  14982. else if (guest.Sex == 1) guestName += @"MS.";
  14983. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14984. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14985. guestNames += @$"{guestName.Trim()}、";
  14986. }
  14987. if (guestNames.Length > 0)
  14988. {
  14989. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14990. }
  14991. }
  14992. }
  14993. #endregion
  14994. //载入模板
  14995. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14996. Document doc = new Document(sss);
  14997. DocumentBuilder builder = new DocumentBuilder(doc);
  14998. if (doc.Range.Bookmarks["GuestName"] != null)
  14999. {
  15000. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  15001. mark.Text = guestNames;
  15002. }
  15003. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15004. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  15005. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  15006. for (int i = 1; i <= vouchers.Count; i++)
  15007. {
  15008. HotelVoucherInfoView hviv = vouchers[i - 1];
  15009. builder.MoveToCell(0, i, 0, 0);
  15010. builder.Write(hviv.HotelName);
  15011. builder.MoveToCell(0, i, 1, 0);
  15012. builder.Write(hviv.CheckInDate);
  15013. builder.MoveToCell(0, i, 2, 0);
  15014. builder.Write(hviv.CheckOutDate);
  15015. builder.MoveToCell(0, i, 3, 0);
  15016. builder.Write(hviv.RoomType);
  15017. builder.MoveToCell(0, i, 4, 0);
  15018. builder.Write(hviv.ConfirmationNumber);
  15019. }
  15020. //删除多余行
  15021. int currRowIndex = vouchers.Count + 1;
  15022. int delRows = 21 - currRowIndex;
  15023. if (delRows > 0)
  15024. {
  15025. for (int i = 0; i < delRows; i++)
  15026. {
  15027. table.Rows.RemoveAt(currRowIndex);
  15028. //cultivateRowIndex++;
  15029. }
  15030. }
  15031. strFileName += "VOUCHER.docx";
  15032. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15033. doc.Save(fileDir);
  15034. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15035. return Ok(JsonView(true, "操作成功!", Url));
  15036. }
  15037. /// <summary>
  15038. /// 酒店预订
  15039. /// 生成VOUCHER 批量生成
  15040. /// New
  15041. /// </summary>
  15042. /// <param name="_dto"></param>
  15043. /// <returns></returns>
  15044. [HttpPost]
  15045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15046. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15047. {
  15048. #region 参数验证
  15049. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15050. if (_dto.PageId < 1) _dto.PageId = 28;
  15051. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15052. #region 团组操作权限验证 76 酒店预定模块
  15053. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15054. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15055. #endregion
  15056. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15057. #region 页面操作权限验证
  15058. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15059. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15060. #endregion
  15061. #endregion
  15062. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15063. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15064. .OrderBy(x => x.CheckInDate)
  15065. .ToListAsync();
  15066. //判断数据是否完整
  15067. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15068. string strFileName = "HotelStatement/";
  15069. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15070. if (dele != null)
  15071. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15072. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15073. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15074. .Where(it => it.IsDel == 0)
  15075. .ToListAsync();
  15076. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15077. for (int i = 0; i < hrDtas.Count; i++)
  15078. {
  15079. string guestNames = string.Empty;
  15080. List<int> guestIds = new List<int>();
  15081. var item = hrDtas[i];
  15082. //处理客户姓名
  15083. if (item.GuestName.Contains(","))
  15084. {
  15085. string[] guestIdArr = item.GuestName.Split(',');
  15086. foreach (var guestIdStr in guestIdArr)
  15087. if (int.TryParse(guestIdStr, out int guestId))
  15088. guestIds.Add(guestId);
  15089. }
  15090. else
  15091. {
  15092. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15093. if (guestIdBool)
  15094. {
  15095. guestIds.Add(guestId);
  15096. }
  15097. //NaN
  15098. if (item.GuestName.Contains("NaN"))
  15099. {
  15100. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15101. }
  15102. }
  15103. if (guestIds.Count > 0)
  15104. {
  15105. guestIds = guestIds.Distinct().ToList();
  15106. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15107. if (guestDatas1.Count > 0)
  15108. {
  15109. guestNames = "";
  15110. foreach (var guest in guestDatas1)
  15111. {
  15112. string guestName = "";
  15113. if (guest.Sex == 0) guestName += @"MR.";
  15114. else if (guest.Sex == 1) guestName += @"MS.";
  15115. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15116. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15117. guestNames += @$"{guestName.Trim()}、";
  15118. }
  15119. if (guestNames.Length > 0)
  15120. {
  15121. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15122. }
  15123. }
  15124. }
  15125. //if (!string.IsNullOrEmpty(guestNames))
  15126. //{
  15127. hrDtas[i].GuestName = guestNames;
  15128. //}
  15129. }
  15130. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15131. Document doc = new Document();
  15132. DocumentBuilder builder = new DocumentBuilder(doc);
  15133. try
  15134. {
  15135. builder.MoveToDocumentStart();
  15136. foreach (var item in hrDtas)
  15137. {
  15138. //标题
  15139. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15140. builder.ParagraphFormat.LineSpacing = 1;
  15141. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15142. builder.ParagraphFormat.Style.Font.Size = 9;
  15143. builder.ParagraphFormat.Style.Font.Bold = true;
  15144. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15145. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15146. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15147. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15148. builder.ParagraphFormat.LineSpacing = 1;
  15149. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15150. builder.ParagraphFormat.Style.Font.Size = 9;
  15151. builder.ParagraphFormat.Style.Font.Bold = true;
  15152. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15153. builder.StartTable();
  15154. // 设置边框颜色
  15155. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15156. //设置边框样式
  15157. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15158. //表格
  15159. #region 第一行
  15160. builder.InsertCell();
  15161. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15162. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15163. //builder.CellFormat.AllowAutoFit = false;
  15164. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15165. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15166. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15167. builder.CellFormat.WrapText = true; //自动换行
  15168. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15169. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15170. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15171. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15172. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15173. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15174. builder.Write("TOUR NO:");
  15175. builder.InsertCell();
  15176. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15177. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15178. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15179. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15180. builder.ParagraphFormat.Style.Font.Bold = false;
  15181. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15182. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15183. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15184. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15185. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15186. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15187. builder.Write($"{dele?.TourCode ?? "-"}");
  15188. builder.InsertCell();
  15189. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15190. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15191. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15192. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15193. builder.ParagraphFormat.Style.Font.Bold = false;
  15194. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15195. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15196. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15197. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15198. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15199. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15200. builder.Write($"CITY:");
  15201. builder.InsertCell();
  15202. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15203. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15204. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15205. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15206. builder.ParagraphFormat.Style.Font.Bold = false;
  15207. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15208. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15209. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15210. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15211. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15212. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15213. builder.Write($"{item.City}");
  15214. builder.EndRow();
  15215. #endregion
  15216. #region 第二行
  15217. builder.InsertCell();
  15218. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15219. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15220. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15221. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15222. builder.ParagraphFormat.Style.Font.Bold = false;
  15223. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15224. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15225. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15226. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15227. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15228. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15229. builder.Write("CONFIRMATION NO:");
  15230. builder.InsertCell();
  15231. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15232. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15233. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15234. builder.ParagraphFormat.Style.Font.Bold = false;
  15235. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15236. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15237. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15238. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15239. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15240. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15241. builder.CellFormat.VerticalMerge = CellMerge.None;
  15242. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15243. builder.Write($"{item.DetermineNo}");
  15244. builder.InsertCell();
  15245. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15246. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15247. builder.InsertCell();
  15248. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15249. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15250. builder.EndRow();
  15251. #endregion
  15252. #region 第三行
  15253. builder.InsertCell();
  15254. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15255. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15256. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15257. builder.ParagraphFormat.Style.Font.Bold = false;
  15258. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15259. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15260. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15261. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15262. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15263. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15264. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15265. builder.Write($"HOTEL NAME:");
  15266. builder.InsertCell();
  15267. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15268. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15269. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15270. builder.ParagraphFormat.Style.Font.Bold = false;
  15271. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15272. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15273. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15274. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15275. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15276. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15277. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15278. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15279. builder.Write($"{item.HotelName}");
  15280. builder.InsertCell();
  15281. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15282. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15283. builder.InsertCell();
  15284. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15285. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15286. builder.EndRow();
  15287. #endregion
  15288. #region 第四行
  15289. builder.InsertCell();
  15290. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15291. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15292. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15293. builder.ParagraphFormat.Style.Font.Bold = false;
  15294. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15295. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15296. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15297. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15298. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15299. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15300. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15301. builder.Write($"HOTEL ADDRESS:");
  15302. builder.InsertCell();
  15303. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15304. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15305. builder.ParagraphFormat.Style.Font.Size = 8;
  15306. builder.ParagraphFormat.Style.Font.Bold = false;
  15307. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15308. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15309. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15310. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15311. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15312. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15313. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15314. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15315. builder.Write($"{item.HotelAddress}");
  15316. builder.InsertCell();
  15317. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15318. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15319. builder.InsertCell();
  15320. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15321. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15322. builder.EndRow();
  15323. #endregion
  15324. #region 第五行
  15325. builder.InsertCell();
  15326. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15327. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15328. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15329. builder.ParagraphFormat.Style.Font.Bold = false;
  15330. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15331. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15332. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15333. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15334. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15335. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15336. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15337. builder.Write("TEL:");
  15338. builder.InsertCell();
  15339. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15340. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15341. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15342. builder.ParagraphFormat.Style.Font.Bold = false;
  15343. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15344. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15345. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15346. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15347. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15348. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15349. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15350. builder.Write($"{item.HotelTel}");
  15351. builder.InsertCell();
  15352. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15353. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15354. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15355. builder.ParagraphFormat.Style.Font.Bold = false;
  15356. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15357. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15358. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15359. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15360. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15361. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15362. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15363. builder.Write($"FAX:");
  15364. builder.InsertCell();
  15365. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15366. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15367. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15368. builder.ParagraphFormat.Style.Font.Bold = false;
  15369. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15370. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15371. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15372. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15373. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15374. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15375. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15376. builder.Write($"{item.HotelFax}");
  15377. builder.EndRow();
  15378. #endregion
  15379. #region 第六行
  15380. builder.InsertCell();
  15381. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15382. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15383. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15384. builder.ParagraphFormat.Style.Font.Bold = false;
  15385. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15386. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15387. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15388. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15389. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15390. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15391. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15392. builder.Write("CHECK IN:");
  15393. builder.InsertCell();
  15394. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  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.Left;//对齐
  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. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15406. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15407. builder.Write($"{checkInStr}");
  15408. builder.InsertCell();
  15409. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15410. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15411. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15412. builder.ParagraphFormat.Style.Font.Bold = false;
  15413. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15414. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15415. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15416. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15417. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15418. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15419. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15420. builder.Write($"CHECK OUT:");
  15421. builder.InsertCell();
  15422. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15423. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15424. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15425. builder.ParagraphFormat.Style.Font.Bold = false;
  15426. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15427. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15428. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15429. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15430. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15431. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15432. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15433. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15434. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15435. builder.Write($"{checkOutStr}");
  15436. builder.EndRow();
  15437. #endregion
  15438. #region 第七行
  15439. builder.InsertCell();
  15440. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15441. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15442. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15443. builder.ParagraphFormat.Style.Font.Bold = false;
  15444. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15445. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15446. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15447. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15448. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15449. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15450. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15451. builder.Write($"GUEST NAME:");
  15452. builder.InsertCell();
  15453. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15454. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15455. builder.ParagraphFormat.Style.Font.Size = 8;
  15456. builder.ParagraphFormat.Style.Font.Bold = false;
  15457. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15458. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15459. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15460. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15461. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15462. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15463. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15464. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15465. builder.Write($"{item.GuestName}");
  15466. builder.InsertCell();
  15467. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15468. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15469. builder.InsertCell();
  15470. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15471. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15472. builder.EndRow();
  15473. #endregion
  15474. #region 第八行
  15475. builder.InsertCell();
  15476. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15477. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15478. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15479. builder.ParagraphFormat.Style.Font.Bold = false;
  15480. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15481. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15482. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15483. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15484. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15485. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15486. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15487. builder.Write($"ROOM TYPE:");
  15488. builder.InsertCell();
  15489. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15490. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15491. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15492. builder.ParagraphFormat.Style.Font.Bold = false;
  15493. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15494. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15495. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15496. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15497. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15498. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15499. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15500. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15501. builder.Write($"{item.RoomExplanation}");
  15502. builder.InsertCell();
  15503. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15504. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15505. builder.InsertCell();
  15506. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15507. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15508. builder.EndRow();
  15509. #endregion
  15510. #region 第九行
  15511. builder.InsertCell();
  15512. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15513. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15514. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15515. builder.ParagraphFormat.Style.Font.Bold = false;
  15516. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15517. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15518. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15519. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15520. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15521. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15522. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15523. builder.Write($"NOTE:");
  15524. builder.InsertCell();
  15525. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15526. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15527. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15528. builder.ParagraphFormat.Style.Font.Bold = false;
  15529. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15530. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15531. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15532. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15533. 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.");
  15534. builder.InsertCell();
  15535. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15536. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15537. builder.InsertCell();
  15538. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15539. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15540. builder.EndRow();
  15541. #endregion
  15542. builder.EndTable();
  15543. //换行
  15544. builder.Writeln("");
  15545. builder.Writeln("");
  15546. }
  15547. #region 获取文档中的所有表格 设置文字自适应
  15548. // 获取文档中的所有表格。
  15549. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15550. {
  15551. // 遍历表格中的所有行。
  15552. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15553. {
  15554. foreach (Cell cell in row.Cells)
  15555. {
  15556. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15557. cellFormat.Width = 0;
  15558. }
  15559. }
  15560. }
  15561. #endregion
  15562. #region 设置页眉
  15563. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15564. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15565. if (System.IO.File.Exists(voucherHeaderPath))
  15566. {
  15567. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15568. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15569. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15570. Shape shape = builder.InsertImage(imageBytes);
  15571. // 调整图片位置
  15572. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15573. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15574. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15575. shape.Left = 0; // 将图片距离页面左边缘的距离
  15576. shape.Width = 81; // 设置图片宽度
  15577. shape.Height = 36; // 设置图片高度
  15578. }
  15579. //靠右
  15580. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15581. //// 设置页脚上下边距
  15582. //builder.PageSetup.HeaderDistance = 42;
  15583. // 添加页眉线
  15584. Aspose.Words.Border borderHeader = null;
  15585. try
  15586. {
  15587. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15588. }
  15589. catch (Exception e)
  15590. {
  15591. // TODO Auto-generated catch block
  15592. //e.printStackTrace();
  15593. }
  15594. borderHeader.Shadow = true;
  15595. borderHeader.DistanceFromText = 2;
  15596. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15597. #endregion
  15598. }
  15599. catch (Exception ex)
  15600. {
  15601. }
  15602. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15603. doc.Save(fileDir);
  15604. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15605. return Ok(JsonView(true, "操作成功!", Url));
  15606. }
  15607. /// <summary>
  15608. /// 酒店预订
  15609. /// 生成 预定成本 Excel
  15610. /// </summary>
  15611. /// <param name="_dto"></param>
  15612. /// <returns></returns>
  15613. [HttpPost]
  15614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15615. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15616. {
  15617. #region 参数验证
  15618. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15619. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15620. if (!vadalitorRes.IsValid)
  15621. {
  15622. var errors = new StringBuilder();
  15623. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15624. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15625. }
  15626. #region 团组操作权限验证 76 酒店预定模块
  15627. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15628. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15629. #endregion
  15630. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15631. #region 页面操作权限验证
  15632. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15633. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15634. #endregion
  15635. #endregion
  15636. decimal _rate = 1.00M;
  15637. string _currency = string.Empty;
  15638. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15639. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15640. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15641. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15642. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15643. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15644. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15645. if (_GroupCostParameter == null)
  15646. {
  15647. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15648. bool isIntType = int.TryParse(_currency, out int currId);
  15649. if (isIntType)
  15650. {
  15651. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15652. }
  15653. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15654. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15655. if (currInfo == null)
  15656. {
  15657. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15658. }
  15659. else _rate = currInfo.Rate;
  15660. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15661. {
  15662. _rate = _GroupCostParameter.Rate;
  15663. }
  15664. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15665. //string strFileName = "HotelStatement/";
  15666. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15667. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15668. var rateDatas = new List<dynamic>();
  15669. #region 数据处理
  15670. foreach (var item in hrDtas)
  15671. {
  15672. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15673. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15674. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15675. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15676. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15677. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15678. {
  15679. continue;
  15680. }
  15681. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15682. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15683. string singleRoomFeeStr = string.Empty,
  15684. doubleRoomFeeStr = string.Empty,
  15685. suiteRoomFeeStr = string.Empty,
  15686. otherRoomFeeStr = string.Empty,
  15687. payMoneyStr = string.Empty,
  15688. cardPriceStr = string.Empty;
  15689. if (roomCurr.Equals("CNY"))
  15690. {
  15691. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15692. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15693. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15694. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15695. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15696. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15697. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15698. }
  15699. else
  15700. {
  15701. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15702. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15703. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15704. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15705. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15706. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15707. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15708. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15709. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15710. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15711. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15712. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15713. if (ccpPaymentCurrency.Equals("CNY"))
  15714. {
  15715. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15716. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15717. }
  15718. else
  15719. {
  15720. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15721. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15722. }
  15723. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15724. if (hotelcardPriceCurrency.Equals("CNY"))
  15725. {
  15726. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15727. }
  15728. else
  15729. {
  15730. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15731. }
  15732. }
  15733. string breakfastPriceStr = string.Empty,
  15734. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15735. governmentRentStr = string.Empty,
  15736. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15737. cityTaxStr = string.Empty,
  15738. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15739. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15740. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15741. {
  15742. if (breakfastCurrency1.Equals("CNY"))
  15743. {
  15744. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15745. }
  15746. else
  15747. {
  15748. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15749. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15750. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15751. }
  15752. }
  15753. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15754. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15755. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15756. {
  15757. if (governmentRentCurrency.Equals("CNY"))
  15758. {
  15759. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15760. }
  15761. else
  15762. {
  15763. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15764. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15765. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15766. }
  15767. }
  15768. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15769. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15770. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15771. {
  15772. if (cityTaxStrCurrency1.Equals("CNY"))
  15773. {
  15774. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15775. }
  15776. else
  15777. {
  15778. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15779. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15780. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15781. }
  15782. }
  15783. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15784. int payDId = roomInfo?.PayDId ?? 0;
  15785. pcfds.Add(new HotelReservations_PCFD_View()
  15786. {
  15787. City = item.City,
  15788. HotelName = item.HotelName,
  15789. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15790. // SingleRoomCount = item.SingleRoomCount,
  15791. SingleRoomPrice = singleRoomFeeStr,
  15792. // DoubleRoomCount = item.DoubleRoomCount,
  15793. DoubleRoomPrice = doubleRoomFeeStr,
  15794. //SuiteRoomCount = item.SuiteRoomCount,
  15795. SuiteRoomPrice = suiteRoomFeeStr,
  15796. OtherRoomPrice = otherRoomFeeStr,
  15797. //OtherRoomCount = item.OtherRoomCount,
  15798. BreakfastPrice = breakfastPriceStr,
  15799. GovernmentRent = governmentRentStr,
  15800. CityTax = cityTaxStr,
  15801. RoomExplanation = item.RoomExplanation,
  15802. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15803. PayTime = roomInfo?.ConsumptionDate,
  15804. BankNo = roomInfo?.BankNo,
  15805. PayMoney = payMoneyStr,
  15806. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15807. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15808. CardPrice = cardPriceStr,
  15809. Remark = ccpInfo.Remark
  15810. });
  15811. }
  15812. #endregion
  15813. //载入模板
  15814. WorkbookDesigner designer = new WorkbookDesigner();
  15815. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15816. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15817. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15818. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15819. var rateDatas1 = rateDatas.Distinct();
  15820. var rateStr = string.Empty;
  15821. foreach (var item in rateDatas1)
  15822. {
  15823. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15824. }
  15825. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15826. designer.SetDataSource("Opertor", userInfo.CnName);
  15827. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15828. dt.TableName = "ViewMyHotelReservations";
  15829. designer.SetDataSource(dt);
  15830. designer.Process();
  15831. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15832. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15833. designer.Workbook.Save(serverPath);
  15834. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15835. #region 删除指定行
  15836. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15837. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15838. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15839. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15840. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15841. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15842. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15843. cssIndex = dt.Columns["CityTax"].Ordinal,
  15844. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15845. remarkIndex = dt.Columns["Remark"].Ordinal;
  15846. //删除指定列
  15847. foreach (DataRow item in dt.Rows)
  15848. {
  15849. string singleStr = item["SingleRoomPrice"].ToString();
  15850. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15851. if (containsDigitButNotZero1) singleDel = false;
  15852. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15853. string doubleStr = item["DoubleRoomPrice"].ToString();
  15854. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15855. if (containsDigitButNotZero2) doubleDel = false;
  15856. string suiteStr = item["SuiteRoomPrice"].ToString();
  15857. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15858. if (containsDigitButNotZero3) suiteDel = false;
  15859. string otherStr = item["OtherRoomPrice"].ToString();
  15860. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15861. if (containsDigitButNotZero4) otherDel = false;
  15862. string zcStr = item["BreakfastPrice"].ToString();
  15863. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15864. if (containsDigitButNotZero5) zcDel = false;
  15865. string dsStr = item["GovernmentRent"].ToString();
  15866. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15867. if (containsDigitButNotZero6) dsDel = false;
  15868. string cssStr = item["CityTax"].ToString();
  15869. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15870. if (containsDigitButNotZero7) cssDel = false;
  15871. string cpStr = item["ConsumptionPatterns"].ToString();
  15872. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15873. string remarkStr = item["Remark"].ToString();
  15874. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15875. }
  15876. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15877. DeleteColumn(serverPath, cpIndex, cpDel);
  15878. DeleteColumn(serverPath, dsIndex, dsDel);
  15879. DeleteColumn(serverPath, cssIndex, cssDel);
  15880. DeleteColumn(serverPath, zcIndex, zcDel);
  15881. DeleteColumn(serverPath, otherIndex, otherDel);
  15882. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15883. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15884. DeleteColumn(serverPath, singleIndex, singleDel);
  15885. #endregion
  15886. //只保留第一个表格
  15887. DeleteSheet(serverPath);
  15888. return Ok(JsonView(true, "操作成功", url = rst));
  15889. }
  15890. else
  15891. {
  15892. _currency = _GroupCostParameter.Currency;
  15893. bool isIntType = int.TryParse(_currency, out int currId);
  15894. if (isIntType)
  15895. {
  15896. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15897. }
  15898. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15899. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15900. if (currInfo == null)
  15901. {
  15902. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15903. }
  15904. if (!_currency.ToUpper().Equals("CNY"))
  15905. {
  15906. _rate = _GroupCostParameter.Rate;
  15907. }
  15908. _rate = currInfo.Rate;
  15909. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15910. //string strFileName = "HotelStatement/";
  15911. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15912. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15913. #region 数据处理
  15914. foreach (var item in hrDtas)
  15915. {
  15916. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15917. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15918. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15919. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15920. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15921. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15922. string singleRoomFeeStr = string.Empty,
  15923. doubleRoomFeeStr = string.Empty,
  15924. suiteRoomFeeStr = string.Empty,
  15925. otherRoomFeeStr = string.Empty,
  15926. payMoneyStr = string.Empty,
  15927. cardPriceStr = string.Empty;
  15928. if (roomCurr.Equals(_currency))
  15929. {
  15930. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15931. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15932. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15933. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15934. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15935. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15936. }
  15937. else
  15938. {
  15939. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15940. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15941. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15942. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15943. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15944. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15945. }
  15946. string breakfastPriceStr = string.Empty,
  15947. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15948. governmentRentStr = string.Empty,
  15949. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15950. cityTaxStrStr = string.Empty,
  15951. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15952. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15953. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15954. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15955. int payDId = roomInfo?.PayDId ?? 0;
  15956. pcfds.Add(new HotelReservations_PCFD_View()
  15957. {
  15958. City = item.City,
  15959. HotelName = item.HotelName,
  15960. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15961. // SingleRoomCount = item.SingleRoomCount,
  15962. SingleRoomPrice = singleRoomFeeStr,
  15963. // DoubleRoomCount = item.DoubleRoomCount,
  15964. DoubleRoomPrice = doubleRoomFeeStr,
  15965. //SuiteRoomCount = item.SuiteRoomCount,
  15966. SuiteRoomPrice = suiteRoomFeeStr,
  15967. OtherRoomPrice = otherRoomFeeStr,
  15968. //OtherRoomCount = item.OtherRoomCount,
  15969. BreakfastPrice = breakfastPriceStr,
  15970. GovernmentRent = governmentRentStr,
  15971. CityTax = cityTaxStrStr,
  15972. RoomExplanation = item.RoomExplanation,
  15973. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15974. PayTime = roomInfo?.ConsumptionDate,
  15975. BankNo = roomInfo?.BankNo,
  15976. PayMoney = payMoneyStr,
  15977. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15978. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15979. CardPrice = cardPriceStr,
  15980. Remark = ccpInfo.Remark
  15981. });
  15982. }
  15983. #endregion
  15984. //载入模板
  15985. WorkbookDesigner designer = new WorkbookDesigner();
  15986. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15987. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15988. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15989. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15990. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15991. designer.SetDataSource("Opertor", userInfo.CnName);
  15992. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15993. dt.TableName = "ViewMyHotelReservations";
  15994. designer.SetDataSource(dt);
  15995. designer.Process();
  15996. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15997. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15998. designer.Workbook.Save(serverPath);
  15999. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16000. #region 删除指定行
  16001. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16002. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16003. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16004. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16005. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16006. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16007. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16008. cssIndex = dt.Columns["CityTax"].Ordinal,
  16009. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16010. remarkIndex = dt.Columns["Remark"].Ordinal;
  16011. //删除指定列
  16012. foreach (DataRow item in dt.Rows)
  16013. {
  16014. string singleStr = item["SingleRoomPrice"].ToString();
  16015. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16016. if (containsDigitButNotZero1) singleDel = false;
  16017. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16018. string doubleStr = item["DoubleRoomPrice"].ToString();
  16019. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16020. if (containsDigitButNotZero2) doubleDel = false;
  16021. string suiteStr = item["SuiteRoomPrice"].ToString();
  16022. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16023. if (containsDigitButNotZero3) suiteDel = false;
  16024. string otherStr = item["OtherRoomPrice"].ToString();
  16025. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16026. if (containsDigitButNotZero4) otherDel = false;
  16027. string zcStr = item["BreakfastPrice"].ToString();
  16028. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16029. if (containsDigitButNotZero5) zcDel = false;
  16030. string dsStr = item["GovernmentRent"].ToString();
  16031. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16032. if (containsDigitButNotZero6) dsDel = false;
  16033. string cssStr = item["CityTax"].ToString();
  16034. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16035. if (containsDigitButNotZero7) cssDel = false;
  16036. string cpStr = item["ConsumptionPatterns"].ToString();
  16037. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16038. string remarkStr = item["Remark"].ToString();
  16039. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16040. }
  16041. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16042. DeleteColumn(serverPath, cpIndex, cpDel);
  16043. DeleteColumn(serverPath, dsIndex, dsDel);
  16044. DeleteColumn(serverPath, cssIndex, cssDel);
  16045. DeleteColumn(serverPath, zcIndex, zcDel);
  16046. DeleteColumn(serverPath, otherIndex, otherDel);
  16047. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16048. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16049. DeleteColumn(serverPath, singleIndex, singleDel);
  16050. #endregion
  16051. //只保留第一个表格
  16052. DeleteSheet(serverPath);
  16053. return Ok(JsonView(true, "操作成功", url = rst));
  16054. }
  16055. //return Ok(JsonView(false));
  16056. }
  16057. /// <summary>
  16058. /// 删除指定列
  16059. /// </summary>
  16060. /// <param name="file"></param>
  16061. /// <param name="columnIndex"></param>
  16062. /// <param name="isDel"></param>
  16063. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16064. {
  16065. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16066. //wb.Save(file);
  16067. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16068. if (sheet1 != null)
  16069. {
  16070. if (isDel)
  16071. {
  16072. Cells cells = sheet1.Cells;
  16073. cells.DeleteColumn(columnIndex);
  16074. }
  16075. }
  16076. wb.Save(file);
  16077. }
  16078. /// <summary>
  16079. /// 删除sheet
  16080. /// </summary>
  16081. /// <param name="file"></param>
  16082. /// <param name="sheetName"></param>
  16083. private void DeleteSheet(string file, string sheetName = "")
  16084. {
  16085. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16086. //wb.Save(file);
  16087. List<string> sheets = new List<string>();
  16088. foreach (var item in wb.Worksheets)
  16089. {
  16090. sheets.Add(item.Name);
  16091. }
  16092. if (sheets.Count > 0)
  16093. {
  16094. sheets.RemoveAt(0);//不删除第一个sheet
  16095. foreach (var item in sheets)
  16096. {
  16097. wb.Worksheets.RemoveAt(item);
  16098. }
  16099. }
  16100. wb.Save(file);
  16101. }
  16102. /// <summary>
  16103. /// 酒店预订
  16104. /// 确认单
  16105. /// </summary>
  16106. /// <param name="_dto"></param>
  16107. /// <returns></returns>
  16108. [HttpPost]
  16109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16110. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16111. {
  16112. try
  16113. {
  16114. #region 参数验证
  16115. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16116. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16117. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16118. #region 团组操作权限验证 76 酒店预定模块
  16119. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16120. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16121. #endregion
  16122. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16123. #region 页面操作权限验证
  16124. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16125. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16126. #endregion
  16127. #endregion
  16128. //团组信息
  16129. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16130. //酒店数据
  16131. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16132. if (listhoteldata.Count < 0)
  16133. {
  16134. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16135. }
  16136. //利datatable存储
  16137. DataTable dt = new DataTable();
  16138. dt.Columns.Add("CheckInDate", typeof(string));
  16139. dt.Columns.Add("City", typeof(string));
  16140. dt.Columns.Add("Hotel", typeof(string));
  16141. dt.Columns.Add("Room", typeof(string));
  16142. for (int i = 0; i < listhoteldata.Count; i++)
  16143. {
  16144. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16145. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16146. while (dayStart < dayEnd)
  16147. {
  16148. string temp = "";
  16149. DataRow row = dt.NewRow();
  16150. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16151. row["City"] = listhoteldata[i].City;
  16152. row["Hotel"] = listhoteldata[i].HotelName;
  16153. if (listhoteldata[i].SingleRoomCount > 0)
  16154. {
  16155. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16156. }
  16157. if (listhoteldata[i].DoubleRoomCount > 0)
  16158. {
  16159. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16160. }
  16161. if (listhoteldata[i].SuiteRoomCount > 0)
  16162. {
  16163. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16164. }
  16165. if (listhoteldata[i].OtherRoomCount > 0)
  16166. {
  16167. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16168. }
  16169. row["Room"] = temp;
  16170. dt.Rows.Add(row);
  16171. dayStart = dayStart.AddDays(1);
  16172. }
  16173. }
  16174. Dictionary<string, string> dic = new Dictionary<string, string>();
  16175. dic.Add("Dele", di.TeamName);
  16176. dic.Add("City", di.VisitCountry);
  16177. //模板路径
  16178. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16179. //载入模板
  16180. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16181. DocumentBuilder builder = new DocumentBuilder(doc);
  16182. foreach (var key in dic.Keys)
  16183. {
  16184. builder.MoveToBookmark(key);
  16185. builder.Write(dic[key]);
  16186. }
  16187. //获取word里所有表格
  16188. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16189. //获取所填表格的序数
  16190. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16191. var rowStart = tableOne.Rows[0]; //获取第1行
  16192. //循环赋值
  16193. for (int i = 0; i < dt.Rows.Count; i++)
  16194. {
  16195. builder.MoveToCell(0, i + 1, 0, 0);
  16196. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16197. builder.MoveToCell(0, i + 1, 1, 0);
  16198. builder.Write(dt.Rows[i]["City"].ToString());
  16199. builder.MoveToCell(0, i + 1, 2, 0);
  16200. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16201. builder.MoveToCell(0, i + 1, 3, 0);
  16202. builder.Write(dt.Rows[i]["Room"].ToString());
  16203. }
  16204. //删除多余行
  16205. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16206. {
  16207. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16208. }
  16209. string strFileName = di.TeamName + "酒店确认单.doc";
  16210. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16211. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16212. return Ok(JsonView(true, "成功", url));
  16213. }
  16214. catch (Exception ex)
  16215. {
  16216. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16217. }
  16218. }
  16219. #endregion
  16220. #region 团组状态
  16221. /// <summary>
  16222. /// 团组状态列表 Page
  16223. /// </summary>
  16224. /// <param name="dto">团组列表请求dto</param>
  16225. /// <returns></returns>
  16226. [HttpPost]
  16227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16228. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16229. {
  16230. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16231. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16232. {
  16233. string sqlWhere = string.Empty;
  16234. if (dto.IsSure == 0) //未完成
  16235. {
  16236. sqlWhere += string.Format(@" And IsSure = 0");
  16237. }
  16238. else if (dto.IsSure == 1) //已完成
  16239. {
  16240. sqlWhere += string.Format(@" And IsSure = 1");
  16241. }
  16242. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16243. {
  16244. string tj = dto.SearchCriteria;
  16245. 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}%')",
  16246. tj, tj, tj, tj, tj);
  16247. }
  16248. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16249. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16250. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16251. From (
  16252. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16253. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16254. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16255. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16256. From Grp_DelegationInfo gdi
  16257. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16258. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16259. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16260. Where gdi.IsDel = 0 {0}
  16261. ) temp ", sqlWhere);
  16262. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16263. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16264. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16265. }
  16266. else
  16267. {
  16268. return Ok(JsonView(false, "查询失败"));
  16269. }
  16270. }
  16271. /// <summary>
  16272. /// 团组状态
  16273. /// 设置操作完成
  16274. /// </summary>
  16275. /// <param name="dto">团组列表请求dto</param>
  16276. /// <returns></returns>
  16277. [HttpPost]
  16278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16279. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16280. {
  16281. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16282. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16283. {
  16284. Id = dto.Id,
  16285. IsSure = 1
  16286. };
  16287. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16288. .UpdateColumns(it => new { it.IsSure })
  16289. .WhereColumns(it => new { it.Id })
  16290. .ExecuteCommandAsync();
  16291. if (result > 0)
  16292. {
  16293. return Ok(JsonView(true, "操作完成!"));
  16294. }
  16295. return Ok(JsonView(false, "操作失败!"));
  16296. }
  16297. #endregion
  16298. #region 保险费用录入
  16299. /// <summary>
  16300. /// 根据团组Id查询保险费用列表
  16301. /// </summary>
  16302. /// <param name="dto"></param>
  16303. /// <returns></returns>
  16304. [HttpPost]
  16305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16306. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16307. {
  16308. Result groupData = await _customersRep.CustomersByDiId(dto);
  16309. if (groupData.Code != 0)
  16310. {
  16311. return Ok(JsonView(false, groupData.Msg));
  16312. }
  16313. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16314. }
  16315. /// <summary>
  16316. /// 根据保险费用Id查询保险费用详细
  16317. /// </summary>
  16318. /// <param name="dto"></param>
  16319. /// <returns></returns>
  16320. [HttpPost]
  16321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16322. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16323. {
  16324. try
  16325. {
  16326. Result groupData = await _customersRep.CustomersById(dto);
  16327. if (groupData.Code != 0)
  16328. {
  16329. return Ok(JsonView(false, groupData.Msg));
  16330. }
  16331. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16332. }
  16333. catch (Exception ex)
  16334. {
  16335. return Ok(JsonView(false, ex.Message));
  16336. }
  16337. }
  16338. /// <summary>
  16339. /// 保险费用录入页面初始化绑定
  16340. /// </summary>
  16341. /// <param name="dto"></param>
  16342. /// <returns></returns>
  16343. [HttpPost]
  16344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16345. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16346. {
  16347. try
  16348. {
  16349. Result groupData = await _customersRep.CustomersInitialize(dto);
  16350. if (groupData.Code != 0)
  16351. {
  16352. return Ok(JsonView(false, groupData.Msg));
  16353. }
  16354. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16355. }
  16356. catch (Exception ex)
  16357. {
  16358. return Ok(JsonView(false, ex.Message));
  16359. }
  16360. }
  16361. /// <summary>
  16362. /// 保险费用操作(Status:1.新增,2.修改)
  16363. /// </summary>
  16364. /// <param name="dto"></param>
  16365. /// <returns></returns>
  16366. [HttpPost]
  16367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16368. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16369. {
  16370. Result groupData = await _customersRep.OpCustomers(dto);
  16371. if (groupData.Code != 0)
  16372. {
  16373. return Ok(JsonView(false, groupData.Msg));
  16374. }
  16375. #region 应用推送
  16376. try
  16377. {
  16378. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16379. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16380. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16381. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16382. //自动审核
  16383. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16384. //2024-10-21 新增LZ UID
  16385. var userIds = new List<int>() { 21 };
  16386. string title = $"系统通知";
  16387. var diId = dto.DiId;
  16388. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16389. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16390. string content = "";
  16391. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16392. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16393. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16394. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16395. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16396. }
  16397. catch (Exception ex)
  16398. {
  16399. }
  16400. #endregion
  16401. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16402. }
  16403. /// <summary>
  16404. /// 保险文件上传
  16405. /// </summary>
  16406. /// <param name="file"></param>
  16407. /// <returns></returns>
  16408. [HttpPost]
  16409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16410. public async Task<IActionResult> UploadCus(IFormFile file)
  16411. {
  16412. try
  16413. {
  16414. if (file != null)
  16415. {
  16416. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16417. //文件名称
  16418. string projectFileName = file.FileName;
  16419. //上传的文件的路径
  16420. string filePath = "";
  16421. if (!Directory.Exists(fileDir))
  16422. {
  16423. Directory.CreateDirectory(fileDir);
  16424. }
  16425. //上传的文件的路径
  16426. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16427. using (FileStream fs = System.IO.File.Create(filePath))
  16428. {
  16429. file.CopyTo(fs);
  16430. fs.Flush();
  16431. }
  16432. return Ok(JsonView(true, "上传成功!", projectFileName));
  16433. }
  16434. else
  16435. {
  16436. return Ok(JsonView(false, "上传失败!"));
  16437. }
  16438. }
  16439. catch (Exception ex)
  16440. {
  16441. return Ok(JsonView(false, "程序错误!"));
  16442. throw;
  16443. }
  16444. }
  16445. /// <summary>
  16446. /// 保险删除指定文件
  16447. /// </summary>
  16448. /// <param name="dto"></param>
  16449. /// <returns></returns>
  16450. [HttpPost]
  16451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16452. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16453. {
  16454. try
  16455. {
  16456. string filePath = "";
  16457. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16458. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16459. //int id = 0;
  16460. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16461. // 删除该文件
  16462. try
  16463. {
  16464. System.IO.File.Delete(filePath);
  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. catch (Exception)
  16479. {
  16480. 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()
  16481. {
  16482. Attachment = "",
  16483. }).ExecuteCommandAsync();
  16484. if (result != 0)
  16485. {
  16486. return Ok(JsonView(true, "成功!"));
  16487. }
  16488. else
  16489. {
  16490. return Ok(JsonView(false, "失败!"));
  16491. }
  16492. }
  16493. }
  16494. catch (Exception ex)
  16495. {
  16496. return Ok(JsonView(false, "程序错误!"));
  16497. throw;
  16498. }
  16499. }
  16500. /// <summary>
  16501. /// 保险费用操作(删除)
  16502. /// </summary>
  16503. /// <param name="dto"></param>
  16504. /// <returns></returns>
  16505. [HttpPost]
  16506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16507. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16508. {
  16509. try
  16510. {
  16511. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16512. if (!res)
  16513. {
  16514. return Ok(JsonView(false, "删除失败"));
  16515. }
  16516. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16517. {
  16518. IsDel = 1,
  16519. DeleteUserId = dto.DeleteUserId,
  16520. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16521. }).ExecuteCommandAsync();
  16522. return Ok(JsonView(true, "删除成功!"));
  16523. }
  16524. catch (Exception ex)
  16525. {
  16526. return Ok(JsonView(false, "程序错误!"));
  16527. throw;
  16528. }
  16529. }
  16530. #endregion
  16531. #region 接团客户名单 PageId 104
  16532. /// <summary>
  16533. /// 接团客户名单
  16534. /// 迁移数据(慎用!)
  16535. /// </summary>
  16536. /// <returns></returns>
  16537. [HttpPost]
  16538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16539. public async Task<IActionResult> PostTourClientListChange()
  16540. {
  16541. try
  16542. {
  16543. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16544. //var groupClinetData1
  16545. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16546. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16547. int updateCount = 0;
  16548. if (oldOAClientList.Count > 0)
  16549. {
  16550. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16551. _sqlSugar.BeginTran();
  16552. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16553. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16554. foreach (var item in oldOAClientList)
  16555. {
  16556. int comId = 0;
  16557. string format = "yyyy-MM-dd HH:mm:ss";
  16558. string data11 = "1990-01-01 00:00";
  16559. var data1 = IsValidDate(item.OPdate, format);
  16560. if (data1) data11 = item.OPdate;
  16561. //客户公司验证
  16562. if (!string.IsNullOrEmpty(item.Company))
  16563. {
  16564. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16565. if (clientComInfo == null) // add
  16566. {
  16567. var addInfo = new Crm_CustomerCompany()
  16568. {
  16569. CompanyAbbreviation = "",
  16570. CompanyFullName = item.Company,
  16571. Address = "",
  16572. PostCodes = "",
  16573. LastedOpUserId = item.OPer,
  16574. LastedOpDt = Convert.ToDateTime(data11),
  16575. CreateUserId = item.OPer,
  16576. CreateTime = Convert.ToDateTime(data11),
  16577. IsDel = 0
  16578. };
  16579. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16580. if (comId1 > 0) comId = comId1;
  16581. }
  16582. else comId = clientComInfo.Id;
  16583. }
  16584. //客户人员验证
  16585. int clientId = 0;
  16586. string name = item.LastName + item.Name;
  16587. if (!string.IsNullOrEmpty(name))
  16588. {
  16589. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16590. if (clientInfo == null)
  16591. {
  16592. DateTime? dateTime = null;
  16593. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16594. if (isDt) dateTime = birthDayDt;
  16595. var addInfo1 = new Crm_DeleClient()
  16596. {
  16597. CrmCompanyId = comId,
  16598. DiId = -1,
  16599. LastName = item.LastName,
  16600. FirstName = item.Name,
  16601. OldName = "",
  16602. Pinyin = item.Pinyin,
  16603. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16604. Marriage = 0,
  16605. Phone = item.Phone,
  16606. Job = item.Job,
  16607. BirthDay = dateTime
  16608. };
  16609. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16610. if (clientId1 > 0) clientId = clientId1;
  16611. }
  16612. else clientId = clientInfo.Id;
  16613. }
  16614. if (clientId < 1)
  16615. {
  16616. continue;
  16617. }
  16618. int airType = 0;
  16619. if (item.AirType == "超经舱") airType = 459;
  16620. else if (item.AirType == "公务舱") airType = 458;
  16621. else if (item.AirType == "经济舱") airType = 460;
  16622. else if (item.AirType == "其他") airType = 565;
  16623. else if (item.AirType == "头等舱") airType = 457;
  16624. var _TourClientListEntity = new Grp_TourClientList()
  16625. {
  16626. DiId = item.Diid,
  16627. ClientId = clientId,
  16628. CreateUserId = item.OPer,
  16629. CreateTime = Convert.ToDateTime(data11),
  16630. Remark = item.Remark,
  16631. IsDel = item.Isdel,
  16632. ShippingSpaceTypeId = airType,
  16633. ShippingSpaceSpecialNeeds = item.AirRemark,
  16634. HotelSpecialNeeds = item.RoomType
  16635. };
  16636. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16637. if (_TourClientList > 0)
  16638. {
  16639. updateCount++;
  16640. }
  16641. }
  16642. _sqlSugar.CommitTran();
  16643. }
  16644. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16645. }
  16646. catch (Exception ex)
  16647. {
  16648. _sqlSugar.RollbackTran();
  16649. return Ok(JsonView(false, ex.Message));
  16650. }
  16651. //return Ok(JsonView(true));
  16652. }
  16653. private bool IsValidDate(string dateString, string format)
  16654. {
  16655. DateTime dateValue;
  16656. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16657. return valid;
  16658. }
  16659. /// <summary>
  16660. /// 接团客户名单
  16661. /// 根据团组Id查询List
  16662. /// </summary>
  16663. /// <param name="_dto"></param>
  16664. /// <returns></returns>
  16665. [HttpPost]
  16666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16667. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16668. {
  16669. #region 参数验证
  16670. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16671. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16672. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16673. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16674. #region 页面操作权限验证
  16675. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16676. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16677. #endregion
  16678. #endregion
  16679. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16680. if (viewData.Code != 0)
  16681. {
  16682. return Ok(JsonView(false, viewData.Msg));
  16683. }
  16684. return Ok(JsonView(viewData.Data));
  16685. }
  16686. /// <summary>
  16687. /// 接团客户名单
  16688. /// 基础数据 Init
  16689. /// </summary>
  16690. /// <param name="_dto"></param>
  16691. /// <returns></returns>
  16692. [HttpPost]
  16693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16694. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16695. {
  16696. #region 参数验证
  16697. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16698. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16699. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16700. #region 页面操作权限验证
  16701. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16702. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16703. #endregion
  16704. #endregion
  16705. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16706. }
  16707. /// <summary>
  16708. /// 接团客户名单
  16709. /// 根据 Id查询 Details
  16710. /// </summary>
  16711. /// <param name="_dto"></param>
  16712. /// <returns></returns>
  16713. [HttpPost]
  16714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16715. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16716. {
  16717. #region 参数验证
  16718. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16719. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16720. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16721. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16722. #region 页面操作权限验证
  16723. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16724. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16725. #endregion
  16726. #endregion
  16727. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16728. if (viewData.Code != 0)
  16729. {
  16730. return Ok(JsonView(false, viewData.Msg));
  16731. }
  16732. return Ok(JsonView(viewData.Data));
  16733. }
  16734. /// <summary>
  16735. /// 接团客户名单
  16736. /// Add Or Edit
  16737. /// </summary>
  16738. /// <param name="_dto"></param>
  16739. /// <returns></returns>
  16740. [HttpPost]
  16741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16742. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16743. {
  16744. #region 参数验证
  16745. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16746. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16747. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16748. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16749. #region 页面操作权限验证
  16750. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16751. if (_dto.Id == 0) //添加
  16752. {
  16753. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16754. }
  16755. else if (_dto.Id >= 0) //修改
  16756. {
  16757. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16758. }
  16759. #endregion
  16760. #endregion
  16761. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16762. if (viewData.Code != 0)
  16763. {
  16764. return Ok(JsonView(false, viewData.Msg));
  16765. }
  16766. return Ok(JsonView(true));
  16767. }
  16768. /// <summary>
  16769. /// 接团客户名单
  16770. /// json字符串 AddMultiple(添加多个)
  16771. /// </summary>
  16772. /// <param name="_dto"></param>
  16773. /// <returns></returns>
  16774. [HttpPost]
  16775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16776. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16777. {
  16778. #region 参数验证
  16779. string jsonLabel = _dto.JsonLabel;
  16780. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16781. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16782. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16783. #region 页面操作权限验证
  16784. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16785. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16786. #endregion
  16787. #endregion
  16788. var request = new TourClientListAddMultipleDto();
  16789. request.DiId = _dto.DiId;
  16790. request.UserId = _dto.UserId;
  16791. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16792. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16793. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16794. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16795. var infos = new List<TourClientListInfo>();
  16796. foreach (var data in datas)
  16797. {
  16798. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16799. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16800. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16801. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16802. {
  16803. continue;
  16804. }
  16805. infos.Add(new TourClientListInfo()
  16806. {
  16807. IsAccompany = 1,
  16808. LastName = lastName,
  16809. FirstName = firstName,
  16810. Pinyin = lastNameEn + @"/" + firstNameEn,
  16811. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16812. CompanyFullName = data.CompanyFullName,
  16813. Job = data.Job
  16814. });
  16815. }
  16816. if (infos.Any())
  16817. {
  16818. var viewData = await _tourClientListRep._AddMultiple(request);
  16819. if (viewData.Code != 0)
  16820. {
  16821. return Ok(JsonView(false, viewData.Msg));
  16822. }
  16823. return Ok(JsonView(true));
  16824. }
  16825. return Ok(JsonView(false));
  16826. }
  16827. /// <summary>
  16828. /// 接团客户名单
  16829. /// AddMultiple(添加多个)
  16830. /// </summary>
  16831. /// <param name="_dto"></param>
  16832. /// <returns></returns>
  16833. [HttpPost]
  16834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16835. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16836. {
  16837. #region 参数验证
  16838. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16839. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16840. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16841. #region 页面操作权限验证
  16842. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16843. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16844. #endregion
  16845. #endregion
  16846. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16847. if (viewData.Code != 0)
  16848. {
  16849. return Ok(JsonView(false, viewData.Msg));
  16850. }
  16851. return Ok(JsonView(true));
  16852. }
  16853. /// <summary>
  16854. /// 接团客户名单
  16855. /// Del
  16856. /// </summary>
  16857. /// <param name="_dto"></param>
  16858. /// <returns></returns>
  16859. [HttpPost]
  16860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16861. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16862. {
  16863. #region 参数验证
  16864. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16865. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16866. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16867. #region 页面操作权限验证
  16868. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16869. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16870. #endregion
  16871. #endregion
  16872. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16873. if (viewData.Code != 0)
  16874. {
  16875. return Ok(JsonView(false, viewData.Msg));
  16876. }
  16877. return Ok(JsonView(true));
  16878. }
  16879. /// <summary>
  16880. /// 接团客户名单
  16881. /// 文件下载 客户名单
  16882. /// </summary>
  16883. /// <param name="_dto"></param>
  16884. /// <returns></returns>
  16885. [HttpPost]
  16886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16887. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16888. {
  16889. #region 参数验证
  16890. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16891. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16892. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16893. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16894. #region 页面操作权限验证
  16895. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16896. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16897. #endregion
  16898. #endregion
  16899. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16900. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16901. From Grp_TourClientList tcl
  16902. Left Join
  16903. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16904. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16905. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16906. From Crm_DeleClient dc
  16907. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16908. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16909. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16910. Where dc.IsDel = 0) temp
  16911. On temp.DcId =tcl.ClientId
  16912. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16913. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16914. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16915. //载入模板
  16916. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16917. if (_dto.Language == 1)
  16918. {
  16919. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16920. }
  16921. //载入模板
  16922. var doc = new Document(tempPath);
  16923. DocumentBuilder builder = new DocumentBuilder(doc);
  16924. //获取word里所有表格
  16925. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16926. //获取所填表格的序数
  16927. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16928. var rowStart = tableOne.Rows[0]; //获取第1行
  16929. if (_dto.Language == 0)
  16930. {
  16931. //循环赋值
  16932. for (int i = 0; i < DcList.Count; i++)
  16933. {
  16934. EncryptionProcessor.DecryptProperties(DcList[i]);
  16935. builder.MoveToCell(0, i + 1, 0, 0);
  16936. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16937. builder.MoveToCell(0, i + 1, 1, 0);
  16938. int sex = DcList[i].Sex;
  16939. string sexStr = string.Empty;
  16940. if (sex == 0) sexStr = "男";
  16941. else if (sex == 1) sexStr = "女";
  16942. else sexStr = "未设置";
  16943. builder.Write(sexStr);
  16944. builder.MoveToCell(0, i + 1, 2, 0);
  16945. string birthDay = DcList[i].BirthDay;
  16946. string birthDayStr = string.Empty;
  16947. if (!string.IsNullOrEmpty(birthDay))
  16948. {
  16949. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16950. }
  16951. builder.Write(birthDayStr);
  16952. builder.MoveToCell(0, i + 1, 3, 0);
  16953. string company = "";
  16954. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16955. {
  16956. company = DcList[i].CompanyFullName.ToString();
  16957. }
  16958. builder.Write(company);
  16959. builder.MoveToCell(0, i + 1, 4, 0);
  16960. builder.Write(DcList[i].Job);
  16961. }
  16962. }
  16963. else if (_dto.Language == 1)
  16964. {
  16965. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16966. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16967. List<string> transArrayStr = new List<string>();
  16968. string transStrRes1 = "";
  16969. for (int i = 0; i < DcList.Count; i++)
  16970. {
  16971. var dc = DcList[i];
  16972. EncryptionProcessor.DecryptProperties(dc);
  16973. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16974. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16975. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16976. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16977. else transStrRes1 += $"{str1}|";
  16978. }
  16979. //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";
  16980. string transStrRes = "";
  16981. if (transStrRes1.Length > 0)
  16982. {
  16983. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16984. }
  16985. //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
  16986. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16987. //List<string> transArray = new List<string> { };
  16988. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16989. if (transStrRes.Contains("|"))
  16990. {
  16991. string[] transArray1 = transStrRes.Split('|');
  16992. if (transArray1.Length > 0)
  16993. {
  16994. foreach (var item in transArray1)
  16995. {
  16996. if (item.Contains("&"))
  16997. {
  16998. string[] transArray2 = item.Split('&');
  16999. int index = 0;
  17000. string companyName = "", job = "";
  17001. if (transArray2.Length > 0)
  17002. {
  17003. bool success = int.TryParse(transArray2[0].Trim(), out index);
  17004. if (1 < transArray2.Length) companyName = transArray2[1];
  17005. if (2 < transArray2.Length) job = transArray2[2];
  17006. }
  17007. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  17008. }
  17009. }
  17010. }
  17011. }
  17012. //循环赋值
  17013. for (int i = 0; i < DcList.Count; i++)
  17014. {
  17015. string PYName = "";
  17016. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17017. {
  17018. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17019. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17020. PYName = PY_First + " " + PY_Last;
  17021. }
  17022. else
  17023. {
  17024. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17025. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17026. PYName = PY_First + " " + PY_Last;
  17027. }
  17028. builder.MoveToCell(0, i + 1, 0, 0);
  17029. builder.Write(PYName);
  17030. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17031. builder.MoveToCell(0, i + 1, 1, 0);
  17032. builder.Write(sex);
  17033. DateTime birthDt;
  17034. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17035. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17036. builder.MoveToCell(0, i + 1, 2, 0);
  17037. builder.Write(birthday);
  17038. string company = string.Empty, job = string.Empty;
  17039. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17040. if (dcTransInfo != null)
  17041. {
  17042. company = dcTransInfo.CompanyName;
  17043. job = dcTransInfo.Job;
  17044. }
  17045. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17046. {
  17047. //查询对照表
  17048. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17049. if (tempCec != null)
  17050. {
  17051. company = tempCec.enName;
  17052. }
  17053. //翻译
  17054. else
  17055. {
  17056. }
  17057. }
  17058. builder.MoveToCell(0, i + 1, 3, 0);
  17059. builder.Write(company);
  17060. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17061. {
  17062. //查询对照表
  17063. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17064. if (tempPec != null)
  17065. {
  17066. job = tempPec.enName;
  17067. }
  17068. //翻译
  17069. else
  17070. {
  17071. }
  17072. }
  17073. builder.MoveToCell(0, i + 1, 4, 0);
  17074. builder.Write(job);
  17075. }
  17076. }
  17077. //删除多余行
  17078. while (tableOne.Rows.Count > DcList.Count + 1)
  17079. {
  17080. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17081. }
  17082. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17083. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17084. doc.Save(fileDir);
  17085. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17086. return Ok(JsonView(true, "操作成功!", Url));
  17087. }
  17088. private class TranslateInfo
  17089. {
  17090. public int Index { get; set; }
  17091. public string CompanyName { get; set; }
  17092. public string Job { get; set; }
  17093. }
  17094. #endregion
  17095. #region 团组倒推表
  17096. /// <summary>
  17097. /// 倒推表基础数据
  17098. /// Init
  17099. /// </summary>
  17100. /// <returns></returns>
  17101. [HttpPost]
  17102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17103. public async Task<IActionResult> PostInvertedListInit()
  17104. {
  17105. var viewData = await _invertedListRep._Init();
  17106. if (viewData.Code != 0)
  17107. {
  17108. return Ok(JsonView(false, viewData.Msg));
  17109. }
  17110. return Ok(JsonView(viewData.Data));
  17111. }
  17112. /// <summary>
  17113. /// 倒推表
  17114. /// Info
  17115. /// </summary>
  17116. /// <param name="dto"></param>
  17117. /// <returns></returns>
  17118. [HttpPost]
  17119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17120. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17121. {
  17122. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17123. if (viewData.Code != 0)
  17124. {
  17125. return Ok(JsonView(false, viewData.Msg));
  17126. }
  17127. return Ok(JsonView(viewData.Data));
  17128. }
  17129. /// <summary>
  17130. /// 倒推表
  17131. /// Create
  17132. /// </summary>
  17133. /// <param name="dto"></param>
  17134. /// <returns></returns>
  17135. [HttpPost]
  17136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17137. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17138. {
  17139. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17140. if (viewData.Code != 0)
  17141. {
  17142. return Ok(JsonView(false, viewData.Msg));
  17143. }
  17144. return Ok(JsonView(viewData.Data));
  17145. }
  17146. /// <summary>
  17147. /// 倒推表
  17148. /// Update
  17149. /// </summary>
  17150. /// <param name="dto"></param>
  17151. /// <returns></returns>
  17152. [HttpPost]
  17153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17154. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17155. {
  17156. var viewData = await _invertedListRep._Update(dto);
  17157. if (viewData.Code != 0)
  17158. {
  17159. return Ok(JsonView(false, viewData.Msg));
  17160. }
  17161. return Ok(JsonView(viewData.Data));
  17162. }
  17163. /// <summary>
  17164. /// 倒推表
  17165. /// File Download
  17166. /// </summary>
  17167. /// <param name="dto"></param>
  17168. /// <returns></returns>
  17169. [HttpPost]
  17170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17171. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17172. {
  17173. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17174. if (info2.Code != 0)
  17175. {
  17176. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17177. }
  17178. var info1 = info2.Data as InvertedListInfoView;
  17179. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17180. string teamName = "";
  17181. if (info != null) teamName = info.TeamName;
  17182. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17183. var doc = new Document();
  17184. var builder = new DocumentBuilder(doc);
  17185. #region old insert
  17186. ////载入模板
  17187. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17188. //Document doc = new Document(tempPath);
  17189. //DocumentBuilder builder = new DocumentBuilder(doc);
  17190. //利用键值对存放数据
  17191. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17192. //dic.Add("TeamName", teamName);
  17193. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17194. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17195. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17196. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17197. //dic.Add("SQRemark", info1.ApprovalRemark);
  17198. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17199. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17200. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17201. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17202. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17203. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17204. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17205. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17206. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17207. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17208. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17209. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17210. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17211. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17212. //#region 填充word模板书签内容
  17213. //foreach (var key in dic.Keys)
  17214. //{
  17215. // builder.MoveToBookmark(key);
  17216. // builder.Write(dic[key]);
  17217. //}
  17218. //#endregion
  17219. #endregion
  17220. #region New Insert
  17221. string titleFont = $"仿宋",
  17222. contentFont = $"仿宋";
  17223. var fontColor = Color.FromArgb(64, 64, 64);
  17224. //设置标题 团组名称
  17225. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17226. builder.Font.Name = titleFont;
  17227. builder.Font.Color = fontColor;
  17228. builder.Font.Size = 12;
  17229. builder.Font.Bold = true;
  17230. builder.Writeln(teamName);
  17231. //设置副标题 团组出访时间
  17232. builder.Font.Size = 12;
  17233. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17234. builder.Writeln();
  17235. var backgroundColor = Color.FromArgb(199, 199, 199);
  17236. var table = builder.StartTable();
  17237. builder.InsertCell();
  17238. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17239. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17240. builder.CellFormat.Borders.LineWidth = 1;
  17241. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17242. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17243. builder.RowFormat.Height = 40;
  17244. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17245. builder.Font.Name = contentFont;
  17246. builder.Font.Size = 12;
  17247. builder.Font.Bold = true;
  17248. builder.Font.Color = fontColor;
  17249. builder.Write("时间");
  17250. builder.InsertCell();
  17251. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17252. builder.Write("流程");
  17253. builder.InsertCell();
  17254. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17255. builder.Write("说明");
  17256. builder.EndRow();
  17257. //报批资料准备
  17258. if (info1.IsSelectedAirportd)
  17259. {
  17260. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17261. }
  17262. //报批/提供送签资料
  17263. if (info1.IsSelectedApprovalData)
  17264. {
  17265. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17266. }
  17267. //出批件护照办理
  17268. if (info1.IsSelectedIssueApproval)
  17269. {
  17270. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17271. }
  17272. //签证资料准备
  17273. if (info1.IsSelectedVisaInfo)
  17274. {
  17275. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17276. }
  17277. //送签
  17278. if (info1.IsSelectedSendVisa)
  17279. {
  17280. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17281. }
  17282. //出签
  17283. if (info1.IsSelectedIssueVisa)
  17284. {
  17285. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17286. }
  17287. //机票
  17288. if (info1.IsSelectedAirTicket)
  17289. {
  17290. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17291. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17292. }
  17293. //酒店
  17294. if (info1.IsSelectedHotel)
  17295. {
  17296. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17297. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17298. }
  17299. //开行前会
  17300. if (info1.IsSelectedPreTripMeeting)
  17301. {
  17302. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17303. }
  17304. //送机
  17305. if (info1.IsSelectedAirportdDropOff)
  17306. {
  17307. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17308. }
  17309. builder.EndTable();
  17310. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17311. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17312. for (int i = 0; i < table.Rows.Count; i++)
  17313. {
  17314. var row = table.Rows[i];
  17315. //设置宽度
  17316. row.Cells[0].CellFormat.Width = 20.00;
  17317. row.Cells[1].CellFormat.Width = 30.00;
  17318. row.Cells[2].CellFormat.Width = 50.00;
  17319. if (i != 0)
  17320. {
  17321. //边框设置
  17322. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17323. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17324. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17325. }
  17326. }
  17327. #region 页脚插入图片
  17328. // 创建页脚
  17329. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17330. doc.FirstSection.HeadersFooters.Add(footer);
  17331. Paragraph para = new Paragraph(doc);
  17332. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17333. footer.AppendChild(para);
  17334. builder.MoveTo(para);
  17335. string imagePath = "./Images/FMGJ_Log.png";
  17336. builder.InsertImage(imagePath);
  17337. #endregion
  17338. #endregion
  17339. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17340. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17341. string filePath = fileDir + $@"InvertedList/{fileName}";
  17342. doc.Save(filePath);
  17343. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17344. return Ok(JsonView(true, "操作成功!", Url));
  17345. }
  17346. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  17347. {
  17348. var fontColor = Color.FromArgb(64, 64, 64);
  17349. builder.InsertCell();
  17350. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17351. builder.RowFormat.Height = 40;
  17352. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17353. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17354. builder.Font.Name = fontName;
  17355. builder.Font.Size = 8;
  17356. builder.Font.Bold = true;
  17357. builder.Font.Color = fontColor;
  17358. builder.Write(dateTime);
  17359. builder.InsertCell();
  17360. builder.Font.Size = 9;
  17361. builder.Font.Bold = true;
  17362. builder.Font.Color = fontColor;
  17363. builder.Write(content);
  17364. builder.InsertCell();
  17365. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17366. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17367. builder.Font.Size = 9;
  17368. builder.Font.Bold = false;
  17369. builder.Font.Color = fontColor;
  17370. builder.Write(reamrk);
  17371. builder.EndRow();
  17372. }
  17373. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  17374. {
  17375. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17376. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17377. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17378. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17379. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17380. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17381. }
  17382. #endregion
  17383. #region 会务倒推表
  17384. /// <summary>
  17385. /// 会务倒推表
  17386. /// Init
  17387. /// </summary>
  17388. /// <returns></returns>
  17389. [HttpPost]
  17390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17391. public async Task<IActionResult> InforRetrogressTableInit()
  17392. {
  17393. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17394. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17395. return Ok(JsonView(false, groupData.Msg));
  17396. }
  17397. /// <summary>
  17398. /// 会务倒推表
  17399. /// ExcelDownload
  17400. /// </summary>
  17401. /// <param name="dto"></param>
  17402. /// <returns></returns>
  17403. [HttpPost]
  17404. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17406. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17407. {
  17408. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17409. var validatorRes = await validator.ValidateAsync(dto);
  17410. if (!validatorRes.IsValid)
  17411. {
  17412. StringBuilder sb = new StringBuilder();
  17413. foreach (var item in validatorRes.Errors)
  17414. {
  17415. sb.AppendLine(item.ErrorMessage);
  17416. }
  17417. return Ok(JsonView(false, sb.ToString()));
  17418. }
  17419. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17420. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17421. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17422. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17423. #region Excel
  17424. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17425. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17426. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17427. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17428. var fileNamePrefix = string.Empty;
  17429. if (days >= 30)
  17430. {
  17431. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17432. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17433. }
  17434. else if (days < 30 && days > 7)
  17435. {
  17436. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17437. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17438. }
  17439. else if (days <= 7)
  17440. {
  17441. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17442. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17443. }
  17444. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17445. fileName = CommonFun.ValidFileName(fileName);
  17446. //载入模板
  17447. WorkbookDesigner designer = new WorkbookDesigner();
  17448. designer.Workbook = new Workbook(tempPath);
  17449. designer.Process();
  17450. if (!Directory.Exists(savePath))
  17451. {
  17452. Directory.CreateDirectory(savePath);
  17453. }
  17454. string serverPath = $"{savePath}{fileName}";
  17455. designer.Workbook.Save(serverPath);
  17456. string rst = $"{servicePath}{ftpPath}{fileName}";
  17457. #endregion
  17458. return Ok(JsonView(new { url = rst }));
  17459. }
  17460. #endregion
  17461. #region 三公签证费用(签证费、代办费)
  17462. /// <summary>
  17463. /// 三公签证费用(签证费、代办费)
  17464. /// List
  17465. /// </summary>
  17466. /// <returns></returns>
  17467. [HttpPost]
  17468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17469. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17470. {
  17471. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17472. if (_view.Code != 0)
  17473. {
  17474. return Ok(JsonView(false, _view.Msg));
  17475. }
  17476. return Ok(JsonView(true, "操作成功!", _view.Data));
  17477. }
  17478. /// <summary>
  17479. /// 三公签证费用(签证费、代办费)
  17480. /// Add Or Update
  17481. /// </summary>
  17482. /// <returns></returns>
  17483. [HttpPost]
  17484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17485. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17486. {
  17487. var _view = await _visaFeeInfoRep._Update(_dto);
  17488. if (_view.Code != 0)
  17489. {
  17490. return Ok(JsonView(false, _view.Msg));
  17491. }
  17492. return Ok(JsonView(true, _view.Msg));
  17493. }
  17494. #endregion
  17495. #region 酒店询价
  17496. /// <summary>
  17497. /// 酒店询价
  17498. /// Init
  17499. /// </summary>
  17500. /// <returns></returns>
  17501. [HttpPost]
  17502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17503. public async Task<IActionResult> PostHotelInquiryInit()
  17504. {
  17505. var res = await _hotelInquiryRep._Init();
  17506. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17507. return Ok(JsonView(true, res.Msg, res.Data));
  17508. }
  17509. /// <summary>
  17510. /// 酒店询价
  17511. /// page Item
  17512. /// </summary>
  17513. /// <param name="_dto"></param>
  17514. /// <returns></returns>
  17515. [HttpPost]
  17516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17517. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17518. {
  17519. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17520. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17521. var view = res.Data as PageDataViewBase;
  17522. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17523. }
  17524. /// <summary>
  17525. /// 酒店询价
  17526. /// info
  17527. /// </summary>
  17528. /// <param name="_dto"></param>
  17529. /// <returns></returns>
  17530. [HttpPost]
  17531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17532. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17533. {
  17534. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17535. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17536. return Ok(JsonView(true, res.Msg, res.Data));
  17537. }
  17538. /// <summary>
  17539. /// 酒店询价
  17540. /// Add Or Edit
  17541. /// </summary>
  17542. /// <param name="_dto"></param>
  17543. /// <returns></returns>
  17544. [HttpPost]
  17545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17546. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17547. {
  17548. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17549. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17550. return Ok(JsonView(true, res.Msg, res.Data));
  17551. }
  17552. /// <summary>
  17553. /// 酒店询价
  17554. /// Del
  17555. /// </summary>
  17556. /// <param name="_dto"></param>
  17557. /// <returns></returns>
  17558. [HttpPost]
  17559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17560. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17561. {
  17562. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17563. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17564. return Ok(JsonView(true, res.Msg, res.Data));
  17565. }
  17566. #endregion
  17567. #region 下载匹配op行程单
  17568. /// <summary>
  17569. /// 匹配op行程单
  17570. /// Init
  17571. /// </summary>
  17572. /// <param name="dto">团组列表请求dto</param>
  17573. /// <returns></returns>
  17574. [HttpPost]
  17575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17576. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17577. {
  17578. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17579. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17580. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17581. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17582. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17583. .Where(it => it.IsDel == 0)
  17584. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17585. .OrderByDescending(it => it.VisitStartDate)
  17586. .ToList();
  17587. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17588. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17589. var diids = groupInfos.Select(it => it.Id).ToList();
  17590. List<string> countrys = new List<string>();
  17591. foreach (var item in country)
  17592. {
  17593. var data = _groupRepository.FormartTeamName(item);
  17594. var dataArray = _groupRepository.GroupSplitCountry(data);
  17595. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17596. }
  17597. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17598. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17599. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17600. foreach (var item in areaItem)
  17601. {
  17602. string areaStr = item.Value;
  17603. if (!string.IsNullOrEmpty(areaStr))
  17604. {
  17605. string[] str1 = areaStr.Split("-");
  17606. if (str1.Length > 0)
  17607. {
  17608. areaArray.AddRange(str1);
  17609. }
  17610. }
  17611. }
  17612. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17613. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17614. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17615. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17616. .ToList();
  17617. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17618. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17619. .Where(it => countriesIds.Contains(it.Id))
  17620. .Select(it => new { it.Id, Name = it.Name_CN })
  17621. .ToList();
  17622. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17623. .Select(it => it.TeamName).ToList();
  17624. stopwatch.Stop();
  17625. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17626. }
  17627. ///// <summary>
  17628. ///// 匹配op行程单
  17629. ///// Init 查询区域数据
  17630. ///// </summary>
  17631. ///// <param name="dto">团组列表请求dto</param>
  17632. ///// <returns></returns>
  17633. //[HttpPost]
  17634. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17635. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17636. //{
  17637. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17638. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17639. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17640. // if (string.IsNullOrEmpty(countriesDataStr))
  17641. // {
  17642. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17643. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17644. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17645. // }
  17646. // else
  17647. // {
  17648. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17649. // }
  17650. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17651. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17652. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17653. // List<dynamic> childList = new List<dynamic>();
  17654. // int parentId = dto.CountriesId;
  17655. // if (provinceData.Count > 1)
  17656. // {
  17657. // foreach (var item1 in provinceData)
  17658. // {
  17659. // List<dynamic> childList1 = new List<dynamic>();
  17660. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17661. // foreach (var item2 in citiesData1)
  17662. // {
  17663. // List<dynamic> childList2 = new List<dynamic>();
  17664. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17665. // foreach (var item3 in countiesData1)
  17666. // {
  17667. // childList2.Add(new
  17668. // {
  17669. // id = item3.Id,
  17670. // parentId = item2.Id,
  17671. // level = "district",
  17672. // name = item3.Name_CN,
  17673. // });
  17674. // }
  17675. // childList1.Add(new
  17676. // {
  17677. // id = item2.Id,
  17678. // parentId = item1.Id,
  17679. // level = "city",
  17680. // name = item2.Name_CN,
  17681. // childList = childList2
  17682. // });
  17683. // }
  17684. // childList.Add(new
  17685. // {
  17686. // id = item1.Id,
  17687. // parentId = parentId,
  17688. // level = "province",
  17689. // name = item1.Name_CN,
  17690. // childList = childList1
  17691. // });
  17692. // }
  17693. // //城市
  17694. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17695. // foreach (var item2 in citiesData2)
  17696. // {
  17697. // List<dynamic> childList22 = new List<dynamic>();
  17698. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17699. // foreach (var item3 in countiesData1)
  17700. // {
  17701. // childList22.Add(new
  17702. // {
  17703. // id = item3.Id,
  17704. // parentId = item2.Id,
  17705. // level = "district",
  17706. // name = item3.Name_CN,
  17707. // });
  17708. // }
  17709. // childList.Add(new
  17710. // {
  17711. // id = item2.Id,
  17712. // parentId = parentId,
  17713. // level = "city",
  17714. // name = item2.Name_CN,
  17715. // childList = childList22
  17716. // });
  17717. // }
  17718. // }
  17719. // else
  17720. // {
  17721. // foreach (var item2 in citiesData)
  17722. // {
  17723. // string cname = item2.Name_CN;
  17724. // List<dynamic> childList1 = new List<dynamic>();
  17725. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17726. // foreach (var item3 in countiesData1)
  17727. // {
  17728. // childList1.Add(new
  17729. // {
  17730. // Id = item3.Id,
  17731. // parentId = item2.Id,
  17732. // level = "district",
  17733. // name = item3.Name_CN
  17734. // });
  17735. // }
  17736. // childList.Add(new
  17737. // {
  17738. // id = item2.Id,
  17739. // parentId = parentId,
  17740. // level = "city",
  17741. // name = item2.Name_CN,
  17742. // childList = childList1
  17743. // });
  17744. // }
  17745. // }
  17746. // stopwatch.Stop();
  17747. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17748. //}
  17749. /// <summary>
  17750. /// 匹配op行程单
  17751. /// 接团信息列表 Page
  17752. /// </summary>
  17753. /// <param name="dto">团组列表请求dto</param>
  17754. /// <returns></returns>
  17755. [HttpPost]
  17756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17757. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17758. {
  17759. var swatch = new Stopwatch();
  17760. swatch.Start();
  17761. #region 参数验证
  17762. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17763. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17764. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17765. #region 页面操作权限验证
  17766. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17767. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17768. #endregion
  17769. #endregion
  17770. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17771. {
  17772. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17773. //string sqlWhere = "";
  17774. if (!string.IsNullOrEmpty(dto.Country))
  17775. {
  17776. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17777. }
  17778. if (!string.IsNullOrEmpty(dto.Area))
  17779. {
  17780. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17781. }
  17782. if (!string.IsNullOrEmpty(dto.TeamName))
  17783. {
  17784. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17785. }
  17786. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17787. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17788. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17789. swatch.Stop();
  17790. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17791. }
  17792. else
  17793. {
  17794. return Ok(JsonView(false, "查询失败"));
  17795. }
  17796. }
  17797. /// <summary>
  17798. /// 匹配op行程单
  17799. /// 行程单下载
  17800. /// </summary>
  17801. /// <param name="dto">团组列表请求dto</param>
  17802. /// <returns></returns>
  17803. [HttpPost]
  17804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17805. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17806. {
  17807. #region 参数验证
  17808. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17809. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17811. #region 页面操作权限验证
  17812. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17813. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17814. #endregion
  17815. #endregion
  17816. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17817. {
  17818. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17819. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17820. }
  17821. else
  17822. {
  17823. return Ok(JsonView(false, "下载失败!"));
  17824. }
  17825. }
  17826. #endregion
  17827. #region 国家信息 数据 注释
  17828. //[HttpPost]
  17829. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17830. //{
  17831. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17832. // foreach (var item in dto)
  17833. // {
  17834. // infos.Add(new Grp_GroupsTaskAssignment()
  17835. // {
  17836. // DIId = item,
  17837. // CTId = 82,
  17838. // UId = 248,
  17839. // IsEnable = 1,
  17840. // CreateUserId = 233,
  17841. // CreateTime = DateTime.Now,
  17842. // IsDel = 0
  17843. // });
  17844. // infos.Add(new Grp_GroupsTaskAssignment()
  17845. // {
  17846. // DIId = item,
  17847. // CTId = 82,
  17848. // UId = 286,
  17849. // IsEnable = 1,
  17850. // CreateUserId = 233,
  17851. // CreateTime = DateTime.Now,
  17852. // IsDel = 0
  17853. // });
  17854. // }
  17855. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17856. // return Ok("操作成功");
  17857. //}
  17858. //public class paramJsonDto
  17859. //{
  17860. // public List<CountriesInfo> str { get; set; }
  17861. //}
  17862. //[HttpPost]
  17863. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17864. //{
  17865. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17866. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17867. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17868. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17869. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17870. // _sqlSugar.BeginTran();
  17871. // int countitiesIndex = 0;
  17872. // foreach (var item in dto.str)
  17873. // {
  17874. // dynamic data = item.c;
  17875. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17876. // if (data != null)
  17877. // {
  17878. // countitiesIndex++;
  17879. // foreach (var item1 in data)
  17880. // {
  17881. // string cnname = item1.cn;
  17882. // string enname = item1.en;
  17883. // Sys_Cities provinceInfo = new Sys_Cities()
  17884. // {
  17885. // CountriesId = countriesId,
  17886. // Name_CN = cnname,
  17887. // Name_EN = enname,
  17888. // ParentId = 0,
  17889. // IsCapital = 1,
  17890. // CreateUserId = 208,
  17891. // CreateTime = DateTime.Now,
  17892. // IsDel = 0
  17893. // };
  17894. // if (item1.lv == "province") //省份
  17895. // {
  17896. // provinceInfo.Level = 1;
  17897. // int provinceId = 0;
  17898. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17899. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17900. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17901. // var data1 = item1.c;
  17902. // foreach (var item2 in data1)
  17903. // {
  17904. // if (item2.lv == "city")
  17905. // {
  17906. // string citycnname = item2.cn;
  17907. // string cityenname = item2.en;
  17908. // Sys_Cities cityInfo = new Sys_Cities()
  17909. // {
  17910. // CountriesId = countriesId,
  17911. // ParentId = provinceId,
  17912. // Level = 2,
  17913. // Name_CN = citycnname,
  17914. // Name_EN = cityenname,
  17915. // IsCapital = 1,
  17916. // CreateUserId = 208,
  17917. // CreateTime = DateTime.Now,
  17918. // IsDel = 0
  17919. // };
  17920. // if (item2.c != null)
  17921. // {
  17922. // int cityId = 0;
  17923. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17924. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17925. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17926. // foreach (var item3 in item2.c)
  17927. // {
  17928. // if (item3.lv == "district")
  17929. // {
  17930. // var districtInfo = new Sys_Cities()
  17931. // {
  17932. // CountriesId = countriesId,
  17933. // Name_CN = item3.cn,
  17934. // Name_EN = item3.en,
  17935. // Level = 3,
  17936. // ParentId = cityId,
  17937. // IsCapital = 1,
  17938. // CreateUserId = 208,
  17939. // CreateTime = DateTime.Now,
  17940. // IsDel = 0
  17941. // };
  17942. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17943. // //{
  17944. // districts.Add(districtInfo);
  17945. // //}
  17946. // }
  17947. // }
  17948. // }
  17949. // else
  17950. // {
  17951. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17952. // //{
  17953. // cities.Add(cityInfo);
  17954. // //}
  17955. // }
  17956. // }
  17957. // }
  17958. // }
  17959. // else if (item1.lv == "city")//城市
  17960. // {
  17961. // provinceInfo.Level = 2;
  17962. // if (item1.c != null)
  17963. // {
  17964. // int cityId = 0;
  17965. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17966. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17967. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17968. // foreach (var item3 in item1.c)
  17969. // {
  17970. // if (item3.lv == "district")
  17971. // {
  17972. // var districtInfo = new Sys_Cities()
  17973. // {
  17974. // CountriesId = countriesId,
  17975. // Name_CN = item3.cn,
  17976. // Name_EN = item3.en,
  17977. // Level = 3,
  17978. // ParentId = cityId,
  17979. // IsCapital = 1,
  17980. // CreateUserId = 208,
  17981. // CreateTime = DateTime.Now,
  17982. // IsDel = 0
  17983. // };
  17984. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17985. // //{
  17986. // districts.Add(districtInfo);
  17987. // //}
  17988. // }
  17989. // }
  17990. // }
  17991. // else
  17992. // {
  17993. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17994. // //{
  17995. // cities.Add(provinceInfo);
  17996. // //}
  17997. // }
  17998. // }
  17999. // }
  18000. // }
  18001. // }
  18002. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  18003. // cities = cities.Distinct().ToList();
  18004. // districts = districts.Distinct().ToList();
  18005. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  18006. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  18007. // cities.AddRange(districts);
  18008. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  18009. // //_sqlSugar.RollbackTran();
  18010. // _sqlSugar.CommitTran();
  18011. // return Ok(JsonView(false, "操作成功!"));
  18012. //}
  18013. //[HttpPost]
  18014. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18015. //{
  18016. // List<CountitiesInfo> infos = dto.MyProperty;
  18017. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18018. // _sqlSugar.BeginTran();
  18019. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18020. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18021. // foreach (var item in infos)
  18022. // {
  18023. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18024. // if (countryInfo != null)
  18025. // {
  18026. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18027. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18028. // if (cityInfo1 != null)
  18029. // {
  18030. // cityInfo1.IsCapital = 0;
  18031. // cityInfos.Add(cityInfo1);
  18032. // }
  18033. // }
  18034. // }
  18035. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18036. // .UpdateColumns(it => it.IsCapital)
  18037. // .WhereColumns(it => it.Id)
  18038. // .ExecuteCommand();
  18039. // //_sqlSugar.RollbackTran();
  18040. // _sqlSugar.CommitTran();
  18041. // return Ok(JsonView(false, "操作成功!"));
  18042. //}
  18043. //public class CounrtiesDto
  18044. //{
  18045. // public List<CountitiesInfo> MyProperty { get; set; }
  18046. //}
  18047. //public class CountitiesInfo
  18048. //{
  18049. // /// <summary>
  18050. // /// 圣约翰
  18051. // /// </summary>
  18052. // public string capital_name_chinese { get; set; }
  18053. // /// <summary>
  18054. // ///
  18055. // /// </summary>
  18056. // public string capital_name { get; set; }
  18057. // /// <summary>
  18058. // ///
  18059. // /// </summary>
  18060. // public string country_type { get; set; }
  18061. // /// <summary>
  18062. // /// 安提瓜和巴布达
  18063. // /// </summary>
  18064. // public string country_name_chinese { get; set; }
  18065. // /// <summary>
  18066. // /// 安提瓜和巴布达
  18067. // /// </summary>
  18068. // public string country_name_chinese_short { get; set; }
  18069. // /// <summary>
  18070. // /// 安提瓜和巴布达
  18071. // /// </summary>
  18072. // public string country_name_chinese_UN { get; set; }
  18073. // /// <summary>
  18074. // ///
  18075. // /// </summary>
  18076. // public string country_name_english_abbreviation { get; set; }
  18077. // /// <summary>
  18078. // ///
  18079. // /// </summary>
  18080. // public string country_name_english_formal { get; set; }
  18081. // /// <summary>
  18082. // ///
  18083. // /// </summary>
  18084. // public string country_name_english_UN { get; set; }
  18085. // /// <summary>
  18086. // ///
  18087. // /// </summary>
  18088. // public string continent_name { get; set; }
  18089. // /// <summary>
  18090. // ///
  18091. // /// </summary>
  18092. // public string subregion_name { get; set; }
  18093. // /// <summary>
  18094. // ///
  18095. // /// </summary>
  18096. // public string country_code2 { get; set; }
  18097. // /// <summary>
  18098. // ///
  18099. // /// </summary>
  18100. // public string country_code3 { get; set; }
  18101. // /// <summary>
  18102. // ///
  18103. // /// </summary>
  18104. // public string phone_code { get; set; }
  18105. //}
  18106. //public class CountriesInfo : BasicInfo
  18107. //{
  18108. // public List<CitiesInfo> c { get; set; }
  18109. //}
  18110. //public class CitiesInfo : BasicInfo
  18111. //{
  18112. // public List<AreaInfo> c { get; set; }
  18113. //}
  18114. //public class AreaInfo : BasicInfo
  18115. //{
  18116. // public List<AreaInfo> c { get; set; }
  18117. //}
  18118. //public class BasicInfo
  18119. //{
  18120. // public string code { get; set; }
  18121. // public string cn { get; set; }
  18122. // public string lv { get; set; }
  18123. // public string en { get; set; }
  18124. //}
  18125. #endregion
  18126. #region 查看邀请方
  18127. /// <summary>
  18128. /// 查看邀请方
  18129. /// 邀请方信息 Init
  18130. /// </summary>
  18131. /// <param name="dto"></param>
  18132. /// <returns></returns>
  18133. [HttpPost]
  18134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18135. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18136. {
  18137. string sqlWhere = string.Empty;
  18138. if (!string.IsNullOrEmpty(dto.Search))
  18139. {
  18140. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18141. }
  18142. string sql = string.Format($@"Select
  18143. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18144. Id,
  18145. UnitName
  18146. From Res_InvitationOfficialActivityData
  18147. Where IsDel = 0
  18148. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18149. RefAsync<int> total = 0;
  18150. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18151. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18152. }
  18153. /// <summary>
  18154. /// 查看邀请方
  18155. /// 国家信息 Init
  18156. /// </summary>
  18157. /// <param name="dto"></param>
  18158. /// <returns></returns>
  18159. [HttpPost]
  18160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18161. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18162. {
  18163. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18164. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18165. var diids = groupInfos.Select(it => it.Id).ToList();
  18166. List<string> countrys = new List<string>();
  18167. foreach (var item in country)
  18168. {
  18169. var data = _groupRepository.FormartTeamName(item);
  18170. var dataArray = _groupRepository.GroupSplitCountry(data);
  18171. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18172. }
  18173. countrys = countrys.Distinct().ToList();
  18174. for (int i = 0; i < countrys.Count; i++)
  18175. {
  18176. string item = countrys[i];
  18177. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18178. {
  18179. countrys.Remove(item);
  18180. i--;
  18181. }
  18182. }
  18183. RefAsync<int> total = 0;
  18184. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18185. .Where(it => countrys.Contains(it.Name_CN))
  18186. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18187. .Select(it => new { id = it.Id, name = it.Name_CN })
  18188. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18189. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18190. }
  18191. /// <summary>
  18192. /// 查看邀请方
  18193. /// 城市信息 Init
  18194. /// </summary>
  18195. /// <param name="dto"></param>
  18196. /// <returns></returns>
  18197. [HttpPost]
  18198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18199. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18200. {
  18201. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18202. RefAsync<int> total = 0;
  18203. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18204. .Where(it => it.CountriesId == dto.CountiesId)
  18205. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18206. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18207. .Select(it => new { id = it.Id, name = it.Name_CN })
  18208. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18209. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18210. }
  18211. /// <summary>
  18212. /// 查看邀请方
  18213. /// 团组名称 Init
  18214. /// </summary>
  18215. /// <param name="dto"></param>
  18216. /// <returns></returns>
  18217. [HttpPost]
  18218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18219. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18220. {
  18221. var watch = new Stopwatch();
  18222. watch.Start();
  18223. RefAsync<int> total = 0;
  18224. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18225. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18226. .Where((oa, di) => oa.IsDel == 0)
  18227. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18228. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18229. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18230. .Distinct()
  18231. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18232. watch.Stop();
  18233. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18234. }
  18235. /// <summary>
  18236. /// 查看邀请方
  18237. /// 团组 & 邀请方信息
  18238. /// </summary>
  18239. /// <param name="dto"></param>
  18240. /// <returns></returns>
  18241. [HttpPost]
  18242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18243. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18244. {
  18245. var watch = new Stopwatch();
  18246. watch.Start();
  18247. RefAsync<int> total = 0;
  18248. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18249. .AS("Grp_DelegationInfo")
  18250. .Includes(x => x.InvitingInfos)
  18251. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18252. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18253. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18254. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18255. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18256. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18257. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18258. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18259. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18260. infos.ForEach(x =>
  18261. {
  18262. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18263. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18264. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18265. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18266. });
  18267. watch.Stop();
  18268. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18269. }
  18270. #endregion
  18271. #region 报批行程
  18272. /// <summary>
  18273. /// 报批行程初始化
  18274. /// </summary>
  18275. /// <param name="dto"></param>
  18276. /// <returns></returns>
  18277. [HttpPost]
  18278. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18279. {
  18280. const int chiNumber = 5;
  18281. var jw = JsonView(false);
  18282. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18283. var group = groupList.First();
  18284. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18285. group = groupList.First(x => x.Id == diid);
  18286. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18287. .Where(x => x.DiId == diid && x.IsDel == 0)
  18288. .ToArray();
  18289. var count = 1;
  18290. foreach (var item in blackCodeList)
  18291. {
  18292. if (string.IsNullOrWhiteSpace(item.Title))
  18293. {
  18294. item.Title = "未设置名称数据" + count;
  18295. }
  18296. count++;
  18297. };
  18298. if (group == null)
  18299. {
  18300. jw.Msg = "暂无团组!";
  18301. return Ok(jw);
  18302. }
  18303. var data = new
  18304. {
  18305. groupList = groupList.Select(x => new
  18306. {
  18307. x.TeamName,
  18308. x.Id
  18309. }),
  18310. content = new ArrayList(),
  18311. groupInfo = new
  18312. {
  18313. group.VisitDays,
  18314. group.TourCode,
  18315. group.VisitPNumber,
  18316. group.TeamName,
  18317. group.Id,
  18318. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18319. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18320. },
  18321. blackCodeList = blackCodeList.Select(x => new
  18322. {
  18323. x.Title,
  18324. x.Id
  18325. }),
  18326. FileTempList = new ArrayList()
  18327. {
  18328. new { Index = 1,FileName = "旧模板" },
  18329. new { Index = 2,FileName = "省外办" },
  18330. new { Index = 3,FileName = "市外办" },
  18331. }
  18332. };
  18333. var resultArr = new ArrayList();
  18334. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18335. #region 默认不生成行程
  18336. //if (content.Count == 0)
  18337. //{
  18338. // var stay = "-";
  18339. // var cityPath = "-";
  18340. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18341. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18342. // .ToList();
  18343. // //添加城市路径以及住宿地
  18344. // //黑屏代码数据
  18345. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18346. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18347. // {
  18348. // jw = JsonView(true, "黑屏代码有误!", data);
  18349. // return Ok(jw);
  18350. // }
  18351. // data = data with
  18352. // {
  18353. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18354. // {
  18355. // x.Title,
  18356. // x.Id,
  18357. // }).ToArray())
  18358. // };
  18359. // foreach (DataRow row in dtBlack.Rows)
  18360. // {
  18361. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18362. // {
  18363. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18364. // return Ok(jw);
  18365. // }
  18366. // }
  18367. // //黑屏代码获取时间区间
  18368. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18369. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18370. // _sqlSugar.BeginTran();
  18371. // for (int i = 0; i < timeArr.Count; i++)
  18372. // {
  18373. // stay = "-";
  18374. // cityPath = "-";
  18375. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18376. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18377. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18378. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18379. // if (tbSelect.Length > 0)
  18380. // {
  18381. // List<string> threeCodeStr = new List<string>();
  18382. // foreach (var item in tbSelect)
  18383. // {
  18384. // var threeCode = item["Three"].ToString() ?? "";
  18385. // if (threeCode.Length == 6)
  18386. // {
  18387. // var start = threeCode.Substring(0, 3);
  18388. // var end = threeCode.Substring(3, 3);
  18389. // if (threeCodeStr.Count == 0)
  18390. // {
  18391. // threeCodeStr.Add(start);
  18392. // threeCodeStr.Add(end);
  18393. // }
  18394. // else
  18395. // {
  18396. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18397. // {
  18398. // threeCodeStr.Add(end);
  18399. // }
  18400. // else
  18401. // {
  18402. // threeCodeStr.Add(start);
  18403. // threeCodeStr.Add(end);
  18404. // }
  18405. // }
  18406. // }
  18407. // }
  18408. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18409. // var last = threeCodeStr.Last();
  18410. // foreach (var item in threeCodeStr)
  18411. // {
  18412. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18413. // if (item.Equals(last))
  18414. // {
  18415. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18416. // }
  18417. // }
  18418. // cityPath = cityPath.Trim('-');
  18419. // }
  18420. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18421. // appro.Diid = diid ?? -1;
  18422. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18423. // appro.Id = thisId;
  18424. // appro.CreateUserId = dto.UserId;
  18425. // appro.CreateTime = DateTime.Now;
  18426. // content.Add(appro);
  18427. // }
  18428. // _sqlSugar.CommitTran();
  18429. //}
  18430. #endregion
  18431. foreach (var x in content)
  18432. {
  18433. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18434. if (chiList.Count < chiNumber)
  18435. {
  18436. for (int i = chiList.Count; i < chiNumber; i++)
  18437. {
  18438. chiList.Add(new Grp_ApprovalTravelDetails());
  18439. }
  18440. }
  18441. resultArr.Add(new
  18442. {
  18443. x.Id,
  18444. x.Date,
  18445. x.Diid,
  18446. chiList = chiList.Select(x1 => new
  18447. {
  18448. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18449. x1.Details,
  18450. x1.ParentId,
  18451. x1.Id
  18452. })
  18453. });
  18454. }
  18455. data = data with
  18456. {
  18457. content = resultArr,
  18458. };
  18459. jw = JsonView(true, "获取成功!", data);
  18460. return Ok(jw);
  18461. }
  18462. /// <summary>
  18463. /// 报批行程删除
  18464. /// </summary>
  18465. /// <param name="dto"></param>
  18466. /// <returns></returns>
  18467. [HttpPost]
  18468. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18469. {
  18470. var jw = JsonView(false);
  18471. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18472. if (group == null)
  18473. {
  18474. jw.Msg = "团组参数有误!";
  18475. return Ok(jw);
  18476. }
  18477. try
  18478. {
  18479. _sqlSugar.BeginTran();
  18480. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18481. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18482. {
  18483. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18484. DeleteUserId = dto.uesrId,
  18485. IsDel = 1
  18486. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18487. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18488. {
  18489. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18490. DeleteUserId = dto.uesrId,
  18491. IsDel = 1
  18492. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18493. _sqlSugar.CommitTran();
  18494. jw = JsonView(true, "删除成功");
  18495. }
  18496. catch (Exception ex)
  18497. {
  18498. jw = JsonView(false, ex.Message);
  18499. }
  18500. return Ok(jw);
  18501. }
  18502. /// <summary>
  18503. /// 报批行程保存
  18504. /// </summary>
  18505. /// <param name="dto"></param>
  18506. /// <returns></returns>
  18507. [HttpPost]
  18508. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18509. {
  18510. var jw = JsonView(false);
  18511. var Find = dto.Arr.Find(x => x.id == 0);
  18512. if (Find != null)
  18513. {
  18514. jw.Msg = "生成的ID为0!";
  18515. return Ok(jw);
  18516. }
  18517. foreach (var item in dto.Arr)
  18518. {
  18519. foreach (var chi in item.chiList)
  18520. {
  18521. if (chi.parentId == 0)
  18522. {
  18523. chi.parentId = item.id;
  18524. }
  18525. }
  18526. }
  18527. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18528. _sqlSugar.BeginTran();
  18529. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18530. {
  18531. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18532. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18533. {
  18534. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18535. DeleteUserId = dto.UserId,
  18536. IsDel = 1
  18537. }).ExecuteCommand();
  18538. }
  18539. try
  18540. {
  18541. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18542. {
  18543. CreateTime = DateTime.Now,
  18544. CreateUserId = dto.UserId,
  18545. Details = x.details,
  18546. ParentId = x.parentId,
  18547. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18548. Remark = "",
  18549. IsDel = 0
  18550. }).ToList()).ExecuteCommand();
  18551. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18552. {
  18553. Id = x.id,
  18554. Details = x.details,
  18555. ParentId = x.parentId,
  18556. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18557. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18558. {
  18559. Details = x.Details,
  18560. ParentId = x.ParentId,
  18561. Time = x.Time
  18562. }).ExecuteCommand();
  18563. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18564. {
  18565. Id = x.id,
  18566. Date = x.date,
  18567. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18568. {
  18569. Date = x.Date
  18570. }).ExecuteCommand();
  18571. _sqlSugar.CommitTran();
  18572. jw = JsonView(true, "保存成功!");
  18573. }
  18574. catch (Exception ex)
  18575. {
  18576. _sqlSugar.RollbackTran();
  18577. jw = JsonView(false, "保存失败!" + ex.Message);
  18578. }
  18579. return Ok(jw);
  18580. }
  18581. /// <summary>
  18582. /// 报批行程生成
  18583. /// </summary>
  18584. /// <param name="dto"></param>
  18585. /// <returns></returns>
  18586. [HttpPost]
  18587. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18588. {
  18589. var jw = JsonView(false);
  18590. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18591. if (group == null)
  18592. {
  18593. jw.Msg = "暂无该团组!";
  18594. return Ok(jw);
  18595. }
  18596. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18597. //黑屏代码数据
  18598. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18599. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18600. {
  18601. jw.Msg = "黑屏代码有误!";
  18602. return Ok(jw);
  18603. }
  18604. foreach (DataRow row in dtBlack.Rows)
  18605. {
  18606. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18607. {
  18608. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18609. return Ok(jw);
  18610. }
  18611. }
  18612. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18613. var resultArr = new ArrayList();
  18614. //if (officialActivitiesArr.Count == 0)
  18615. //{
  18616. // jw.Msg = "暂无公务出访信息!";
  18617. // return Ok(jw);
  18618. //}
  18619. try
  18620. {
  18621. _sqlSugar.BeginTran();
  18622. DeleteApprovalJourney(new
  18623. Domain.Dtos.Groups.DeleteApprovalJourney
  18624. {
  18625. Diid = dto.Diid,
  18626. uesrId = dto.Userid
  18627. });
  18628. var stay = "-";
  18629. var cityPath = "-";
  18630. //添加城市路径以及住宿地
  18631. //黑屏代码获取时间区间
  18632. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18633. var empty = "【未收入该三字码!请机票同事录入】";
  18634. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18635. for (int i = 0; i < timeArr.Count; i++)
  18636. {
  18637. stay = "-";
  18638. cityPath = "-";
  18639. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18640. DateTime NewData = DateTime.Parse(timeArr[i]);
  18641. //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();
  18642. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18643. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18644. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18645. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18646. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18647. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18648. if (tbSelect.Length > 0)
  18649. {
  18650. List<string> threeCodeStr = new List<string>();
  18651. bool isTrade = false;
  18652. string trip = string.Empty;
  18653. var rowLast = tbSelect.Last();
  18654. var rowFirst = tbSelect.First();
  18655. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18656. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18657. var takeOffTime = DateTime.Parse(timeArr[i]);
  18658. var fallToTime = DateTime.Parse(timeArr[i]);
  18659. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18660. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18661. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18662. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18663. foreach (var item in tbSelect)
  18664. {
  18665. var start = string.Empty;
  18666. var end = string.Empty;
  18667. var threeCode = item["Three"].ToString() ?? "";
  18668. if (threeCode.Length == 6)
  18669. {
  18670. start = threeCode.Substring(0, 3);
  18671. end = threeCode.Substring(3, 3);
  18672. if (threeCodeStr.Count == 0)
  18673. {
  18674. threeCodeStr.Add(start);
  18675. threeCodeStr.Add(end);
  18676. }
  18677. else
  18678. {
  18679. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18680. {
  18681. threeCodeStr.Add(end);
  18682. }
  18683. else
  18684. {
  18685. threeCodeStr.Add(start);
  18686. threeCodeStr.Add(end);
  18687. }
  18688. }
  18689. }
  18690. //处理机票信息
  18691. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18692. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18693. if (start_Object == null)
  18694. {
  18695. start_Object = new Res_ThreeCode()
  18696. {
  18697. AirPort = empty,
  18698. AirPort_En = empty,
  18699. City = empty,
  18700. Country = empty,
  18701. Four = empty,
  18702. Three = empty,
  18703. };
  18704. }
  18705. if (end_Object == null)
  18706. {
  18707. end_Object = new Res_ThreeCode()
  18708. {
  18709. AirPort = empty,
  18710. AirPort_En = empty,
  18711. City = empty,
  18712. Country = empty,
  18713. Four = empty,
  18714. Three = empty,
  18715. };
  18716. }
  18717. //机型判断
  18718. string airModel = item["AirModel"].ToString();
  18719. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18720. string flightTime = item["FlightTime"].ToString();
  18721. if (flightTime!.Contains(":"))
  18722. {
  18723. flightTime = flightTime.Replace(":", "小时");
  18724. flightTime += "分钟";
  18725. }
  18726. if (flightTime.Contains("H"))
  18727. {
  18728. flightTime = flightTime.Replace("H", "小时");
  18729. }
  18730. if (flightTime.Contains("M"))
  18731. {
  18732. flightTime = flightTime.Replace("M", "分钟");
  18733. }
  18734. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18735. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18736. {
  18737. flightTime = flightDataTime.Hour > 0
  18738. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18739. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18740. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18741. }
  18742. //航班号
  18743. string flightcode = item["Fliagtcode"].ToString();
  18744. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18745. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18746. if (aircompany == null)
  18747. {
  18748. aircompany = new Res_AirCompany
  18749. {
  18750. CnName = hsEmpty,
  18751. EnName = hsEmpty,
  18752. ShortCode = hsEmpty,
  18753. };
  18754. }
  18755. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18756. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18757. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18758. if (isTrade)
  18759. {
  18760. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18761. }
  18762. else
  18763. {
  18764. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18765. }
  18766. }
  18767. chiarr.Add(new Grp_ApprovalTravelDetails
  18768. {
  18769. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18770. CreateTime = DateTime.Now,
  18771. CreateUserId = dto.Userid,
  18772. ParentId = 0,
  18773. Details = trip
  18774. });
  18775. //添加乘车语句
  18776. chiarr.Add(new Grp_ApprovalTravelDetails
  18777. {
  18778. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18779. CreateTime = DateTime.Now,
  18780. CreateUserId = dto.Userid,
  18781. ParentId = 0,
  18782. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18783. });
  18784. if (i != timeArr.Count - 1)
  18785. {
  18786. fallToTime = fallToTime.AddHours(2.5);
  18787. foreach (var item in Times)
  18788. {
  18789. //排列公务时间
  18790. if (fallToTime.Hour < item.Item1)
  18791. {
  18792. chiarr.Add(new Grp_ApprovalTravelDetails
  18793. {
  18794. Time = $"{item.Item2} - {item.Item3}",
  18795. CreateTime = DateTime.Now,
  18796. CreateUserId = dto.Userid,
  18797. ParentId = 0,
  18798. Details = "公务活动"
  18799. });
  18800. }
  18801. }
  18802. }
  18803. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18804. var last = threeCodeStr.Last();
  18805. foreach (var item in threeCodeStr)
  18806. {
  18807. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18808. if (item.Equals(last))
  18809. {
  18810. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18811. }
  18812. }
  18813. cityPath = cityPath.Trim('-');
  18814. }
  18815. else
  18816. {
  18817. foreach (var item in Times)
  18818. {
  18819. chiarr.Add(new Grp_ApprovalTravelDetails
  18820. {
  18821. Time = $"{item.Item2} - {item.Item3}",
  18822. CreateTime = DateTime.Now,
  18823. CreateUserId = dto.Userid,
  18824. ParentId = 0,
  18825. Details = "公务活动"
  18826. });
  18827. }
  18828. }
  18829. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18830. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18831. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18832. appro.Diid = dto.Diid;
  18833. appro.CreateUserId = dto.Userid;
  18834. appro.CreateTime = DateTime.Now;
  18835. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18836. appro.Id = thisId;
  18837. //foreach (var item in gwinfo)
  18838. //{
  18839. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18840. // chi.Details = "拜访" + item.Client;
  18841. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18842. // {
  18843. // chi.Details += "," + item.ReqSample;
  18844. // }
  18845. // chi.ParentId = thisId;
  18846. // chi.Time = item.Time;
  18847. // chiarr.Add(chi);
  18848. //}
  18849. if (chiarr.Count < 6)
  18850. {
  18851. for (int j = chiarr.Count; j < 6; j++)
  18852. {
  18853. chiarr.Add(new
  18854. Grp_ApprovalTravelDetails());
  18855. }
  18856. }
  18857. resultArr.Add(new
  18858. {
  18859. appro.Id,
  18860. appro.Date,
  18861. appro.Diid,
  18862. chiList = chiarr.Select(x1 => new
  18863. {
  18864. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18865. x1.Details,
  18866. x1.ParentId,
  18867. x1.Id
  18868. })
  18869. });
  18870. }
  18871. _sqlSugar.CommitTran();
  18872. jw = JsonView(true, "生成成功!", resultArr);
  18873. }
  18874. catch (Exception ex)
  18875. {
  18876. jw.Code = 400;
  18877. jw.Msg = "生成失败!" + ex.Message;
  18878. }
  18879. return Ok(jw);
  18880. }
  18881. /// <summary>
  18882. /// 报批行程word导出
  18883. /// </summary>
  18884. /// <param name="dto"></param>
  18885. /// <returns></returns>
  18886. [HttpPost]
  18887. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18888. {
  18889. var jw = JsonView(false);
  18890. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18891. if (group == null)
  18892. {
  18893. jw.Msg = "暂无该团组!";
  18894. return Ok(jw);
  18895. }
  18896. //模板路径
  18897. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18898. var fileName = string.Empty;
  18899. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18900. bool bold = false;
  18901. if (dto.FileIndex == 1)
  18902. {
  18903. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18904. }
  18905. else if (dto.FileIndex == 2)
  18906. {
  18907. fileName = "省外办-报批.docx";
  18908. bold = false;
  18909. titleFont = "方正黑体简体";
  18910. timeFont = "Times New Roman";
  18911. contentFont = "方正仿宋_GBK";
  18912. }
  18913. else if (dto.FileIndex == 3)
  18914. {
  18915. fileName = "市外办-报批.docx";
  18916. titleFont = "方正黑体简体";
  18917. timeFont = "Times New Roman";
  18918. contentFont = "方正仿宋简体";
  18919. }
  18920. tempPath = tempPath + fileName;
  18921. //载入模板
  18922. Document doc = new Document(tempPath);
  18923. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18924. //获取所填表格的序数
  18925. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18926. Aspose.Words.Tables.Row titleRowClone = null;
  18927. Aspose.Words.Tables.Row CenterRowClone = null;
  18928. int index = 0;
  18929. int indexChi = 0;
  18930. int SetIndex = 0;
  18931. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18932. //获取数据,放到datatable
  18933. foreach (var item in ApprovalTravelArr)
  18934. {
  18935. if (index > 0)
  18936. {
  18937. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18938. tableOne.AppendChild(titleRowClone);
  18939. }
  18940. var textTime = item.Date;
  18941. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18942. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18943. SetIndex++;
  18944. if (ChiRep.Count > 0)
  18945. {
  18946. foreach (var itemChi in ChiRep)
  18947. {
  18948. var txtTime = itemChi.Time;
  18949. var txtDetail = itemChi.Details;
  18950. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18951. {
  18952. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  18953. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18954. //indexChi++;
  18955. //SetIndex++;
  18956. break;
  18957. }
  18958. if (indexChi > 0)
  18959. {
  18960. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18961. tableOne.AppendChild(CenterRowClone);
  18962. }
  18963. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  18964. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  18965. indexChi++;
  18966. SetIndex++;
  18967. }
  18968. }
  18969. //else
  18970. //{
  18971. // if (indexChi > 0)
  18972. // {
  18973. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18974. // tableOne.AppendChild(CenterRowClone);
  18975. // }
  18976. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  18977. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18978. // indexChi++;
  18979. // SetIndex++;
  18980. //}
  18981. index++;
  18982. }
  18983. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  18984. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18985. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18986. jw.Code = 200;
  18987. jw.Msg = "";
  18988. return Ok(jw);
  18989. }
  18990. private string intToString(int numberVal)
  18991. {
  18992. string numberval = numberVal.ToString();
  18993. Dictionary<char, string> Number = new Dictionary<char, string>();
  18994. Number.Add('1', "一");
  18995. Number.Add('2', "二");
  18996. Number.Add('3', "三");
  18997. Number.Add('4', "四");
  18998. Number.Add('5', "五");
  18999. Number.Add('6', "六");
  19000. Number.Add('7', "七");
  19001. Number.Add('8', "八");
  19002. Number.Add('9', "九");
  19003. string stringNumberVal = string.Empty;
  19004. for (int i = 0; i < numberval.Length; i++)
  19005. {
  19006. if (i == 0)
  19007. {
  19008. stringNumberVal += Number[numberval[i]];
  19009. }
  19010. else if (i >= 1)
  19011. {
  19012. if (numberval[i] == '0')
  19013. {
  19014. stringNumberVal = "十";
  19015. }
  19016. else
  19017. {
  19018. stringNumberVal += "十" + Number[numberval[i]];
  19019. }
  19020. }
  19021. }
  19022. return stringNumberVal;
  19023. }
  19024. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  19025. {
  19026. //获取table中的某个单元格,从0开始
  19027. Cell lshCell = table.Rows[rows].Cells[cells];
  19028. //将单元格中段落移除
  19029. foreach (Paragraph item in lshCell.Paragraphs)
  19030. {
  19031. lshCell.Paragraphs.Remove(item);
  19032. }
  19033. if (val.Contains("\r\n"))
  19034. {
  19035. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19036. foreach (var item in spArr)
  19037. {
  19038. //新建一个段落
  19039. Paragraph p = new Paragraph(doc);
  19040. var r = new Run(doc, item);
  19041. //设置字体
  19042. if (!string.IsNullOrEmpty(font))
  19043. {
  19044. r.Font.Name = font;
  19045. }
  19046. r.Font.Bold = bold;
  19047. //把设置的值赋给之前新建的段落
  19048. p.AppendChild(r);
  19049. //将此段落加到单元格内
  19050. lshCell.AppendChild(p);
  19051. }
  19052. }
  19053. else
  19054. {
  19055. //新建一个段落
  19056. Paragraph p = new Paragraph(doc);
  19057. var r = new Run(doc, val);
  19058. //设置字体
  19059. if (!string.IsNullOrEmpty(font))
  19060. {
  19061. r.Font.Name = font;
  19062. }
  19063. r.Font.Bold = bold;
  19064. //把设置的值赋给之前新建的段落
  19065. p.AppendChild(r);
  19066. //将此段落加到单元格内
  19067. lshCell.AppendChild(p);
  19068. }
  19069. }
  19070. [HttpPost]
  19071. public async Task<IActionResult> ServerHttp(string paramStr)
  19072. {
  19073. paramStr = paramStr.TrimEnd('\'');
  19074. paramStr = paramStr.TrimStart('\'');
  19075. JsonView jw = JsonView(false);
  19076. JObject param = JObject.Parse(paramStr);
  19077. if (!param.ContainsKey("url"))
  19078. {
  19079. jw.Msg = "url null";
  19080. return Ok(jw);
  19081. }
  19082. string url = param["url"]!.ToString();
  19083. var methon = "get";
  19084. Dictionary<string, string> headValues = null;
  19085. string bodyStr = string.Empty;
  19086. if (param.ContainsKey("methon"))
  19087. {
  19088. methon = param["methon"]!.ToString().ToLower();
  19089. }
  19090. if (param.ContainsKey("header"))
  19091. {
  19092. var header = param["header"]!.ToString();
  19093. JObject headerJobject = JObject.Parse(header);
  19094. headValues = new Dictionary<string, string>();
  19095. foreach (JProperty item in headerJobject.Properties())
  19096. {
  19097. var value = item.Value.ToString();
  19098. var head = item.Path;
  19099. headValues.Add(head, value);
  19100. }
  19101. }
  19102. HttpClient client = new HttpClient();
  19103. string responseString = string.Empty;
  19104. StringContent content = null;
  19105. if (headValues != null)
  19106. {
  19107. foreach (var item in headValues.Keys)
  19108. {
  19109. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19110. {
  19111. if (param.ContainsKey("body"))
  19112. {
  19113. bodyStr = param["body"]!.ToString();
  19114. }
  19115. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19116. }
  19117. else
  19118. {
  19119. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19120. }
  19121. }
  19122. }
  19123. try
  19124. {
  19125. if (methon == "get")
  19126. {
  19127. responseString = await client.GetStringAsync(url);
  19128. }
  19129. else if (methon == "post")
  19130. {
  19131. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19132. {
  19133. Content = content
  19134. };
  19135. var response = await client.SendAsync(request);
  19136. try
  19137. {
  19138. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19139. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19140. {
  19141. using (StreamReader reader = new StreamReader(gzipStream))
  19142. {
  19143. responseString = await reader.ReadToEndAsync();
  19144. }
  19145. }
  19146. }
  19147. catch (Exception)
  19148. {
  19149. responseString = await response.Content.ReadAsStringAsync();
  19150. }
  19151. }
  19152. else
  19153. {
  19154. responseString = "methon error";
  19155. }
  19156. jw = JsonView(true, "success", responseString);
  19157. }
  19158. catch (Exception ex)
  19159. {
  19160. jw.Msg = "error " + ex.Message;
  19161. jw.Data = ex.StackTrace;
  19162. }
  19163. finally
  19164. {
  19165. client.Dispose();
  19166. }
  19167. return Ok(jw);
  19168. }
  19169. #endregion
  19170. #region 团组接待意见调查
  19171. /// <summary>
  19172. /// 团组接待意见调查 - 信息管理
  19173. /// 基础数据(团组)
  19174. /// </summary>
  19175. /// <returns></returns>
  19176. [HttpGet]
  19177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19178. public async Task<IActionResult> OpinionaireInit()
  19179. {
  19180. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19181. .Select(x => new
  19182. {
  19183. x.Id,
  19184. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19185. })
  19186. .OrderByDescending(x => x.Id)
  19187. .ToListAsync();
  19188. return Ok(JsonView(groupData, groupData.Count));
  19189. }
  19190. /// <summary>
  19191. /// 团组接待意见调查 - 信息管理
  19192. /// 列表
  19193. /// </summary>
  19194. /// <param name="groupId"></param>
  19195. /// <returns></returns>
  19196. [HttpGet("{groupId}")]
  19197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19198. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19199. {
  19200. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19201. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19202. .Select(x => new
  19203. {
  19204. x.Id,
  19205. x.TourGuideName,
  19206. x.CityName,
  19207. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19208. x.CreateTime
  19209. })
  19210. .OrderBy(x => x.Id)
  19211. .ToListAsync();
  19212. return Ok(JsonView(data));
  19213. }
  19214. /// <summary>
  19215. /// 团组接待意见调查 - 信息管理
  19216. /// 保存
  19217. /// </summary>
  19218. /// <param name="dto"></param>
  19219. /// <returns></returns>
  19220. [HttpPost]
  19221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19222. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19223. {
  19224. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19225. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19226. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19227. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19228. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19229. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19230. _opinionaireRep.BeginTran();
  19231. if (addData != null && addData.Count > 0)
  19232. {
  19233. foreach (var item in addData)
  19234. {
  19235. item.CreateUserId = currUserInfo.UserId;
  19236. item.DiId = dto.DiId;
  19237. }
  19238. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19239. }
  19240. if (updData != null && updData.Count > 0)
  19241. {
  19242. var upd = await _opinionaireRep._sqlSugar
  19243. .Updateable(updData)
  19244. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19245. .WhereColumns(x => new { x.Id })
  19246. .ExecuteCommandAsync();
  19247. }
  19248. _opinionaireRep.CommitTran();
  19249. return Ok(JsonView("操作成功!"));
  19250. }
  19251. /// <summary>
  19252. /// 团组接待意见调查 - 信息管理
  19253. /// 删除
  19254. /// </summary>
  19255. /// <param name="id"></param>
  19256. /// <returns></returns>
  19257. [HttpDelete("{id}")]
  19258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19259. public async Task<IActionResult> OpinionaireManageDel(int id)
  19260. {
  19261. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19262. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19263. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19264. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19265. if (!del) return Ok(JsonView("操作失败!"));
  19266. return Ok(JsonView("操作成功!"));
  19267. }
  19268. /// <summary>
  19269. /// 团组接待意见调查 - 用户
  19270. /// 列表
  19271. /// </summary>
  19272. /// <param name="diId"></param>
  19273. /// <returns></returns>
  19274. [HttpGet("{diId}")]
  19275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19276. public async Task<IActionResult> OpinionaireUserList(int diId)
  19277. {
  19278. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19279. var sql = string.Format(@"
  19280. SELECT
  19281. o.Id,
  19282. o.DiId,
  19283. di.TeamName AS 'GroupName',
  19284. di.VisitPNumber AS 'PeopleNumber',
  19285. di.ClientName AS 'LeadGroup',
  19286. di.VisitCountry AS 'Travel',
  19287. di.VisitDays AS 'Days',
  19288. o.CityName,
  19289. o.TourGuideName,
  19290. o.Catering,
  19291. o.CateringReason,
  19292. o.Stay,
  19293. o.StayReason,
  19294. o.[Route],
  19295. o.RouteReason,
  19296. o.OfficialActivity,
  19297. o.OfficialActivityReason,
  19298. o.TourGuide,
  19299. o.TourGuideReason,
  19300. o.[Translate],
  19301. o.TranslateReason,
  19302. o.Trip,
  19303. o.TripReason,
  19304. o.ESFileName,
  19305. o.SignatureDate,
  19306. o.Remark
  19307. FROM
  19308. Grp_Opinionaire o
  19309. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19310. WHERE
  19311. o.IsDel = 0
  19312. AND o.DiId = {0}
  19313. ORDER BY
  19314. o.Id ASC", diId);
  19315. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19316. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19317. return Ok(JsonView(data));
  19318. }
  19319. /// <summary>
  19320. /// 团组接待意见调查 - 用户
  19321. /// 保存
  19322. /// </summary>
  19323. /// <param name="dto"></param>
  19324. /// <returns></returns>
  19325. [HttpPost]
  19326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19327. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19328. {
  19329. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19330. foreach (var item in dto)
  19331. {
  19332. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19333. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19334. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19335. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19336. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19337. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19338. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19339. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19340. }
  19341. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19342. if (!Directory.Exists(filePathBase))
  19343. {
  19344. Directory.CreateDirectory(filePathBase);
  19345. }
  19346. #region 上传文件
  19347. var filePaths = new List<string>();
  19348. foreach (var item in dto)
  19349. {
  19350. var file = item.File;
  19351. // 将文件保存到指定位置
  19352. var filePath = Path.Combine(filePathBase, file.FileName);
  19353. using (var stream = new FileStream(filePath, FileMode.Create))
  19354. {
  19355. await file.CopyToAsync(stream);
  19356. }
  19357. //验证文件是否上传成功
  19358. if (!System.IO.File.Exists(filePath))
  19359. {
  19360. foreach (var filePathStr in filePaths)
  19361. {
  19362. System.IO.File.Delete(filePathStr);
  19363. }
  19364. return Ok(JsonView(false, "文件上传失败!"));
  19365. }
  19366. item.ESFileName = file.FileName;
  19367. }
  19368. #endregion
  19369. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19370. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19371. .UpdateColumns(x => new
  19372. {
  19373. x.Catering,
  19374. x.CateringReason,
  19375. x.Stay,
  19376. x.StayReason,
  19377. x.Route,
  19378. x.RouteReason,
  19379. x.OfficialActivity,
  19380. x.OfficialActivityReason,
  19381. x.TourGuide,
  19382. x.TourGuideReason,
  19383. x.Translate,
  19384. x.TranslateReason,
  19385. x.Trip,
  19386. x.TripReason,
  19387. x.ESFileName,
  19388. x.SignatureDate,
  19389. x.Remark
  19390. })
  19391. .WhereColumns(x => new { x.Id })
  19392. .ExecuteCommandAsync();
  19393. if (upd < 1)
  19394. {
  19395. foreach (var filePathStr in filePaths)
  19396. {
  19397. System.IO.File.Delete(filePathStr);
  19398. }
  19399. return Ok(JsonView(false));
  19400. }
  19401. return Ok(JsonView(true));
  19402. }
  19403. #endregion
  19404. #region 团组餐厅相关信息
  19405. /// <summary>
  19406. /// 团组相关餐厅信息
  19407. /// 基础数据(团组)
  19408. /// </summary>
  19409. /// <returns></returns>
  19410. [HttpGet]
  19411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19412. public async Task<IActionResult> RestaurantInit()
  19413. {
  19414. return Ok(await _restaurantRep.InitAsync());
  19415. }
  19416. /// <summary>
  19417. /// 团组相关餐厅信息
  19418. /// Item
  19419. /// </summary>
  19420. /// <param name="dto"></param>
  19421. /// <returns></returns>
  19422. [HttpPost]
  19423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19424. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19425. {
  19426. int portType = dto.PortType,
  19427. groupId = dto.GroupId;
  19428. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19429. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19430. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19431. }
  19432. /// <summary>
  19433. /// 团组相关餐厅信息
  19434. /// List
  19435. /// </summary>
  19436. /// <param name="dto"></param>
  19437. /// <returns></returns>
  19438. [HttpPost]
  19439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19440. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19441. {
  19442. int portType = dto.PortType,
  19443. groupId = dto.GroupId;
  19444. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19445. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19446. var sql = string.Format(@" SELECT
  19447. ri.Id,
  19448. ri.GroupId,
  19449. ri.Date,
  19450. ri.StartTime,
  19451. ri.EndTime,
  19452. CASE WHEN ri.Type = 1 THEN '早餐'
  19453. WHEN ri.Type = 2 THEN '午餐'
  19454. WHEN ri.Type = 3 THEN '晚餐'
  19455. ELSE '其他'
  19456. END AS 'Type',
  19457. ri.Name,
  19458. ri.Address,
  19459. ri.Tel,
  19460. ri.Remark,
  19461. ri.CreateTime,
  19462. u.CnName AS CreateUserName
  19463. FROM
  19464. Grp_RestaurantInfo ri
  19465. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19466. WHERE
  19467. ri.IsDel = 0
  19468. AND ri.GroupId = {0}
  19469. ORDER BY
  19470. ri.Date ASC
  19471. ", groupId);
  19472. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19473. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19474. return Ok(JsonView(infos));
  19475. }
  19476. /// <summary>
  19477. /// 团组相关餐厅信息
  19478. /// Info
  19479. /// </summary>
  19480. /// <param name="dto"></param>
  19481. /// <returns></returns>
  19482. [HttpPost]
  19483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19484. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19485. {
  19486. int portType = dto.PortType,
  19487. id = dto.Id;
  19488. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19489. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19490. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19491. }
  19492. /// <summary>
  19493. /// 团组相关餐厅信息
  19494. /// Op
  19495. /// </summary>
  19496. /// <param name="dto"></param>
  19497. /// <returns></returns>
  19498. [HttpPost]
  19499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19500. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19501. {
  19502. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19503. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19504. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19505. return Ok(await _restaurantRep.OpAsync(dto));
  19506. }
  19507. /// <summary>
  19508. /// 团组相关餐厅信息
  19509. /// Del
  19510. /// </summary>
  19511. /// <param name="dto"></param>
  19512. /// <returns></returns>
  19513. [HttpPost]
  19514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19515. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19516. {
  19517. int userId = dto.DeleteUserId;
  19518. var id = dto.Id;
  19519. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19520. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19521. return Ok(await _restaurantRep.DelAsync(dto));
  19522. }
  19523. #endregion
  19524. // /// <summary>
  19525. // ///
  19526. // /// </summary>
  19527. // /// <param name="_dto"></param>
  19528. // /// <returns></returns>
  19529. // [HttpPost]
  19530. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19531. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19532. // {
  19533. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19534. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19535. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19536. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19537. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19538. // dic_psg.Add("客人", 974);
  19539. // dic_psg.Add("司机", 975);
  19540. // dic_psg.Add("导游", 976);
  19541. // dic_psg.Add("公司内部人员", 977);
  19542. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19543. // foreach (var item in list_visa)
  19544. // {
  19545. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19546. // temp.Id = item.Id;
  19547. // temp.DIId = item.DIId;
  19548. // temp.VisaClient = item.VisaClient;
  19549. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19550. // temp.VisaCurrency = item.VisaCurrency;
  19551. // temp.IsThird = item.IsThird;
  19552. // if (dic_psg.ContainsKey(item.PassengerType))
  19553. // {
  19554. // temp.PassengerType = dic_psg[item.PassengerType];
  19555. // }
  19556. // else {
  19557. // temp.PassengerType = -1;
  19558. // }
  19559. // temp.VisaNumber = item.VisaNumber;
  19560. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19561. // temp.CreateUserId = item.Operators;
  19562. // DateTime dt_ct;
  19563. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19564. // if (b_ct)
  19565. // {
  19566. // temp.CreateTime = dt_ct;
  19567. // }
  19568. // else
  19569. // {
  19570. // temp.CreateTime = DateTime.Now;
  19571. // }
  19572. // temp.DeleteTime = "";
  19573. // temp.DeleteUserId = 0;
  19574. // temp.Remark = item.Remark;
  19575. // if (string.IsNullOrEmpty(temp.Remark)) {
  19576. // temp.Remark = "";
  19577. // }
  19578. // temp.IsDel = item.IsDel;
  19579. // temp.VisaDescription = item.VisaAttachment;
  19580. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19581. //([Id]
  19582. // ,[DIId]
  19583. // ,[VisaClient]
  19584. // ,[VisaPrice]
  19585. // ,[VisaCurrency]
  19586. // ,[IsThird]
  19587. // ,[PassengerType]
  19588. // ,[VisaNumber]
  19589. // ,[VisaFreeNumber]
  19590. // ,[CreateUserId]
  19591. // ,[CreateTime]
  19592. // ,[DeleteTime]
  19593. // ,[DeleteUserId]
  19594. // ,[Remark]
  19595. // ,[IsDel]
  19596. // ,[visaDescription])
  19597. // VALUES
  19598. // ({0},{1},'{2}',{3},{4}
  19599. //,{5},{6},{7},{8},{9}
  19600. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19601. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19602. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19603. //);
  19604. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19605. // }
  19606. // return Ok(JsonView(true, "操作成功!"));
  19607. // }
  19608. /// <summary>
  19609. /// 123132123
  19610. /// </summary>
  19611. /// <param name="_dto"></param>
  19612. /// <returns></returns>
  19613. [HttpPost]
  19614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19615. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19616. {
  19617. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19618. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19619. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19620. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19621. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19622. dicDetail.Add(789, 1034);
  19623. dicDetail.Add(790, 1035);
  19624. dicDetail.Add(791, 1036);
  19625. dicDetail.Add(792, 1037);
  19626. dicDetail.Add(793, 1038);
  19627. dicDetail.Add(794, 1039);
  19628. dicDetail.Add(795, 1040);
  19629. dicDetail.Add(796, 1041);
  19630. dicDetail.Add(797, 1042);
  19631. dicDetail.Add(798, 1043);
  19632. dicDetail.Add(801, 1044);
  19633. dicDetail.Add(802, 1045);
  19634. dicDetail.Add(803, 1046);
  19635. Dictionary<int, int> dic = new Dictionary<int, int>();
  19636. dic.Add(806, 1027);
  19637. dic.Add(807, 1028);
  19638. dic.Add(808, 1029);
  19639. dic.Add(809, 1030);
  19640. dic.Add(810, 1031);
  19641. dic.Add(811, 1032);
  19642. dic.Add(812, 1033);
  19643. foreach (var item in list_visa)
  19644. {
  19645. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19646. temp.Coefficient = item.coefficient;
  19647. DateTime dtCrt;
  19648. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19649. if (b1)
  19650. {
  19651. temp.CreateTime = dtCrt;
  19652. }
  19653. else
  19654. {
  19655. temp.CreateTime = DateTime.Now;
  19656. }
  19657. temp.CreateUserId = item.Operators;
  19658. temp.DeleteTime = "";
  19659. temp.DeleteUserId = 0;
  19660. temp.DiId = int.Parse(item.DIID);
  19661. temp.FilePath = item.FilePath;
  19662. temp.IsDel = item.IsDel;
  19663. temp.Price = item.Price;
  19664. temp.PriceCount = 1;
  19665. temp.PriceCurrency = item.Currency;
  19666. int detailId = 0;
  19667. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19668. {
  19669. detailId = dicDetail[item.PriceTypeDetail];
  19670. }
  19671. temp.PriceDetailType = detailId;
  19672. temp.PriceDt = DateTime.Now;
  19673. temp.PriceName = item.PriceName;
  19674. temp.PriceSum = item.Price;
  19675. int tid = 0;
  19676. if (dic.ContainsKey(item.PriceType))
  19677. {
  19678. tid = dic[item.PriceType];
  19679. }
  19680. temp.PriceType = tid;
  19681. temp.Remark = item.Remark;
  19682. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19683. }
  19684. return Ok(JsonView(true, "操作成功!"));
  19685. }
  19686. [HttpPost]
  19687. public IActionResult TimeTest()
  19688. {
  19689. var jw = JsonView(false, "error");
  19690. _sqlSugar.BeginTran();
  19691. try
  19692. {
  19693. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19694. .Select(x => new Crm_NewClientData
  19695. {
  19696. Id = x.Id,
  19697. Client = x.Client,
  19698. Contact = x.Contact,
  19699. Location = x.Location,
  19700. })
  19701. .ToList();
  19702. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19703. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19704. Stopwatch stopwatch = new Stopwatch();
  19705. // 开始计时
  19706. stopwatch.Start();
  19707. foreach (var item in clientList)
  19708. {
  19709. EncryptionProcessor.DecryptProperties(item);
  19710. }
  19711. stopwatch.Stop();
  19712. jw.Code = 200;
  19713. jw.Data = stopwatch.ElapsedMilliseconds;
  19714. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19715. }
  19716. catch (Exception ex)
  19717. {
  19718. jw.Code = 400;
  19719. jw.Msg = ex.Message;
  19720. }
  19721. return Ok(jw);
  19722. }
  19723. }
  19724. }