GroupsController.cs 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using DiffMatchPatch;
  7. using EyeSoft.Runtime.InteropServices;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.Mvc.RazorPages;
  10. using Microsoft.AspNetCore.SignalR;
  11. using Microsoft.EntityFrameworkCore.Metadata.Internal;
  12. using Microsoft.IdentityModel.Tokens;
  13. using Microsoft.VisualBasic;
  14. using MySqlX.XDevAPI.Relational;
  15. using NetTaste;
  16. using NPOI.HSSF.UserModel;
  17. using NPOI.SS.Formula.Functions;
  18. using NPOI.SS.UserModel;
  19. using NPOI.SS.Util;
  20. using NPOI.XSSF.UserModel;
  21. using OASystem.API.Middlewares;
  22. using OASystem.API.OAMethodLib;
  23. using OASystem.API.OAMethodLib.APNs;
  24. using OASystem.API.OAMethodLib.File;
  25. using OASystem.API.OAMethodLib.Hub.HubClients;
  26. using OASystem.API.OAMethodLib.Hub.Hubs;
  27. using OASystem.API.OAMethodLib.JuHeAPI;
  28. using OASystem.API.OAMethodLib.KiMiApi;
  29. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  30. using OASystem.Domain.AesEncryption;
  31. using OASystem.Domain.Attributes;
  32. using OASystem.Domain.Dtos.CRM;
  33. using OASystem.Domain.Dtos.FileDto;
  34. using OASystem.Domain.Dtos.Financial;
  35. using OASystem.Domain.Dtos.Groups;
  36. using OASystem.Domain.Entities.Customer;
  37. using OASystem.Domain.Entities.Financial;
  38. using OASystem.Domain.Entities.Groups;
  39. using OASystem.Domain.ViewModels.Financial;
  40. using OASystem.Domain.ViewModels.Groups;
  41. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  42. using OASystem.Domain.ViewModels.OCR;
  43. using OASystem.Domain.ViewModels.QiYeWeChat;
  44. using OASystem.Domain.ViewModels.Statistics;
  45. using OASystem.Infrastructure.Repositories.CRM;
  46. using OASystem.Infrastructure.Repositories.Financial;
  47. using OASystem.Infrastructure.Repositories.Groups;
  48. using OASystem.Infrastructure.Tools;
  49. using OASystem.RedisRepository;
  50. using Org.BouncyCastle.Crypto;
  51. using Org.BouncyCastle.Utilities;
  52. using Quartz.Util;
  53. using SqlSugar.Extensions;
  54. using System.Collections;
  55. using System.Collections.Generic;
  56. using System.Data;
  57. using System.Diagnostics;
  58. using System.Drawing.Printing;
  59. using System.Globalization;
  60. using System.IO;
  61. using System.IO.Compression;
  62. using System.Reflection;
  63. using System.Text.Json;
  64. using System.Web;
  65. using System.Xml.Linq;
  66. using TencentCloud.Ocr.V20181119.Models;
  67. using static OASystem.API.OAMethodLib.JWTHelper;
  68. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  69. using Bookmark = Aspose.Words.Bookmark;
  70. using Cell = Aspose.Words.Tables.Cell;
  71. using Table = Aspose.Words.Tables.Table;
  72. namespace OASystem.API.Controllers
  73. {
  74. /// <summary>
  75. /// 团组相关
  76. /// </summary>
  77. //[Authorize]
  78. [Route("api/[controller]/[action]")]
  79. public class GroupsController : ControllerBase
  80. {
  81. private readonly ILogger<GroupsController> _logger;
  82. private readonly GrpScheduleRepository _grpScheduleRep;
  83. private readonly IMapper _mapper;
  84. private readonly DelegationInfoRepository _groupRepository;
  85. private readonly TaskAssignmentRepository _taskAssignmentRep;
  86. private readonly AirTicketResRepository _airTicketResRep;
  87. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  88. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  89. private readonly DelegationEnDataRepository _delegationEnDataRep;
  90. private readonly DelegationVisaRepository _delegationVisaRep;
  91. private readonly VisaPriceRepository _visaPriceRep;
  92. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  93. private readonly HotelPriceRepository _hotelPriceRep;
  94. private readonly CustomersRepository _customersRep;
  95. private readonly MessageRepository _message;
  96. private readonly SqlSugarClient _sqlSugar;
  97. private readonly TourClientListRepository _tourClientListRep;
  98. private readonly TeamRateRepository _teamRateRep;
  99. #region 成本相关
  100. private readonly CheckBoxsRepository _checkBoxs;
  101. private readonly GroupCostRepository _GroupCostRepository;
  102. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  103. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  104. #endregion
  105. private readonly SetDataRepository _setDataRep;
  106. private string url;
  107. private string path;
  108. private readonly EnterExitCostRepository _enterExitCostRep;
  109. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  110. private readonly UsersRepository _usersRep;
  111. private readonly IJuHeApiService _juHeApi;
  112. private readonly InvertedListRepository _invertedListRep;
  113. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  114. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  115. private readonly ThreeCodeRepository _threeCodeRepository;
  116. private readonly HotelInquiryRepository _hotelInquiryRep;
  117. private readonly FeeAuditRepository _feeAuditRep;
  118. private readonly VisaCommissionRepository _visaCommissionRep;
  119. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  120. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  121. private readonly List<CurrencyInfo> _currencyInit;
  122. private readonly List<int> _portTypeData;
  123. private readonly TableOperationRecordRepository _tableorRep;
  124. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  125. private readonly RestaurantRepository _restaurantRep;
  126. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  127. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  128. /// <summary>
  129. /// 构造函数
  130. /// </summary>
  131. /// <param name="logger"></param>
  132. /// <param name="mapper"></param>
  133. /// <param name="hubContext"></param>
  134. /// <param name="sqlSugar"></param>
  135. /// <param name="grpScheduleRep"></param>
  136. /// <param name="groupRepository"></param>
  137. /// <param name="taskAssignmentRep"></param>
  138. /// <param name="airTicketResRep"></param>
  139. /// <param name="decreasePaymentsRep"></param>
  140. /// <param name="InvitationOfficialActivitiesRep"></param>
  141. /// <param name="delegationEnDataRep"></param>
  142. /// <param name="enterExitCostRep"></param>
  143. /// <param name="delegationVisaRep"></param>
  144. /// <param name="message"></param>
  145. /// <param name="visaPriceRep"></param>
  146. /// <param name="carTouristGuideGroundRep"></param>
  147. /// <param name="checkBoxs"></param>
  148. /// <param name="GroupCostRepository"></param>
  149. /// <param name="CostTypeHotelNumberRepository"></param>
  150. /// <param name="GroupCostParameterRepository"></param>
  151. /// <param name="hotelPriceRep"></param>
  152. /// <param name="customersRep"></param>
  153. /// <param name="setDataRep"></param>
  154. /// <param name="tourClientListRep"></param>
  155. /// <param name="teamRateRep"></param>
  156. /// <param name="usersRep"></param>
  157. /// <param name="juHeApi"></param>
  158. /// <param name="invertedListRep"></param>
  159. /// <param name="visaFeeInfoRep"></param>
  160. /// <param name="ticketBlackCodeRep"></param>
  161. /// <param name="hotelInquiryRep"></param>
  162. /// <param name="threeCodeRepository"></param>
  163. /// <param name="feeAuditRep"></param>
  164. /// <param name="visaCommissionRep"></param>
  165. /// <param name="ffrRep"></param>
  166. /// <param name="opinionaireRep"></param>
  167. /// <param name="tableorRep"></param>
  168. /// <param name="enterExitCostDraftRep"></param>
  169. /// <param name="restaurantRep"></param>
  170. /// <param name="enterExitCostQuoteRep"></param>
  171. /// <param name="grpOrderPreInfoRep"></param>
  172. public GroupsController(
  173. ILogger<GroupsController> logger,
  174. IMapper mapper,
  175. IHubContext<ChatHub, IChatClient> hubContext,
  176. SqlSugarClient sqlSugar,
  177. GrpScheduleRepository grpScheduleRep,
  178. DelegationInfoRepository groupRepository,
  179. TaskAssignmentRepository taskAssignmentRep,
  180. AirTicketResRepository airTicketResRep,
  181. DecreasePaymentsRepository decreasePaymentsRep,
  182. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  183. DelegationEnDataRepository delegationEnDataRep,
  184. EnterExitCostRepository enterExitCostRep,
  185. DelegationVisaRepository delegationVisaRep,
  186. MessageRepository message,
  187. VisaPriceRepository visaPriceRep,
  188. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  189. CheckBoxsRepository checkBoxs,
  190. GroupCostRepository GroupCostRepository,
  191. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  192. GroupCostParameterRepository GroupCostParameterRepository,
  193. HotelPriceRepository hotelPriceRep,
  194. CustomersRepository customersRep,
  195. SetDataRepository setDataRep,
  196. TourClientListRepository tourClientListRep,
  197. TeamRateRepository teamRateRep,
  198. UsersRepository usersRep,
  199. IJuHeApiService juHeApi,
  200. InvertedListRepository invertedListRep,
  201. VisaFeeInfoRepository visaFeeInfoRep,
  202. TicketBlackCodeRepository ticketBlackCodeRep,
  203. HotelInquiryRepository hotelInquiryRep,
  204. ThreeCodeRepository threeCodeRepository,
  205. FeeAuditRepository feeAuditRep,
  206. VisaCommissionRepository visaCommissionRep,
  207. ForeignReceivablesRepository ffrRep,
  208. OpinionaireRepository opinionaireRep,
  209. TableOperationRecordRepository tableorRep,
  210. EnterExitCostDraftRepository enterExitCostDraftRep,
  211. RestaurantRepository restaurantRep,
  212. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  213. GroupOrderPreInfoRepository grpOrderPreInfoRep
  214. )
  215. {
  216. _logger = logger;
  217. _mapper = mapper;
  218. _grpScheduleRep = grpScheduleRep;
  219. _groupRepository = groupRepository;
  220. _taskAssignmentRep = taskAssignmentRep;
  221. _airTicketResRep = airTicketResRep;
  222. _sqlSugar = sqlSugar;
  223. url = AppSettingsHelper.Get("ExcelBaseUrl");
  224. path = AppSettingsHelper.Get("ExcelBasePath");
  225. if (!System.IO.Directory.Exists(path))
  226. {
  227. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  228. }
  229. _decreasePaymentsRep = decreasePaymentsRep;
  230. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  231. _delegationEnDataRep = delegationEnDataRep;
  232. _enterExitCostRep = enterExitCostRep;
  233. _delegationVisaRep = delegationVisaRep;
  234. _message = message;
  235. _visaPriceRep = visaPriceRep;
  236. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  237. _checkBoxs = checkBoxs;
  238. _GroupCostRepository = GroupCostRepository;
  239. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  240. _GroupCostParameterRepository = GroupCostParameterRepository;
  241. _hotelPriceRep = hotelPriceRep;
  242. _customersRep = customersRep;
  243. _setDataRep = setDataRep;
  244. _tourClientListRep = tourClientListRep;
  245. _teamRateRep = teamRateRep;
  246. _hubContext = hubContext;
  247. _usersRep = usersRep;
  248. _juHeApi = juHeApi;
  249. _invertedListRep = invertedListRep;
  250. _visaFeeInfoRep = visaFeeInfoRep;
  251. _ticketBlackCodeRep = ticketBlackCodeRep;
  252. _hotelInquiryRep = hotelInquiryRep;
  253. _threeCodeRepository = threeCodeRepository;
  254. _feeAuditRep = feeAuditRep;
  255. _visaCommissionRep = visaCommissionRep;
  256. _ffrRep = ffrRep;
  257. _opinionaireRep = opinionaireRep;
  258. _currencyInit = new List<CurrencyInfo>()
  259. {
  260. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  261. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  262. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  263. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  264. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  265. };
  266. _portTypeData = new List<int>() { 2, 3 };
  267. _tableorRep = tableorRep;
  268. _enterExitCostDraftRep = enterExitCostDraftRep;
  269. _restaurantRep = restaurantRep;
  270. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  271. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  272. }
  273. #region 流程管控
  274. /// <summary>
  275. /// 获取团组流程管控信息
  276. /// </summary>
  277. /// <param name="_jsonDto">查询参数</param>
  278. /// <returns></returns>
  279. [HttpPost]
  280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  281. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  282. {
  283. if (string.IsNullOrEmpty(_jsonDto.Paras))
  284. {
  285. return Ok(JsonView(false, "参数为空"));
  286. }
  287. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  288. if (_ScheduleDto != null)
  289. {
  290. if (_ScheduleDto.SearchType == 2)//获取列表
  291. {
  292. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  293. return Ok(JsonView(_grpScheduleViewList));
  294. }
  295. else//获取对象
  296. {
  297. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  298. if (_grpScheduleView != null)
  299. {
  300. return Ok(JsonView(_grpScheduleView));
  301. }
  302. }
  303. }
  304. else
  305. {
  306. return Ok(JsonView(false, "参数反序列化失败"));
  307. }
  308. return Ok(JsonView(false, "暂无数据!"));
  309. }
  310. /// <summary>
  311. /// 修改团组流程管控详细表数据
  312. /// </summary>
  313. /// <param name="dto"></param>
  314. /// <returns></returns>
  315. [HttpPost]
  316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  317. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  318. {
  319. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  320. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  321. .SetColumns(it => it.Duty == _detail.Duty)
  322. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  323. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  324. .SetColumns(it => it.JobContent == _detail.JobContent)
  325. .SetColumns(it => it.Remark == _detail.Remark)
  326. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  327. .Where(s => s.Id == dto.Id)
  328. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  329. .ExecuteCommandAsync();
  330. if (result > 0)
  331. {
  332. return Ok(JsonView(true, "保存成功!"));
  333. }
  334. return Ok(JsonView(false, "保存失败!"));
  335. }
  336. /// <summary>
  337. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  338. /// </summary>
  339. /// <param name="dto"></param>
  340. /// <returns></returns>
  341. [HttpPost]
  342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  343. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  344. {
  345. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  346. _detail.IsDel = 1;
  347. _detail.DeleteUserId = dto.Duty;
  348. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  349. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  350. .SetColumns(it => it.IsDel == _detail.IsDel)
  351. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  352. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  353. .Where(it => it.Id == dto.Id)
  354. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  355. //.WhereColumns(s => s.Id == dto.Id)
  356. .ExecuteCommandAsync();
  357. if (result > 0)
  358. {
  359. return Ok(JsonView(true, "删除成功!"));
  360. }
  361. return Ok(JsonView(false, "删除失败!"));
  362. }
  363. /// <summary>
  364. /// 增加团组流程管控详细表数据
  365. /// </summary>
  366. /// <param name="dto"></param>
  367. /// <returns></returns>
  368. [HttpPost]
  369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  370. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  371. {
  372. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  373. if (DateTime.Now < _detail.ExpectBeginDt)
  374. {
  375. _detail.StepStatus = 0;
  376. }
  377. else
  378. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  379. _detail.StepStatus = 1;
  380. }
  381. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  382. if (result > 0)
  383. {
  384. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  385. return Ok(JsonView(true, "添加成功!", _result));
  386. }
  387. return Ok(JsonView(false, "添加失败!"));
  388. }
  389. #endregion
  390. #region 团组前期信息
  391. /// <summary>
  392. /// 团组前期信息 List
  393. /// </summary>
  394. /// <returns></returns>
  395. [HttpPost]
  396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  397. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  398. {
  399. var search = dto.Search;
  400. int[] nameTempIds = new int[] { 1, 12, 28 },
  401. countryTempIds = new int[] { 2, 13, 29 },
  402. daysTempIds = new int[] { 4, 15, 31 },
  403. ppNumTempIds = new int[] { 6 };
  404. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  405. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  406. .Where((opi, u) => opi.IsDel == 0)
  407. .OrderByDescending((opi, u) => opi.CreateTime)
  408. .Select((opi, u) => new GroupOrderPreInfoListView()
  409. {
  410. Id = opi.Id,
  411. Name = opi.Name,
  412. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains( x.FormTempId)).Select(x => x.Value),
  413. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  415. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  416. Operator = u.CnName,
  417. OperationTime = opi.CreateTime
  418. })
  419. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  420. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  421. .ToListAsync();
  422. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  423. int total = list.Count;
  424. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  425. var listPageData1 = listPageData
  426. .Skip((dto.PageIndex - 1) * dto.PageSize)
  427. .Take(dto.PageSize)
  428. .ToList();
  429. var infoIds = listPageData1.Select(x => x.Id).ToList();
  430. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  431. .Where(x => x.IsDel == 0 && x.STid == 109)
  432. .ToArrayAsync();
  433. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  434. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  435. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  436. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  437. .ToListAsync();
  438. foreach (var item in listPageData1)
  439. {
  440. var typeDatas1 = typeDatas.Select(x => new
  441. {
  442. Id = x.Id,
  443. Name = x.Name,
  444. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  445. }).ToArray();
  446. item.VersionDetails = typeDatas1;
  447. }
  448. return Ok(JsonView(listPageData1, listPageData1.Count));
  449. }
  450. /// <summary>
  451. /// 团组前期信息 Init
  452. /// </summary>
  453. /// <returns></returns>
  454. [HttpGet("{userId}")]
  455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  456. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  457. {
  458. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  459. }
  460. /// <summary>
  461. /// 国家数据源
  462. /// </summary>
  463. /// <param name="pageIndex">当前页码</param>
  464. /// <param name="pageSize">每页条数</param>
  465. /// <param name="search">查询条件</param>
  466. /// <returns></returns>
  467. [HttpGet]
  468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  469. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  470. {
  471. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  472. if (pageIndex == 0 && pageSize == 0)
  473. {
  474. //所有数据
  475. return Ok(JsonView(countrys, countrys.Count));
  476. }
  477. //分页
  478. int skip = (pageIndex - 1) * pageSize;
  479. int take = pageSize;
  480. if (!string.IsNullOrEmpty(search))
  481. {
  482. IEnumerable<char> charSequence = search.Select(c => c);
  483. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  484. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  485. return Ok(JsonView(pageData, pageResult1.Count));
  486. }
  487. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  488. return Ok(JsonView(pageResult2, countrys.Count));
  489. }
  490. /// <summary>
  491. /// 城市数据源
  492. /// </summary>
  493. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  494. /// <param name="pageIndex">当前页码</param>
  495. /// <param name="pageSize">每页条数</param>
  496. /// <param name="search">查询条件</param>
  497. /// <returns></returns>
  498. [HttpGet("{countryLabel}")]
  499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  500. public async Task<IActionResult> CityByCountry(
  501. string countryLabel,
  502. [FromQuery] int pageIndex,
  503. [FromQuery] int pageSize,
  504. [FromQuery] string search)
  505. {
  506. countryLabel = HttpUtility.UrlDecode(countryLabel);
  507. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  508. var citys = Array.Empty<string?>();
  509. if (countryList.Any())
  510. {
  511. var cityDatas = await _sqlSugar
  512. .Queryable<Grp_NationalTravelFee>()
  513. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  514. .ToArrayAsync();
  515. foreach (var item in cityDatas)
  516. {
  517. if (item.City.Contains("城市"))
  518. {
  519. item.City = item.Country + "-所有城市";
  520. }
  521. }
  522. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  523. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  524. }
  525. if (pageIndex == 0 && pageSize == 0)
  526. {
  527. //所有数据
  528. return Ok(JsonView(citys, citys?.Length ?? 0));
  529. }
  530. //分页
  531. int skip = (pageIndex - 1) * pageSize;
  532. int take = pageSize;
  533. if (!string.IsNullOrEmpty(search))
  534. {
  535. IEnumerable<char> charSequence = search.Select(c => c);
  536. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  537. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  538. return Ok(JsonView(pageData, pageResult1.Count()));
  539. }
  540. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  541. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  542. }
  543. /// <summary>
  544. /// 团组前期信息 Info
  545. /// </summary>
  546. /// <param name="dto">Id</param>
  547. /// <param name="portType">Id</param>
  548. /// <returns></returns>
  549. [HttpGet("{Id}/{TempId}")]
  550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  551. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto,int portType=1)
  552. {
  553. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  554. }
  555. /// <summary>
  556. /// 团组前期信息 移动端 Info
  557. /// </summary>
  558. /// <param name="dto">Id</param>
  559. /// <returns></returns>
  560. [HttpGet("{Id}/{TempId}")]
  561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  562. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  563. {
  564. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  565. }
  566. /// <summary>
  567. /// 团组前期信息 Save
  568. /// </summary>
  569. /// <param name="dto">Id</param>
  570. /// <returns></returns>
  571. [HttpPost]
  572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  573. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  574. {
  575. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  576. }
  577. /// <summary>
  578. /// 团组前期信息 Del
  579. /// </summary>
  580. /// <param name="dto">Id</param>
  581. /// <returns></returns>
  582. [HttpPost]
  583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  584. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  585. {
  586. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  587. }
  588. /// <summary>
  589. /// 团组前期信息 文件下载
  590. /// </summary>
  591. /// <param name="dto">Id</param>
  592. /// <returns></returns>
  593. [HttpGet("{Id}/{TempId}")]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  596. {
  597. int id = dto.Id, tempId = dto.TempId;
  598. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  599. var data = view.Data as GrpOrderPreInfoView;
  600. #region Excel
  601. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  602. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  603. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  604. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  605. var fileNamePrefix = string.Empty;
  606. if (tempId == 1405)
  607. {
  608. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  609. fileNamePrefix = $"{data.Name}_无商邀版";
  610. }
  611. else if (tempId == 1406)
  612. {
  613. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  614. fileNamePrefix = $"{data.Name}_有商邀版";
  615. }
  616. else
  617. {
  618. //tempId == 1404 默认下载
  619. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  620. fileNamePrefix = $"{data.Name}_单接送机";
  621. }
  622. foreach (var item in data.Items)
  623. {
  624. var obj = item.NewValue;
  625. if (obj == null) item.OriginVal = "";
  626. else if (obj.Equals("有") || obj.Equals("无"))
  627. {
  628. item.OriginVal = obj.ToString();
  629. }
  630. else if (obj is object[] objArray)
  631. {
  632. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  633. item.OriginVal = string.Join("、", stringArray);
  634. }
  635. else if (obj is string[] stringArray)
  636. {
  637. item.OriginVal = string.Join("、", stringArray);
  638. }
  639. else if (obj.Equals("-"))
  640. {
  641. item.OriginVal = "";
  642. }
  643. }
  644. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  645. fileName = CommonFun.ValidFileName(fileName);
  646. //载入模板
  647. WorkbookDesigner designer = new WorkbookDesigner();
  648. designer.Workbook = new Workbook(tempPath);
  649. if (tempId == 1406)
  650. {
  651. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  652. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  653. for (int i = 1; i <= view2.Length; i++)
  654. {
  655. view2[i - 1].Index = i;
  656. }
  657. designer.SetDataSource("View1", view1);
  658. designer.SetDataSource("View2", view2);
  659. }
  660. else
  661. {
  662. designer.SetDataSource("View", data.Items);
  663. }
  664. designer.Process();
  665. if (!Directory.Exists(savePath))
  666. {
  667. Directory.CreateDirectory(savePath);
  668. }
  669. string serverPath = $"{savePath}{fileName}";
  670. designer.Workbook.Save(serverPath);
  671. string rst = $"{servicePath}{ftpPath}{fileName}";
  672. #endregion
  673. return Ok(JsonView(new { url = rst }));
  674. }
  675. #endregion
  676. #region 团组基本信息
  677. /// <summary>
  678. /// 接团信息列表
  679. /// </summary>
  680. /// <param name="dto">团组列表请求dto</param>
  681. /// <returns></returns>
  682. [HttpPost]
  683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  684. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  685. {
  686. var groupData = await _groupRepository.GetGroupList(dto);
  687. if (groupData.Code != 0)
  688. {
  689. return Ok(JsonView(false, groupData.Msg));
  690. }
  691. return Ok(JsonView(groupData.Data));
  692. }
  693. /// <summary>
  694. /// 分页查询团组列表
  695. /// </summary>
  696. /// <param name="dto"></param>
  697. /// <returns></returns>
  698. [HttpPost]
  699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  700. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  701. {
  702. var watch = new Stopwatch();
  703. watch.Start();
  704. RefAsync<int> total = 0;
  705. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  706. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  707. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  708. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  709. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  710. .Distinct()
  711. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  712. watch.Stop();
  713. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  714. }
  715. /// <summary>
  716. /// 接团信息列表 Page Init
  717. /// </summary>
  718. /// <returns></returns>
  719. [HttpPost]
  720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  721. public async Task<IActionResult> PostGroupPageListInit()
  722. {
  723. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  724. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  725. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  726. var _view = new
  727. {
  728. depData = depDatas,
  729. rankData = rankDatas
  730. };
  731. return Ok(JsonView(true, "查询成功!", _view));
  732. }
  733. /// <summary>
  734. /// 接团信息列表 Page
  735. /// </summary>
  736. /// <param name="dto">团组列表请求dto</param>
  737. /// <returns></returns>
  738. [HttpPost]
  739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  740. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  741. {
  742. #region 参数验证
  743. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  744. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  745. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  746. #region 页面操作权限验证
  747. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  748. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  749. #endregion
  750. #endregion
  751. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  752. {
  753. string sqlWhere = string.Empty;
  754. if (dto.IsSure == 0) //未完成
  755. {
  756. sqlWhere += string.Format(@" And IsSure = 0");
  757. }
  758. else if (dto.IsSure == 1) //已完成
  759. {
  760. sqlWhere += string.Format(@" And IsSure = 1");
  761. }
  762. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  763. {
  764. string tj = dto.SearchCriteria;
  765. 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}%')",
  766. tj, tj, tj, tj, tj);
  767. }
  768. if (int.TryParse(dto.Rank, out int rankId))
  769. {
  770. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  771. }
  772. string sqlWhere1 = string.Empty;
  773. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  774. {
  775. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  776. }
  777. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  778. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  779. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  780. JietuanOperator,IsSure,CreateTime,IsBid
  781. From (
  782. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  783. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  784. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  785. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  786. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  787. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  788. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  789. From Grp_DelegationInfo gdi
  790. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  791. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  792. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  793. Where gdi.IsDel = 0 {0}
  794. ) temp {1}", sqlWhere, sqlWhere1);
  795. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  796. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  797. var _view = new
  798. {
  799. PageFuncAuth = pageFunAuthView,
  800. Data = _DelegationList
  801. };
  802. return Ok(JsonView(true, "查询成功!", _view, total));
  803. }
  804. else
  805. {
  806. return Ok(JsonView(false, "查询失败"));
  807. }
  808. }
  809. /// <summary>
  810. /// 团组列表
  811. /// </summary>
  812. /// <returns></returns>
  813. [HttpPost]
  814. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  815. {
  816. #region 参数验证
  817. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  818. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  819. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  820. #region 页面操作权限验证
  821. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  822. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  823. #endregion
  824. #endregion
  825. if (dto.PortType != 1 && dto.PortType != 2)
  826. {
  827. return Ok(JsonView(false, "查询失败!"));
  828. }
  829. string orderbyStr = "order by gdi.CreateTime Desc";
  830. string sqlWhere = string.Empty;
  831. if (dto.IsSure == 0) //未完成
  832. {
  833. sqlWhere += string.Format(@" And IsSure = 0");
  834. }
  835. else if (dto.IsSure == 1) //已完成
  836. {
  837. sqlWhere += string.Format(@" And IsSure = 1");
  838. }
  839. //团组类型
  840. if (dto.TeamDid > 0)
  841. {
  842. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  843. }
  844. //团组名称
  845. if (!string.IsNullOrEmpty(dto.TeamName))
  846. {
  847. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  848. }
  849. //客户名称
  850. if (!string.IsNullOrEmpty(dto.ClientName))
  851. {
  852. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  853. }
  854. //客户单位
  855. if (!string.IsNullOrEmpty(dto.ClientUnit))
  856. {
  857. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  858. }
  859. //出访时间
  860. if (!string.IsNullOrEmpty(dto.visitDataTime))
  861. {
  862. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  863. orderbyStr = "order by gdi.VisitDate";
  864. }
  865. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  866. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  867. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  868. JietuanOperator,IsSure,CreateTime
  869. From (
  870. Select row_number() over({0}) as Row_Number,
  871. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  872. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  873. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  874. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  875. From Grp_DelegationInfo gdi
  876. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  877. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  878. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  879. Where gdi.IsDel = 0 {1}
  880. ) temp ", orderbyStr, sqlWhere);
  881. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  882. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  883. #region 处理所属部门
  884. /*
  885. * 1.sq 和 gyy 等显示 市场部
  886. * 2.王鸽和主管及张总还有管理员号统一国交部
  887. * 2-1. 4 管理员 ,21 张海麟
  888. */
  889. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  890. List<int> userIds1 = new List<int>() { 4, 21 };
  891. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  892. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  893. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  894. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  895. .ToList();
  896. foreach (var item in _DelegationList)
  897. {
  898. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  899. }
  900. #endregion
  901. var _view = new
  902. {
  903. PageFuncAuth = pageFunAuthView,
  904. Data = _DelegationList
  905. };
  906. return Ok(JsonView(true, "查询成功!", _view, total));
  907. }
  908. /// <summary>
  909. /// 接团信息详情
  910. /// </summary>
  911. /// <param name="dto">团组info请求dto</param>
  912. /// <returns></returns>
  913. [HttpPost]
  914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  915. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  916. {
  917. var groupData = await _groupRepository.GetGroupInfo(dto);
  918. if (groupData.Code != 0)
  919. {
  920. return Ok(JsonView(false, groupData.Msg));
  921. }
  922. return Ok(JsonView(groupData.Data));
  923. }
  924. /// <summary>
  925. /// 接团信息 编辑添加
  926. /// 基础信息数据源
  927. /// </summary>
  928. /// <param name="dto"></param>
  929. /// <returns></returns>
  930. [HttpPost]
  931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  932. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  933. {
  934. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  935. if (groupData.Code != 0)
  936. {
  937. return Ok(JsonView(false, groupData.Msg));
  938. }
  939. return Ok(JsonView(groupData.Data));
  940. }
  941. /// <summary>
  942. /// 成本修改团组信息
  943. /// </summary>
  944. /// <param name="dto"></param>
  945. /// <returns></returns>
  946. [HttpPost]
  947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  948. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  949. {
  950. var jw = JsonView(false, "操作失败");
  951. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  952. if (di == null)
  953. {
  954. jw.Msg = "参数有误!";
  955. return Ok(jw);
  956. }
  957. #region 添加出访起止时间
  958. var startTime = new DateTime();
  959. var endTime = new DateTime();
  960. if (DateTime.TryParse(dto.VisitDate, out startTime))
  961. {
  962. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  963. }
  964. else
  965. {
  966. jw.Msg = "参数有误!";
  967. return Ok(jw);
  968. }
  969. #endregion
  970. di.VisitDate = startTime;
  971. di.VisitPNumber = dto.VisitPNumber;
  972. di.VisitDays = dto.VisitDays;
  973. di.VisitStartDate = startTime;
  974. di.VisitEndDate = endTime;
  975. var count = _sqlSugar.Updateable(di)
  976. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays , x.VisitStartDate, x.VisitEndDate })
  977. .ExecuteCommand();
  978. return Ok( count > 0 ? JsonView(true, "操作成功") : jw);
  979. }
  980. /// <summary>
  981. /// 接团信息 编辑添加
  982. /// 省份-城市 基础信息数据源
  983. /// </summary>
  984. /// <param name="dto"></param>
  985. /// <returns></returns>
  986. [HttpPost]
  987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  988. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  989. {
  990. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  991. string search = dto.Search;
  992. var data = await _groupRepository.CityBasicSource();
  993. int total = data.Length;
  994. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  995. .Skip((pageIndex - 1) * pageSize)
  996. .Take(pageSize)
  997. .ToArray();
  998. return Ok(JsonView(data, total));
  999. }
  1000. /// <summary>
  1001. /// 接团信息 操作(增改)
  1002. /// </summary>
  1003. /// <param name="dto"></param>
  1004. /// <returns></returns>
  1005. [HttpPost]
  1006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1007. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1008. {
  1009. // 创建 Stopwatch 实例
  1010. Stopwatch stopwatch = Stopwatch.StartNew();
  1011. decimal ffrPrice = 0.00M;
  1012. DateTime? visitDt = null;
  1013. if (dto.Status == 2)
  1014. {
  1015. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1016. if (groupInfo != null)
  1017. {
  1018. ffrPrice = groupInfo.PaymentMoney;
  1019. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1020. }
  1021. }
  1022. var groupData = await _groupRepository.GroupOperation(dto);
  1023. if (groupData.Code != 0)
  1024. {
  1025. return Ok(JsonView(false, groupData.Msg));
  1026. }
  1027. int diId = 0;
  1028. try
  1029. {
  1030. //添加时 默认加入团组汇率
  1031. if (dto.Status == 1) //添加
  1032. {
  1033. diId = groupData.Data;
  1034. //添加默认币种
  1035. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1036. //默认分配权限
  1037. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1038. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1039. var _managerIds = new List<int>() { 22, 32, 21 };
  1040. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1041. if (userIds.Count > 0)
  1042. {
  1043. userIds.Add(208);
  1044. //创建团组管控
  1045. GroupStepForDelegation.CreateWorkStep(diId);
  1046. //发送消息
  1047. string groupName = dto.TeamName;
  1048. string createGroupUser = string.Empty;
  1049. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1050. if (userInfo != null) createGroupUser = userInfo.CnName;
  1051. string title = $"系统通知";
  1052. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1053. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1054. }
  1055. //默认创建倒推表
  1056. await _invertedListRep._Create(dto.UserId, diId);
  1057. }
  1058. else if (dto.Status == 2)
  1059. {
  1060. diId = dto.Id;
  1061. }
  1062. #region 签证人员团组时间通知
  1063. #region 计算出访起止时间
  1064. var startTime = new DateTime();
  1065. var endTime = new DateTime();
  1066. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1067. {
  1068. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1069. }
  1070. #endregion
  1071. #endregion
  1072. #region 团组操作默认添加/修改收款账单
  1073. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1074. {
  1075. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1076. .Where(x => x.IsDel == 0 &&
  1077. x.Diid == diId &&
  1078. x.Remark.Equals("预付款")
  1079. )
  1080. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1081. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1082. .FirstAsync();
  1083. ffrInfo = new Fin_ForeignReceivables()
  1084. {
  1085. Diid = diId,
  1086. PriceName = dto.ClientUnit,
  1087. Price = dto.PaymentMoney,
  1088. Count = 1,
  1089. Unit = $"元",
  1090. ItemSumPrice = dto.PaymentMoney,
  1091. Rate = 1.0000M,
  1092. Currency = 836,
  1093. AddingWay = 0,
  1094. CreateUserId = dto.UserId,
  1095. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1096. Remark = $"预付款"
  1097. };
  1098. if (ffrInfo == null) //Add
  1099. {
  1100. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1101. }
  1102. else //修改
  1103. {
  1104. await _sqlSugar.Updateable(ffrInfo)
  1105. .UpdateColumns(x => new
  1106. {
  1107. x.PriceName,
  1108. x.Price,
  1109. x.ItemSumPrice,
  1110. x.CreateTime,
  1111. x.CreateUserId
  1112. })
  1113. .WhereColumns(x => x.Id)
  1114. .ExecuteCommandAsync();
  1115. }
  1116. }
  1117. #endregion
  1118. if (diId > 0)
  1119. {
  1120. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1121. }
  1122. // 停止计时
  1123. stopwatch.Stop();
  1124. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1125. }
  1126. catch (Exception ex)
  1127. {
  1128. // 停止计时
  1129. stopwatch.Stop();
  1130. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1131. Logs(ex.Message);
  1132. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1133. }
  1134. // 停止计时
  1135. stopwatch.Stop();
  1136. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1137. }
  1138. /// <summary>
  1139. /// 接团流程操作(增改)
  1140. /// 安卓端使用 建团时添加客户名单
  1141. /// </summary>
  1142. /// <param name="dto"></param>
  1143. /// <returns></returns>
  1144. [HttpPost]
  1145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1146. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1147. {
  1148. #region 参数验证
  1149. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1151. #region 页面操作权限验证
  1152. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1153. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1154. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1155. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1156. #endregion
  1157. #endregion
  1158. try
  1159. {
  1160. //_sqlSugar.BeginTran();
  1161. decimal ffrPrice = 0.00M;
  1162. DateTime? visitDt = null;
  1163. if (dto.Status == 2)
  1164. {
  1165. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1166. if (groupInfo != null)
  1167. {
  1168. ffrPrice = groupInfo.PaymentMoney;
  1169. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1170. }
  1171. }
  1172. var _dto = new GroupOperationDto();
  1173. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1174. var groupData = await _groupRepository.GroupOperation(_dto);
  1175. if (groupData.Code != 0)
  1176. {
  1177. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1178. }
  1179. int diId = 0;
  1180. //添加时 默认加入团组汇率
  1181. if (dto.Status == 1) //添加
  1182. {
  1183. diId = groupData.Data;
  1184. //添加默认币种
  1185. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1186. //默认分配权限
  1187. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1188. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1189. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1190. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1191. if (userIds.Count > 0)
  1192. {
  1193. userIds.Add(208);
  1194. //创建团组管控
  1195. GroupStepForDelegation.CreateWorkStep(diId);
  1196. //发送消息
  1197. string groupName = dto.TeamName;
  1198. string createGroupUser = string.Empty;
  1199. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1200. if (userInfo != null) createGroupUser = userInfo.CnName;
  1201. string title = $"系统通知";
  1202. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1203. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1204. }
  1205. #region 应用推送
  1206. try
  1207. {
  1208. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1209. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1210. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1211. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1212. {
  1213. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1214. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1215. }
  1216. }
  1217. catch (Exception ex)
  1218. {
  1219. }
  1220. #endregion
  1221. //默认创建倒推表
  1222. await _invertedListRep._Create(dto.UserId, diId);
  1223. }
  1224. if (dto.Status == 2)
  1225. {
  1226. diId = dto.Id;
  1227. if (diId == 0)
  1228. {
  1229. //_sqlSugar.RollbackTran();
  1230. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1231. }
  1232. }
  1233. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1234. if (viewData.Code != 0)
  1235. {
  1236. //_sqlSugar.RollbackTran();
  1237. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1238. }
  1239. #region 团组操作默认添加/修改收款账单
  1240. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1241. {
  1242. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1243. .Where(x => x.IsDel == 0 &&
  1244. x.Diid == diId &&
  1245. x.Remark.Equals("预付款")
  1246. )
  1247. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1248. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1249. .FirstAsync();
  1250. ffrInfo = new Fin_ForeignReceivables()
  1251. {
  1252. Diid = diId,
  1253. PriceName = dto.ClientUnit,
  1254. Price = dto.PaymentMoney,
  1255. Count = 1,
  1256. Unit = $"元",
  1257. ItemSumPrice = dto.PaymentMoney,
  1258. Rate = 1.0000M,
  1259. Currency = 836,
  1260. AddingWay = 0,
  1261. CreateUserId = dto.UserId,
  1262. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1263. Remark = $"预付款"
  1264. };
  1265. if (ffrInfo == null) //Add
  1266. {
  1267. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1268. }
  1269. else //修改
  1270. {
  1271. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1272. .UpdateColumns(x => new
  1273. {
  1274. x.PriceName,
  1275. x.Price,
  1276. x.ItemSumPrice,
  1277. x.CreateTime,
  1278. x.CreateUserId
  1279. })
  1280. .WhereColumns(x => x.Id)
  1281. .ExecuteCommandAsync();
  1282. }
  1283. }
  1284. #endregion
  1285. #region 签证人员团组时间通知
  1286. #region 计算出访起止时间
  1287. var startTime = new DateTime();
  1288. var endTime = new DateTime();
  1289. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1290. {
  1291. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1292. }
  1293. #endregion
  1294. if (diId > 0)
  1295. {
  1296. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1297. }
  1298. #endregion
  1299. //_sqlSugar.CommitTran();
  1300. return Ok(JsonView(true, "添加成功"));
  1301. }
  1302. catch (Exception ex)
  1303. {
  1304. _sqlSugar.RollbackTran();
  1305. return Ok(JsonView(false, ex.Message));
  1306. }
  1307. }
  1308. /// <summary>
  1309. /// 接团流程操作(增改)
  1310. /// 安卓端使用 建团时添加客户名单
  1311. /// </summary>
  1312. /// <param name="dto"></param>
  1313. /// <returns></returns>
  1314. [HttpPost]
  1315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1316. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1317. {
  1318. #region 参数验证
  1319. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1320. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1321. #region 页面操作权限验证
  1322. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1323. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1324. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1325. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1326. #endregion
  1327. #endregion
  1328. _sqlSugar.BeginTran();
  1329. decimal ffrPrice = 0.00M;
  1330. DateTime? visitDt = null;
  1331. if (dto.Status == 2)
  1332. {
  1333. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1334. if (groupInfo != null)
  1335. {
  1336. ffrPrice = groupInfo.PaymentMoney;
  1337. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1338. }
  1339. }
  1340. var _dto = new GroupOperationDto();
  1341. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1342. var groupData = await _groupRepository.GroupOperation(_dto);
  1343. if (groupData.Code != 0)
  1344. {
  1345. _sqlSugar.RollbackTran();
  1346. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1347. }
  1348. try
  1349. {
  1350. int diId = 0;
  1351. //添加时 默认加入团组汇率
  1352. if (dto.Status == 1) //添加
  1353. {
  1354. diId = groupData.Data;
  1355. //添加默认币种
  1356. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1357. //默认分配权限
  1358. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1359. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1360. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1361. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1362. if (userIds.Count > 0)
  1363. {
  1364. userIds.Add(208);
  1365. //创建团组管控
  1366. GroupStepForDelegation.CreateWorkStep(diId);
  1367. //发送消息
  1368. string groupName = dto.TeamName;
  1369. string createGroupUser = string.Empty;
  1370. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1371. if (userInfo != null) createGroupUser = userInfo.CnName;
  1372. string title = $"系统通知";
  1373. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1374. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1375. }
  1376. #region 应用推送
  1377. try
  1378. {
  1379. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1380. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1381. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1382. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1383. {
  1384. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1385. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1386. }
  1387. }
  1388. catch (Exception ex)
  1389. {
  1390. _sqlSugar.CommitTran();
  1391. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1392. }
  1393. #endregion
  1394. //默认创建倒推表
  1395. await _invertedListRep._Create(dto.UserId, diId);
  1396. }
  1397. else if (dto.Status == 2)
  1398. {
  1399. diId = dto.Id;
  1400. if (diId == 0)
  1401. {
  1402. _sqlSugar.RollbackTran();
  1403. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1404. }
  1405. }
  1406. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1407. if (viewData.Code != 0)
  1408. {
  1409. _sqlSugar.RollbackTran();
  1410. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1411. }
  1412. #region 团组操作默认添加/修改收款账单
  1413. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1414. {
  1415. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1416. .Where(x => x.IsDel == 0 &&
  1417. x.Diid == diId &&
  1418. x.Remark.Equals("预付款")
  1419. )
  1420. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1421. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1422. .FirstAsync();
  1423. ffrInfo = new Fin_ForeignReceivables()
  1424. {
  1425. Diid = diId,
  1426. PriceName = dto.ClientUnit,
  1427. Price = dto.PaymentMoney,
  1428. Count = 1,
  1429. Unit = $"元",
  1430. ItemSumPrice = dto.PaymentMoney,
  1431. Rate = 1.0000M,
  1432. Currency = 836,
  1433. AddingWay = 0,
  1434. CreateUserId = dto.UserId,
  1435. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1436. Remark = $"预付款"
  1437. };
  1438. if (ffrInfo == null) //Add
  1439. {
  1440. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1441. }
  1442. else //修改
  1443. {
  1444. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1445. .UpdateColumns(x => new
  1446. {
  1447. x.PriceName,
  1448. x.Price,
  1449. x.ItemSumPrice,
  1450. x.CreateTime,
  1451. x.CreateUserId
  1452. })
  1453. .WhereColumns(x => x.Id)
  1454. .ExecuteCommandAsync();
  1455. }
  1456. }
  1457. #endregion
  1458. #region 签证人员团组时间通知
  1459. #region 计算出访起止时间
  1460. var startTime = new DateTime();
  1461. var endTime = new DateTime();
  1462. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1463. {
  1464. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1465. }
  1466. #endregion
  1467. if (diId > 0)
  1468. {
  1469. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1470. }
  1471. #endregion
  1472. _sqlSugar.CommitTran();
  1473. return Ok(JsonView(true));
  1474. }
  1475. catch (Exception ex)
  1476. {
  1477. _sqlSugar.RollbackTran();
  1478. return Ok(JsonView(false, ex.Message));
  1479. }
  1480. }
  1481. /// <summary>
  1482. /// 接团信息 操作(删除)
  1483. /// </summary>
  1484. /// <param name="dto"></param>
  1485. /// <returns></returns>
  1486. [HttpPost]
  1487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1488. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1489. {
  1490. var diId = dto.Id;
  1491. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1492. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1493. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1494. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1495. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1496. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1497. #endregion
  1498. var groupData = await _groupRepository.GroupDel(dto);
  1499. if (groupData.Code != 0)
  1500. {
  1501. return Ok(JsonView(false, groupData.Msg));
  1502. }
  1503. return Ok(JsonView(true));
  1504. }
  1505. /// <summary>
  1506. /// 获取团组销售报价号
  1507. /// 团组添加时 使用
  1508. /// </summary>
  1509. /// <returns></returns>
  1510. [HttpPost]
  1511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1512. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1513. {
  1514. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1515. if (groupData.Code != 0)
  1516. {
  1517. return Ok(JsonView(false, groupData.Msg));
  1518. }
  1519. object salesQuoteNo = new
  1520. {
  1521. SalesQuoteNo = groupData.Data
  1522. };
  1523. return Ok(JsonView(salesQuoteNo));
  1524. }
  1525. /// <summary>
  1526. /// 设置确认出团
  1527. /// </summary>
  1528. /// <param name="dto"></param>
  1529. /// <returns></returns>
  1530. [HttpPost]
  1531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1532. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1533. {
  1534. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1535. if (groupData.Code != 0)
  1536. {
  1537. return Ok(JsonView(false, groupData.Msg));
  1538. }
  1539. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1540. #region OA消息推送
  1541. try
  1542. {
  1543. string groupName = groupInfo.TeamName;
  1544. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1545. string title = $"系统通知";
  1546. string content = $"团组[{groupName}]已确认出团!";
  1547. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1548. }
  1549. catch (Exception ex)
  1550. {
  1551. }
  1552. #endregion
  1553. #region 应用推送
  1554. try
  1555. {
  1556. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1557. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1558. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1559. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1560. {
  1561. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1562. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1563. }
  1564. }
  1565. catch (Exception ex)
  1566. {
  1567. }
  1568. #endregion
  1569. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1570. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1571. }
  1572. /// <summary>
  1573. /// 获取团组名称data And 签证国别Data
  1574. /// </summary>
  1575. /// <param name="dto"></param>
  1576. /// <returns></returns>
  1577. [HttpPost]
  1578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1579. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1580. {
  1581. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1582. if (groupData.Code != 0)
  1583. {
  1584. return Ok(JsonView(false, groupData.Msg));
  1585. }
  1586. return Ok(JsonView(groupData.Data));
  1587. }
  1588. /// <summary>
  1589. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1590. /// </summary>
  1591. /// <returns></returns>
  1592. [HttpPost]
  1593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1594. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1595. {
  1596. try
  1597. {
  1598. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1599. if (groupData.Code != 0)
  1600. {
  1601. return Ok(JsonView(false, groupData.Msg));
  1602. }
  1603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1604. }
  1605. catch (Exception ex)
  1606. {
  1607. return Ok(JsonView(false, "程序错误!"));
  1608. throw;
  1609. }
  1610. }
  1611. /// <summary>
  1612. /// 团组清单 Excel
  1613. /// </summary>
  1614. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1615. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1616. /// <returns></returns>
  1617. [HttpGet]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1620. {
  1621. DateTime _beginDt, _endDt;
  1622. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1623. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1624. if (!beginBool && !endBool)
  1625. {
  1626. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1627. }
  1628. string sql = string.Format(@"
  1629. SELECT
  1630. ROW_NUMBER,
  1631. Id,
  1632. SalesQuoteNo,
  1633. TourCode,
  1634. TeamTypeId,
  1635. TeamType,
  1636. TeamLevId,
  1637. TeamLev,
  1638. TeamName,
  1639. ClientName,
  1640. ClientUnit,
  1641. VisitDate,
  1642. VisitDays,
  1643. VisitPNumber,
  1644. JietuanOperatorId,
  1645. JietuanOperator,
  1646. IsSure,
  1647. CreateUserName,
  1648. IsBid
  1649. FROM
  1650. (
  1651. SELECT
  1652. ROW_NUMBER() OVER(
  1653. ORDER BY
  1654. gdi.VisitDate Desc
  1655. ) AS ROW_NUMBER,
  1656. gdi.Id,
  1657. SalesQuoteNo,
  1658. TourCode,
  1659. ssd.Id TeamTypeId,
  1660. ssd.Name TeamType,
  1661. ssd1.Id TeamLevId,
  1662. ssd1.Name TeamLev,
  1663. TeamName,
  1664. ClientName,
  1665. ClientUnit,
  1666. VisitDate,
  1667. VisitDays,
  1668. VisitPNumber,
  1669. JietuanOperator JietuanOperatorId,
  1670. su.CnName JietuanOperator,
  1671. IsSure,
  1672. gdi.CreateTime,
  1673. su1.CnName As CreateUserName,
  1674. gdi.IsBid
  1675. FROM
  1676. Grp_DelegationInfo gdi
  1677. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1678. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1679. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1680. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1681. WHERE
  1682. gdi.IsDel = 0
  1683. AND gdi.IsBid = 0
  1684. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1685. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1686. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1687. #region 处理所属部门
  1688. /*
  1689. * 1.sq 和 gyy 等显示 市场部
  1690. * 2.王鸽和主管及张总还有管理员号统一国交部
  1691. * 2-1. 4 管理员 ,21 张海麟
  1692. */
  1693. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1694. List<int> userIds1 = new List<int>() { 4, 21 };
  1695. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1696. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1697. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1698. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1699. .ToListAsync();
  1700. var droupIds = groupList.Select(it => it.Id).ToList();
  1701. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1702. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1703. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1704. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1705. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1706. {
  1707. DiId = tcl.DiId,
  1708. LastName = dc.LastName,
  1709. FirstName = dc.FirstName,
  1710. Sex = dc.Sex,
  1711. Birthday = dc.BirthDay,
  1712. Company = cc.CompanyFullName,
  1713. Job = dc.Job,
  1714. CreateTime = tcl.CreateTime,
  1715. })
  1716. .ToList();
  1717. foreach (var item in groupList)
  1718. {
  1719. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1720. string groupFirstName = "";
  1721. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1722. if (currDatas.Any())
  1723. {
  1724. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1725. }
  1726. item.GroupFirst = groupFirstName;
  1727. }
  1728. #endregion
  1729. #region Excel
  1730. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1731. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1732. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1733. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1734. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1735. //载入模板
  1736. WorkbookDesigner designer = new WorkbookDesigner();
  1737. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1738. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1739. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1740. dt.TableName = "GroupList";
  1741. designer.SetDataSource(dt);
  1742. designer.Process();
  1743. if (!Directory.Exists(savePath))
  1744. {
  1745. Directory.CreateDirectory(savePath);
  1746. }
  1747. string serverPath = $"{savePath}{fileName}";
  1748. designer.Workbook.Save(serverPath);
  1749. string rst = $"{servicePath}{ftpPath}{fileName}";
  1750. #endregion
  1751. return Ok(JsonView(true, "操作成功!", rst));
  1752. }
  1753. /// <summary>
  1754. /// 团组合同下载(1.付款80% 2.付全款)
  1755. /// </summary>
  1756. /// <param name="dto"></param>
  1757. /// <returns></returns>
  1758. /// <exception cref="Exception"></exception>
  1759. [HttpPost]
  1760. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1761. {
  1762. var jw = JsonView(false);
  1763. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1764. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1765. if (di == null)
  1766. {
  1767. jw.Msg = "团组Id有误!";
  1768. return Ok(jw);
  1769. }
  1770. #region 权限校验
  1771. var allDownFile = new List<int>() { 21 };
  1772. try
  1773. {
  1774. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1775. .First(x => x.Id == 1418 && x.IsDel == 0);
  1776. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1777. }
  1778. catch (Exception)
  1779. { }
  1780. var guojiaoDownFile = new List<int>() { 330 };
  1781. var shichangDownFile = new List<int>() { 95 };
  1782. if (allDownFile.Contains(dto.UserId))
  1783. {
  1784. }
  1785. else if (guojiaoDownFile.Contains(dto.UserId))
  1786. {
  1787. var guojiaobuDi = new List<int>() { 4, 21 };
  1788. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1789. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1790. .Where((d, u) => u.Id == di.JietuanOperator)
  1791. .Select((d, u) => d.DepName)
  1792. .First();
  1793. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1794. {
  1795. jw.Msg = "暂无下载权限!";
  1796. return Ok(jw);
  1797. }
  1798. }
  1799. else if (shichangDownFile.Contains(dto.UserId))
  1800. {
  1801. var dic = new Dictionary<int, int[]>()
  1802. {
  1803. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1804. };
  1805. try
  1806. {
  1807. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1808. if (sqSetting != null)
  1809. {
  1810. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1811. foreach (var item in result.Keys)
  1812. {
  1813. if (dic.Keys.Contains(item))
  1814. {
  1815. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1816. Array.Copy(dic[item], dilatation, dic[item].Length);
  1817. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1818. dic[item] = dilatation;
  1819. }
  1820. else
  1821. {
  1822. dic.Add(item, result[item]);
  1823. }
  1824. }
  1825. }
  1826. if (!dic[95].Contains(di.CreateUserId))
  1827. {
  1828. jw.Msg = "暂无下载权限!";
  1829. return Ok(jw);
  1830. }
  1831. }
  1832. catch (Exception)
  1833. { }
  1834. }
  1835. else if (dto.UserId == di.CreateUserId)
  1836. {
  1837. }
  1838. else
  1839. {
  1840. jw.Msg = "暂无下载权限!";
  1841. return Ok(jw);
  1842. }
  1843. #endregion
  1844. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1845. .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
  1846. .ToListAsync();
  1847. if (!blackCodeList.Any())
  1848. {
  1849. jw.Msg = "该团无机票行程代码!";
  1850. return Ok(jw);
  1851. }
  1852. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1853. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1854. if (groupEnterExitCost == null)
  1855. {
  1856. jw.Msg = "暂无三公费用信息!";
  1857. return Ok(jw);
  1858. }
  1859. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1860. rateList ??= new List<CurrencyInfo>();
  1861. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1862. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1863. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1864. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1865. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1866. .Select((x, a, b) => new
  1867. {
  1868. x.Index,
  1869. itemName = a.Name,
  1870. CurrencyStr = b.Name,
  1871. x.Cost,
  1872. x.SubTotal,
  1873. x.Remark
  1874. })
  1875. .OrderBy((x) => x.Index)
  1876. .ToList();
  1877. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1878. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1879. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1880. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1881. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1882. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1883. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1884. decimal subJJC = 0.00M,
  1885. subGWC = 0.00M,
  1886. subTDC = 0.00M;
  1887. //经济舱
  1888. if (groupEnterExitCost.SumJJC == 1)
  1889. {
  1890. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1891. }
  1892. //公务舱
  1893. if (groupEnterExitCost.SumGWC == 1)
  1894. {
  1895. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1896. }
  1897. //头等舱
  1898. if (groupEnterExitCost.SumTDC == 1)
  1899. {
  1900. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1901. }
  1902. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1903. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1904. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1905. .LeftJoin<Crm_CustomerCompany>((x, s, dc,cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1906. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1907. .Select((x, s, dc, cc) => new groupClints
  1908. {
  1909. Id =x.Id,
  1910. Name =s.Name,
  1911. IsAccompany =x.IsAccompany,
  1912. CompanyFullName =cc.CompanyFullName
  1913. })
  1914. .ToListAsync();
  1915. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1916. //获取舱位人数
  1917. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1918. .GroupBy(x => x.Name)
  1919. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1920. .ToList();
  1921. string cityPath = string.Empty;
  1922. string startCity = string.Empty;
  1923. string endCity = string.Empty;
  1924. foreach (var item in blackCodeList)
  1925. {
  1926. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1927. cityPath += city + "\r\n";
  1928. if (item.Equals(blackCodeList.First()))
  1929. {
  1930. var sp = city.Split('-');
  1931. startCity = sp[0];
  1932. endCity = sp[sp.Length - 1];
  1933. }
  1934. }
  1935. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1936. bookMarkDic.Add("ClientUnit",di.ClientUnit);
  1937. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1938. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1939. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1940. bookMarkDic.Add("CityPath", cityPath);
  1941. bookMarkDic.Add("StartCity", startCity);
  1942. bookMarkDic.Add("EndCity", endCity);
  1943. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
  1944. Document doc = null;
  1945. var percentage = 0.8M;
  1946. var fileNameadd = "预付";
  1947. if (dto.FileType == 1)
  1948. {
  1949. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1950. }
  1951. else if (dto.FileType == 2)
  1952. {
  1953. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1954. percentage = 1;
  1955. fileNameadd = "全款";
  1956. }
  1957. else
  1958. {
  1959. throw new Exception("FileType有误!");
  1960. }
  1961. DocumentBuilder builder = new DocumentBuilder(doc);
  1962. decimal totalPrice = 0.00M;
  1963. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1964. if (firstTable != null)
  1965. {
  1966. // 遍历表格的行和单元格
  1967. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1968. {
  1969. for (int i = 0; i < row.Cells.Count; i++)
  1970. {
  1971. var cell = row.Cells[i];
  1972. // 读取单元格内容
  1973. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  1974. if (cellTextFirst.Contains("舱位"))
  1975. {
  1976. break;
  1977. }
  1978. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  1979. {
  1980. if (i == 2)
  1981. {
  1982. if (cellTextFirst == "经济舱")
  1983. {
  1984. // 设置单元格内容
  1985. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1986. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  1987. }
  1988. else
  1989. {
  1990. // 设置单元格内容
  1991. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1992. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  1993. }
  1994. }
  1995. if (i == 3)
  1996. {
  1997. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1998. if (count != null)
  1999. {
  2000. // 设置单元格内容
  2001. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2002. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2003. }
  2004. }
  2005. if (i == 4)
  2006. {
  2007. var rowPrice = 0.00M;
  2008. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2009. count ??= 0;
  2010. if (cellTextFirst == "经济舱")
  2011. {
  2012. rowPrice = subJJC * (int)count;
  2013. }
  2014. else
  2015. {
  2016. rowPrice = subGWC * (int)count;
  2017. }
  2018. totalPrice += rowPrice;
  2019. // 设置单元格内容
  2020. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2021. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2022. }
  2023. }
  2024. }
  2025. }
  2026. }
  2027. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2028. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2029. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2030. //--合同表格部分
  2031. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2032. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2033. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2034. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2035. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日")+"-"+di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2036. bookMarkDic.Add("CityPath1", cityPath);
  2037. bookMarkDic.Add("CityPath2", cityPath);
  2038. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2039. if (contractTable != null)
  2040. {
  2041. //数据源
  2042. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2043. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2044. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2045. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2046. .Select((it, y, s) => new
  2047. {
  2048. it.Cost,
  2049. it.SubTotal,
  2050. it.Type,
  2051. y.Id,
  2052. y.City,
  2053. s.Name,
  2054. CurrencyCodeCn = s.Remark
  2055. })
  2056. .ToList()
  2057. .Select(x => new
  2058. {
  2059. CurrencyCode = x.Name,
  2060. CityId = x.Id,
  2061. x.City,
  2062. VisitPNumber = di.VisitPNumber,
  2063. x.Type,
  2064. x.Cost,
  2065. x.SubTotal,
  2066. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2067. x.CurrencyCodeCn,
  2068. });
  2069. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2070. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2071. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2072. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2073. List<tableSetting> tableSettings = new List<tableSetting>()
  2074. {
  2075. new tableSetting{ Index = 1 , Property = "City"},
  2076. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  2077. new tableSetting{ Index = 3 , Property = "Cost"},
  2078. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  2079. //new tableSetting{ Index = 5 , Property = ""},
  2080. //new tableSetting{ Index = 6 , Property = ""},
  2081. new tableSetting{ Index = 7 , Property = "Rate"},
  2082. //new tableSetting{ Index = 8 , Property = ""},
  2083. };
  2084. //1.住宿费
  2085. int cloneRow = 8;
  2086. int startDayPrice = 8; //写入index
  2087. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2088. foreach (var dac in dac1)
  2089. {
  2090. var first = dac.First();
  2091. var dayCount = dac.Count();
  2092. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2093. for (int i = 1; i < row.Cells.Count; i++)
  2094. {
  2095. var cell = row.Cells[i];
  2096. var findProperty = tableSettings.Find(x => x.Index == i);
  2097. if (findProperty != null)
  2098. {
  2099. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2100. // 设置单元格内容
  2101. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2102. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2103. }
  2104. else
  2105. {
  2106. switch (i)
  2107. {
  2108. case 5:
  2109. cell.FirstParagraph.Runs.Clear();
  2110. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2111. break;
  2112. case 6:
  2113. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2114. cell.FirstParagraph.Runs.Clear();
  2115. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2116. break;
  2117. case 8:
  2118. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2119. cell.FirstParagraph.Runs.Clear();
  2120. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2121. ZSPriceSum += xiaojiRMB;
  2122. break;
  2123. default:
  2124. break;
  2125. }
  2126. }
  2127. }
  2128. startDayPrice++;
  2129. if (!dac1.Last().Equals(dac))
  2130. {
  2131. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2132. // 将克隆的行追加到原行后面
  2133. contractTable.Rows.Insert(startDayPrice, newRow);
  2134. }
  2135. else
  2136. {
  2137. cloneRow += dac1.Count() + 1;
  2138. startDayPrice = cloneRow;
  2139. }
  2140. }
  2141. //2.伙食费
  2142. foreach (var dac in dac2)
  2143. {
  2144. var first = dac.First();
  2145. var dayCount = dac.Count();
  2146. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2147. for (int i = 1; i < row.Cells.Count; i++)
  2148. {
  2149. var cell = row.Cells[i];
  2150. var findProperty = tableSettings.Find(x => x.Index == i);
  2151. if (findProperty != null)
  2152. {
  2153. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2154. // 设置单元格内容
  2155. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2156. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2157. }
  2158. else
  2159. {
  2160. switch (i)
  2161. {
  2162. case 5:
  2163. cell.FirstParagraph.Runs.Clear();
  2164. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2165. break;
  2166. case 6:
  2167. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2168. cell.FirstParagraph.Runs.Clear();
  2169. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2170. break;
  2171. case 8:
  2172. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2173. cell.FirstParagraph.Runs.Clear();
  2174. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2175. HSPriceSum += xiaojiRMB;
  2176. break;
  2177. default:
  2178. break;
  2179. }
  2180. }
  2181. }
  2182. startDayPrice++;
  2183. if (!dac2.Last().Equals(dac))
  2184. {
  2185. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2186. // 将克隆的行追加到原行后面
  2187. contractTable.Rows.Insert(startDayPrice, newRow);
  2188. }
  2189. else
  2190. {
  2191. cloneRow += dac2.Count() + 1;
  2192. startDayPrice = cloneRow;
  2193. }
  2194. }
  2195. //3.公杂费
  2196. foreach (var dac in dac3)
  2197. {
  2198. var first = dac.First();
  2199. var dayCount = dac.Count();
  2200. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2201. for (int i = 1; i < row.Cells.Count; i++)
  2202. {
  2203. var cell = row.Cells[i];
  2204. var findProperty = tableSettings.Find(x => x.Index == i);
  2205. if (findProperty != null)
  2206. {
  2207. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2208. // 设置单元格内容
  2209. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2210. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2211. }
  2212. else
  2213. {
  2214. switch (i)
  2215. {
  2216. case 5:
  2217. cell.FirstParagraph.Runs.Clear();
  2218. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2219. break;
  2220. case 6:
  2221. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2222. cell.FirstParagraph.Runs.Clear();
  2223. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2224. break;
  2225. case 8:
  2226. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2227. cell.FirstParagraph.Runs.Clear();
  2228. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2229. GZPriceSum += xiaojiRMB;
  2230. break;
  2231. default:
  2232. break;
  2233. }
  2234. }
  2235. }
  2236. startDayPrice++;
  2237. if (!dac3.Last().Equals(dac))
  2238. {
  2239. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2240. // 将克隆的行追加到原行后面
  2241. contractTable.Rows.Insert(startDayPrice, newRow);
  2242. }
  2243. else
  2244. {
  2245. cloneRow += dac3.Count() + 1;
  2246. startDayPrice = cloneRow;
  2247. }
  2248. }
  2249. //合并单元格
  2250. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2251. {
  2252. var currentRow = contractTable.Rows[i];
  2253. var nextRow = contractTable.Rows[i + 1];
  2254. // 获取当前行和下一行的第一个单元格
  2255. Cell currentCell = currentRow.Cells[0];
  2256. Cell nextCell = nextRow.Cells[0];
  2257. // 检查单元格内容是否一致(去除尾部的换行符)
  2258. string currentText = currentCell.GetText().Trim();
  2259. string nextText = nextCell.GetText().Trim();
  2260. if (currentText == nextText)
  2261. {
  2262. // 如果当前单元格已经被合并,找到合并的起始单元格
  2263. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2264. {
  2265. // 找到合并的起始单元格
  2266. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2267. // 将下一行的单元格设置为合并的后续单元格
  2268. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2269. }
  2270. else
  2271. {
  2272. // 如果当前单元格是合并的起始单元格
  2273. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2274. // 将下一行的单元格设置为合并的后续单元格
  2275. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2276. }
  2277. }
  2278. else
  2279. {
  2280. // 如果内容不一致,重置当前单元格的合并属性
  2281. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2282. {
  2283. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2284. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2285. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2286. }
  2287. else
  2288. {
  2289. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2290. }
  2291. }
  2292. }
  2293. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2294. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2295. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2296. }
  2297. foreach (var bookmarkName in bookMarkDic.Keys)
  2298. {
  2299. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2300. if (bookmark != null)
  2301. {
  2302. if (bookmarkName == "ClientUnit")
  2303. {
  2304. // 移动到书签位置
  2305. builder.MoveTo(bookmark.BookmarkStart);
  2306. // 设置字体样式为下划线
  2307. builder.Font.Underline = Aspose.Words.Underline.Single;
  2308. // 插入书签值
  2309. builder.Write(bookMarkDic[bookmarkName]);
  2310. // 清除字体格式,避免影响后续文本
  2311. builder.Font.ClearFormatting();
  2312. }
  2313. else
  2314. {
  2315. builder.MoveToBookmark(bookmarkName);
  2316. builder.Write(bookMarkDic[bookmarkName]);
  2317. }
  2318. }
  2319. }
  2320. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2321. doc.Save(savePaht);
  2322. jw.Msg = "生成成功!";
  2323. jw.Code = 200;
  2324. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
  2325. return Ok(jw);
  2326. }
  2327. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2328. {
  2329. int index = rowIndex;
  2330. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2331. {
  2332. index--;
  2333. }
  2334. return index;
  2335. }
  2336. #endregion
  2337. #region 团组&签证
  2338. /// <summary>
  2339. /// 根据团组Id获取签证客户信息List
  2340. /// </summary>
  2341. /// <param name="dto">请求dto</param>
  2342. /// <returns></returns>
  2343. [HttpPost]
  2344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2345. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2346. {
  2347. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2348. if (groupData.Code != 0)
  2349. {
  2350. return Ok(JsonView(false, groupData.Msg));
  2351. }
  2352. return Ok(JsonView(groupData.Data));
  2353. }
  2354. /// <summary>
  2355. /// IOS获取团组签证拍照上传进度01(团组列表)
  2356. /// </summary>
  2357. /// <param name="dto">请求dto</param>
  2358. /// <returns></returns>
  2359. [HttpPost]
  2360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2361. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2362. {
  2363. if (dto == null)
  2364. {
  2365. return Ok(JsonView(false, "参数为空"));
  2366. }
  2367. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2368. return Ok(JsonView(visaList));
  2369. }
  2370. /// <summary>
  2371. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2372. /// </summary>
  2373. /// <returns></returns>
  2374. [HttpPost]
  2375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2376. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2377. {
  2378. if (dto == null)
  2379. {
  2380. return Ok(JsonView(false, "请求错误:"));
  2381. }
  2382. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2383. return Ok(JsonView(list));
  2384. }
  2385. /// <summary>
  2386. /// IOS获取团组签证拍照上传进度03(相册)
  2387. /// </summary>
  2388. /// <returns></returns>
  2389. [HttpPost]
  2390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2391. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2392. {
  2393. if (dto == null)
  2394. {
  2395. return Ok(JsonView(false, "请求错误:"));
  2396. }
  2397. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2398. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2399. list.ForEach(s => s.url = url);
  2400. return Ok(JsonView(list));
  2401. }
  2402. /// <summary>
  2403. /// IOS获取团组签证拍照上传进度04(图片上传)
  2404. /// </summary>
  2405. /// <param name="dto"></param>
  2406. /// <returns></returns>
  2407. [HttpPost]
  2408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2409. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2410. {
  2411. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2412. //if (!string.IsNullOrEmpty(result))
  2413. //{
  2414. //}
  2415. //else {
  2416. // return Ok(JsonView(false, "上传失败"));
  2417. //}
  2418. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2419. int sucNum = 0;
  2420. try
  2421. {
  2422. foreach (var item in dto.base64DataList)
  2423. {
  2424. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2425. string result = DecodeBase64ToImage(item, imageName);
  2426. if (!string.IsNullOrEmpty(result))
  2427. {
  2428. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2429. pic.CreateUserId = dto.CreateUserId;
  2430. pic.PicName = imageName;
  2431. pic.PicPath = result;
  2432. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2433. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2434. if (insertResult > 0)
  2435. {
  2436. sucNum++;
  2437. }
  2438. }
  2439. }
  2440. }
  2441. catch (Exception ex)
  2442. {
  2443. return Ok(JsonView(false, ex.Message));
  2444. }
  2445. string msg = string.Format(@"成功上传{0}张", sucNum);
  2446. return Ok(JsonView(true, msg));
  2447. }
  2448. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2449. {
  2450. string filename = "";//声明一个string类型的相对路径
  2451. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2452. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2453. try//会有异常抛出,try,catch一下
  2454. {
  2455. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2456. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2457. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2458. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2459. //文件名称
  2460. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2461. //上传的文件的路径
  2462. string filePath = "";
  2463. if (!Directory.Exists(fileDir))
  2464. {
  2465. Directory.CreateDirectory(fileDir);
  2466. }
  2467. //上传的文件的路径
  2468. filePath = fileDir + filename;
  2469. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2470. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2471. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2472. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2473. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2474. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2475. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2476. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2477. bitmap.Dispose();
  2478. }
  2479. catch (Exception e)
  2480. {
  2481. string massage = e.Message;
  2482. Logs("IOS图片上传Error:" + massage);
  2483. //filename = e.Message;
  2484. }
  2485. return filename;//返回相对路径
  2486. }
  2487. /// <summary>
  2488. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2489. /// </summary>
  2490. /// <param name="dto"></param>
  2491. /// <returns></returns>
  2492. [HttpPost]
  2493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2494. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2495. {
  2496. if (dto == null)
  2497. {
  2498. return Ok(JsonView(false, "请求错误:"));
  2499. }
  2500. string msg = "参数错误";
  2501. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2502. {
  2503. try
  2504. {
  2505. //_delegationVisaRep.BeginTran();
  2506. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2507. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2508. .Where(s => s.Id == dto.visaProgressCustomerId)
  2509. .ExecuteCommandAsync();
  2510. if (updCount > 0 && dto.publishCode == 1)
  2511. {
  2512. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2513. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2514. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2515. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2516. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2517. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2518. if (groupData == null)
  2519. {
  2520. _delegationVisaRep.RollbackTran();
  2521. }
  2522. string title = string.Format(@"[签证进度更新]");
  2523. string content = string.Format(@"测试文本");
  2524. bool rst = await _message.AddMsg(new MessageDto()
  2525. {
  2526. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2527. IssuerId = dto.publisher,
  2528. Title = title,
  2529. Content = content,
  2530. ReleaseTime = DateTime.Now,
  2531. UIdList = new List<int> {
  2532. 234
  2533. }
  2534. });
  2535. if (rst)
  2536. {
  2537. return Ok(JsonView(true, "发送通知成功"));
  2538. }
  2539. }
  2540. //_delegationVisaRep.CommitTran();
  2541. }
  2542. catch (Exception)
  2543. {
  2544. //_delegationVisaRep.RollbackTran();
  2545. }
  2546. }
  2547. return Ok(JsonView(true, msg));
  2548. }
  2549. #endregion
  2550. #region 团组任务分配
  2551. /// <summary>
  2552. /// 团组任务分配初始化
  2553. /// </summary>
  2554. /// <returns></returns>
  2555. [HttpPost]
  2556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2557. public async Task<IActionResult> GetTaskAssignmen()
  2558. {
  2559. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2560. if (groupData.Code != 0)
  2561. {
  2562. return Ok(JsonView(false, groupData.Msg));
  2563. }
  2564. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2565. }
  2566. /// <summary>
  2567. /// 团组任务分配查询
  2568. /// </summary>
  2569. /// <param name="dto"></param>
  2570. /// <returns></returns>
  2571. [HttpPost]
  2572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2573. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2574. {
  2575. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2576. if (groupData.Code != 0)
  2577. {
  2578. return Ok(JsonView(false, groupData.Msg));
  2579. }
  2580. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2581. }
  2582. /// <summary>
  2583. /// 团组任务分配操作
  2584. /// </summary>
  2585. /// <param name="dto"></param>
  2586. /// <returns></returns>
  2587. [HttpPost]
  2588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2589. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2590. {
  2591. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2592. if (groupData.Code != 0)
  2593. {
  2594. return Ok(JsonView(false, groupData.Msg));
  2595. }
  2596. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2597. }
  2598. /// <summary>
  2599. /// 团组任务分配
  2600. /// 批量分配
  2601. /// 查询团组
  2602. /// </summary>
  2603. /// <param name="dto"></param>
  2604. /// <returns></returns>
  2605. [HttpPost]
  2606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2607. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2608. {
  2609. //参数验证
  2610. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2611. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2612. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2613. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2614. }
  2615. /// <summary>
  2616. /// 团组任务分配
  2617. /// 批量分配
  2618. /// </summary>
  2619. /// <param name="dto"></param>
  2620. /// <returns></returns>
  2621. [HttpPost]
  2622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2623. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2624. {
  2625. //参数验证
  2626. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2627. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2628. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2629. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2630. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2631. }
  2632. #endregion
  2633. #region 团组费用审核
  2634. /// <summary>
  2635. /// 费用审核
  2636. /// 团组列表 Page
  2637. /// </summary>
  2638. /// <param name="_dto">团组列表请求dto</param>
  2639. /// <returns></returns>
  2640. [HttpPost]
  2641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2642. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2643. {
  2644. #region 参数验证
  2645. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2646. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2647. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2648. #region 页面操作权限验证
  2649. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2650. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2651. #endregion
  2652. #endregion
  2653. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2654. {
  2655. string sqlWhere = string.Empty;
  2656. if (_dto.IsSure == 0) //未完成
  2657. {
  2658. sqlWhere += string.Format(@" And IsSure = 0");
  2659. }
  2660. else if (_dto.IsSure == 1) //已完成
  2661. {
  2662. sqlWhere += string.Format(@" And IsSure = 1");
  2663. }
  2664. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2665. {
  2666. string tj = _dto.SearchCriteria;
  2667. 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}%')",
  2668. tj, tj, tj, tj, tj);
  2669. }
  2670. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2671. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2672. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2673. From (
  2674. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2675. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2676. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2677. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2678. From Grp_DelegationInfo gdi
  2679. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2680. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2681. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2682. Where gdi.IsDel = 0 {0}
  2683. ) temp ", sqlWhere);
  2684. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2685. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2686. var _view = new
  2687. {
  2688. PageFuncAuth = pageFunAuthView,
  2689. Data = _DelegationList
  2690. };
  2691. return Ok(JsonView(true, "查询成功!", _view, total));
  2692. }
  2693. else
  2694. {
  2695. return Ok(JsonView(false, "查询失败"));
  2696. }
  2697. }
  2698. /// <summary>
  2699. /// 获取团组费用审核
  2700. /// </summary>
  2701. /// <param name="_dto"></param>
  2702. /// <returns></returns>
  2703. [HttpPost]
  2704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2705. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2706. {
  2707. try
  2708. {
  2709. #region 参数验证
  2710. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2711. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2712. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2713. #region 页面操作权限验证
  2714. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2715. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2716. #endregion
  2717. #endregion
  2718. var _view = new Grp_CreditCardPaymentView();
  2719. var clientNameList = getSimplClientList(_dto.DiId);
  2720. #region 费用清单
  2721. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2722. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2723. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2724. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2725. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2726. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2727. /*
  2728. * 76://酒店预订
  2729. */
  2730. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2731. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2732. /*
  2733. * 79://车/导游地接
  2734. */
  2735. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2736. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2737. /*
  2738. * 80: //签证
  2739. */
  2740. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2741. /*
  2742. *81: //邀请/公务活动
  2743. */
  2744. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2745. /*
  2746. * 82: //团组客户保险
  2747. */
  2748. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2749. /*
  2750. * Lable = 85 机票预订
  2751. */
  2752. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2753. /*
  2754. * 85 机票预定
  2755. */
  2756. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2757. /*
  2758. * 98 其他款项
  2759. */
  2760. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2761. /*
  2762. * 285:收款退还
  2763. */
  2764. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2765. /*
  2766. * 1015: //超支费用
  2767. */
  2768. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2769. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2770. /*
  2771. * 币种信息
  2772. */
  2773. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2774. /*
  2775. * 车/导游地接 费用类型
  2776. */
  2777. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2778. /*
  2779. * 车/导游地接 费用类型
  2780. */
  2781. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2782. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2783. /*
  2784. * 用户信息
  2785. */
  2786. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2787. /*
  2788. * 费用模块
  2789. */
  2790. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2791. string priceModule = string.Empty;
  2792. if (sdPriceName != null)
  2793. {
  2794. priceModule = sdPriceName.Name;
  2795. }
  2796. /*
  2797. * 成本信息
  2798. */
  2799. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2800. decimal _groupRate = 0.0000M;
  2801. string _groupCurrencyCode = "-";
  2802. if (groupCost != null)
  2803. {
  2804. _groupRate = groupCost.Rate;
  2805. if (int.TryParse(groupCost.Currency, out int _currency))
  2806. {
  2807. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2808. }
  2809. else _groupCurrencyCode = groupCost.Currency;
  2810. }
  2811. string costContentSql = $"Select * From Grp_GroupCost";
  2812. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2813. //处理日期为空的天数
  2814. for (int i = 0; i < groupCostDetails.Count; i++)
  2815. if (i != 0)
  2816. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2817. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2818. /*
  2819. * 处理详情数据
  2820. */
  2821. foreach (var entity in entityList)
  2822. {
  2823. var _detail = new Grp_CreditCardPaymentDetailView();
  2824. _detail.Id = entity.Id;
  2825. _detail.PriceName = priceModule;
  2826. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2827. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2828. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2829. //处理金额
  2830. if (entity.CTable == 1015)
  2831. {
  2832. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2833. if (czInfo != null)
  2834. {
  2835. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2836. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2837. }
  2838. }
  2839. /*
  2840. * 应付款金额
  2841. */
  2842. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2843. string PaymentCurrency_WaitPay = "Unknown";
  2844. string hotelCurrncyCode = "Unknown";
  2845. string hotelCurrncyName = "Unknown";
  2846. if (sdPaymentCurrency_WaitPay != null)
  2847. {
  2848. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2849. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2850. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2851. if (hotelCurrncyCode.Equals("CNY"))
  2852. {
  2853. entity.DayRate = 1.0000M;
  2854. }
  2855. }
  2856. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2857. /*
  2858. * 此次付款金额
  2859. */
  2860. decimal CurrPayStr = 0.00M,
  2861. OriginalCurrPay = 0.00M;
  2862. if (entity.PayPercentage == 0)
  2863. {
  2864. if (entity.PayThenMoney != 0)
  2865. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2866. }
  2867. else
  2868. {
  2869. if (entity.PayMoney != 0)
  2870. {
  2871. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2872. }
  2873. }
  2874. //if (_dto.Label == 79)
  2875. //{
  2876. // string original = string.Empty;
  2877. // if (hotelCurrncyCode.Equals("CNY"))
  2878. // {
  2879. // OriginalCurrPay = CurrPayStr;
  2880. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2881. // }
  2882. // else
  2883. // {
  2884. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2885. // //760 EUR(7600.00 CNY)
  2886. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2887. // }
  2888. //}
  2889. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2890. string original = string.Empty;
  2891. if (hotelCurrncyCode.Equals("CNY"))
  2892. {
  2893. OriginalCurrPay = CurrPayStr;
  2894. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2895. }
  2896. else
  2897. {
  2898. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2899. //760 EUR(7600.00 CNY)
  2900. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2901. }
  2902. /*
  2903. * 剩余尾款
  2904. */
  2905. decimal BalanceStr = 0;
  2906. if (CurrPayStr != 0)
  2907. {
  2908. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2909. BalanceStr = 0;
  2910. else
  2911. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2912. }
  2913. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2914. /*
  2915. * Bus名称
  2916. */
  2917. _detail.BusName = "待增加";
  2918. /*
  2919. *费用所属
  2920. */
  2921. switch (entity.CTable)
  2922. {
  2923. case 76://酒店预订
  2924. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2925. if (hotelReservations != null)
  2926. {
  2927. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2928. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2929. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2930. string roomFeeStr = "", roomFeestr1 = "";
  2931. //是否比较房型价格
  2932. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2933. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2934. roomFeeStr += $"<br/>";
  2935. var roomTotal = 0.00M;
  2936. if (hotelReservations.SingleRoomPrice > 0)
  2937. {
  2938. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2939. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee:#0.00}<br/>";
  2940. //__isSingle = true;
  2941. roomTotal += fee;
  2942. }
  2943. if (hotelReservations.DoubleRoomPrice > 0)
  2944. {
  2945. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2946. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee:#0.00}<br/>";
  2947. // __isDouble = true;
  2948. roomTotal += fee;
  2949. }
  2950. if (hotelReservations.SuiteRoomPrice > 0)
  2951. {
  2952. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2953. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee:#0.00}<br/>";
  2954. //__isSuite = true;
  2955. roomTotal += fee;
  2956. }
  2957. if (hotelReservations.OtherRoomPrice > 0)
  2958. {
  2959. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2960. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee:#0.00}<br/>";
  2961. //__isOther = true;
  2962. roomTotal += fee;
  2963. }
  2964. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  2965. else roomFeeStr += " 0.00 * 0";
  2966. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2967. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2968. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2969. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2970. /*
  2971. * 费用类型
  2972. * 1:房费
  2973. * 2:早餐
  2974. * 3:地税
  2975. * 4:城市税
  2976. * </summary>
  2977. */
  2978. //地税
  2979. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2980. if (governmentRentData != null)
  2981. {
  2982. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2983. governmentRentFee = governmentRentData.Price;
  2984. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2985. if (governmentRentCurrData != null)
  2986. {
  2987. governmentRentCode = governmentRentCurrData.Name;
  2988. governmentRentName = $"({governmentRentCurrData.Remark})";
  2989. }
  2990. }
  2991. //城市税
  2992. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2993. if (cityTaxData != null)
  2994. {
  2995. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2996. cityTaxFee = cityTaxData.Price;
  2997. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2998. if (cityTaxCurrData != null)
  2999. {
  3000. cityTaxCode = cityTaxCurrData.Name;
  3001. cityTaxName = $"({cityTaxCurrData.Remark})";
  3002. }
  3003. }
  3004. //酒店早餐
  3005. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3006. if (breakfastData != null)
  3007. {
  3008. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3009. breakfastFee = breakfastData.Price;
  3010. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3011. if (breakfastCurrData != null)
  3012. {
  3013. breakfastCode = breakfastCurrData.Name;
  3014. breakfastName = $"({breakfastCurrData.Remark})";
  3015. }
  3016. }
  3017. //房间费用
  3018. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3019. if (roomData != null)
  3020. {
  3021. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3022. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3023. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3024. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3025. roomFee = roomData.Price;
  3026. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3027. if (roomCurrData != null)
  3028. {
  3029. roomCode = roomCurrData.Name;
  3030. roomName = $"({roomCurrData.Remark})";
  3031. }
  3032. }
  3033. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3034. string hotelCostStr = "";
  3035. decimal hotelCsotTotal = 0.00M;
  3036. if (groupCost != null)
  3037. {
  3038. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3039. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3040. }
  3041. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3042. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3043. string hotelCost_day = "";
  3044. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3045. foreach (var item in hotelCostDetails1)
  3046. {
  3047. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3048. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3049. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3050. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3051. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3052. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3053. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3054. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3055. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3056. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3057. hotelCost_day += @$"<br/>";
  3058. }
  3059. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3060. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3061. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3062. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3063. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3064. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3065. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3066. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3067. $"房间说明: {hotelReservations.Remark} <br/>" +
  3068. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3069. $"{hotelBreakfastStr}" +
  3070. $"{hotelGovernmentRentStr}" +
  3071. $"{hotelCityTaxStr}";
  3072. _detail.PriceNameContent = hotelReservations.HotelName;
  3073. }
  3074. break;
  3075. case 79://车/导游地接
  3076. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3077. if (touristGuideGroundReservations != null)
  3078. {
  3079. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3080. {
  3081. _detail.BusName = touristGuideGroundReservations.BusName;
  3082. }
  3083. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3084. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3085. //if (isInt)
  3086. //{
  3087. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3088. // if (cityInfo != null)
  3089. // {
  3090. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3091. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3092. // if (carFeeItem != null)
  3093. // {
  3094. // nameContent += $@"({carFeeItem.Name})";
  3095. // }
  3096. // _detail.PriceNameContent = nameContent;
  3097. // }
  3098. //}
  3099. //else
  3100. //{
  3101. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3102. //}
  3103. var touristGuideGroundReservationsContents =
  3104. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3105. var opContent_sb = new StringBuilder();
  3106. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3107. opContent_sb.AppendLine(contetTitle);
  3108. foreach (var item in touristGuideGroundReservationsContents)
  3109. {
  3110. string typeName = "Unknown";
  3111. string carCurrencyCode = "Unknown";
  3112. string carCurrencyName = "Unknown";
  3113. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3114. if (carTypeData != null) typeName = carTypeData.Name;
  3115. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3116. if (currencyData != null)
  3117. {
  3118. carCurrencyCode = currencyData.Name;
  3119. carCurrencyName = currencyData.Remark;
  3120. }
  3121. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3122. bool IsCurrencyAgreement = false;
  3123. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3124. string opCostStr = string.Empty;
  3125. decimal opCostTypePrice = 0.00M;
  3126. #region 处理成本各项费用
  3127. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3128. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3129. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3130. costOPFeeCNY = 0.00M, //团组成本 op费用
  3131. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3132. if (opCost.Count > 0)
  3133. {
  3134. switch (item.SId)
  3135. {
  3136. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3137. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3138. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3139. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3140. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3141. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3142. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3143. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3144. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3145. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3146. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3147. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3148. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3149. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3150. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3151. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3152. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3153. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3154. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3155. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3156. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3157. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3158. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3159. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3160. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3161. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3162. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3163. }
  3164. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3165. costOPFeeCNY = opCostTypePrice * _groupRate;
  3166. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3167. }
  3168. #endregion
  3169. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3170. aduitOPFeeCNY = item.Price * entity.DayRate;
  3171. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3172. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3173. $"{opTypeStr} {opCostStr}<br/>" +
  3174. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3175. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3176. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3177. {
  3178. if (IsCurrencyAgreement)
  3179. {
  3180. if (item.Price > opCostTypePrice)
  3181. {
  3182. opContent_sb.Append("<span style='color:red;'>");
  3183. opContent_sb.Append(opContent);
  3184. opContent_sb.Append("</span>");
  3185. opContent_sb.AppendLine();
  3186. }
  3187. else
  3188. {
  3189. opContent_sb.Append(opContent);
  3190. opContent_sb.AppendLine();
  3191. }
  3192. }
  3193. else
  3194. {
  3195. //验证是否超成本 按付款比例计算
  3196. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3197. {
  3198. opContent_sb.Append("<span style='color:red;'>");
  3199. opContent_sb.Append(opContent);
  3200. opContent_sb.Append("</span>");
  3201. opContent_sb.AppendLine();
  3202. }
  3203. else
  3204. {
  3205. opContent_sb.Append(opContent);
  3206. opContent_sb.AppendLine();
  3207. }
  3208. }
  3209. }
  3210. else
  3211. {
  3212. opContent_sb.Append(opContent);
  3213. opContent_sb.AppendLine();
  3214. }
  3215. }
  3216. _detail.PriceMsgContent = opContent_sb.ToString();
  3217. }
  3218. break;
  3219. case 80: //签证
  3220. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3221. if (visaInfo != null)
  3222. {
  3223. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3224. _detail.PriceNameContent = visaInfo.VisaDescription;
  3225. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3226. }
  3227. break;
  3228. case 81: //邀请/公务活动
  3229. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3230. if (_ioa != null)
  3231. {
  3232. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3233. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3234. sendCurrName = "Unknown", //快递费用币种 Name
  3235. sendCurrCode = "Unknown", //快递费用币种 Code
  3236. eventsCurrName = "Unknown", //公务活动费币种 Name
  3237. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3238. translateCurrName = "Unknown", //公务翻译费 Name
  3239. translateCurrCode = "Unknown"; //公务翻译费 Code
  3240. #region 处理费用币种
  3241. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3242. if (inviteCurrData != null)
  3243. {
  3244. inviteCurrName = inviteCurrData.Remark;
  3245. inviteCurrCode = inviteCurrData.Name;
  3246. }
  3247. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3248. if (sendCurrData != null)
  3249. {
  3250. sendCurrName = sendCurrData.Remark;
  3251. sendCurrCode = sendCurrData.Name;
  3252. }
  3253. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3254. if (eventsCurrData != null)
  3255. {
  3256. eventsCurrName = eventsCurrData.Remark;
  3257. eventsCurrCode = eventsCurrData.Name;
  3258. }
  3259. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3260. if (translateCurrData != null)
  3261. {
  3262. translateCurrName = translateCurrData.Remark;
  3263. translateCurrCode = translateCurrData.Name;
  3264. }
  3265. #endregion
  3266. _detail.PriceNameContent = _ioa.InviterArea;
  3267. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3268. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3269. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3270. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3271. $@"备注:" + _ioa.Remark + "<br/>";
  3272. }
  3273. break;
  3274. case 82: //团组客户保险
  3275. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3276. if (customers != null)
  3277. {
  3278. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3279. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3280. }
  3281. break;
  3282. case 85: //机票预订
  3283. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3284. if (jpRes != null)
  3285. {
  3286. string FlightsDescription = jpRes.FlightsDescription;
  3287. string PriceDescription = jpRes.PriceDescription;
  3288. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3289. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3290. }
  3291. break;
  3292. case 98://其他款项
  3293. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3294. if (gdpRes != null)
  3295. {
  3296. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3297. _detail.PriceNameContent = gdpRes.PriceName;
  3298. }
  3299. break;
  3300. case 285://收款退还
  3301. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3302. if (refundAndOtherMoney != null)
  3303. {
  3304. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3305. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3306. }
  3307. break;
  3308. case 751://酒店早餐
  3309. break;
  3310. case 1015://超支费用
  3311. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3312. if (groupExtraCost != null)
  3313. {
  3314. _detail.PriceNameContent = groupExtraCost.PriceName;
  3315. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3316. }
  3317. break;
  3318. default:
  3319. break;
  3320. }
  3321. /*
  3322. * 申请人
  3323. */
  3324. string operatorName = " - ";
  3325. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3326. if (_opUser != null)
  3327. {
  3328. operatorName = _opUser.CnName;
  3329. }
  3330. _detail.OperatorName = operatorName;
  3331. /*
  3332. * 审核人
  3333. */
  3334. string auditOperatorName = "Unknown";
  3335. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3336. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3337. else
  3338. {
  3339. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3340. if (_adUser != null)
  3341. {
  3342. auditOperatorName = _adUser.CnName;
  3343. }
  3344. }
  3345. _detail.AuditOperatorName = auditOperatorName;
  3346. /*
  3347. * 超预算比例
  3348. */
  3349. string overBudgetStr = "";
  3350. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3351. else if (entity.ExceedBudget == 0)
  3352. {
  3353. if (entity.CTable == 76 || entity.CTable == 79)
  3354. {
  3355. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3356. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3357. }
  3358. else
  3359. {
  3360. overBudgetStr = "未超预算";
  3361. }
  3362. }
  3363. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3364. _detail.OverBudget = overBudgetStr;
  3365. decimal auditFee = 0.00M; //已审核金额 人名币
  3366. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3367. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3368. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3369. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3370. {
  3371. auditedFeeOriginal = entity.PayMoney;
  3372. auditFee = CurrPayStr;
  3373. }
  3374. else if (entity.IsAuditGM == 0)
  3375. {
  3376. unAuditFeeCNY = CurrPayStr;
  3377. unAuditFeeOriginal = OriginalCurrPay;
  3378. OriginalCurrPay = 0.00M;
  3379. }
  3380. /*
  3381. * 费用总计
  3382. */
  3383. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3384. {
  3385. CurrencyId = entity.PaymentCurrency,
  3386. CurrencyName = PaymentCurrency_WaitPay,
  3387. AmountPayable = entity.PayMoney,
  3388. ThisPayment = OriginalCurrPay,
  3389. BalancePayment = BalanceStr,
  3390. AuditedFunds = auditFee,
  3391. AuditedFundsOriginal = auditedFeeOriginal,
  3392. UnAuditFundsCNY = unAuditFeeCNY,
  3393. UnAuditFundsOriginal = unAuditFeeOriginal
  3394. });
  3395. _detail.IsAuditGM = entity.IsAuditGM;
  3396. detailList.Add(_detail);
  3397. }
  3398. #endregion
  3399. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3400. /*
  3401. * 下方描述处理
  3402. */
  3403. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3404. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3405. if (ccpCurrencyPrice != null)
  3406. {
  3407. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3408. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3409. }
  3410. else
  3411. {
  3412. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3413. }
  3414. string amountPayableStr = string.Format(@"应付款总金额: ");
  3415. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3416. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3417. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3418. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3419. foreach (var item in nonDuplicat)
  3420. {
  3421. var currencyName = item.CurrencyName;
  3422. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3423. if (strs.Count > 0)
  3424. {
  3425. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3426. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3427. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3428. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3429. //单独处理此次付款金额
  3430. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3431. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3432. //单独处理已审核费用
  3433. //if (item.CurrencyId == 836) //人民币
  3434. //{
  3435. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3436. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3437. //}
  3438. //else
  3439. //{
  3440. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3441. //}
  3442. if (currencyName.Equals("CNY"))
  3443. {
  3444. //已审核费用
  3445. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3446. //未审核费用
  3447. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3448. }
  3449. else
  3450. {
  3451. //已审核费用
  3452. 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"));
  3453. //未审核费用
  3454. 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"));
  3455. }
  3456. }
  3457. }
  3458. _view.TotalStr1 = amountPayableStr[..^1];
  3459. _view.TotalStr2 = thisPaymentStr[..^1];
  3460. _view.TotalStr3 = balancePaymentStr[..^1];
  3461. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3462. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3463. var _view1 = new
  3464. {
  3465. PageFuncAuth = pageFunAuthView,
  3466. Data = _view
  3467. };
  3468. return Ok(JsonView(_view1));
  3469. }
  3470. catch (Exception ex)
  3471. {
  3472. return Ok(JsonView(false, ex.Message));
  3473. }
  3474. }
  3475. /// <summary>
  3476. /// 费用审核
  3477. /// 修改团组费用审核状态
  3478. /// </summary>
  3479. /// <param name="_dto">参数Json字符串</param>
  3480. /// <returns></returns>
  3481. [HttpPost]
  3482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3483. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3484. {
  3485. #region 参数验证
  3486. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3487. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3488. #endregion
  3489. #region 页面操作权限验证
  3490. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3491. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3492. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3493. #endregion
  3494. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3495. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3496. DateTime dtNow = DateTime.Now;
  3497. _groupRepository.BeginTran();
  3498. int rst = 0;
  3499. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3500. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3501. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3502. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3503. List<dynamic> msgDatas = new List<dynamic>();
  3504. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3505. foreach (var item in idList)
  3506. {
  3507. int CreditId = int.Parse(item);
  3508. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3509. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3510. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3511. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3512. .Where(s => s.Id == CreditId)
  3513. .ExecuteCommandAsync();
  3514. if (result < 1)
  3515. {
  3516. rst = -1;
  3517. _groupRepository.RollbackTran();
  3518. return Ok(JsonView(false, "操作失败并回滚!"));
  3519. }
  3520. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3521. if (creditData != null)
  3522. {
  3523. #region 应用通知配置
  3524. try
  3525. {
  3526. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3527. }
  3528. catch (Exception ex)
  3529. {
  3530. }
  3531. #endregion
  3532. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3533. string groupNameStr = string.Empty;
  3534. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3535. if (groupData != null) groupNameStr = groupData.TeamName;
  3536. string creditTypeStr = string.Empty;
  3537. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3538. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3539. string creditCurrency = string.Empty;
  3540. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3541. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3542. if (creditCurrency.Equals("CNY"))
  3543. {
  3544. creditData.DayRate = 1.0000M;
  3545. }
  3546. if (creditData.PayPercentage == 0.00M)
  3547. {
  3548. creditData.PayPercentage = 100M;
  3549. }
  3550. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3551. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3552. string msgContent = "";
  3553. if (creditCurrency.Equals("CNY"))
  3554. {
  3555. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3556. }
  3557. else
  3558. {
  3559. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3560. }
  3561. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3562. }
  3563. }
  3564. if (rst == 0)
  3565. {
  3566. _groupRepository.CommitTran();
  3567. foreach (var item in msgDatas)
  3568. {
  3569. //发送消息
  3570. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3571. }
  3572. #region 应用推送
  3573. try
  3574. {
  3575. foreach (var ccpId in dic_ccp_user.Keys)
  3576. {
  3577. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3578. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3579. }
  3580. }
  3581. catch (Exception)
  3582. {
  3583. }
  3584. #endregion
  3585. return Ok(JsonView(true, "操作成功!"));
  3586. }
  3587. return Ok(JsonView(false, "操作失败!"));
  3588. }
  3589. #endregion
  3590. #region 机票费用录入
  3591. /// <summary>
  3592. /// 机票录入当前登录人可操作团组
  3593. /// </summary>
  3594. /// <param name="dto"></param>
  3595. /// <returns></returns>
  3596. [HttpPost]
  3597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3598. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3599. {
  3600. try
  3601. {
  3602. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3603. if (groupData.Code != 0)
  3604. {
  3605. return Ok(JsonView(false, groupData.Msg));
  3606. }
  3607. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3608. }
  3609. catch (Exception ex)
  3610. {
  3611. return Ok(JsonView(false, "程序错误!"));
  3612. throw;
  3613. }
  3614. }
  3615. /// <summary>
  3616. /// 机票费用录入列表
  3617. /// </summary>
  3618. /// <param name="dto"></param>
  3619. /// <returns></returns>
  3620. [HttpPost]
  3621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3622. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3623. {
  3624. try
  3625. {
  3626. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3627. if (groupData.Code != 0)
  3628. {
  3629. return Ok(JsonView(false, groupData.Msg));
  3630. }
  3631. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3632. }
  3633. catch (Exception ex)
  3634. {
  3635. return Ok(JsonView(false, ex.Message));
  3636. throw;
  3637. }
  3638. }
  3639. /// <summary>
  3640. /// 根据id查询费用录入信息
  3641. /// </summary>
  3642. /// <param name="dto"></param>
  3643. /// <returns></returns>
  3644. [HttpPost]
  3645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3646. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3647. {
  3648. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3649. if (groupData.Code != 0)
  3650. {
  3651. return Ok(JsonView(false, groupData.Msg));
  3652. }
  3653. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3654. }
  3655. /// <summary>
  3656. /// 机票费用录入操作(Status:1.新增,2.修改)
  3657. /// </summary>
  3658. /// <param name="dto"></param>
  3659. /// <returns></returns>
  3660. [HttpPost]
  3661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3662. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3663. {
  3664. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3665. if (groupData.Code != 0)
  3666. {
  3667. return Ok(JsonView(false, groupData.Msg));
  3668. }
  3669. #region 应用推送
  3670. try
  3671. {
  3672. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3673. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3674. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3675. //2024-10-21 新增LZ UID
  3676. var userIds = new List<int>() { 21 };
  3677. string title = $"系统通知";
  3678. string content = "";
  3679. var diId = dto.AirTicketResOpData.DiId;
  3680. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3681. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3682. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3683. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3684. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3685. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3686. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3687. }
  3688. catch (Exception ex)
  3689. {
  3690. }
  3691. #endregion
  3692. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3693. }
  3694. /// <summary>
  3695. /// 根据舱位类型查询接团客户名单信息
  3696. /// </summary>
  3697. /// <param name="dto"></param>
  3698. /// <returns></returns>
  3699. [HttpPost]
  3700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3701. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3702. {
  3703. try
  3704. {
  3705. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3706. if (crm_Groups.Count != 0)
  3707. {
  3708. List<dynamic> Customer = new List<dynamic>();
  3709. foreach (var item in crm_Groups)
  3710. {
  3711. var data = new
  3712. {
  3713. Id = item.Id,
  3714. Pinyin = item.Pinyin,
  3715. Name = item.LastName + item.FirstName
  3716. };
  3717. Customer.Add(data);
  3718. }
  3719. return Ok(JsonView(true, "查询成功!", Customer));
  3720. }
  3721. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3722. }
  3723. catch (Exception ex)
  3724. {
  3725. return Ok(JsonView(false, "程序错误!"));
  3726. throw;
  3727. }
  3728. }
  3729. /// <summary>
  3730. /// 根据团号获取客户信息
  3731. /// </summary>
  3732. /// <param name="dto"></param>
  3733. /// <returns></returns>
  3734. [HttpPost]
  3735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3736. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3737. {
  3738. var jw = JsonView(false);
  3739. if (dto.DIID < 1)
  3740. {
  3741. jw.Msg += "请输入正确的diid";
  3742. return Ok(jw);
  3743. }
  3744. var arr = getSimplClientList(dto.DIID);
  3745. jw = JsonView(true, "获取成功!", arr);
  3746. return Ok(jw);
  3747. }
  3748. private List<SimplClientInfo> getSimplClientList(int diId)
  3749. {
  3750. 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);
  3751. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3752. foreach (var item in arr)
  3753. {
  3754. EncryptionProcessor.DecryptProperties(item);
  3755. }
  3756. return arr;
  3757. }
  3758. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3759. {
  3760. string result = origin;
  3761. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3762. {
  3763. string[] temparr = origin.Split(',');
  3764. string fistrStr = temparr[0];
  3765. int count = temparr.Count();
  3766. int tempId;
  3767. bool success = int.TryParse(fistrStr, out tempId);
  3768. if (success)
  3769. {
  3770. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3771. if (tempInfo != null)
  3772. {
  3773. if (count > 1)
  3774. {
  3775. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3776. }
  3777. else
  3778. {
  3779. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3780. }
  3781. }
  3782. }
  3783. }
  3784. return result;
  3785. }
  3786. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3787. {
  3788. string result = origin;
  3789. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3790. {
  3791. string[] temparr = origin.Split(',');
  3792. result = "";
  3793. foreach (var item in temparr)
  3794. {
  3795. int tempId;
  3796. bool success = int.TryParse(item, out tempId);
  3797. if (success)
  3798. {
  3799. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3800. if (tempInfo != null)
  3801. {
  3802. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3803. }
  3804. }
  3805. }
  3806. }
  3807. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3808. return result;
  3809. }
  3810. /// <summary>
  3811. /// 机票费用录入,删除
  3812. /// </summary>
  3813. /// <param name="dto"></param>
  3814. /// <returns></returns>
  3815. [HttpPost]
  3816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3817. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3818. {
  3819. try
  3820. {
  3821. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3822. if (res)
  3823. {
  3824. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3825. {
  3826. IsDel = 1,
  3827. DeleteUserId = dto.DeleteUserId,
  3828. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3829. }).ExecuteCommandAsync();
  3830. return Ok(JsonView(true, "删除成功!"));
  3831. }
  3832. return Ok(JsonView(false, "删除失败!"));
  3833. }
  3834. catch (Exception ex)
  3835. {
  3836. return Ok(JsonView(false, "程序错误!"));
  3837. throw;
  3838. }
  3839. }
  3840. /// <summary>
  3841. /// 导出机票录入报表
  3842. /// </summary>
  3843. /// <param name="dto"></param>
  3844. /// <returns></returns>
  3845. [HttpPost]
  3846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3847. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3848. {
  3849. try
  3850. {
  3851. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3852. if (groupData.Code != 0)
  3853. {
  3854. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3855. }
  3856. else
  3857. {
  3858. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3859. if (AirTicketReservations.Count != 0)
  3860. {
  3861. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3862. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3863. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3864. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3865. WorkbookDesigner designer = new WorkbookDesigner();
  3866. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3867. decimal countCost = 0;
  3868. foreach (var item in AirTicketReservations)
  3869. {
  3870. #region 处理客人姓名
  3871. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3872. item.ClientName = clientNames;
  3873. #endregion
  3874. if (item.BankType == "其他")
  3875. {
  3876. item.BankNo = "--";
  3877. }
  3878. else
  3879. {
  3880. if (!string.IsNullOrEmpty(item.BankType))
  3881. {
  3882. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3883. }
  3884. }
  3885. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3886. item.Price = System.Decimal.Round(item.Price, 2);
  3887. countCost += Convert.ToDecimal(item.Price);
  3888. }
  3889. designer.SetDataSource("Export", AirTicketReservations);
  3890. designer.SetDataSource("ExportDiCode", diCode);
  3891. designer.SetDataSource("ExportDiName", diName);
  3892. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3893. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3894. designer.Process();
  3895. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3896. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3897. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3898. return Ok(JsonView(true, "成功", url = rst));
  3899. }
  3900. else
  3901. {
  3902. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3903. }
  3904. }
  3905. }
  3906. catch (Exception ex)
  3907. {
  3908. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3909. throw;
  3910. }
  3911. }
  3912. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3913. /// <summary>
  3914. /// 行程单导出
  3915. /// </summary>
  3916. /// <param name="dto"></param>
  3917. /// <returns></returns>
  3918. [HttpPost]
  3919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3920. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3921. {
  3922. try
  3923. {
  3924. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3925. if (groupData.Code != 0)
  3926. {
  3927. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3928. }
  3929. else
  3930. {
  3931. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3932. if (dto.Language == "CN")
  3933. {
  3934. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3935. DocumentBuilder builder = new DocumentBuilder(doc);
  3936. int tableIndex = 0;//表格索引
  3937. //得到文档中的第一个表格
  3938. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3939. foreach (var item in _AirTicketReservations)
  3940. {
  3941. #region 处理固定数据
  3942. string[] FlightsCode = item.FlightsCode.Split('/');
  3943. if (FlightsCode.Length != 0)
  3944. {
  3945. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3946. if (_AirCompany != null)
  3947. {
  3948. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3949. }
  3950. else
  3951. {
  3952. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3953. }
  3954. }
  3955. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3956. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3957. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3958. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3959. string name = "";
  3960. foreach (string clientName in nameArray)
  3961. {
  3962. if (!name.Contains(clientName))
  3963. {
  3964. name += clientName + ",";
  3965. }
  3966. }
  3967. if (!string.IsNullOrWhiteSpace(name))
  3968. {
  3969. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3970. }
  3971. else
  3972. {
  3973. table.Range.Bookmarks["ClientName"].Text = "--";
  3974. }
  3975. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3976. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3977. table.Range.Bookmarks["JointTicket"].Text = "--";
  3978. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3979. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3980. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3981. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3982. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3983. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3984. #endregion
  3985. #region 循环数据处理
  3986. List<AirInfo> airs = new List<AirInfo>();
  3987. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3988. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3989. for (int i = 0; i < FlightsCode.Length; i++)
  3990. {
  3991. AirInfo air = new AirInfo();
  3992. string[] tempstr = DayArray[i]
  3993. .Replace("\r\n", string.Empty)
  3994. .Replace("\\r\\n", string.Empty)
  3995. .TrimStart().TrimEnd()
  3996. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3997. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3998. string starCity = "";
  3999. if (star_Three != null)
  4000. {
  4001. starCity = star_Three.AirPort;
  4002. }
  4003. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4004. string EndCity = "";
  4005. if (End_Three != null)
  4006. {
  4007. EndCity = End_Three.AirPort;
  4008. }
  4009. air.Destination = starCity + "/" + EndCity;
  4010. air.Flight = FlightsCode[i];
  4011. air.SeatingClass = item.CTypeName;
  4012. string dateTime = tempstr[2];
  4013. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4014. air.FlightDate = DateTemp;
  4015. air.DepartureTime = tempstr[5];
  4016. air.LandingTime = tempstr[6];
  4017. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4018. air.TicketStatus = "--";
  4019. air.Luggage = "--";
  4020. air.DepartureTerminal = "--";
  4021. air.LandingTerminal = "--";
  4022. airs.Add(air);
  4023. }
  4024. int row = 13;
  4025. for (int i = 0; i < airs.Count; i++)
  4026. {
  4027. if (airs.Count > 2)
  4028. {
  4029. for (int j = 0; j < airs.Count - 2; j++)
  4030. {
  4031. var CopyRow = table.Rows[12].Clone(true);
  4032. table.Rows.Add(CopyRow);
  4033. }
  4034. }
  4035. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4036. int index = 0;
  4037. foreach (PropertyInfo property in properties)
  4038. {
  4039. string value = property.GetValue(airs[i]).ToString();
  4040. Cell ishcel0 = table.Rows[row].Cells[index];
  4041. Paragraph p = new Paragraph(doc);
  4042. string s = value;
  4043. p.AppendChild(new Run(doc, s));
  4044. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4045. ishcel0.AppendChild(p);
  4046. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4047. index++;
  4048. }
  4049. row++;
  4050. }
  4051. #endregion
  4052. Paragraph lastParagraph = new Paragraph(doc);
  4053. //第一个表格末尾加段落
  4054. table.ParentNode.InsertAfter(lastParagraph, table);
  4055. //复制第一个表格
  4056. Table cloneTable = (Table)table.Clone(true);
  4057. //在文档末尾段落后面加入复制的表格
  4058. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4059. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4060. {
  4061. int rownewsIndex = 13;
  4062. for (int i = 0; i < 2; i++)
  4063. {
  4064. var CopyRow = table.Rows[12].Clone(true);
  4065. table.Rows.RemoveAt(13);
  4066. table.Rows.Add(CopyRow);
  4067. rownewsIndex++;
  4068. }
  4069. }
  4070. else
  4071. {
  4072. table.Rows.RemoveAt(12);
  4073. }
  4074. cloneTable.Rows.RemoveAt(12);
  4075. }
  4076. if (_AirTicketReservations.Count != 0)
  4077. {
  4078. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4079. if (FlightsCode.Length != 0)
  4080. {
  4081. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4082. if (_AirCompany != null)
  4083. {
  4084. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4085. }
  4086. else
  4087. {
  4088. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4089. }
  4090. }
  4091. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4092. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4093. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4094. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4095. string name = "";
  4096. foreach (string clientName in nameArray)
  4097. {
  4098. if (!name.Contains(clientName))
  4099. {
  4100. name += clientName + ",";
  4101. }
  4102. }
  4103. if (!string.IsNullOrWhiteSpace(name))
  4104. {
  4105. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4106. }
  4107. else
  4108. {
  4109. table.Range.Bookmarks["ClientName"].Text = "--";
  4110. }
  4111. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4112. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4113. table.Range.Bookmarks["JointTicket"].Text = "--";
  4114. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4115. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4116. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4117. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4118. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4119. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4120. }
  4121. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4122. //保存合并后的文档
  4123. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4124. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4125. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4126. return Ok(JsonView(true, "成功!", rst));
  4127. }
  4128. else
  4129. {
  4130. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4131. DocumentBuilder builder = new DocumentBuilder(doc);
  4132. int tableIndex = 0;//表格索引
  4133. //得到文档中的第一个表格
  4134. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4135. List<string> texts = new List<string>();
  4136. foreach (var item in _AirTicketReservations)
  4137. {
  4138. string[] FlightsCode = item.FlightsCode.Split('/');
  4139. if (FlightsCode.Length != 0)
  4140. {
  4141. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4142. if (_AirCompany != null)
  4143. {
  4144. if (!transDic.ContainsKey(_AirCompany.CnName))
  4145. {
  4146. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4147. }
  4148. }
  4149. else
  4150. {
  4151. if (!transDic.ContainsKey("--"))
  4152. {
  4153. transDic.Add("--", "--");
  4154. }
  4155. }
  4156. }
  4157. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4158. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4159. string name = "";
  4160. foreach (string clientName in nameArray)
  4161. {
  4162. name += clientName + ",";
  4163. }
  4164. if (!texts.Contains(name))
  4165. {
  4166. texts.Add(name);
  4167. }
  4168. List<AirInfo> airs = new List<AirInfo>();
  4169. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4170. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4171. for (int i = 0; i < FlightsCode.Length; i++)
  4172. {
  4173. AirInfo air = new AirInfo();
  4174. string[] tempstr = DayArray[i]
  4175. .Replace("\r\n", string.Empty)
  4176. .Replace("\\r\\n", string.Empty)
  4177. .TrimStart().TrimEnd()
  4178. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4179. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4180. if (star_Three != null)
  4181. {
  4182. if (!transDic.ContainsKey(star_Three.AirPort))
  4183. {
  4184. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4185. }
  4186. }
  4187. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4188. if (End_Three != null)
  4189. {
  4190. if (!transDic.ContainsKey(End_Three.AirPort))
  4191. {
  4192. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4193. }
  4194. }
  4195. if (!texts.Contains(item.CTypeName))
  4196. {
  4197. texts.Add(item.CTypeName);
  4198. }
  4199. }
  4200. }
  4201. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4202. if (transData.Count > 0)
  4203. {
  4204. foreach (TranslateResult item in transData)
  4205. {
  4206. if (!transDic.ContainsKey(item.Query))
  4207. {
  4208. transDic.Add(item.Query, item.Translation);
  4209. }
  4210. }
  4211. }
  4212. foreach (var item in _AirTicketReservations)
  4213. {
  4214. #region 处理固定数据
  4215. string[] FlightsCode = item.FlightsCode.Split('/');
  4216. if (FlightsCode.Length != 0)
  4217. {
  4218. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4219. if (_AirCompany != null)
  4220. {
  4221. string str = "--";
  4222. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4223. if (!string.IsNullOrEmpty(translateResult))
  4224. {
  4225. str = translateResult;
  4226. str = _airTicketResRep.Processing(str);
  4227. }
  4228. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4229. }
  4230. else
  4231. {
  4232. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4233. }
  4234. }
  4235. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4236. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4237. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4238. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4239. string names = "";
  4240. foreach (string clientName in nameArray)
  4241. {
  4242. names += clientName + ",";
  4243. }
  4244. if (!string.IsNullOrWhiteSpace(names))
  4245. {
  4246. string str = "--";
  4247. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4248. if (!string.IsNullOrEmpty(translateResult))
  4249. {
  4250. str = translateResult;
  4251. str = _airTicketResRep.Processing(str);
  4252. }
  4253. table.Range.Bookmarks["ClientName"].Text = str;
  4254. }
  4255. else
  4256. {
  4257. table.Range.Bookmarks["ClientName"].Text = "--";
  4258. }
  4259. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4260. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4261. table.Range.Bookmarks["JointTicket"].Text = "--";
  4262. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4263. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4264. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4265. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4266. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4267. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4268. #endregion
  4269. #region 循环数据处理
  4270. List<AirInfo> airs = new List<AirInfo>();
  4271. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4272. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4273. for (int i = 0; i < FlightsCode.Length; i++)
  4274. {
  4275. AirInfo air = new AirInfo();
  4276. string[] tempstr = DayArray[i]
  4277. .Replace("\r\n", string.Empty)
  4278. .Replace("\\r\\n", string.Empty)
  4279. .TrimStart().TrimEnd()
  4280. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4281. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4282. string starCity = "";
  4283. if (star_Three != null)
  4284. {
  4285. string str2 = "--";
  4286. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4287. if (!string.IsNullOrEmpty(translateResult2))
  4288. {
  4289. str2 = translateResult2;
  4290. str2 = _airTicketResRep.Processing(str2);
  4291. }
  4292. starCity = str2;
  4293. }
  4294. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4295. string EndCity = "";
  4296. if (End_Three != null)
  4297. {
  4298. string str1 = "--";
  4299. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4300. if (!string.IsNullOrEmpty(translateResult1))
  4301. {
  4302. str1 = translateResult1;
  4303. str1 = _airTicketResRep.Processing(str1);
  4304. }
  4305. EndCity = str1;
  4306. }
  4307. air.Destination = starCity + "/" + EndCity;
  4308. air.Flight = FlightsCode[i];
  4309. string str = "--";
  4310. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4311. if (!string.IsNullOrEmpty(translateResult))
  4312. {
  4313. str = translateResult;
  4314. str = _airTicketResRep.Processing(str);
  4315. }
  4316. air.SeatingClass = str;
  4317. string dateTime = tempstr[2];
  4318. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4319. air.FlightDate = DateTemp;
  4320. air.DepartureTime = tempstr[5];
  4321. air.LandingTime = tempstr[6];
  4322. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4323. air.TicketStatus = "--";
  4324. air.Luggage = "--";
  4325. air.DepartureTerminal = "--";
  4326. air.LandingTerminal = "--";
  4327. airs.Add(air);
  4328. }
  4329. int row = 13;
  4330. for (int i = 0; i < airs.Count; i++)
  4331. {
  4332. if (airs.Count > 2)
  4333. {
  4334. for (int j = 0; j < airs.Count - 2; j++)
  4335. {
  4336. var CopyRow = table.Rows[12].Clone(true);
  4337. table.Rows.Add(CopyRow);
  4338. }
  4339. }
  4340. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4341. int index = 0;
  4342. foreach (PropertyInfo property in properties)
  4343. {
  4344. string value = property.GetValue(airs[i]).ToString();
  4345. Cell ishcel0 = table.Rows[row].Cells[index];
  4346. Paragraph p = new Paragraph(doc);
  4347. string s = value;
  4348. p.AppendChild(new Run(doc, s));
  4349. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4350. ishcel0.AppendChild(p);
  4351. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4352. //ishcel0.CellFormat.VerticalAlignment=
  4353. index++;
  4354. }
  4355. row++;
  4356. }
  4357. #endregion
  4358. Paragraph lastParagraph = new Paragraph(doc);
  4359. //第一个表格末尾加段落
  4360. table.ParentNode.InsertAfter(lastParagraph, table);
  4361. //复制第一个表格
  4362. Table cloneTable = (Table)table.Clone(true);
  4363. //在文档末尾段落后面加入复制的表格
  4364. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4365. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4366. {
  4367. int rownewsIndex = 13;
  4368. for (int i = 0; i < 2; i++)
  4369. {
  4370. var CopyRow = table.Rows[12].Clone(true);
  4371. table.Rows.RemoveAt(13);
  4372. table.Rows.Add(CopyRow);
  4373. rownewsIndex++;
  4374. }
  4375. }
  4376. else
  4377. {
  4378. table.Rows.RemoveAt(12);
  4379. }
  4380. cloneTable.Rows.RemoveAt(12);
  4381. }
  4382. if (_AirTicketReservations.Count != 0)
  4383. {
  4384. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4385. if (FlightsCode.Length != 0)
  4386. {
  4387. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4388. if (_AirCompany != null)
  4389. {
  4390. string str = "--";
  4391. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4392. if (!string.IsNullOrEmpty(translateResult))
  4393. {
  4394. str = translateResult;
  4395. str = _airTicketResRep.Processing(str);
  4396. }
  4397. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4398. }
  4399. else
  4400. {
  4401. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4402. }
  4403. }
  4404. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4405. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4406. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4407. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4408. string names = "";
  4409. foreach (string clientName in nameArray)
  4410. {
  4411. names += clientName + ",";
  4412. }
  4413. if (!string.IsNullOrWhiteSpace(names))
  4414. {
  4415. string str = "--";
  4416. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4417. if (!string.IsNullOrEmpty(translateResult))
  4418. {
  4419. str = translateResult;
  4420. str = _airTicketResRep.Processing(str);
  4421. }
  4422. table.Range.Bookmarks["ClientName"].Text = str;
  4423. }
  4424. else
  4425. {
  4426. table.Range.Bookmarks["ClientName"].Text = "--";
  4427. }
  4428. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4429. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4430. table.Range.Bookmarks["JointTicket"].Text = "--";
  4431. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4432. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4433. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4434. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4435. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4436. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4437. }
  4438. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4439. //保存合并后的文档
  4440. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4441. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4442. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4443. return Ok(JsonView(true, "成功!", rst));
  4444. }
  4445. }
  4446. }
  4447. catch (Exception ex)
  4448. {
  4449. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4450. throw;
  4451. }
  4452. }
  4453. #endregion
  4454. #region 团组增减款项 --> 其他款项
  4455. /// <summary>
  4456. /// 团组增减款项下拉框绑定
  4457. /// </summary>
  4458. /// <param name="dto"></param>
  4459. /// <returns></returns>
  4460. [HttpPost]
  4461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4462. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4463. {
  4464. #region 参数验证
  4465. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4466. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4467. #endregion
  4468. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4469. }
  4470. /// <summary>
  4471. /// 根据团组Id查询团组增减款项
  4472. /// </summary>
  4473. /// <param name="dto"></param>
  4474. /// <returns></returns>
  4475. [HttpPost]
  4476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4477. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4478. {
  4479. #region 参数验证
  4480. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4481. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4482. #endregion
  4483. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4484. }
  4485. /// <summary>
  4486. /// 团组增减款项操作(Status:1.新增,2.修改)
  4487. /// </summary>
  4488. /// <param name="dto"></param>
  4489. /// <returns></returns>
  4490. [HttpPost]
  4491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4492. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4493. {
  4494. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4495. if (groupData.Code != 200)
  4496. {
  4497. return Ok(JsonView(false, groupData.Msg));
  4498. }
  4499. #region 应用推送
  4500. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4501. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4502. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4503. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4504. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4505. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4506. //自动审核
  4507. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4508. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4509. //2024-10-21 新增LZ UID
  4510. var userIds = new List<int>() { 21 };
  4511. string title = $"系统通知";
  4512. string content = "";
  4513. var diId = dto.DiId;
  4514. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4515. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4516. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4517. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4518. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4519. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4520. #endregion
  4521. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4522. }
  4523. /// <summary>
  4524. /// 团组增减款项操作 删除
  4525. /// </summary>
  4526. /// <param name="dto"></param>
  4527. /// <returns></returns>
  4528. [HttpPost]
  4529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4530. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4531. {
  4532. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4533. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4534. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4535. if (res.Code == 0)
  4536. {
  4537. return Ok(JsonView(true, "删除成功!"));
  4538. }
  4539. return Ok(JsonView(false, "删除失败!"));
  4540. }
  4541. /// <summary>
  4542. /// 根据团组增减款项Id查询
  4543. /// </summary>
  4544. /// <param name="dto"></param>
  4545. /// <returns></returns>
  4546. [HttpPost]
  4547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4548. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4549. {
  4550. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4551. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4552. }
  4553. /// <summary>
  4554. /// 查询供应商名称
  4555. /// </summary>
  4556. /// <param name="dto"></param>
  4557. /// <returns></returns>
  4558. [HttpPost]
  4559. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4560. {
  4561. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4562. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4563. ?? new List<Grp_DecreasePayments>();
  4564. dbResult = dbResult.Distinct(new
  4565. ProductComparer()).ToList();
  4566. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4567. {
  4568. x.Id,
  4569. x.SupplierAddress,
  4570. x.SupplierArea,
  4571. x.SupplierContact,
  4572. x.SupplierContactNumber,
  4573. x.SupplierEmail,
  4574. x.SupplierName,
  4575. x.SupplierSocialAccount,
  4576. x.SupplierTypeId,
  4577. }).ToList());
  4578. return Ok(jw);
  4579. }
  4580. /// <summary>
  4581. /// 团组增减款项 OTA匹配
  4582. /// </summary>
  4583. /// <param name="file"></param>
  4584. /// <returns></returns>
  4585. [HttpPost]
  4586. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4587. {
  4588. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4589. string fileName = file.FileName;
  4590. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4591. {
  4592. return Ok(JsonView(false, "请上传Excel文件!"));
  4593. }
  4594. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4595. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4596. if (!Directory.Exists(path))
  4597. {
  4598. Directory.CreateDirectory(path);
  4599. }
  4600. var filePath = @$"{path}/{fileName}";
  4601. //保存文件
  4602. using (FileStream fs = System.IO.File.Create(filePath))
  4603. {
  4604. file.CopyTo(fs);
  4605. fs.Flush();
  4606. }
  4607. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4608. //读取ExcelFile
  4609. DataTable dt = ConvertExcelToDataTable(filePath);
  4610. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4611. dt.TableName = "TB";
  4612. //修改table列名
  4613. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4614. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4615. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4616. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4617. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4618. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4619. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4620. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4621. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4622. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4623. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4624. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4625. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4626. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4627. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4628. var otaOrderNos = new List<string>();
  4629. foreach (DataRow item in dt.Rows)
  4630. {
  4631. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4632. }
  4633. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4634. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4635. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4636. .Select((dp, di) => new
  4637. {
  4638. dp.PriceName,
  4639. dp.OTAOrderNo,
  4640. dp.FeeTotal,
  4641. di.TeamName,
  4642. })
  4643. .ToListAsync();
  4644. foreach (DataRow item in dt.Rows)
  4645. {
  4646. var otaOrderNo = item["OTAOrderNo"].ToString();
  4647. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4648. if (oaData == null) continue;
  4649. item["GroupName"] = oaData.TeamName;
  4650. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4651. }
  4652. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4653. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4654. List<DataTable> datas = new List<DataTable>();
  4655. datas.Add(dt);
  4656. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4657. return Ok(JsonView(true, "操作成功", new { url = url }));
  4658. }
  4659. #region
  4660. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4661. {
  4662. // 创建Workbook对象
  4663. Workbook workbook = new Workbook(excelFilePath);
  4664. // 获取第一个工作表
  4665. Worksheet worksheet = workbook.Worksheets[0];
  4666. // 将工作表转换为DataTable
  4667. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4668. return dataTable;
  4669. }
  4670. #endregion
  4671. #endregion
  4672. #region 文件上传、删除
  4673. /// <summary>
  4674. /// region 文件上传 可以带参数
  4675. /// </summary>
  4676. /// <param name="file"></param>
  4677. /// <returns></returns>
  4678. [HttpPost]
  4679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4680. public async Task<IActionResult> UploadProject(IFormFile file)
  4681. {
  4682. //var TypeName = Request.Headers["TypeName"].ToString();
  4683. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4684. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4685. ////文件名称
  4686. //string projectFileName = file.FileName;
  4687. ////上传的文件的路径
  4688. //string filePath = $"{fileDir}/{projectFileName}";
  4689. //if (TypeName == "A")//A代表团组增减款项
  4690. //{
  4691. // filePath = fileDir + $@"\团组增减款项相关文件";
  4692. // if (!Directory.Exists(filePath))
  4693. // {
  4694. // Directory.CreateDirectory(filePath);
  4695. // }
  4696. // //上传的文件的路径
  4697. // filePath += $@"\{projectFileName}";
  4698. //}
  4699. //else if (TypeName == "B")//B代表商邀相关文件
  4700. //{
  4701. // //上传的文件的路径
  4702. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4703. // if (!Directory.Exists(filePath))
  4704. // {
  4705. // Directory.CreateDirectory(filePath);
  4706. // }
  4707. // //上传的文件的路径
  4708. // filePath = $@"\{projectFileName}";
  4709. //}
  4710. //try
  4711. //{
  4712. // using (FileStream fs = System.IO.File.Create(filePath))
  4713. // {
  4714. // file.CopyTo(fs);
  4715. // fs.Flush();
  4716. // }
  4717. //}
  4718. //catch (Exception ex)
  4719. //{
  4720. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4721. //}
  4722. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4723. try
  4724. {
  4725. var TypeName = Request.Headers["TypeName"].ToString();
  4726. if (file != null)
  4727. {
  4728. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4729. //文件名称
  4730. string projectFileName = file.FileName;
  4731. //上传的文件的路径
  4732. string filePath = $"{fileDir}/{projectFileName}";
  4733. if (TypeName == "A")//A代表团组增减款项
  4734. {
  4735. if (!Directory.Exists(fileDir))
  4736. {
  4737. Directory.CreateDirectory(fileDir);
  4738. }
  4739. //上传的文件的路径
  4740. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4741. }
  4742. else if (TypeName == "B")//B代表商邀相关文件
  4743. {
  4744. if (!Directory.Exists(fileDir))
  4745. {
  4746. Directory.CreateDirectory(fileDir);
  4747. }
  4748. //上传的文件的路径
  4749. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4750. }
  4751. using (FileStream fs = System.IO.File.Create(filePath))
  4752. {
  4753. file.CopyTo(fs);
  4754. fs.Flush();
  4755. }
  4756. return Ok(JsonView(true, "上传成功!", projectFileName));
  4757. }
  4758. else
  4759. {
  4760. return Ok(JsonView(false, "上传失败!"));
  4761. }
  4762. }
  4763. catch (Exception ex)
  4764. {
  4765. return Ok(JsonView(false, "程序错误!"));
  4766. }
  4767. }
  4768. /// <summary>
  4769. /// 删除指定文件
  4770. /// </summary>
  4771. /// <param name="dto"></param>
  4772. /// <returns></returns>
  4773. [HttpPost]
  4774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4775. public async Task<IActionResult> DelFile(DelFileDto dto)
  4776. {
  4777. try
  4778. {
  4779. var TypeName = Request.Headers["TypeName"].ToString();
  4780. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4781. string filePath = "";
  4782. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4783. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4784. int id = 0;
  4785. if (TypeName == "A")
  4786. {
  4787. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4788. // 删除该文件
  4789. System.IO.File.Delete(filePath);
  4790. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4791. .Where(a => a.Id == dto.Id)
  4792. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4793. .ExecuteCommandAsync();
  4794. }
  4795. else if (TypeName == "B")
  4796. {
  4797. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4798. // 删除该文件
  4799. System.IO.File.Delete(filePath);
  4800. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4801. if (info != null)
  4802. {
  4803. string[] files = new string[] { };
  4804. if (!string.IsNullOrEmpty(info.Attachment))
  4805. {
  4806. try
  4807. {
  4808. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4809. }
  4810. catch (Exception)
  4811. {
  4812. files = new List<string>() { info.Attachment }.ToArray();
  4813. }
  4814. }
  4815. if (files.Length > 0)
  4816. {
  4817. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4818. string filePath2 = string.Empty;
  4819. if (files1.Length > 0)
  4820. {
  4821. filePath2 = JsonConvert.SerializeObject(files1);
  4822. }
  4823. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4824. .Where(a => a.Id == dto.Id)
  4825. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4826. .ExecuteCommandAsync();
  4827. }
  4828. }
  4829. }
  4830. if (id != 0)
  4831. {
  4832. return Ok(JsonView(true, "成功!"));
  4833. }
  4834. else
  4835. {
  4836. return Ok(JsonView(false, "失败!"));
  4837. }
  4838. }
  4839. catch (Exception ex)
  4840. {
  4841. return Ok(JsonView(false, "程序错误!"));
  4842. throw;
  4843. }
  4844. }
  4845. /// <summary>
  4846. /// 文件上传多个文件 可以带参数
  4847. /// </summary>
  4848. /// <param name="files"></param>
  4849. /// <returns></returns>
  4850. [HttpPost]
  4851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4852. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4853. {
  4854. try
  4855. {
  4856. var TypeName = Request.Headers["TypeName"].ToString();
  4857. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4858. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4859. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4860. var filePahts = new List<string>();
  4861. foreach (var file in files)
  4862. {
  4863. //文件名称
  4864. string projectFileName = file.FileName;
  4865. //上传的文件的路径
  4866. string filePath = $"{fileDir}/{projectFileName}";
  4867. if (TypeName == "A")//A代表团组增减款项
  4868. {
  4869. if (!Directory.Exists(fileDir))
  4870. {
  4871. Directory.CreateDirectory(fileDir);
  4872. }
  4873. //上传的文件的路径
  4874. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4875. }
  4876. else if (TypeName == "B")//B代表商邀相关文件
  4877. {
  4878. if (!Directory.Exists(fileDir))
  4879. {
  4880. Directory.CreateDirectory(fileDir);
  4881. }
  4882. //上传的文件的路径
  4883. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4884. }
  4885. using (FileStream fs = System.IO.File.Create(filePath))
  4886. {
  4887. file.CopyTo(fs);
  4888. fs.Flush();
  4889. }
  4890. filePahts.Add(projectFileName);
  4891. }
  4892. return Ok(JsonView(true, "上传成功!", filePahts));
  4893. }
  4894. catch (Exception ex)
  4895. {
  4896. return Ok(JsonView(false, "程序错误!"));
  4897. }
  4898. }
  4899. #endregion
  4900. #region 商邀费用录入
  4901. /// <summary>
  4902. /// 根据团组Id查询商邀费用列表
  4903. /// </summary>
  4904. /// <param name="dto"></param>
  4905. /// <returns></returns>
  4906. [HttpPost]
  4907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4908. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4909. {
  4910. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4911. if (groupData.Code != 0)
  4912. {
  4913. return Ok(JsonView(false, groupData.Msg));
  4914. }
  4915. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4916. }
  4917. /// <summary>
  4918. /// 商邀费用列表
  4919. /// 下载文件
  4920. /// </summary>
  4921. /// <param name="id"></param>
  4922. /// <returns></returns>
  4923. [HttpGet("{id}")]
  4924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4925. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4926. {
  4927. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4928. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4929. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4930. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4931. var filePaths = new List<string>();
  4932. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4933. try
  4934. {
  4935. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4936. }
  4937. catch (Exception ex)
  4938. {
  4939. filePaths.Add(info.Attachment);
  4940. }
  4941. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4942. for (int i = 0; i < filePaths.Count; i++)
  4943. {
  4944. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4945. }
  4946. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4947. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4948. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4949. {
  4950. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4951. {
  4952. foreach (string filePath in filePaths)
  4953. {
  4954. if (System.IO.File.Exists(filePath))
  4955. {
  4956. // 获取文件名
  4957. string fileName = Path.GetFileName(filePath);
  4958. // 将文件添加到ZIP归档中
  4959. zipArchive.CreateEntryFromFile(filePath, fileName);
  4960. }
  4961. }
  4962. }
  4963. }
  4964. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4965. }
  4966. /// <summary>
  4967. /// 商邀费用 Info Page 基础数据源
  4968. /// </summary>
  4969. /// <returns></returns>
  4970. [HttpPost]
  4971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4972. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4973. {
  4974. try
  4975. {
  4976. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4977. if (groupData.Code != 0)
  4978. {
  4979. return Ok(JsonView(false, groupData.Msg));
  4980. }
  4981. return Ok(JsonView(true, "操作成功", groupData.Data));
  4982. }
  4983. catch (Exception ex)
  4984. {
  4985. return Ok(JsonView(false, ex.Message));
  4986. throw;
  4987. }
  4988. }
  4989. /// <summary>
  4990. /// 根据商邀费用ID查询C表和商邀费用数据
  4991. /// </summary>
  4992. /// <param name="dto"></param>
  4993. /// <returns></returns>
  4994. [HttpPost]
  4995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4996. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4997. {
  4998. try
  4999. {
  5000. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5001. if (groupData.Code != 0)
  5002. {
  5003. return Ok(JsonView(false, groupData.Msg));
  5004. }
  5005. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5006. }
  5007. catch (Exception ex)
  5008. {
  5009. return Ok(JsonView(false, ex.Message));
  5010. throw;
  5011. }
  5012. }
  5013. /// <summary>
  5014. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5015. /// </summary>
  5016. /// <param name="dto"></param>
  5017. /// <returns></returns>
  5018. [HttpPost]
  5019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5020. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5021. {
  5022. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5023. if (groupData.Code != 0)
  5024. {
  5025. return Ok(JsonView(false, groupData.Msg));
  5026. }
  5027. #region 应用推送
  5028. try
  5029. {
  5030. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5031. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5032. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5033. //2024-10-21 新增LZ UID
  5034. var userIds = new List<int>() { 21 };
  5035. string title = $"系统通知";
  5036. string content = "";
  5037. var diId = dto.DiId;
  5038. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5039. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5040. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5041. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5042. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5043. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5044. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5045. }
  5046. catch (Exception ex)
  5047. {
  5048. }
  5049. #endregion
  5050. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5051. }
  5052. /// <summary>
  5053. /// 商邀删除
  5054. /// </summary>
  5055. /// <param name="dto"></param>
  5056. /// <returns></returns>
  5057. [HttpPost]
  5058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5059. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5060. {
  5061. try
  5062. {
  5063. _sqlSugar.BeginTran();
  5064. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5065. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5066. {
  5067. IsDel = 1,
  5068. DeleteUserId = dto.DeleteUserId,
  5069. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5070. })
  5071. .Where(it => it.Id == dto.Id)
  5072. .ExecuteCommand();
  5073. if (res1 > 0)
  5074. {
  5075. int _diId = 0;
  5076. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5077. if (_ioaInfo != null)
  5078. {
  5079. _diId = _ioaInfo.DiId;
  5080. }
  5081. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5082. .SetColumns(a => new Grp_CreditCardPayment()
  5083. {
  5084. IsDel = 1,
  5085. DeleteUserId = dto.DeleteUserId,
  5086. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5087. })
  5088. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5089. .ExecuteCommand();
  5090. if (res2 > 0)
  5091. {
  5092. _sqlSugar.CommitTran();
  5093. return Ok(JsonView(true, "删除成功!"));
  5094. }
  5095. }
  5096. _sqlSugar.RollbackTran();
  5097. return Ok(JsonView(false, "删除失败"));
  5098. }
  5099. catch (Exception ex)
  5100. {
  5101. _sqlSugar.RollbackTran();
  5102. return Ok(JsonView(false, ex.Message));
  5103. }
  5104. }
  5105. #endregion
  5106. #region 票据上传
  5107. /// <summary>
  5108. /// 团组模块文件上传
  5109. /// </summary>
  5110. /// <param name="dto"></param>
  5111. /// <returns></returns>
  5112. [HttpPost]
  5113. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5114. {
  5115. var jw = JsonView(false);
  5116. long M = 1024 * 1024;
  5117. if (dto.Files == null || dto.Files.Count == 0)
  5118. {
  5119. jw.Msg = "无文件信息!";
  5120. return Ok(jw);
  5121. }
  5122. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5123. {
  5124. jw.Msg = "文件大小超过20M!";
  5125. return Ok(jw);
  5126. }
  5127. //var nameSp = dto.File.FileName.Split(".");
  5128. //if (nameSp.Length < 2)
  5129. //{
  5130. // jw.Msg = "拓展名称有误!";
  5131. // return Ok(jw);
  5132. //}
  5133. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5134. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5135. //{
  5136. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5137. // return Ok(jw);
  5138. //}
  5139. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5140. if (Ctable == null)
  5141. {
  5142. jw.Msg = "Ctable指向有误!";
  5143. return Ok(jw);
  5144. }
  5145. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5146. if (groupInfo == null)
  5147. {
  5148. jw.Msg = "团组信息不存在!";
  5149. return Ok(jw);
  5150. }
  5151. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5152. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5153. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5154. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5155. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5156. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5157. try
  5158. {
  5159. if (!Directory.Exists(fileBase))
  5160. {
  5161. Directory.CreateDirectory(fileBase);
  5162. }
  5163. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5164. foreach (var fileStream in dto.Files)
  5165. {
  5166. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5167. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5168. {
  5169. Cid = dto.Cid,
  5170. CreateTime = DateTime.Now,
  5171. CreateUserId = dto.Userid,
  5172. Ctable = dto.Ctable,
  5173. Diid = dto.Diid,
  5174. IsDel = 0,
  5175. FilePath = saveFilePath,
  5176. FileName = fileStream.FileName
  5177. };
  5178. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5179. {
  5180. fileStream.CopyTo(fs);
  5181. fs.Flush();
  5182. }
  5183. saveArr.Add(file);
  5184. }
  5185. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5186. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5187. jw = JsonView(true, "保存成功!", new
  5188. {
  5189. count = addResult,
  5190. filesName = saveArr.Select(x => x.FileName)
  5191. });
  5192. }
  5193. catch (Exception ex)
  5194. {
  5195. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5196. {
  5197. count = 0,
  5198. filesName = new string[0],
  5199. });
  5200. }
  5201. return Ok(jw);
  5202. }
  5203. /// <summary>
  5204. /// 查询各模块已保存文件
  5205. /// </summary>
  5206. /// <param name="dto"></param>
  5207. /// <returns></returns>
  5208. [HttpPost]
  5209. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5210. {
  5211. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5212. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5213. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5214. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5215. {
  5216. expression = Expressionable.Create<Grp_GroupModelFile>()
  5217. .And(x => visaIds.Contains(x.CreateUserId));
  5218. }
  5219. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5220. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5221. .Where(expression.ToExpression())
  5222. .ToList();
  5223. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5224. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5225. {
  5226. x.FileName,
  5227. x.Id,
  5228. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5229. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5230. })));
  5231. }
  5232. /// <summary>
  5233. /// 下载该团组下的所有文件
  5234. /// </summary>
  5235. /// <param name="dto"></param>
  5236. /// <returns></returns>
  5237. [HttpPost]
  5238. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5239. {
  5240. var jw = JsonView(false);
  5241. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5242. if (groupInfo == null)
  5243. {
  5244. jw.Msg = "团组信息不存在!";
  5245. return Ok(jw);
  5246. }
  5247. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5248. var isModule = Convert.ToBoolean(dto.isModule);
  5249. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5250. IOOperatorHelper io = new IOOperatorHelper();
  5251. if (isModule)
  5252. {
  5253. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5254. foreach (var moduleArr in moduleGroup)
  5255. {
  5256. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5257. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5258. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5259. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5260. foreach (var item in moduleArr)
  5261. {
  5262. if (System.IO.File.Exists(item.FilePath))
  5263. {
  5264. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5265. {
  5266. byte[] bytes = new byte[fileStream.Length];
  5267. fileStream.Read(bytes, 0, bytes.Length);
  5268. fileStream.Close();
  5269. Stream stream = new MemoryStream(bytes);
  5270. chiZips.Add(item.FileName, stream);
  5271. }
  5272. }
  5273. }
  5274. if (chiZips.Count > 0)
  5275. {
  5276. var byts = io.ConvertZipStream(chiZips);
  5277. Stream stream = new MemoryStream(byts);
  5278. Zips.Add(key.Name + "_.zip", stream);
  5279. }
  5280. }
  5281. }
  5282. else
  5283. {
  5284. foreach (var item in dbQuery)
  5285. {
  5286. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5287. {
  5288. byte[] bytes = new byte[fileStream.Length];
  5289. fileStream.Read(bytes, 0, bytes.Length);
  5290. fileStream.Close();
  5291. Stream stream = new MemoryStream(bytes);
  5292. while (Zips.Keys.Contains(item.FileName))
  5293. {
  5294. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5295. }
  5296. Zips.Add(item.FileName, stream);
  5297. }
  5298. }
  5299. }
  5300. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5301. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5302. if (Zips.Count > 0)
  5303. {
  5304. var byts = io.ConvertZipStream(Zips);
  5305. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5306. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5307. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5308. }
  5309. else
  5310. {
  5311. jw.Msg = "暂无生成文件!";
  5312. }
  5313. return Ok(jw);
  5314. }
  5315. /// <summary>
  5316. /// 下载该团组下此模块的所有文件
  5317. /// </summary>
  5318. /// <param name="dto"></param>
  5319. /// <returns></returns>
  5320. [HttpPost]
  5321. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5322. {
  5323. var jw = JsonView(false);
  5324. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5325. if (groupInfo == null)
  5326. {
  5327. jw.Msg = "团组信息不存在!";
  5328. return Ok(jw);
  5329. }
  5330. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5331. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5332. && x.IsDel == 0);
  5333. if (key == null)
  5334. {
  5335. jw.Msg = "Ctable指向错误!";
  5336. return Ok(jw);
  5337. }
  5338. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5339. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5340. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5341. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5342. IOOperatorHelper io = new IOOperatorHelper();
  5343. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5344. foreach (var item in dbQuery)
  5345. {
  5346. if (System.IO.File.Exists(item.FilePath))
  5347. {
  5348. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5349. {
  5350. byte[] bytes = new byte[fileStream.Length];
  5351. fileStream.Read(bytes, 0, bytes.Length);
  5352. fileStream.Close();
  5353. Stream stream = new MemoryStream(bytes);
  5354. while (Zips.Keys.Contains(item.FileName))
  5355. {
  5356. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5357. }
  5358. Zips.Add(item.FileName, stream);
  5359. }
  5360. }
  5361. }
  5362. if (Zips.Count > 0)
  5363. {
  5364. var byts = io.ConvertZipStream(Zips);
  5365. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5366. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5367. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5368. }
  5369. else
  5370. {
  5371. jw.Msg = "暂无生成文件!";
  5372. }
  5373. return Ok(jw);
  5374. }
  5375. /// <summary>
  5376. /// 删除该团组下的指定文件
  5377. /// </summary>
  5378. /// <param name="dto"></param>
  5379. /// <returns></returns>
  5380. [HttpPost]
  5381. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5382. {
  5383. var jw = JsonView(false);
  5384. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5385. if (sing == null)
  5386. {
  5387. jw.Msg = "暂无";
  5388. return Ok(jw);
  5389. }
  5390. if (System.IO.File.Exists(sing.FilePath))
  5391. {
  5392. try
  5393. {
  5394. System.IO.File.Delete(sing.FilePath);
  5395. }
  5396. catch (Exception ex)
  5397. {
  5398. jw.Msg = "删除失败!" + ex.Message;
  5399. return Ok(jw);
  5400. }
  5401. }
  5402. sing.IsDel = 1;
  5403. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5404. sing.DeleteUserId = dto.UserId;
  5405. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5406. jw = JsonView(true, "删除成功!");
  5407. return Ok(jw);
  5408. }
  5409. #endregion
  5410. #region 共享文件上传
  5411. /// <summary>
  5412. /// 共享文件数据初始化
  5413. /// </summary>
  5414. /// <returns></returns>
  5415. [HttpGet]
  5416. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  5417. {
  5418. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  5419. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5420. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5421. .Select(x => x.Id)
  5422. .ToList()
  5423. .Contains(userid);
  5424. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5425. .Where(x => x.STid == 111 && x.IsDel == 0)
  5426. .Select(x => new
  5427. {
  5428. x.Name,
  5429. x.Id,
  5430. }).ToList();
  5431. if (isMarketingDepartment)
  5432. {
  5433. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5434. }
  5435. if (portType == 1)
  5436. {
  5437. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5438. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5439. .Where(x => x.IsDel == 0)
  5440. .OrderByDescending(x=> x.VisitDate )
  5441. .Select(x => new
  5442. {
  5443. x.TeamName,
  5444. x.Id,
  5445. x.CityId,
  5446. })
  5447. .ToList()
  5448. .Select(x=>
  5449. {
  5450. var provinceId = x.CityId;
  5451. var isDefualtVal = true;
  5452. if (provinceId > 0)
  5453. {
  5454. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5455. if (parentId != null)
  5456. {
  5457. isDefualtVal = false;
  5458. provinceId = (int)parentId;
  5459. }
  5460. }
  5461. if (isDefualtVal)
  5462. {
  5463. provinceId = 122; //默认四川
  5464. }
  5465. return new
  5466. {
  5467. x.TeamName,
  5468. x.Id,
  5469. provinceId,
  5470. };
  5471. })
  5472. .ToList();
  5473. return Ok(JsonView(true, "SUCCESS!", new
  5474. {
  5475. dropDownType,
  5476. dropDownGroupList,
  5477. isMarketingDepartment
  5478. }));
  5479. }
  5480. else if (portType == 2 || portType == 3)
  5481. {
  5482. return Ok(JsonView(true, "SUCCESS!", new
  5483. {
  5484. dropDownType,
  5485. isMarketingDepartment
  5486. }));
  5487. }
  5488. else
  5489. {
  5490. return Ok(JsonView(false, "portType有误!"));
  5491. }
  5492. }
  5493. /// <summary>
  5494. /// 共享文件上传
  5495. /// </summary>
  5496. /// <param name="dto"></param>
  5497. /// <returns></returns>
  5498. [HttpPost]
  5499. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5500. {
  5501. var isGroup = new List<int> { 1412 };
  5502. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5503. {
  5504. return Ok(JsonView(false, "该文件需要关联团组!"));
  5505. }
  5506. if (dto.Files == null || dto.Files.Count == 0)
  5507. {
  5508. return Ok(JsonView(false, "无文件信息!"));
  5509. }
  5510. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5511. {
  5512. return Ok(JsonView(false, "文件大小超过20M!"));
  5513. }
  5514. if (dto.Userid < 1)
  5515. {
  5516. return Ok(JsonView(false, "请传入有效的Userid!"));
  5517. }
  5518. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5519. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5520. .Select((u, j) => new
  5521. {
  5522. u.CnName,
  5523. UserId = u.Id,
  5524. j.JobName,
  5525. })
  5526. .First();
  5527. if (jobInfo == null)
  5528. {
  5529. return Ok(JsonView(false, "请传入有效的Userid!"));
  5530. }
  5531. List<string> commonFileExtensions = new List<string>
  5532. {
  5533. // 文本文件
  5534. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5535. // 图片文件
  5536. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5537. // 视频文件
  5538. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5539. // 音频文件
  5540. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5541. // 压缩文件
  5542. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5543. // 数据文件
  5544. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5545. };
  5546. try
  5547. {
  5548. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5549. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5550. commonFileExtensions.AddRange(settingExtend);
  5551. }
  5552. catch (Exception)
  5553. { }
  5554. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5555. if (setdata == null)
  5556. {
  5557. return Ok(JsonView(false, "请传入有效的FileType!"));
  5558. }
  5559. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5560. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5561. if (!Directory.Exists(winPath))
  5562. {
  5563. Directory.CreateDirectory(winPath);
  5564. }
  5565. foreach (var item in dto.Files)
  5566. {
  5567. var houzui = Path.GetExtension(item.FileName);
  5568. if (!commonFileExtensions.Contains(houzui))
  5569. {
  5570. return Ok(JsonView(false, "未知后缀名称!"));
  5571. }
  5572. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5573. var saveFilePath = winPath + fileName;
  5574. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5575. {
  5576. item.CopyTo(fs);
  5577. fs.Flush();
  5578. }
  5579. var fileDetail = new Grp_GroupShareFile()
  5580. {
  5581. CreateUserId = dto.Userid,
  5582. CreateTime = DateTime.Now,
  5583. UploadJob = jobInfo.JobName,
  5584. FileName = fileName,
  5585. FileType = dto.FileType,
  5586. Diid = dto.Diid,
  5587. FilePath = winPath + fileName,
  5588. };
  5589. insertList.Add(fileDetail);
  5590. }
  5591. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5592. return Ok(JsonView(true, "保存成功!"));
  5593. }
  5594. /// <summary>
  5595. /// 查询共享文件列表
  5596. /// </summary>
  5597. /// <param name="dto"></param>
  5598. /// <returns></returns>
  5599. [HttpPost]
  5600. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5601. {
  5602. var isGroup = new List<int> { 1412 };
  5603. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5604. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5605. .And(x => x.Diid == dto.Diid)
  5606. .And(x => x.FileType == dto.FileType)
  5607. .And(x => x.IsDel == 0)
  5608. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5609. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5610. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5611. int totalCount = 0;
  5612. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5613. .Where(queryExpression.ToExpression())
  5614. .OrderBy(x => x.UploadJob)
  5615. .Select(x => new
  5616. {
  5617. x.Id,
  5618. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5619. x.FileName,
  5620. x.FileType,
  5621. x.CreateTime,
  5622. })
  5623. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5624. return Ok(JsonView(true, "SUCCESS!", new
  5625. {
  5626. FileList = dbQuery,
  5627. dto.PageSize,
  5628. dto.PageIndex,
  5629. totalCount
  5630. }));
  5631. }
  5632. /// <summary>
  5633. /// 删除共享文件模块下的指定文件
  5634. /// </summary>
  5635. /// <param name="dto"></param>
  5636. /// <returns></returns>
  5637. [HttpPost]
  5638. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5639. {
  5640. var jw = JsonView(false);
  5641. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5642. if (sing == null)
  5643. {
  5644. jw.Msg = "暂无文件信息!";
  5645. return Ok(jw);
  5646. }
  5647. if (sing.CreateUserId != dto.UserId)
  5648. {
  5649. jw.Msg = "只能删除自己上传的文件!";
  5650. return Ok(jw);
  5651. }
  5652. if (System.IO.File.Exists(sing.FilePath))
  5653. {
  5654. try
  5655. {
  5656. System.IO.File.Delete(sing.FilePath);
  5657. }
  5658. catch (Exception ex)
  5659. {
  5660. jw.Msg = "删除失败!" + ex.Message;
  5661. return Ok(jw);
  5662. }
  5663. }
  5664. sing.IsDel = 1;
  5665. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5666. sing.DeleteUserId = dto.UserId;
  5667. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5668. jw = JsonView(true, "删除成功!");
  5669. return Ok(jw);
  5670. }
  5671. #endregion
  5672. #region 团组英文资料
  5673. /// <summary>
  5674. /// 查询团组英文所有资料
  5675. /// </summary>
  5676. /// <param name="dto"></param>
  5677. /// <returns></returns>
  5678. [HttpPost]
  5679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5680. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5681. {
  5682. try
  5683. {
  5684. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5685. if (groupData.Code != 0)
  5686. {
  5687. return Ok(JsonView(false, groupData.Msg));
  5688. }
  5689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5690. }
  5691. catch (Exception ex)
  5692. {
  5693. return Ok(JsonView(false, "程序错误!"));
  5694. throw;
  5695. }
  5696. }
  5697. /// <summary>
  5698. /// 团组英文资料操作(Status:1.新增,2.修改)
  5699. /// </summary>
  5700. /// <param name="dto"></param>
  5701. /// <returns></returns>
  5702. [HttpPost]
  5703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5704. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5705. {
  5706. try
  5707. {
  5708. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5709. if (groupData.Code != 0)
  5710. {
  5711. return Ok(JsonView(false, groupData.Msg));
  5712. }
  5713. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5714. }
  5715. catch (Exception ex)
  5716. {
  5717. return Ok(JsonView(false, "程序错误!"));
  5718. throw;
  5719. }
  5720. }
  5721. /// <summary>
  5722. /// 团组英文资料Id查询数据
  5723. /// </summary>
  5724. /// <param name="dto"></param>
  5725. /// <returns></returns>
  5726. [HttpPost]
  5727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5728. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5729. {
  5730. try
  5731. {
  5732. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5733. if (_DelegationEnData != null)
  5734. {
  5735. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5736. }
  5737. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5738. }
  5739. catch (Exception ex)
  5740. {
  5741. return Ok(JsonView(false, "程序错误!"));
  5742. throw;
  5743. }
  5744. }
  5745. /// <summary>
  5746. /// 团组英文资料删除
  5747. /// </summary>
  5748. /// <param name="dto"></param>
  5749. /// <returns></returns>
  5750. [HttpPost]
  5751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5752. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5753. {
  5754. try
  5755. {
  5756. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5757. if (!res)
  5758. {
  5759. return Ok(JsonView(false, "删除失败"));
  5760. }
  5761. return Ok(JsonView(true, "删除成功!"));
  5762. }
  5763. catch (Exception ex)
  5764. {
  5765. return Ok(JsonView(false, "程序错误!"));
  5766. throw;
  5767. }
  5768. }
  5769. #endregion
  5770. #region 导出邀请函
  5771. /// <summary>
  5772. /// 导出邀请函页面初始化
  5773. /// </summary>
  5774. /// <param name="dto"></param>
  5775. /// <returns></returns>
  5776. [HttpPost]
  5777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5778. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5779. {
  5780. try
  5781. {
  5782. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5783. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5784. if (dto.DiId == 0)
  5785. {
  5786. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5787. }
  5788. else
  5789. {
  5790. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5791. }
  5792. return Ok(JsonView(true, "查询成功!", new
  5793. {
  5794. deleClient = crm_Deles,
  5795. delegations = grp_Delegations
  5796. }));
  5797. }
  5798. catch (Exception ex)
  5799. {
  5800. return Ok(JsonView(false, "程序错误!"));
  5801. throw;
  5802. }
  5803. }
  5804. /// <summary>
  5805. /// 导出邀请函
  5806. /// </summary>
  5807. /// <param name="dto"></param>
  5808. /// <returns></returns>
  5809. [HttpPost]
  5810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5811. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5812. {
  5813. #region 参数验证
  5814. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5815. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5816. #endregion
  5817. try
  5818. {
  5819. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5820. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5821. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5822. From Grp_TourClientList tcl
  5823. Left Join
  5824. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5825. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5826. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5827. From Crm_DeleClient dc
  5828. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5829. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5830. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5831. Where dc.IsDel = 0) temp
  5832. On temp.DcId =tcl.ClientId
  5833. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5834. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5835. List<string> texts = new List<string>();
  5836. if (datas.Count != 0)
  5837. {
  5838. foreach (TourClientListDetailsView item in datas)
  5839. {
  5840. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5841. {
  5842. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5843. }
  5844. else
  5845. {
  5846. string name = item.LastName + item.FirstName;
  5847. texts.Add(name);
  5848. }
  5849. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5850. {
  5851. if (!transDic.ContainsKey(item.Job))
  5852. {
  5853. texts.Add(item.Job);
  5854. }
  5855. }
  5856. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5857. {
  5858. texts.Add(item.CompanyFullName);
  5859. }
  5860. }
  5861. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5862. if (transData.Count > 0)
  5863. {
  5864. foreach (TranslateResult item in transData)
  5865. {
  5866. if (!transDic.ContainsKey(item.Query))
  5867. {
  5868. transDic.Add(item.Query, item.Translation);
  5869. }
  5870. }
  5871. }
  5872. List<GuestList> list = new List<GuestList>();
  5873. foreach (TourClientListDetailsView dele in datas)
  5874. {
  5875. GuestList guestList = new GuestList();
  5876. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5877. {
  5878. guestList.Name = dele.Pinyin;
  5879. }
  5880. else
  5881. {
  5882. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5883. guestList.Name = Name;
  5884. }
  5885. if (dele.Sex == 0)
  5886. {
  5887. guestList.Sex = "Male";
  5888. }
  5889. else if (dele.Sex == 1)
  5890. {
  5891. guestList.Sex = "Female";
  5892. }
  5893. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5894. if (!string.IsNullOrEmpty(dele.Job))
  5895. {
  5896. guestList.Job = dele.Job;
  5897. }
  5898. list.Add(guestList);
  5899. }
  5900. //载入模板
  5901. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5902. DocumentBuilder builder = new DocumentBuilder(doc);
  5903. //获取word里所有表格
  5904. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5905. //获取所填表格的序数
  5906. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5907. var rowStart = tableOne.Rows[0]; //获取第1行
  5908. //循环赋值
  5909. for (int i = 0; i < list.Count; i++)
  5910. {
  5911. builder.MoveToCell(0, i + 1, 0, 0);
  5912. builder.Write(list[i].Name.ToString());
  5913. builder.MoveToCell(0, i + 1, 1, 0);
  5914. builder.Write(list[i].Sex.ToString());
  5915. builder.MoveToCell(0, i + 1, 2, 0);
  5916. builder.Write(list[i].DOB.ToString());
  5917. builder.MoveToCell(0, i + 1, 3, 0);
  5918. builder.Write(list[i].Job.ToString());
  5919. }
  5920. //删除多余行
  5921. while (tableOne.Rows.Count > list.Count + 1)
  5922. {
  5923. tableOne.Rows.RemoveAt(list.Count + 1);
  5924. }
  5925. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5926. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5927. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5928. doc.Save(filePath);
  5929. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5930. return Ok(JsonView(true, "操作成功!", Url));
  5931. }
  5932. else
  5933. {
  5934. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5935. }
  5936. }
  5937. catch (Exception ex)
  5938. {
  5939. return Ok(JsonView(false, ex.Message));
  5940. throw;
  5941. }
  5942. }
  5943. #endregion
  5944. #region 团组经理模块 出入境费用
  5945. /// <summary>
  5946. /// 团组模块 - 出入境费用 - 省份基础数据源
  5947. /// </summary>
  5948. /// <returns></returns>
  5949. [HttpGet]
  5950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5951. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5952. {
  5953. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5954. }
  5955. /// <summary>
  5956. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5957. /// </summary>
  5958. /// <returns></returns>
  5959. [HttpPost]
  5960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5961. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5962. {
  5963. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5964. var groupNamFirst = groupNameData.FirstOrDefault();
  5965. //SetDataInfoView
  5966. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5967. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5968. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5969. //验证城市归属并给默认值
  5970. int provinceId = 122;
  5971. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5972. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5973. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5974. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5975. return Ok(JsonView(true, "查询成功!", new
  5976. {
  5977. GroupNameData = groupNameData,
  5978. CurrencyData = _CurrencyData,
  5979. WordTypeData = wordTypeData,
  5980. ExcelTypeData = excelTypeData,
  5981. CurrencyInit = _currencyInfos,
  5982. ViewPermissionData = viewPermissionData
  5983. }));
  5984. }
  5985. /// <summary>
  5986. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5987. /// </summary>
  5988. /// <returns></returns>
  5989. [HttpGet("{provinceId}")]
  5990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5991. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5992. {
  5993. //验证城市归属并给默认值
  5994. if (provinceId < 1) provinceId = 122;
  5995. /*
  5996. * 122 四川
  5997. * 108 贵州
  5998. * 103 重庆
  5999. * 132 云南
  6000. */
  6001. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6002. return Ok(JsonView(true, "查询成功!", new
  6003. {
  6004. WordTypeData = wordTypeData,
  6005. ExcelTypeData = excelTypeData,
  6006. }));
  6007. }
  6008. /// <summary>
  6009. /// 团组模块 - 出入境费用
  6010. /// 实时汇率 tips
  6011. /// 签证费用 tips
  6012. /// 机票费用 tips
  6013. /// </summary>
  6014. /// <returns></returns>
  6015. [HttpPost]
  6016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6017. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6018. {
  6019. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6020. //默认币种显示
  6021. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6022. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6023. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6024. return Ok(JsonView(true, "查询成功!", new
  6025. {
  6026. //GroupNameData = groupNameData.Data,
  6027. visaData = visaData.Data,
  6028. airData = airData,
  6029. reteInfos = reteInfos
  6030. }));
  6031. }
  6032. /// <summary>
  6033. /// 团组模块 - 出入境费用 - Info
  6034. /// </summary>
  6035. /// <returns></returns>
  6036. [HttpPost]
  6037. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6039. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6040. {
  6041. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6042. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6043. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6044. }
  6045. /// <summary>
  6046. /// 团组模块 - 出入境费用 - 设置view权限
  6047. /// </summary>
  6048. /// <returns></returns>
  6049. [HttpPost]
  6050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6051. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6052. {
  6053. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6054. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6055. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6056. var permissions = new List<Grp_EnterExitCostPermission>();
  6057. foreach (var userId in dto.UserIds)
  6058. {
  6059. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6060. }
  6061. if (permissions.Any())
  6062. {
  6063. _sqlSugar.BeginTran();
  6064. try
  6065. {
  6066. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6067. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6068. if (result < 1)
  6069. {
  6070. _sqlSugar.RollbackTran();
  6071. return Ok(JsonView(false));
  6072. }
  6073. }
  6074. catch (Exception ex)
  6075. {
  6076. _sqlSugar.RollbackTran();
  6077. return Ok(JsonView(false, ex.Message));
  6078. }
  6079. _sqlSugar.CommitTran();
  6080. return Ok(JsonView(true));
  6081. }
  6082. return Ok(JsonView(false));
  6083. }
  6084. /// <summary>
  6085. /// 团组模块 - 出入境费用 - Add And Update
  6086. /// </summary>
  6087. /// <returns></returns>
  6088. [HttpPost]
  6089. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6091. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6092. {
  6093. try
  6094. {
  6095. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6096. if (dto.DayOtherPriceData.Any())
  6097. {
  6098. var inserList = dto.DayOtherPriceData
  6099. .Where(x => x.Id == 0)
  6100. .Select(x => new Grp_DayOtherPrice
  6101. {
  6102. Cost = x.Cost,
  6103. Id = x.Id,
  6104. CreateTime = DateTime.Now,
  6105. CreateUserId = dto.UserId,
  6106. Currency = x.Currency,
  6107. Diid = x.DiId,
  6108. Index = x.Index,
  6109. IsDel = 0,
  6110. SetDataId = x.SetDataId,
  6111. SubTotal = x.SubTotal,
  6112. Remark = x.Remark
  6113. })
  6114. .ToList();
  6115. var updateList = dto.DayOtherPriceData
  6116. .Where(x => x.Id != 0)
  6117. .Select(x => new Grp_DayOtherPrice
  6118. {
  6119. Cost = x.Cost,
  6120. Id = x.Id,
  6121. CreateTime = DateTime.Now,
  6122. CreateUserId = dto.UserId,
  6123. Currency = x.Currency,
  6124. Diid = x.DiId,
  6125. Index = x.Index,
  6126. IsDel = 0,
  6127. SetDataId = x.SetDataId,
  6128. SubTotal = x.SubTotal,
  6129. Remark = x.Remark
  6130. })
  6131. .ToList();
  6132. //添加
  6133. _sqlSugar.BeginTran();
  6134. if (inserList.Any())
  6135. {
  6136. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6137. }
  6138. if (updateList.Any())
  6139. {
  6140. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6141. }
  6142. _sqlSugar.CommitTran();
  6143. }
  6144. if (data.Code != 0)
  6145. {
  6146. return Ok(JsonView(false, data.Msg));
  6147. }
  6148. //生成默认文件pdf并且通知人员
  6149. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6150. {
  6151. DiId = dto.DiId,
  6152. ExportType = 1,
  6153. SubTypeId = 1005
  6154. }, "pdf");
  6155. //发送通知
  6156. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6157. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6158. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6159. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6160. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6161. //汇率信息记录
  6162. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6163. return Ok(JsonView(true, data.Msg, data.Data));
  6164. }
  6165. catch (Exception ex)
  6166. {
  6167. return Ok(JsonView(false, ex.Message));
  6168. }
  6169. }
  6170. /// <summary>
  6171. /// 团组模块 - 出入境费用 - Confirm 费用
  6172. /// </summary>
  6173. /// <returns></returns>
  6174. [HttpPost]
  6175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6176. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6177. {
  6178. //TODO:测试完毕需把对应的用户ID更改
  6179. //1、数据表添加字段
  6180. //2、更改字段接口()
  6181. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6182. //3、确认成功 给财务发送消息
  6183. if (_view.Code == 200)
  6184. {
  6185. if (dto.Type == 1)
  6186. {
  6187. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6188. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6189. }
  6190. }
  6191. return Ok(_view);
  6192. }
  6193. /// <summary>
  6194. /// 团组模块 - 出入境费用 - File download
  6195. /// </summary>
  6196. /// <param name="dto"></param>
  6197. /// <returns></returns>
  6198. [HttpPost]
  6199. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6201. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6202. {
  6203. try
  6204. {
  6205. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6206. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6207. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6208. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6209. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6210. 3 团组成员名单 1 团组成员名单", ""));
  6211. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6212. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6213. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6214. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6215. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6216. //数据源
  6217. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6218. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6219. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6220. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6221. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6222. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6223. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6224. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6225. .Select((x, a, b) => new
  6226. {
  6227. x.Index,
  6228. itemName = a.Name,
  6229. CurrencyStr = b.Name,
  6230. x.Cost,
  6231. x.SubTotal,
  6232. x.Remark
  6233. })
  6234. .OrderBy((x) => x.Index)
  6235. .ToList(); //其他款项费用
  6236. var peiceItemCurrencys = new List<string>();
  6237. if (_DayAndCosts.Any())
  6238. {
  6239. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6240. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6241. }
  6242. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6243. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6244. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6245. {
  6246. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6247. }
  6248. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6249. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6250. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6251. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6252. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6253. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6254. .Select((tcl, dc, cc) => new ClientInfo
  6255. {
  6256. LastName = dc.LastName,
  6257. FirstName = dc.FirstName,
  6258. Sex = dc.Sex,
  6259. Birthday = dc.BirthDay,
  6260. Company = cc.CompanyFullName,
  6261. Job = dc.Job
  6262. })
  6263. .ToList();
  6264. foreach (var item in DeleClientList)
  6265. {
  6266. EncryptionProcessor.DecryptProperties(item);
  6267. }
  6268. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6269. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6270. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6271. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6272. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6273. if (dto.ExportType == 1) //明细表
  6274. {
  6275. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6276. {
  6277. //获取模板
  6278. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6279. //载入模板
  6280. Document doc = new Document(tempPath);
  6281. DocumentBuilder builder = new DocumentBuilder(doc);
  6282. //利用键值对存放数据
  6283. Dictionary<string, string> dic = new Dictionary<string, string>();
  6284. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6285. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6286. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6287. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6288. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6289. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6290. //境内费用(其他费用)
  6291. if (_EnterExitCosts.ChoiceOne == 1)
  6292. {
  6293. string row1_1 = "";
  6294. if (_EnterExitCosts.Visa > 0)
  6295. {
  6296. //insidePayTotal += _EnterExitCosts.Visa;
  6297. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6298. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6299. //{
  6300. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6301. //}
  6302. }
  6303. string row1_2 = "";
  6304. if (_EnterExitCosts.YiMiao > 0)
  6305. {
  6306. //insidePayTotal += _EnterExitCosts.YiMiao;
  6307. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6308. }
  6309. if (_EnterExitCosts.HeSuan > 0)
  6310. {
  6311. //insidePayTotal += _EnterExitCosts.HeSuan;
  6312. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6313. }
  6314. if (_EnterExitCosts.Service > 0)
  6315. {
  6316. //insidePayTotal += _EnterExitCosts.Service;
  6317. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6318. }
  6319. string row1_3 = "";
  6320. if (_EnterExitCosts.Safe > 0)
  6321. {
  6322. //insidePayTotal += _EnterExitCosts.Safe;
  6323. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6324. }
  6325. if (_EnterExitCosts.Ticket > 0)
  6326. {
  6327. //insidePayTotal += _EnterExitCosts.Ticket;
  6328. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6329. }
  6330. string row1 = "";
  6331. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6332. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6333. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6334. row1 += $"备注:{_EnterExitCosts.Remark}";
  6335. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6336. dic.Add("Row1Str", row1);
  6337. }
  6338. string airTotalStr = string.Empty,
  6339. airPriceStr = string.Empty;
  6340. //经济舱
  6341. if (_EnterExitCosts.SumJJC == 1)
  6342. {
  6343. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6344. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6345. }
  6346. //公务舱
  6347. if (_EnterExitCosts.SumGWC == 1)
  6348. {
  6349. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6350. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6351. }
  6352. //头等舱
  6353. if (_EnterExitCosts.SumTDC == 1)
  6354. {
  6355. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6356. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6357. }
  6358. //汇率描述
  6359. string rateStr = "";
  6360. if (peiceItemCurrencyInfos.Any())
  6361. {
  6362. rateStr = "\r\n汇率描述:";
  6363. foreach (var item in peiceItemCurrencyInfos)
  6364. {
  6365. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6366. }
  6367. }
  6368. string twoItemRemark = "备注:";
  6369. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6370. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6371. dic.Add("AirTotalStr", airTotalStr);
  6372. dic.Add("AirPriceStr", airPriceStr);
  6373. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6374. dic.Add("TwoItemRemark", twoItemRemark);
  6375. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6376. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6377. int table1Row = 0,
  6378. table2Row = 0,
  6379. table3Row = 0,
  6380. table4Row = 0,
  6381. table5Row = 0;
  6382. //住宿费
  6383. if (_EnterExitCosts.ChoiceThree == 1)
  6384. {
  6385. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6386. table1Row = dac1.Count;
  6387. #region 填充word表格内容
  6388. for (int i = 0; i < dac1.Count; i++)
  6389. {
  6390. Grp_DayAndCost dac = dac1[i];
  6391. if (dac == null) continue;
  6392. builder.MoveToCell(0, i, 0, 0);
  6393. builder.Write("第" + dac.Days.ToString() + "晚:");
  6394. builder.MoveToCell(0, i, 1, 0);
  6395. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6396. //builder.Write(dac.Place == null ? "" : dac.Place);
  6397. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6398. builder.MoveToCell(0, i, 2, 0);
  6399. builder.Write("费用标准:");
  6400. string curr = "";
  6401. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6402. if (currData != null)
  6403. {
  6404. curr = currData.Name;
  6405. }
  6406. builder.MoveToCell(0, i, 3, 0);
  6407. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6408. builder.MoveToCell(0, i, 4, 0);
  6409. builder.Write("费用小计:");
  6410. builder.MoveToCell(0, i, 5, 0);
  6411. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6412. }
  6413. #endregion
  6414. }
  6415. else dic.Add("SubZS", "0.00");
  6416. //删除多余行
  6417. while (table1.Rows.Count > table1Row)
  6418. {
  6419. table1.Rows.RemoveAt(table1Row);
  6420. }
  6421. //伙食费
  6422. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6423. if (_EnterExitCosts.ChoiceFour == 1)
  6424. {
  6425. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6426. table2Row = dac2.Count;
  6427. #region 填充word表格内容
  6428. for (int i = 0; i < dac2.Count; i++)
  6429. {
  6430. Grp_DayAndCost dac = dac2[i];
  6431. if (dac == null) continue;
  6432. builder.MoveToCell(1, i, 0, 0);
  6433. builder.Write("第" + dac.Days.ToString() + "天:");
  6434. builder.MoveToCell(1, i, 1, 0);
  6435. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6436. builder.MoveToCell(1, i, 2, 0);
  6437. builder.Write("费用标准:");
  6438. string curr = "";
  6439. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6440. if (currData != null)
  6441. {
  6442. curr = currData.Name;
  6443. }
  6444. builder.MoveToCell(1, i, 3, 0);
  6445. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6446. builder.MoveToCell(1, i, 4, 0);
  6447. builder.Write("费用小计:");
  6448. builder.MoveToCell(1, i, 5, 0);
  6449. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6450. }
  6451. #endregion
  6452. }
  6453. else dic.Add("SubHS", "0.00");
  6454. //删除多余行
  6455. while (table2.Rows.Count > table2Row)
  6456. {
  6457. table2.Rows.RemoveAt(table2Row);
  6458. }
  6459. //公杂费
  6460. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6461. if (_EnterExitCosts.ChoiceFive == 1)
  6462. {
  6463. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6464. table3Row = dac3.Count;
  6465. #region 填充word表格内容
  6466. for (int i = 0; i < dac3.Count; i++)
  6467. {
  6468. Grp_DayAndCost dac = dac3[i];
  6469. if (dac == null) continue;
  6470. builder.MoveToCell(2, i, 0, 0);
  6471. builder.Write("第" + dac.Days.ToString() + "天:");
  6472. builder.MoveToCell(2, i, 1, 0);
  6473. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6474. builder.MoveToCell(2, i, 2, 0);
  6475. builder.Write("费用标准:");
  6476. string curr = "";
  6477. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6478. if (currData != null)
  6479. {
  6480. curr = currData.Name;
  6481. }
  6482. builder.MoveToCell(2, i, 3, 0);
  6483. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6484. builder.MoveToCell(2, i, 4, 0);
  6485. builder.Write("费用小计:");
  6486. builder.MoveToCell(2, i, 5, 0);
  6487. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6488. }
  6489. //删除多余行
  6490. while (table3.Rows.Count > table3Row)
  6491. {
  6492. table3.Rows.RemoveAt(table3Row);
  6493. }
  6494. #endregion
  6495. }
  6496. else dic.Add("SubGZF", "0.00");
  6497. //删除多余行
  6498. while (table3.Rows.Count > table3Row)
  6499. {
  6500. table3.Rows.RemoveAt(table3Row);
  6501. }
  6502. //培训费
  6503. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6504. if (_EnterExitCosts.ChoiceSix == 1)
  6505. {
  6506. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6507. dic.Add("SubPX", pxStr);
  6508. table4Row = dac4.Count;
  6509. #region 填充word表格内容
  6510. for (int i = 0; i < dac4.Count; i++)
  6511. {
  6512. Grp_DayAndCost dac = dac4[i];
  6513. if (dac == null) continue;
  6514. builder.MoveToCell(3, i, 0, 0);
  6515. builder.Write("第" + dac.Days.ToString() + "天:");
  6516. builder.MoveToCell(3, i, 1, 0);
  6517. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6518. builder.MoveToCell(3, i, 2, 0);
  6519. builder.Write("费用标准:");
  6520. string curr = "";
  6521. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6522. if (currData != null)
  6523. {
  6524. curr = currData.Name;
  6525. }
  6526. builder.MoveToCell(3, i, 3, 0);
  6527. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6528. builder.MoveToCell(3, i, 4, 0);
  6529. builder.Write("费用小计:");
  6530. builder.MoveToCell(3, i, 5, 0);
  6531. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6532. }
  6533. #endregion
  6534. }
  6535. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6536. //删除多余行
  6537. while (table4.Rows.Count > table4Row)
  6538. {
  6539. table4.Rows.RemoveAt(table4Row);
  6540. }
  6541. //其他费用
  6542. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6543. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6544. {
  6545. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6546. dic.Add("titleQi", qtStr);
  6547. table5Row = dac5.Count;
  6548. #region 填充word表格内容
  6549. for (int i = 0; i < dac5.Count; i++)
  6550. {
  6551. var dac = dac5[i];
  6552. if (dac == null) continue;
  6553. builder.MoveToCell(4, i, 0, 0);
  6554. builder.Write("第" + dac.Index.ToString() + "项:");
  6555. builder.MoveToCell(4, i, 1, 0);
  6556. builder.Write(dac.itemName);
  6557. builder.MoveToCell(4, i, 2, 0);
  6558. builder.Write("费用标准:");
  6559. builder.MoveToCell(4, i, 3, 0);
  6560. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6561. builder.MoveToCell(4, i, 4, 0);
  6562. builder.Write("费用小计:");
  6563. builder.MoveToCell(4, i, 5, 0);
  6564. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6565. builder.MoveToCell(4, i, 6, 0);
  6566. builder.Write("备注:");
  6567. builder.MoveToCell(4, i, 7, 0);
  6568. builder.Write(dac.Remark);
  6569. }
  6570. #endregion
  6571. }
  6572. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6573. //删除多余行
  6574. while (table5.Rows.Count > table5Row)
  6575. {
  6576. table5.Rows.RemoveAt(table5Row);
  6577. }
  6578. //加上其他费用
  6579. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6580. decimal subJJC = 0.00M,
  6581. subGWC = 0.00M,
  6582. subTDC = 0.00M;
  6583. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6584. string totalLabel = string.Format("全部费用总计:");
  6585. //经济舱
  6586. if (_EnterExitCosts.SumJJC == 1)
  6587. {
  6588. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6589. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6590. }
  6591. //公务舱
  6592. if (_EnterExitCosts.SumGWC == 1)
  6593. {
  6594. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6595. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6596. }
  6597. //头等舱
  6598. if (_EnterExitCosts.SumTDC == 1)
  6599. {
  6600. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6601. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6602. }
  6603. //TotalLabel
  6604. dic.Add("TotalLabel", totalLabel);
  6605. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6606. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6607. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6608. #region 填充word模板书签内容
  6609. foreach (var key in dic.Keys)
  6610. {
  6611. Bookmark bookmark = doc.Range.Bookmarks[key];
  6612. if (bookmark != null)
  6613. {
  6614. builder.MoveToBookmark(key);
  6615. builder.Write(dic[key]);
  6616. }
  6617. }
  6618. #endregion
  6619. #region 设置页眉
  6620. string userLabel = string.Empty;
  6621. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6622. if (currUserInfo != null)
  6623. {
  6624. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6625. if (userInfo != null)
  6626. {
  6627. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6628. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6629. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6630. }
  6631. }
  6632. //设置页脚
  6633. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6634. #endregion
  6635. //文件名
  6636. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6637. AsposeHelper.removewatermark_v2180();
  6638. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6639. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6640. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6641. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6642. }
  6643. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6644. {
  6645. //获取模板
  6646. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6647. //载入模板
  6648. Document doc = new Document(tempPath);
  6649. DocumentBuilder builder = new DocumentBuilder(doc);
  6650. Dictionary<string, string> dic = new Dictionary<string, string>();
  6651. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6652. {
  6653. List<string> list = new List<string>();
  6654. try
  6655. {
  6656. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6657. foreach (var item in spilitArr)
  6658. {
  6659. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6660. var depCode = spDotandEmpty[2].Substring(0, 3);
  6661. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6662. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6663. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6664. list.Add(depName);
  6665. list.Add(arrName);
  6666. }
  6667. list = list.Distinct().ToList();
  6668. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6669. }
  6670. catch (Exception)
  6671. {
  6672. dic.Add("ReturnCode", "行程录入不正确!");
  6673. }
  6674. }
  6675. else
  6676. {
  6677. dic.Add("ReturnCode", "未录入行程!");
  6678. }
  6679. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6680. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6681. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6682. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6683. {
  6684. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6685. dic.Add("Day", sp.Days.ToString());
  6686. }
  6687. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6688. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6689. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6690. //dic.Add("Names", Names);
  6691. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6692. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6693. decimal dac1totalPrice = 0.00M;
  6694. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6695. foreach (var dac in dac1)
  6696. {
  6697. if (dac.SubTotal == 0.00M)
  6698. {
  6699. continue;
  6700. }
  6701. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6702. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6703. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6704. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6705. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6706. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6707. builder.Write(currency);//币种
  6708. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6709. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6710. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6711. builder.Write("");//人数
  6712. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6713. builder.Write("");//天数
  6714. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6715. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6716. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6717. decimal rate = 0.00M;
  6718. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6719. builder.Write(rate.ToString("#0.0000"));//汇率
  6720. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6721. decimal rbmPrice = dac.SubTotal;
  6722. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6723. accommodationStartIndex++;
  6724. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6725. }
  6726. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6727. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6728. {
  6729. table1.Rows.RemoveAt(i - 1);
  6730. foodandotherStartIndex--;
  6731. }
  6732. if (dac2.Count == dac3.Count)//国家 币种 金额
  6733. {
  6734. for (int i = 0; i < dac2.Count; i++)
  6735. {
  6736. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6737. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6738. }
  6739. }
  6740. decimal dac2totalPrice = 0.00M;
  6741. foreach (var dac in dac2)
  6742. {
  6743. if (dac.SubTotal == 0)
  6744. {
  6745. continue;
  6746. }
  6747. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6748. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6749. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6750. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6751. builder.Write(currency);//币种
  6752. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6753. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6754. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6755. builder.Write("");//人数
  6756. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6757. builder.Write("");//天数
  6758. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6759. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6760. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6761. decimal rate = 0.00M;
  6762. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6763. builder.Write(rate.ToString("#0.0000"));//汇率
  6764. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6765. decimal rbmPrice = dac.SubTotal;
  6766. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6767. foodandotherStartIndex++;
  6768. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6769. }
  6770. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6771. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6772. {
  6773. table1.Rows.RemoveAt(i - 1);
  6774. }
  6775. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6776. string otherFeeStr = "";
  6777. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6778. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6779. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6780. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6781. foreach (var otherInfo in dac5)
  6782. {
  6783. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6784. }
  6785. #endregion
  6786. if (otherFeeStr.Length > 0)
  6787. {
  6788. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6789. otherFeeStr = $"({otherFeeStr})";
  6790. dic.Add("OtherFeeStr", otherFeeStr);
  6791. }
  6792. //总计
  6793. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6794. //国际旅费
  6795. string outsideAir = string.Empty;
  6796. string allPriceAir = string.Empty;
  6797. if (_EnterExitCosts.SumJJC == 1)
  6798. {
  6799. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6800. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6801. }
  6802. if (_EnterExitCosts.SumGWC == 1)
  6803. {
  6804. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6805. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6806. }
  6807. if (_EnterExitCosts.SumTDC == 1)
  6808. {
  6809. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6810. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6811. }
  6812. dic.Add("InTravelPrice", $"({outsideAir})");
  6813. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6814. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6815. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6816. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6817. foreach (var key in dic.Keys)
  6818. {
  6819. builder.MoveToBookmark(key);
  6820. builder.Write(dic[key]);
  6821. }
  6822. //模板文件名
  6823. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6824. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6825. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6826. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6827. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6828. }
  6829. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6830. {
  6831. //获取模板
  6832. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6833. //载入模板
  6834. WorkbookDesigner designer = new WorkbookDesigner();
  6835. designer.Workbook = new Workbook(tempPath);
  6836. Dictionary<string, string> dic = new Dictionary<string, string>();
  6837. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6838. {
  6839. List<string> list = new List<string>();
  6840. try
  6841. {
  6842. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6843. foreach (var item in spilitArr)
  6844. {
  6845. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6846. var depCode = spDotandEmpty[2].Substring(0, 3);
  6847. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6848. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6849. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6850. list.Add(depName);
  6851. list.Add(arrName);
  6852. }
  6853. list = list.Distinct().ToList();
  6854. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6855. }
  6856. catch (Exception)
  6857. {
  6858. dic.Add("ReturnCode", "行程录入不正确!");
  6859. }
  6860. }
  6861. else
  6862. {
  6863. dic.Add("ReturnCode", "未录入行程!");
  6864. }
  6865. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6866. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6867. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6868. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6869. {
  6870. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6871. dic.Add("Day", sp.Days.ToString());
  6872. }
  6873. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6874. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6875. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6876. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6877. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6878. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6879. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6880. designer.SetDataSource("Name", Names);
  6881. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6882. designer.SetDataSource("Day", dic["Day"] + "天");
  6883. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6884. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6885. int startIndex = 10;
  6886. const int startIndexcopy = 10;
  6887. if (dac2.Count == dac3.Count)//国家 币种 金额
  6888. {
  6889. for (int i = 0; i < dac2.Count; i++)
  6890. {
  6891. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6892. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6893. }
  6894. }
  6895. DataTable dtdac1 = new DataTable();
  6896. List<string> place = new List<string>();
  6897. dtdac1.Columns.AddRange(new DataColumn[] {
  6898. new DataColumn(){ ColumnName = "city"},
  6899. new DataColumn(){ ColumnName = "curr"},
  6900. new DataColumn(){ ColumnName = "criterion"},
  6901. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6902. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6903. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6904. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6905. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6906. });
  6907. DataTable dtdac2 = new DataTable();
  6908. dtdac2.Columns.AddRange(new DataColumn[] {
  6909. new DataColumn(){ ColumnName = "city"},
  6910. new DataColumn(){ ColumnName = "curr"},
  6911. new DataColumn(){ ColumnName = "criterion"},
  6912. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6913. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6914. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6915. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6916. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6917. });
  6918. dtdac1.TableName = "tb1";
  6919. dtdac2.TableName = "tb2";
  6920. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6921. foreach (var item in dac1)
  6922. {
  6923. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6924. if (place.Contains(item.Place))
  6925. {
  6926. continue;
  6927. }
  6928. DataRow row = dtdac1.NewRow();
  6929. row["city"] = item.Place;
  6930. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6931. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6932. row["curr"] = currency;
  6933. row["rate"] = rate.ToString("#0.0000");
  6934. row["criterion"] = item.Cost.ToString("#0.00");
  6935. row["number"] = 1;
  6936. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6937. //row["costRMB"] = rbmPrice;
  6938. dtdac1.Rows.Add(row);
  6939. place.Add(item.Place);
  6940. }
  6941. place = new List<string>();
  6942. foreach (var item in dac2)
  6943. {
  6944. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6945. if (place.Contains(item.Place))
  6946. {
  6947. continue;
  6948. }
  6949. DataRow row = dtdac2.NewRow();
  6950. row["city"] = item.Place;
  6951. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6952. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6953. row["curr"] = currency;
  6954. row["rate"] = rate.ToString("#0.0000");
  6955. row["criterion"] = item.Cost.ToString("#0.00");
  6956. row["number"] = 1;
  6957. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6958. //row["cost"] = item.SubTotal;
  6959. //row["costRMB"] = rbmPrice;
  6960. dtdac2.Rows.Add(row);
  6961. place.Add(item.Place);
  6962. //dac2totalPrice += rbmPrice;
  6963. }
  6964. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6965. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6966. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6967. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6968. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6969. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6970. string cell4Str1 = string.Empty;
  6971. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6972. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6973. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6974. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6975. string cellStr = $" 5.其他费用(";
  6976. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6977. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6978. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6979. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6980. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6981. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6982. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6983. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6984. foreach (var otherInfo in dac5)
  6985. {
  6986. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6987. }
  6988. #endregion
  6989. if (cellStr.Length > 8)
  6990. {
  6991. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6992. }
  6993. cellStr += ")";
  6994. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6995. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6996. decimal pxFee = dac4.Sum(it => it.Cost);
  6997. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6998. string celllastStr1 = "";
  6999. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7000. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7001. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7002. celllastStr1 += $",国际旅费 元";
  7003. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7004. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7005. designer.SetDataSource("cell4Str", cell4Str);
  7006. designer.SetDataSource("cellStr", cellStr);
  7007. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7008. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7009. designer.SetDataSource("celllastStr", celllastStr);
  7010. Workbook wb = designer.Workbook;
  7011. var sheet = wb.Worksheets[0];
  7012. //绑定datatable数据集
  7013. designer.SetDataSource(dtdac1);
  7014. designer.SetDataSource(dtdac2);
  7015. designer.Process();
  7016. var rowStart = dtdac1.Rows.Count;
  7017. while (rowStart > 0)
  7018. {
  7019. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7020. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7021. startIndex++;
  7022. rowStart--;
  7023. }
  7024. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7025. startIndex += 1; //总计行
  7026. rowStart = dtdac2.Rows.Count;
  7027. while (rowStart > 0)
  7028. {
  7029. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7030. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7031. startIndex++;
  7032. rowStart--;
  7033. }
  7034. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7035. wb.CalculateFormula(true);
  7036. //模板文件名
  7037. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7038. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7039. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7040. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7041. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7042. }
  7043. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7044. {
  7045. //获取模板
  7046. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7047. //载入模板
  7048. Document doc = new Document(tempPath);
  7049. DocumentBuilder builder = new DocumentBuilder(doc);
  7050. Dictionary<string, string> dic = new Dictionary<string, string>();
  7051. dic.Add("GroupName", _DelegationInfo.TeamName);
  7052. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7053. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7054. string missionLeaderJob = "";//负责人job
  7055. //int groupNumber = 0; //团人数
  7056. if (DeleClientList.Count > 0)
  7057. {
  7058. missionLeader = DeleClientList[0]?.Name ?? "";
  7059. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7060. }
  7061. dic.Add("MissionLeader", missionLeader); //团负责人
  7062. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7063. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7064. #region MyRegion
  7065. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7066. //{
  7067. // List<string> list = new List<string>();
  7068. // try
  7069. // {
  7070. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7071. // foreach (var item in spilitArr)
  7072. // {
  7073. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7074. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7075. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7076. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7077. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7078. // list.Add(depName);
  7079. // list.Add(arrName);
  7080. // }
  7081. // list = list.Distinct().ToList();
  7082. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7083. // }
  7084. // catch (Exception)
  7085. // {
  7086. // dic.Add("ReturnCode", "行程录入不正确!");
  7087. // }
  7088. //}
  7089. //else
  7090. //{
  7091. // dic.Add("ReturnCode", "未录入行程!");
  7092. //}
  7093. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7094. dic.Add("ReturnCode", string.Join("、", countrys));
  7095. #endregion
  7096. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7097. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7098. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7099. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7100. //{
  7101. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7102. // dic.Add("Day", sp.Days.ToString());
  7103. //}
  7104. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7105. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7106. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7107. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7108. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7109. //培训人员名单
  7110. int cultivateRowIndex = 7;
  7111. foreach (var item in DeleClientList)
  7112. {
  7113. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7114. builder.Write(item.Name);
  7115. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7116. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7117. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7118. string birthDay = "";
  7119. if (item.Birthday != null)
  7120. {
  7121. DateTime dt = Convert.ToDateTime(item.Birthday);
  7122. birthDay = $"{dt.Year}.{dt.Month}";
  7123. }
  7124. builder.Write(birthDay);
  7125. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7126. builder.Write(item.Company);
  7127. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7128. builder.Write(item.Job);
  7129. cultivateRowIndex++;
  7130. }
  7131. //删除多余行
  7132. //cultivateRowIndex -= 2;
  7133. int delRows = 10 + 7 - cultivateRowIndex;
  7134. if (delRows > 0)
  7135. {
  7136. for (int i = 0; i < delRows; i++)
  7137. {
  7138. table1.Rows.RemoveAt(cultivateRowIndex);
  7139. //cultivateRowIndex++;
  7140. }
  7141. }
  7142. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7143. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7144. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7145. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7146. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7147. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7148. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7149. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7150. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7151. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7152. //其他费用
  7153. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7154. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7155. //其他费用合计
  7156. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7157. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7158. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7159. //公务舱合计
  7160. //国际旅费
  7161. //string outsideJJ = "";
  7162. //string allPriceJJ = "";
  7163. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7164. {
  7165. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7166. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7167. }
  7168. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7169. {
  7170. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7171. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7172. }
  7173. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7174. {
  7175. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7176. dic.Add("AirFeeTotal", airFeeTotalStr);
  7177. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7178. dic.Add("FeeTotal", feeTotalStr);
  7179. }
  7180. foreach (var key in dic.Keys)
  7181. {
  7182. builder.MoveToBookmark(key);
  7183. builder.Write(dic[key]);
  7184. }
  7185. //模板文件名
  7186. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7187. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7188. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7189. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7190. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7191. }
  7192. }
  7193. else if (dto.ExportType == 2) //表格
  7194. {
  7195. //利用键值对存放数据
  7196. Dictionary<string, string> dic = new Dictionary<string, string>();
  7197. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7198. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7199. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7200. dic.Add("Day", sp.Days.ToString());
  7201. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7202. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7203. {
  7204. //获取模板
  7205. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7206. //载入模板
  7207. Document doc = new Document(tempPath);
  7208. DocumentBuilder builder = new DocumentBuilder(doc);
  7209. dic.Add("TeamName", _DelegationInfo.TeamName);
  7210. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7211. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7212. string missionLeaderName = "",
  7213. missionLeaderJob = "";
  7214. if (DeleClientList.Count > 0)
  7215. {
  7216. missionLeaderName = DeleClientList[0].Name;
  7217. missionLeaderJob = DeleClientList[0].Job;
  7218. }
  7219. dic.Add("MissionLeaderName", missionLeaderName);
  7220. dic.Add("MissionLeaderJob", missionLeaderJob);
  7221. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7222. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7223. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7224. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7225. int rowCount = 10;//总人数行
  7226. int startRowIndex = 7; //起始行
  7227. for (int i = 0; i < DeleClientList.Count; i++)
  7228. {
  7229. builder.MoveToCell(0, startRowIndex, 0, 0);
  7230. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7231. builder.MoveToCell(0, startRowIndex, 1, 0);
  7232. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7233. builder.Write(sex);//性别
  7234. builder.MoveToCell(0, startRowIndex, 2, 0);
  7235. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7236. builder.MoveToCell(0, startRowIndex, 3, 0);
  7237. builder.Write(DeleClientList[i].Company);//工作单位
  7238. builder.MoveToCell(0, startRowIndex, 4, 0);
  7239. builder.Write(DeleClientList[i].Job);//职务及级别
  7240. builder.MoveToCell(0, startRowIndex, 5, 0);
  7241. builder.Write("");//人员属性
  7242. builder.MoveToCell(0, startRowIndex, 6, 0);
  7243. builder.Write("");//上次出国时间
  7244. startRowIndex++;
  7245. }
  7246. int nullRow = rowCount - DeleClientList.Count;//空行
  7247. for (int i = 0; i < nullRow; i++)
  7248. {
  7249. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7250. }
  7251. foreach (var key in dic.Keys)
  7252. {
  7253. builder.MoveToBookmark(key);
  7254. builder.Write(dic[key]);
  7255. }
  7256. //模板文件名
  7257. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7258. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7259. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7260. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7261. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7262. }
  7263. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7264. {
  7265. //获取模板
  7266. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7267. //载入模板
  7268. Document doc = new Document(tempPath);
  7269. DocumentBuilder builder = new DocumentBuilder(doc);
  7270. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7271. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7272. dic.Add("Names", Names);
  7273. int accommodationRows = 12;
  7274. //int foodandotherRows = 12;
  7275. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7276. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7277. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7278. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7279. int accommodationStartIndex = 6;
  7280. decimal dac1totalPrice = 0.00M;
  7281. foreach (var dac in dac1)
  7282. {
  7283. if (dac.SubTotal == 0)
  7284. {
  7285. continue;
  7286. }
  7287. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7288. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7289. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7290. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7291. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7292. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7293. builder.Write(currency);//币种
  7294. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7295. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7296. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7297. builder.Write("");//人数
  7298. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7299. builder.Write("");//天数
  7300. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7301. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7302. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7303. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7304. builder.Write(rate.ToString("#0.0000"));//汇率
  7305. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7306. decimal rbmPrice = rate * dac.SubTotal;
  7307. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7308. accommodationStartIndex++;
  7309. dac1totalPrice += rbmPrice;
  7310. }
  7311. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7312. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7313. builder.Write("小计");
  7314. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7315. builder.Write(dac1totalPrice.ToString("#0.00"));
  7316. accommodationStartIndex++;
  7317. int nullRow = accommodationRows - dac1.Count;
  7318. //删除空行
  7319. //if (nullRow > 0)
  7320. //{
  7321. // int rowIndex = accommodationStartIndex;
  7322. // for (int i = 0; i < nullRow; i++)
  7323. // {
  7324. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7325. // row.Remove();
  7326. // rowIndex++;
  7327. // }
  7328. //}
  7329. if (dac2.Count == dac3.Count)//国家 币种 金额
  7330. {
  7331. for (int i = 0; i < dac2.Count; i++)
  7332. {
  7333. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7334. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7335. }
  7336. }
  7337. int foodandotherStartIndex = 19;//
  7338. decimal dac2totalPrice = 0.00M;
  7339. foreach (var dac in dac2)
  7340. {
  7341. if (dac.SubTotal == 0)
  7342. {
  7343. continue;
  7344. }
  7345. //foodandotherStartIndex = 12;
  7346. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7347. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7348. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7349. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7350. builder.Write(currency);//币种
  7351. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7352. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7353. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7354. builder.Write("");//人数
  7355. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7356. builder.Write("");//天数
  7357. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7358. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7359. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7360. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7361. builder.Write(rate.ToString("#0.0000"));//汇率
  7362. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7363. decimal rbmPrice = rate * dac.SubTotal;
  7364. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7365. foodandotherStartIndex++;
  7366. dac2totalPrice += rbmPrice;
  7367. }
  7368. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7369. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7370. //删除空行
  7371. //if (dac2.Count < foodandotherRows)
  7372. //{
  7373. // while (table2.Rows.Count > dac2.Count)
  7374. // {
  7375. // table2.Rows.RemoveAt(dac2.Count);
  7376. // }
  7377. //}
  7378. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7379. string otherFeeStr = "";
  7380. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7381. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7382. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7383. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7384. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7385. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7386. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7387. foreach (var otherInfo in dac5)
  7388. {
  7389. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7390. }
  7391. #endregion
  7392. if (otherFeeStr.Length > 0)
  7393. {
  7394. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7395. otherFeeStr = $"({otherFeeStr})";
  7396. dic.Add("OtherFeeStr", otherFeeStr);
  7397. }
  7398. foreach (var key in dic.Keys)
  7399. {
  7400. builder.MoveToBookmark(key);
  7401. builder.Write(dic[key]);
  7402. }
  7403. //模板文件名
  7404. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7405. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7406. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7407. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7408. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7409. }
  7410. }
  7411. else if (dto.ExportType == 3)
  7412. {
  7413. if (dto.SubTypeId == 1) //团组成员名单
  7414. {
  7415. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7416. //获取模板
  7417. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7418. //载入模板
  7419. Document doc = new Document(tempPath);
  7420. DocumentBuilder builder = new DocumentBuilder(doc);
  7421. //获取word里所有表格
  7422. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7423. //获取所填表格的序数
  7424. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7425. var rowStart = tableOne.Rows[0]; //获取第1行
  7426. //循环赋值
  7427. for (int i = 0; i < DeleClientList.Count; i++)
  7428. {
  7429. builder.MoveToCell(0, i + 1, 0, 0);
  7430. builder.Write(DeleClientList[i].Name);
  7431. builder.MoveToCell(0, i + 1, 1, 0);
  7432. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7433. builder.Write(sex);
  7434. builder.MoveToCell(0, i + 1, 2, 0);
  7435. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7436. builder.MoveToCell(0, i + 1, 3, 0);
  7437. builder.Write(DeleClientList[i].Company);
  7438. builder.MoveToCell(0, i + 1, 4, 0);
  7439. builder.Write(DeleClientList[i].Job);
  7440. }
  7441. //删除多余行
  7442. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7443. {
  7444. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7445. }
  7446. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7447. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7448. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7449. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7450. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7451. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7452. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7453. }
  7454. }
  7455. return Ok(JsonView(400, "操作失败!", ""));
  7456. }
  7457. catch (Exception ex)
  7458. {
  7459. return Ok(JsonView(400, ex.Message, ""));
  7460. }
  7461. }
  7462. /// <summary>
  7463. /// 获取三公费用标准city
  7464. /// </summary>
  7465. /// <param name="placeData"></param>
  7466. /// <param name="nationalTravelFeeId"></param>
  7467. /// <returns></returns>
  7468. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7469. {
  7470. string _city = string.Empty;
  7471. if (placeData.Count < 1) return _city;
  7472. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7473. if (data == null) return _city;
  7474. string country = data.Country;
  7475. string city = data.City;
  7476. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7477. else _city = city;
  7478. return _city;
  7479. }
  7480. ///// <summary>
  7481. ///// 团组模块 - 出入境费用 - 明细表导出
  7482. ///// </summary>
  7483. ///// <returns></returns>
  7484. //[HttpPost]
  7485. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7486. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7487. //{
  7488. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7489. // if (data.Code != 0)
  7490. // {
  7491. // return Ok(JsonView(false, data.Msg));
  7492. // }
  7493. // return Ok(JsonView(true, data.Msg, data.Data));
  7494. //}
  7495. /// <summary>
  7496. /// 团组模块 - 出入境费用 - 一键清空
  7497. /// </summary>
  7498. /// <returns></returns>
  7499. [HttpPost]
  7500. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7502. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7503. {
  7504. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7505. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7506. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7507. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7508. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7509. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7510. .SetColumns(x => new Grp_DayOtherPrice
  7511. {
  7512. IsDel = 1,
  7513. DeleteUserId = dto.UserId,
  7514. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7515. })
  7516. .ExecuteCommandAsync();
  7517. if (_view.Code == 0)
  7518. {
  7519. return Ok(JsonView(true, "操作成功"));
  7520. }
  7521. return Ok(JsonView(false, "操作失败"));
  7522. }
  7523. /// <summary>
  7524. /// 团组模块 - 出入境费用 - 子项删除
  7525. /// </summary>
  7526. /// <returns></returns>
  7527. [HttpPost]
  7528. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7530. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7531. {
  7532. try
  7533. {
  7534. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7535. if (data.Code != 0)
  7536. {
  7537. return Ok(JsonView(false, data.Msg));
  7538. }
  7539. return Ok(JsonView(true, "操作成功!", data.Data));
  7540. }
  7541. catch (Exception ex)
  7542. {
  7543. return Ok(JsonView(false, ex.Message));
  7544. }
  7545. }
  7546. /// <summary>
  7547. /// 删除三公其他费用
  7548. /// </summary>
  7549. /// <param name="dto"></param>
  7550. /// <returns></returns>
  7551. [HttpPost]
  7552. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7553. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7554. {
  7555. var jw = JsonView(false, "删除失败!");
  7556. var data = new Grp_DayOtherPrice()
  7557. {
  7558. Id = dto.Id,
  7559. IsDel = 1,
  7560. DeleteUserId = dto.DeleteUserId,
  7561. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7562. };
  7563. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7564. if (del > 0)
  7565. {
  7566. jw.Code = 200;
  7567. jw.Msg = "删除成功!";
  7568. }
  7569. return Ok(jw);
  7570. }
  7571. /// <summary>
  7572. /// 团组模块 - 出入境国家费用标准 List
  7573. /// </summary>
  7574. /// <returns></returns>
  7575. [HttpPost]
  7576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7577. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7578. {
  7579. int provinceId = dto.ProvinceId;
  7580. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7581. var nftData = await _sqlSugar
  7582. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7583. JoinType.Left, ntf.Currency == sd1.Id,
  7584. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7585. JoinType.Left, ntf.ProvinceId == c.Id
  7586. ))
  7587. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7588. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7589. {
  7590. Id = ntf.Id,
  7591. ProvinceId = ntf.ProvinceId,
  7592. ProvinceName = c.Name_CN,
  7593. Continent = ntf.Continent,
  7594. Country = ntf.Country,
  7595. City = ntf.City,
  7596. Currency = ntf.Currency,
  7597. CurrencyCode = sd1.Name,
  7598. CurrencyName = sd1.Remark,
  7599. RoomCost = ntf.RoomCost,
  7600. FoodCost = ntf.FoodCost,
  7601. PublicCost = ntf.PublicCost,
  7602. LastUpdateUserId = ntf.LastUpdateUserId,
  7603. LastUpdateUserName = u.CnName,
  7604. LastUpdateTime = ntf.LastUpdateTime
  7605. })
  7606. .ToListAsync();
  7607. return Ok(JsonView(true, "查询成功!", nftData));
  7608. }
  7609. /// <summary>
  7610. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7611. /// </summary>
  7612. /// <returns></returns>
  7613. [HttpPost]
  7614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7615. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7616. {
  7617. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7618. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7619. List<string> countryData = new List<string>();
  7620. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7621. countryData = countryData.Distinct().ToList();
  7622. List<dynamic> dataSource = new List<dynamic>();
  7623. foreach (var item in countryData)
  7624. {
  7625. var cityData1 = new List<string>();
  7626. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7627. var countryData2 = new
  7628. {
  7629. CountryName = item,
  7630. CityData = cityData1
  7631. };
  7632. if (!dataSource.Contains(countryData2))
  7633. {
  7634. dataSource.Add(countryData2);
  7635. }
  7636. }
  7637. return Ok(JsonView(true, "查询成功!", dataSource));
  7638. }
  7639. /// <summary>
  7640. /// 团组模块 - 出入境国家费用标准 Page List
  7641. /// </summary>
  7642. /// <returns></returns>
  7643. [HttpPost]
  7644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7645. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7646. {
  7647. int portId = dto.PortType,
  7648. pageIndex = dto.PageIndex,
  7649. pageSize = dto.PageSize;
  7650. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7651. if (pageIndex == 0) pageIndex = 1;
  7652. if (pageSize == 0) pageSize = 10;
  7653. RefAsync<int> total = 0;
  7654. var nationalTravelFeeData = await _sqlSugar
  7655. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7656. JoinType.Left, ntf.Currency == sd1.Id,
  7657. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7658. JoinType.Left, ntf.ProvinceId == sd2.Id
  7659. ))
  7660. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7661. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7662. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7663. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7664. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7665. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7666. {
  7667. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7668. Id = ntf.Id,
  7669. ProvinceId = ntf.ProvinceId,
  7670. ProvinceName = sd2.Name_CN,
  7671. Continent = ntf.Continent,
  7672. Country = ntf.Country,
  7673. City = ntf.City,
  7674. Currency = ntf.Currency,
  7675. CurrencyCode = sd1.Name,
  7676. CurrencyName = sd1.Remark,
  7677. RoomCost = ntf.RoomCost,
  7678. FoodCost = ntf.FoodCost,
  7679. PublicCost = ntf.PublicCost,
  7680. LastUpdateUserId = ntf.LastUpdateUserId,
  7681. LastUpdateUserName = u.CnName,
  7682. LastUpdateTime = ntf.LastUpdateTime,
  7683. Remark = ntf.Remark
  7684. })
  7685. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7686. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7687. }
  7688. /// <summary>
  7689. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7690. /// </summary>
  7691. /// <returns></returns>
  7692. [HttpPost]
  7693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7694. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7695. {
  7696. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7697. int portId = dto.PortType;
  7698. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7699. string whereSql = string.Empty;
  7700. if (!string.IsNullOrEmpty(dto.Country))
  7701. {
  7702. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7703. }
  7704. if (!string.IsNullOrEmpty(dto.City))
  7705. {
  7706. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7707. }
  7708. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7709. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7710. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7711. From Grp_NationalTravelFee gntf
  7712. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7713. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7714. Where gntf.Isdel = 0 {0} ", whereSql);
  7715. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7716. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7717. }
  7718. /// <summary>
  7719. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7720. /// </summary>
  7721. /// <returns></returns>
  7722. [HttpPost]
  7723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7724. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7725. {
  7726. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7727. }
  7728. /// <summary>
  7729. /// 团组模块 - 出入境国家费用标准 - Del
  7730. /// </summary>
  7731. /// <returns></returns>
  7732. [HttpPost]
  7733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7734. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7735. {
  7736. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7737. {
  7738. Id = dto.Id,
  7739. DeleteUserId = dto.DeleteUserId,
  7740. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7741. IsDel = 1
  7742. };
  7743. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7744. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7745. .WhereColumns(it => new { it.Id })
  7746. .ExecuteCommandAsync();
  7747. if (delStatus <= 0)
  7748. {
  7749. return Ok(JsonView(false, "删除失败!"));
  7750. }
  7751. return Ok(JsonView(true, "操作成功!"));
  7752. }
  7753. /// <summary>
  7754. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7755. /// 注:Get 请求Headers 加 Token
  7756. /// </summary>
  7757. /// <param name="groupId"></param>
  7758. /// <returns></returns>
  7759. [HttpGet("{groupId}")]
  7760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7761. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7762. {
  7763. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7764. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7765. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7766. data.ForEach(x =>
  7767. {
  7768. x.CreateUserId = _currUserInfo.UserId;
  7769. });
  7770. if (data.Any())
  7771. {
  7772. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7773. if (add > 0)
  7774. {
  7775. return Ok(JsonView(true, "操作成功!"));
  7776. }
  7777. }
  7778. return Ok(JsonView(false, "未操作!"));
  7779. }
  7780. #endregion
  7781. #region 团组经理模块 出入境费用-草稿
  7782. /// <summary>
  7783. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7784. /// </summary>
  7785. /// <returns></returns>
  7786. [HttpGet]
  7787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7788. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7789. {
  7790. var provData = await _groupRepository.ProvinceBasicSource();
  7791. return Ok(JsonView(true, "查询成功!", provData));
  7792. }
  7793. /// <summary>
  7794. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7795. /// </summary>
  7796. /// <returns></returns>
  7797. [HttpGet("{provinceId}")]
  7798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7799. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7800. {
  7801. //验证城市归属并给默认值
  7802. if (provinceId < 1) provinceId = 122;
  7803. /*
  7804. * 122 四川
  7805. * 108 贵州
  7806. * 103 重庆
  7807. * 132 云南
  7808. */
  7809. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7810. return Ok(JsonView(true, "查询成功!", new
  7811. {
  7812. WordTypeData = wordTypeData,
  7813. ExcelTypeData = excelTypeData,
  7814. }));
  7815. }
  7816. /// <summary>
  7817. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7818. /// </summary>
  7819. /// <returns></returns>
  7820. [HttpPost]
  7821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7822. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7823. {
  7824. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7825. .Where(x => x.IsDel == 0)
  7826. .OrderByDescending(x => x.CreateTime)
  7827. .Select(x => new { x.Id, x.DraftName })
  7828. .ToListAsync();
  7829. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7830. //SetDataInfoView
  7831. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7832. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7833. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7834. int provinceId = dto.ProvinceId;
  7835. if (provinceId < 1) provinceId = 122;
  7836. /*
  7837. * 122 四川
  7838. * 108 贵州
  7839. * 103 重庆
  7840. * 132 云南
  7841. */
  7842. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7843. //默认币种显示
  7844. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7845. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7846. return Ok(JsonView(true, "查询成功!", new
  7847. {
  7848. DraftNameDatas = draftNameDatas,
  7849. CurrencyData = _CurrencyData,
  7850. WordTypeData = wordTypeData,
  7851. ExcelTypeData = excelTypeData,
  7852. CurrencyInit = _currencyInfos,
  7853. ViewPermissionData = viewPermissionData
  7854. }));
  7855. }
  7856. /// <summary>
  7857. /// 团组模块 - 出入境费用-草稿
  7858. /// 实时汇率 tips
  7859. /// 机票费用 tips
  7860. /// </summary>
  7861. /// <returns></returns>
  7862. [HttpPost]
  7863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7864. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7865. {
  7866. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7867. return Ok(JsonView(true, "查询成功!", new
  7868. {
  7869. //GroupNameData = groupNameData.Data,
  7870. //visaData = visaData.Data,
  7871. //airData = airData.Data,
  7872. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7873. }));
  7874. }
  7875. /// <summary>
  7876. /// 团组模块 - 出入境费用-草稿
  7877. /// 签证费用 tips
  7878. /// </summary>
  7879. /// <returns></returns>
  7880. [HttpPost]
  7881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7882. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7883. {
  7884. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7885. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7886. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7887. .Select(x => x.NationalTravelFeeId)
  7888. .Distinct()
  7889. .ToListAsync();
  7890. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7891. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7892. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7893. .Select(x => x.Country)
  7894. .Distinct()
  7895. .ToArrayAsync();
  7896. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7897. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7898. return Ok(JsonView(true, "查询成功!", new
  7899. {
  7900. totalAmt = totalAmt,
  7901. remark = remark
  7902. }));
  7903. }
  7904. /// <summary>
  7905. /// 团组模块 - 出入境费用-草稿 - Info
  7906. /// </summary>
  7907. /// <returns></returns>
  7908. [HttpPost]
  7909. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7911. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7912. {
  7913. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7914. }
  7915. /// <summary>
  7916. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7917. /// </summary>
  7918. /// <returns></returns>
  7919. [HttpPost]
  7920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7921. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7922. {
  7923. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7924. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7925. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7926. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7927. foreach (var userId in dto.UserIds)
  7928. {
  7929. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7930. }
  7931. if (permissions.Any())
  7932. {
  7933. _sqlSugar.BeginTran();
  7934. try
  7935. {
  7936. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7937. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7938. if (result < 1)
  7939. {
  7940. _sqlSugar.RollbackTran();
  7941. return Ok(JsonView(false));
  7942. }
  7943. }
  7944. catch (Exception ex)
  7945. {
  7946. _sqlSugar.RollbackTran();
  7947. return Ok(JsonView(false, ex.Message));
  7948. }
  7949. _sqlSugar.CommitTran();
  7950. return Ok(JsonView(true));
  7951. }
  7952. return Ok(JsonView(false));
  7953. }
  7954. /// <summary>
  7955. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7956. /// </summary>
  7957. /// <returns></returns>
  7958. [HttpPost]
  7959. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7961. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7962. {
  7963. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7964. if (data.Code != 0)
  7965. {
  7966. return Ok(JsonView(false, data.Msg));
  7967. }
  7968. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7969. //汇率信息记录
  7970. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7971. return Ok(JsonView(true, data.Msg, data.Data));
  7972. }
  7973. /// <summary>
  7974. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7975. /// </summary>
  7976. /// <param name="dto"></param>
  7977. /// <returns></returns>
  7978. [HttpPost]
  7979. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7981. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7982. {
  7983. try
  7984. {
  7985. var id = dto.Id;
  7986. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7987. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7988. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7989. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7990. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7991. 3 团组成员名单 1 团组成员名单", ""));
  7992. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7993. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7994. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7995. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7996. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7997. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7998. //数据源
  7999. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8000. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8001. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8002. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8003. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8004. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8005. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8006. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8007. .Select((x, a, b) => new
  8008. {
  8009. x.Index,
  8010. itemName = a.Name,
  8011. CurrencyStr = b.Name,
  8012. x.Cost,
  8013. x.SubTotal,
  8014. x.Remark
  8015. })
  8016. .OrderBy((x) => x.Index)
  8017. .ToList(); //其他款项费用
  8018. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8019. var peiceItemCurrencys = new List<string>();
  8020. if (_DayAndCosts.Any())
  8021. {
  8022. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8023. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8024. }
  8025. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8026. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8027. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8028. {
  8029. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8030. }
  8031. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8032. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8033. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8034. if (dto.ExportType == 1) //明细表
  8035. {
  8036. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8037. {
  8038. //获取模板
  8039. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8040. //载入模板
  8041. Document doc = new Document(tempPath);
  8042. DocumentBuilder builder = new DocumentBuilder(doc);
  8043. //利用键值对存放数据
  8044. Dictionary<string, string> dic = new Dictionary<string, string>();
  8045. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8046. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8047. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8048. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8049. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8050. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8051. //境内费用(其他费用)
  8052. if (_EnterExitCosts.ChoiceOne == 1)
  8053. {
  8054. string row1_1 = "";
  8055. if (_EnterExitCosts.Visa > 0)
  8056. {
  8057. //insidePayTotal += _EnterExitCosts.Visa;
  8058. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8059. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8060. //{
  8061. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8062. //}
  8063. }
  8064. string row1_2 = "";
  8065. if (_EnterExitCosts.YiMiao > 0)
  8066. {
  8067. //insidePayTotal += _EnterExitCosts.YiMiao;
  8068. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8069. }
  8070. if (_EnterExitCosts.HeSuan > 0)
  8071. {
  8072. //insidePayTotal += _EnterExitCosts.HeSuan;
  8073. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8074. }
  8075. if (_EnterExitCosts.Service > 0)
  8076. {
  8077. //insidePayTotal += _EnterExitCosts.Service;
  8078. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8079. }
  8080. string row1_3 = "";
  8081. if (_EnterExitCosts.Safe > 0)
  8082. {
  8083. //insidePayTotal += _EnterExitCosts.Safe;
  8084. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8085. }
  8086. if (_EnterExitCosts.Ticket > 0)
  8087. {
  8088. //insidePayTotal += _EnterExitCosts.Ticket;
  8089. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8090. }
  8091. string row1 = "";
  8092. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8093. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8094. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8095. row1 += $"备注:{_EnterExitCosts.Remark}";
  8096. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8097. dic.Add("Row1Str", row1);
  8098. }
  8099. string airTotalStr = string.Empty,
  8100. airPriceStr = string.Empty;
  8101. //经济舱
  8102. if (_EnterExitCosts.SumJJC == 1)
  8103. {
  8104. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8105. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8106. }
  8107. //公务舱
  8108. if (_EnterExitCosts.SumGWC == 1)
  8109. {
  8110. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8111. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8112. }
  8113. //头等舱
  8114. if (_EnterExitCosts.SumTDC == 1)
  8115. {
  8116. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8117. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8118. }
  8119. //汇率描述
  8120. string rateStr = "";
  8121. if (peiceItemCurrencyInfos.Any())
  8122. {
  8123. rateStr = "\r\n汇率描述:";
  8124. foreach (var item in peiceItemCurrencyInfos)
  8125. {
  8126. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8127. }
  8128. }
  8129. string twoItemRemark = "备注:";
  8130. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8131. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8132. dic.Add("AirTotalStr", airTotalStr);
  8133. dic.Add("AirPriceStr", airPriceStr);
  8134. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8135. dic.Add("TwoItemRemark", twoItemRemark);
  8136. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8137. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8138. int table1Row = 0,
  8139. table2Row = 0,
  8140. table3Row = 0,
  8141. table4Row = 0,
  8142. table5Row = 0;
  8143. //住宿费
  8144. if (_EnterExitCosts.ChoiceThree == 1)
  8145. {
  8146. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8147. table1Row = dac1.Count;
  8148. #region 填充word表格内容
  8149. for (int i = 0; i < dac1.Count; i++)
  8150. {
  8151. var dac = dac1[i];
  8152. if (dac == null) continue;
  8153. builder.MoveToCell(0, i, 0, 0);
  8154. builder.Write("第" + dac.Days.ToString() + "晚:");
  8155. builder.MoveToCell(0, i, 1, 0);
  8156. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8157. //builder.Write(dac.Place == null ? "" : dac.Place);
  8158. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8159. builder.MoveToCell(0, i, 2, 0);
  8160. builder.Write("费用标准:");
  8161. string curr = "";
  8162. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8163. if (currData != null)
  8164. {
  8165. curr = currData.Name;
  8166. }
  8167. builder.MoveToCell(0, i, 3, 0);
  8168. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8169. builder.MoveToCell(0, i, 4, 0);
  8170. builder.Write("费用小计:");
  8171. builder.MoveToCell(0, i, 5, 0);
  8172. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8173. }
  8174. #endregion
  8175. }
  8176. else dic.Add("SubZS", "0.00");
  8177. //删除多余行
  8178. while (table1.Rows.Count > table1Row)
  8179. {
  8180. table1.Rows.RemoveAt(table1Row);
  8181. }
  8182. //伙食费
  8183. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8184. if (_EnterExitCosts.ChoiceFour == 1)
  8185. {
  8186. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8187. table2Row = dac2.Count;
  8188. #region 填充word表格内容
  8189. for (int i = 0; i < dac2.Count; i++)
  8190. {
  8191. var dac = dac2[i];
  8192. if (dac == null) continue;
  8193. builder.MoveToCell(1, i, 0, 0);
  8194. builder.Write("第" + dac.Days.ToString() + "天:");
  8195. builder.MoveToCell(1, i, 1, 0);
  8196. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8197. builder.MoveToCell(1, i, 2, 0);
  8198. builder.Write("费用标准:");
  8199. string curr = "";
  8200. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8201. if (currData != null)
  8202. {
  8203. curr = currData.Name;
  8204. }
  8205. builder.MoveToCell(1, i, 3, 0);
  8206. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8207. builder.MoveToCell(1, i, 4, 0);
  8208. builder.Write("费用小计:");
  8209. builder.MoveToCell(1, i, 5, 0);
  8210. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8211. }
  8212. #endregion
  8213. }
  8214. else dic.Add("SubHS", "0.00");
  8215. //删除多余行
  8216. while (table2.Rows.Count > table2Row)
  8217. {
  8218. table2.Rows.RemoveAt(table2Row);
  8219. }
  8220. //公杂费
  8221. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8222. if (_EnterExitCosts.ChoiceFive == 1)
  8223. {
  8224. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8225. table3Row = dac3.Count;
  8226. #region 填充word表格内容
  8227. for (int i = 0; i < dac3.Count; i++)
  8228. {
  8229. var dac = dac3[i];
  8230. if (dac == null) continue;
  8231. builder.MoveToCell(2, i, 0, 0);
  8232. builder.Write("第" + dac.Days.ToString() + "天:");
  8233. builder.MoveToCell(2, i, 1, 0);
  8234. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8235. builder.MoveToCell(2, i, 2, 0);
  8236. builder.Write("费用标准:");
  8237. string curr = "";
  8238. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8239. if (currData != null)
  8240. {
  8241. curr = currData.Name;
  8242. }
  8243. builder.MoveToCell(2, i, 3, 0);
  8244. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8245. builder.MoveToCell(2, i, 4, 0);
  8246. builder.Write("费用小计:");
  8247. builder.MoveToCell(2, i, 5, 0);
  8248. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8249. }
  8250. //删除多余行
  8251. while (table3.Rows.Count > table3Row)
  8252. {
  8253. table3.Rows.RemoveAt(table3Row);
  8254. }
  8255. #endregion
  8256. }
  8257. else dic.Add("SubGZF", "0.00");
  8258. //删除多余行
  8259. while (table3.Rows.Count > table3Row)
  8260. {
  8261. table3.Rows.RemoveAt(table3Row);
  8262. }
  8263. //培训费
  8264. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8265. if (_EnterExitCosts.ChoiceSix == 1)
  8266. {
  8267. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8268. dic.Add("SubPX", pxStr);
  8269. table4Row = dac4.Count;
  8270. #region 填充word表格内容
  8271. for (int i = 0; i < dac4.Count; i++)
  8272. {
  8273. var dac = dac4[i];
  8274. if (dac == null) continue;
  8275. builder.MoveToCell(3, i, 0, 0);
  8276. builder.Write("第" + dac.Days.ToString() + "天:");
  8277. builder.MoveToCell(3, i, 1, 0);
  8278. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8279. builder.MoveToCell(3, i, 2, 0);
  8280. builder.Write("费用标准:");
  8281. string curr = "";
  8282. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8283. if (currData != null)
  8284. {
  8285. curr = currData.Name;
  8286. }
  8287. builder.MoveToCell(3, i, 3, 0);
  8288. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8289. builder.MoveToCell(3, i, 4, 0);
  8290. builder.Write("费用小计:");
  8291. builder.MoveToCell(3, i, 5, 0);
  8292. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8293. }
  8294. #endregion
  8295. }
  8296. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8297. //删除多余行
  8298. while (table4.Rows.Count > table4Row)
  8299. {
  8300. table4.Rows.RemoveAt(table4Row);
  8301. }
  8302. //其他费用
  8303. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8304. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8305. {
  8306. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8307. dic.Add("titleQi", qtStr);
  8308. table5Row = dac5.Count;
  8309. #region 填充word表格内容
  8310. for (int i = 0; i < dac5.Count; i++)
  8311. {
  8312. var dac = dac5[i];
  8313. if (dac == null) continue;
  8314. builder.MoveToCell(4, i, 0, 0);
  8315. builder.Write("第" + dac.Index.ToString() + "项:");
  8316. builder.MoveToCell(4, i, 1, 0);
  8317. builder.Write(dac.itemName);
  8318. builder.MoveToCell(4, i, 2, 0);
  8319. builder.Write("费用标准:");
  8320. builder.MoveToCell(4, i, 3, 0);
  8321. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8322. builder.MoveToCell(4, i, 4, 0);
  8323. builder.Write("费用小计:");
  8324. builder.MoveToCell(4, i, 5, 0);
  8325. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8326. builder.MoveToCell(4, i, 6, 0);
  8327. builder.Write("备注:");
  8328. builder.MoveToCell(4, i, 7, 0);
  8329. builder.Write(dac.Remark);
  8330. }
  8331. #endregion
  8332. }
  8333. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8334. //删除多余行
  8335. while (table5.Rows.Count > table5Row)
  8336. {
  8337. table5.Rows.RemoveAt(table5Row);
  8338. }
  8339. //加上其他费用
  8340. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8341. decimal subJJC = 0.00M,
  8342. subGWC = 0.00M,
  8343. subTDC = 0.00M;
  8344. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8345. string totalLabel = string.Format("全部费用总计:");
  8346. //经济舱
  8347. if (_EnterExitCosts.SumJJC == 1)
  8348. {
  8349. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8350. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8351. }
  8352. //公务舱
  8353. if (_EnterExitCosts.SumGWC == 1)
  8354. {
  8355. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8356. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8357. }
  8358. //头等舱
  8359. if (_EnterExitCosts.SumTDC == 1)
  8360. {
  8361. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8362. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8363. }
  8364. //TotalLabel
  8365. dic.Add("TotalLabel", totalLabel);
  8366. #region 填充word模板书签内容
  8367. foreach (var key in dic.Keys)
  8368. {
  8369. Bookmark bookmark = doc.Range.Bookmarks[key];
  8370. if (bookmark != null)
  8371. {
  8372. builder.MoveToBookmark(key);
  8373. builder.Write(dic[key]);
  8374. }
  8375. }
  8376. #endregion
  8377. //文件名
  8378. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8379. strFileName = CommonFun.ValidFileName(strFileName);
  8380. AsposeHelper.removewatermark_v2180();
  8381. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8382. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8383. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8384. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8385. }
  8386. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8387. {
  8388. //获取模板
  8389. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8390. //载入模板
  8391. Document doc = new Document(tempPath);
  8392. DocumentBuilder builder = new DocumentBuilder(doc);
  8393. Dictionary<string, string> dic = new Dictionary<string, string>();
  8394. string returnCodeLabel = string.Empty;
  8395. if (nationalTravelFeeData.Any())
  8396. {
  8397. List<string> list = new List<string>();
  8398. foreach (var item in nationalTravelFeeData)
  8399. {
  8400. list.Add($"{item.Country}({item.City})");
  8401. }
  8402. list = list.Distinct().ToList();
  8403. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8404. }
  8405. var countryLabel = string.Empty;
  8406. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8407. if (countryData.Any())
  8408. {
  8409. countryLabel = string.Join("、", countryData);
  8410. }
  8411. dic.Add("ReturnCodeAir", returnCodeLabel);
  8412. dic.Add("VisitStartDate", "-");
  8413. dic.Add("VisitEndDate", "-");
  8414. dic.Add("Day", "-");
  8415. dic.Add("VisitCountry", countryLabel);
  8416. dic.Add("ClientUnit", "-");
  8417. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8418. //dic.Add("Names", Names);
  8419. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8420. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8421. decimal dac1totalPrice = 0.00M;
  8422. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8423. foreach (var dac in dac1)
  8424. {
  8425. if (dac.SubTotal == 0.00M)
  8426. {
  8427. continue;
  8428. }
  8429. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8430. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8431. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8432. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8433. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8434. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8435. builder.Write(currency);//币种
  8436. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8437. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8438. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8439. builder.Write("");//人数
  8440. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8441. builder.Write("");//天数
  8442. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8443. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8444. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8445. decimal rate = 0.00M;
  8446. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8447. builder.Write(rate.ToString("#0.0000"));//汇率
  8448. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8449. decimal rbmPrice = dac.SubTotal;
  8450. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8451. accommodationStartIndex++;
  8452. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8453. }
  8454. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8455. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8456. {
  8457. table1.Rows.RemoveAt(i - 1);
  8458. foodandotherStartIndex--;
  8459. }
  8460. if (dac2.Count == dac3.Count)//国家 币种 金额
  8461. {
  8462. for (int i = 0; i < dac2.Count; i++)
  8463. {
  8464. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8465. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8466. }
  8467. }
  8468. decimal dac2totalPrice = 0.00M;
  8469. foreach (var dac in dac2)
  8470. {
  8471. if (dac.SubTotal == 0)
  8472. {
  8473. continue;
  8474. }
  8475. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8476. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8477. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8478. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8479. builder.Write(currency);//币种
  8480. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8481. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8482. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8483. builder.Write("");//人数
  8484. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8485. builder.Write("");//天数
  8486. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8487. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8488. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8489. decimal rate = 0.00M;
  8490. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8491. builder.Write(rate.ToString("#0.0000"));//汇率
  8492. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8493. decimal rbmPrice = dac.SubTotal;
  8494. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8495. foodandotherStartIndex++;
  8496. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8497. }
  8498. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8499. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8500. {
  8501. table1.Rows.RemoveAt(i - 1);
  8502. }
  8503. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8504. string otherFeeStr = "";
  8505. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8506. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8507. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8508. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8509. foreach (var otherInfo in dac5)
  8510. {
  8511. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8512. }
  8513. #endregion
  8514. if (otherFeeStr.Length > 0)
  8515. {
  8516. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8517. otherFeeStr = $"({otherFeeStr})";
  8518. dic.Add("OtherFeeStr", otherFeeStr);
  8519. }
  8520. //总计
  8521. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8522. //国际旅费
  8523. string outsideAir = string.Empty;
  8524. string allPriceAir = string.Empty;
  8525. if (_EnterExitCosts.SumJJC == 1)
  8526. {
  8527. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8528. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8529. }
  8530. if (_EnterExitCosts.SumGWC == 1)
  8531. {
  8532. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8533. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8534. }
  8535. if (_EnterExitCosts.SumTDC == 1)
  8536. {
  8537. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8538. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8539. }
  8540. dic.Add("InTravelPrice", $"({outsideAir})");
  8541. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8542. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8543. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8544. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8545. foreach (var key in dic.Keys)
  8546. {
  8547. builder.MoveToBookmark(key);
  8548. builder.Write(dic[key]);
  8549. }
  8550. //模板文件名
  8551. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8552. strFileName = CommonFun.ValidFileName(strFileName);
  8553. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8554. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8555. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8556. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8557. }
  8558. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8559. {
  8560. //获取模板
  8561. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8562. //载入模板
  8563. WorkbookDesigner designer = new WorkbookDesigner();
  8564. designer.Workbook = new Workbook(tempPath);
  8565. Dictionary<string, string> dic = new Dictionary<string, string>();
  8566. string returnCodeLabel = string.Empty;
  8567. if (nationalTravelFeeData.Any())
  8568. {
  8569. List<string> list = new List<string>();
  8570. foreach (var item in nationalTravelFeeData)
  8571. {
  8572. list.Add($"{item.Country}({item.City})");
  8573. }
  8574. list = list.Distinct().ToList();
  8575. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8576. }
  8577. var countryLabel = string.Empty;
  8578. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8579. if (countryData.Any())
  8580. {
  8581. countryLabel = string.Join("、", countryData);
  8582. }
  8583. dic.Add("ReturnCodeAir", returnCodeLabel);
  8584. dic.Add("VisitStartDate", "-");
  8585. dic.Add("VisitEndDate", "-");
  8586. dic.Add("Day", "0");
  8587. dic.Add("VisitCountry", countryLabel);
  8588. dic.Add("ClientUnit", "-");
  8589. designer.SetDataSource("ClientUnit", "-");
  8590. designer.SetDataSource("VisitCountry", countryLabel);
  8591. designer.SetDataSource("Group", "-");
  8592. designer.SetDataSource("ClientUnitTitle", "-");
  8593. designer.SetDataSource("Name", "-");
  8594. designer.SetDataSource("VisitStartDate", "-");
  8595. designer.SetDataSource("Day", "0");
  8596. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8597. designer.SetDataSource("ReturnCodeAir", "-");
  8598. int startIndex = 10;
  8599. const int startIndexcopy = 10;
  8600. if (dac2.Count == dac3.Count)//国家 币种 金额
  8601. {
  8602. for (int i = 0; i < dac2.Count; i++)
  8603. {
  8604. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8605. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8606. }
  8607. }
  8608. DataTable dtdac1 = new DataTable();
  8609. List<string> place = new List<string>();
  8610. dtdac1.Columns.AddRange(new DataColumn[] {
  8611. new DataColumn(){ ColumnName = "city"},
  8612. new DataColumn(){ ColumnName = "curr"},
  8613. new DataColumn(){ ColumnName = "criterion"},
  8614. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8615. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8616. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8617. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8618. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8619. });
  8620. DataTable dtdac2 = new DataTable();
  8621. dtdac2.Columns.AddRange(new DataColumn[] {
  8622. new DataColumn(){ ColumnName = "city"},
  8623. new DataColumn(){ ColumnName = "curr"},
  8624. new DataColumn(){ ColumnName = "criterion"},
  8625. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8626. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8627. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8628. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8629. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8630. });
  8631. dtdac1.TableName = "tb1";
  8632. dtdac2.TableName = "tb2";
  8633. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8634. foreach (var item in dac1)
  8635. {
  8636. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8637. if (place.Contains(item.Place))
  8638. {
  8639. continue;
  8640. }
  8641. DataRow row = dtdac1.NewRow();
  8642. row["city"] = item.Place;
  8643. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8644. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8645. row["curr"] = currency;
  8646. row["rate"] = rate.ToString("#0.0000");
  8647. row["criterion"] = item.Cost.ToString("#0.00");
  8648. row["number"] = 1;
  8649. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8650. //row["costRMB"] = rbmPrice;
  8651. dtdac1.Rows.Add(row);
  8652. place.Add(item.Place);
  8653. }
  8654. place = new List<string>();
  8655. foreach (var item in dac2)
  8656. {
  8657. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8658. if (place.Contains(item.Place))
  8659. {
  8660. continue;
  8661. }
  8662. DataRow row = dtdac2.NewRow();
  8663. row["city"] = item.Place;
  8664. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8665. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8666. row["curr"] = currency;
  8667. row["rate"] = rate.ToString("#0.0000");
  8668. row["criterion"] = item.Cost.ToString("#0.00");
  8669. row["number"] = 1;
  8670. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8671. //row["cost"] = item.SubTotal;
  8672. //row["costRMB"] = rbmPrice;
  8673. dtdac2.Rows.Add(row);
  8674. place.Add(item.Place);
  8675. //dac2totalPrice += rbmPrice;
  8676. }
  8677. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8678. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8679. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8680. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8681. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8682. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8683. string cell4Str1 = string.Empty;
  8684. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8685. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8686. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8687. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8688. string cellStr = $" 5.其他费用(";
  8689. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8690. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8691. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8692. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8693. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8694. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8695. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8696. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8697. foreach (var otherInfo in dac5)
  8698. {
  8699. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8700. }
  8701. #endregion
  8702. if (cellStr.Length > 8)
  8703. {
  8704. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8705. }
  8706. cellStr += ")";
  8707. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8708. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8709. decimal pxFee = dac4.Sum(it => it.Cost);
  8710. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8711. string celllastStr1 = "";
  8712. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8713. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8714. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8715. celllastStr1 += $",国际旅费 元";
  8716. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8717. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8718. designer.SetDataSource("cell4Str", cell4Str);
  8719. designer.SetDataSource("cellStr", cellStr);
  8720. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8721. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8722. designer.SetDataSource("celllastStr", celllastStr);
  8723. Workbook wb = designer.Workbook;
  8724. var sheet = wb.Worksheets[0];
  8725. //绑定datatable数据集
  8726. designer.SetDataSource(dtdac1);
  8727. designer.SetDataSource(dtdac2);
  8728. designer.Process();
  8729. var rowStart = dtdac1.Rows.Count;
  8730. while (rowStart > 0)
  8731. {
  8732. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8733. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8734. startIndex++;
  8735. rowStart--;
  8736. }
  8737. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8738. startIndex += 1; //总计行
  8739. rowStart = dtdac2.Rows.Count;
  8740. while (rowStart > 0)
  8741. {
  8742. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8743. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8744. startIndex++;
  8745. rowStart--;
  8746. }
  8747. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8748. wb.CalculateFormula(true);
  8749. //模板文件名
  8750. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8751. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8752. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8753. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8754. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8755. }
  8756. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8757. {
  8758. //获取模板
  8759. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8760. //载入模板
  8761. Document doc = new Document(tempPath);
  8762. DocumentBuilder builder = new DocumentBuilder(doc);
  8763. Dictionary<string, string> dic = new Dictionary<string, string>();
  8764. dic.Add("GroupName", "-");
  8765. dic.Add("ClientUnit", "-");
  8766. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8767. //string missionLeaderJob = "";//负责人job
  8768. //int groupNumber = 0; //团人数
  8769. dic.Add("MissionLeader", "-"); //团负责人
  8770. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8771. dic.Add("GroupNumber", "0"); //团人数
  8772. dic.Add("Day", "0");
  8773. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8774. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8775. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8776. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8777. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8778. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8779. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8780. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8781. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8782. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8783. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8784. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8785. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8786. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8787. //其他费用
  8788. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8789. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8790. //其他费用合计
  8791. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8792. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8793. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8794. //公务舱合计
  8795. //国际旅费
  8796. //string outsideJJ = "";
  8797. //string allPriceJJ = "";
  8798. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8799. {
  8800. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8801. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8802. }
  8803. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8804. {
  8805. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8806. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8807. }
  8808. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8809. {
  8810. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8811. dic.Add("AirFeeTotal", airFeeTotalStr);
  8812. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8813. dic.Add("FeeTotal", feeTotalStr);
  8814. }
  8815. foreach (var key in dic.Keys)
  8816. {
  8817. builder.MoveToBookmark(key);
  8818. builder.Write(dic[key]);
  8819. }
  8820. //模板文件名
  8821. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8822. strFileName = CommonFun.ValidFileName(strFileName);
  8823. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8824. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8825. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8826. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8827. }
  8828. }
  8829. else if (dto.ExportType == 2) //表格
  8830. {
  8831. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8832. }
  8833. else if (dto.ExportType == 3)
  8834. {
  8835. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8836. }
  8837. return Ok(JsonView(400, "只可导出明细表!", ""));
  8838. }
  8839. catch (Exception ex)
  8840. {
  8841. return Ok(JsonView(400, ex.Message, ""));
  8842. }
  8843. }
  8844. /// <summary>
  8845. /// 获取三公费用标准city
  8846. /// </summary>
  8847. /// <param name="placeData"></param>
  8848. /// <param name="nationalTravelFeeId"></param>
  8849. /// <returns></returns>
  8850. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8851. {
  8852. string _city = string.Empty;
  8853. if (!placeData.Any()) return _city;
  8854. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8855. if (data == null) return _city;
  8856. string country = data.Country;
  8857. string city = data.City;
  8858. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8859. else _city = city;
  8860. return _city;
  8861. }
  8862. /// <summary>
  8863. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8864. /// </summary>
  8865. /// <returns></returns>
  8866. [HttpPost]
  8867. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8869. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8870. {
  8871. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8872. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8873. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8874. if (_view.Code == 0)
  8875. {
  8876. return Ok(JsonView(true, "操作成功"));
  8877. }
  8878. return Ok(JsonView(false, "操作失败"));
  8879. }
  8880. /// <summary>
  8881. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8882. /// </summary>
  8883. /// <returns></returns>
  8884. [HttpPost]
  8885. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8887. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8888. {
  8889. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8890. if (data.Code != 0)
  8891. {
  8892. return Ok(JsonView(false, data.Msg));
  8893. }
  8894. return Ok(JsonView(true, "操作成功!", data.Data));
  8895. }
  8896. /// <summary>
  8897. /// 三公其他费用草稿 删除
  8898. /// </summary>
  8899. /// <param name="dto"></param>
  8900. /// <returns></returns>
  8901. [HttpPost]
  8902. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8903. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8904. {
  8905. var jw = JsonView(false, "删除失败!");
  8906. var data = new Grp_DayOtherPriceDraft()
  8907. {
  8908. Id = dto.Id,
  8909. IsDel = 1,
  8910. DeleteUserId = dto.DeleteUserId,
  8911. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8912. };
  8913. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8914. if (del > 0)
  8915. {
  8916. jw.Code = 200;
  8917. jw.Msg = "删除成功!";
  8918. }
  8919. return Ok(jw);
  8920. }
  8921. /// <summary>
  8922. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8923. /// </summary>
  8924. /// <returns></returns>
  8925. [HttpPost]
  8926. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8927. {
  8928. var jw = JsonView(false);
  8929. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8930. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8931. jw.Code = StatusCodes.Status200OK;
  8932. jw.Msg = "操作成功!";
  8933. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8934. return Ok(jw);
  8935. }
  8936. /// <summary>
  8937. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8938. /// </summary>
  8939. /// <param name="dto"></param>
  8940. /// <returns></returns>
  8941. [HttpPost]
  8942. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8943. {
  8944. int userId = dto.UserId,
  8945. portId = dto.PortType,
  8946. groupId = dto.GroupId,
  8947. draftId = dto.DraftId;
  8948. _portTypeData.Add(1);
  8949. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8950. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8951. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8952. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8953. _sqlSugar.BeginTran();
  8954. try
  8955. {
  8956. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8957. if (draftDatas == null)
  8958. {
  8959. _sqlSugar.RollbackTran();
  8960. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8961. }
  8962. //验证可覆盖已有数据 两边创建人需为同一人;
  8963. int draftCreateUserId = draftDatas.CreateUserId,
  8964. formalCreateUserId = 0;
  8965. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8966. if (formalData != null)
  8967. {
  8968. formalCreateUserId = formalData.CreateUserId;
  8969. if (draftCreateUserId != formalCreateUserId)
  8970. {
  8971. _sqlSugar.RollbackTran();
  8972. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8973. }
  8974. }
  8975. //默认添加查看、编辑权限(创建人、自己)
  8976. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8977. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8978. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8979. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8980. newExterData.DiId = groupId;
  8981. newExterData.CreateUserId = userId;
  8982. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8983. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8984. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8985. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8986. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8987. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8988. //数据如果存在执行删除
  8989. if (enterExitCostInfo != null)
  8990. {
  8991. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8992. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8993. .Where(x => x.Id == enterExitCostInfo.Id)
  8994. .ExecuteCommand();
  8995. _sqlSugar.Updateable<Grp_DayAndCost>()
  8996. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8997. .Where(x => x.DiId == groupId)
  8998. .ExecuteCommand();
  8999. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9000. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9001. .Where(x => x.Diid == groupId)
  9002. .ExecuteCommand();
  9003. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9004. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9005. .Where(x => x.GroupId == groupId)
  9006. .ExecuteCommand();
  9007. }
  9008. //执行insert
  9009. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9010. if (insertId < 1)
  9011. {
  9012. _sqlSugar.RollbackTran();
  9013. return Ok(JsonView(false, "草稿数据导入失败!"));
  9014. }
  9015. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9016. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9017. #region 默认添加权限
  9018. #endregion
  9019. _sqlSugar.CommitTran();
  9020. //执行操作之后
  9021. //生成默认文件pdf并且通知人员
  9022. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9023. {
  9024. DiId = groupId,
  9025. ExportType = 1,
  9026. SubTypeId = 1005
  9027. }, "pdf");
  9028. //发送通知
  9029. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9030. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9031. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9032. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9033. //汇率信息记录
  9034. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9035. return Ok(JsonView(true));
  9036. }
  9037. catch (Exception ex)
  9038. {
  9039. _sqlSugar.RollbackTran();
  9040. return Ok(JsonView(false, ex.Message));
  9041. }
  9042. }
  9043. #endregion
  9044. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9045. /// <summary>
  9046. /// 获取币种基础数据(含逻辑处理)
  9047. /// </summary>
  9048. /// <returns></returns>
  9049. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9050. {
  9051. return await GeneralMethod.EnterExitCostInitRate();
  9052. }
  9053. /// <summary>
  9054. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9055. /// </summary>
  9056. /// <returns></returns>
  9057. [HttpPost]
  9058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9059. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9060. {
  9061. //验证城市归属并给默认值
  9062. int provinceId = dto.ProvinceId;
  9063. if (provinceId < 1) provinceId = 122;
  9064. var dataSource = await _sqlSugar
  9065. .Queryable<Sys_SetData>()
  9066. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9067. .ToListAsync();
  9068. var fileTypes = new List<EecSetDataInfoView>();
  9069. //三公费用-Word明细类型
  9070. var wordTypeData = dataSource
  9071. .Where(it => it.STid == 72)
  9072. .Select(x => new EecSetDataInfoView
  9073. {
  9074. ParentId = 1,
  9075. Id = x.Id,
  9076. Name = x.Name
  9077. })
  9078. .ToArray();
  9079. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9080. var excelTypeData = dataSource
  9081. .Where(it => it.STid == 73)
  9082. .Select(x => new EecSetDataInfoView
  9083. {
  9084. ParentId = 2,
  9085. Id = x.Id,
  9086. Name = x.Name
  9087. })
  9088. .ToArray();
  9089. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9090. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9091. fileTypes.Add(groupNameList);
  9092. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9093. //默认币种显示
  9094. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9095. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9096. return Ok(JsonView(true, "查询成功!", new
  9097. {
  9098. FileTypeData = fileTypes,
  9099. CurrencyInit = _currencyInfos,
  9100. viewPermissionData = viewPermissionData
  9101. }));
  9102. }
  9103. /// <summary>
  9104. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9105. /// </summary>
  9106. /// <returns></returns>
  9107. [HttpPost]
  9108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9109. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9110. {
  9111. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9112. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9113. RefAsync<int> total = 0;
  9114. int diId = 0;
  9115. var status = int.TryParse(dto.GroupName, out diId);
  9116. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9117. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9118. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9119. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9120. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9121. .OrderByDescending(x => x.VisitStartDate)
  9122. .Select(x => new EnterExitCostMobileGroupView()
  9123. {
  9124. Id = x.Id,
  9125. GroupName = x.TeamName,
  9126. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9127. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9128. ProvinceId = x.CityId
  9129. })
  9130. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9131. //处理省份Id
  9132. if (data.Any())
  9133. {
  9134. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9135. if (provCityDatas.Any())
  9136. {
  9137. foreach (var item in data)
  9138. {
  9139. var provinceId = item.ProvinceId;
  9140. var isDefualtVal = true;
  9141. if (provinceId > 0)
  9142. {
  9143. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9144. if (parentId != null)
  9145. {
  9146. isDefualtVal = false;
  9147. item.ProvinceId = (int)parentId;
  9148. }
  9149. }
  9150. if (isDefualtVal)
  9151. {
  9152. item.ProvinceId = 122; //默认四川
  9153. }
  9154. }
  9155. }
  9156. }
  9157. //处理是否显示
  9158. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9159. {
  9160. foreach (var item in data)
  9161. {
  9162. item.IsView = true;
  9163. }
  9164. }
  9165. return Ok(JsonView(true, "查询成功!", data, total));
  9166. }
  9167. /// <summary>
  9168. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9169. /// </summary>
  9170. /// <returns></returns>
  9171. [HttpPost]
  9172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9173. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9174. {
  9175. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9176. RefAsync<int> total = 0;
  9177. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9178. .Where(x => x.IsDel == 0 && x.STid == 66)
  9179. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9180. .Select(x => new
  9181. {
  9182. id = x.Id,
  9183. name = x.Name,
  9184. remark = x.Remark,
  9185. })
  9186. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9187. return Ok(JsonView(true, "查询成功!", data, total));
  9188. }
  9189. /// <summary>
  9190. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9191. /// </summary>
  9192. /// <returns></returns>
  9193. [HttpPost]
  9194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9195. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9196. {
  9197. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9198. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9199. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9200. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9201. var groupOtherRateData = groupRateData.TeamRates;
  9202. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9203. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9204. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9205. groupOtherRateData = groupOtherRateData
  9206. .Select(x => new TeamRateDescAddCurrencyIdView
  9207. {
  9208. CurrencyId = x.CurrencyId,
  9209. CurrencyName = x.CurrencyName,
  9210. CurrencyCode = x.CurrencyCode,
  9211. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9212. }).ToList();
  9213. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9214. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9215. }
  9216. /// <summary>
  9217. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9218. /// </summary>
  9219. /// <returns></returns>
  9220. [HttpPost]
  9221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9222. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9223. {
  9224. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9225. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9226. var tipsData = new List<int>() { 1, 2, 3 };
  9227. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9228. if (dto.TipsType == 1)
  9229. {
  9230. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9231. }
  9232. else if (dto.TipsType == 2)
  9233. {
  9234. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9235. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9236. }
  9237. else if (dto.TipsType == 3)
  9238. {
  9239. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9240. return Ok(JsonView(true, "查询成功!", airData));
  9241. }
  9242. return Ok(JsonView(false));
  9243. }
  9244. /// <summary>
  9245. /// 团组模块 - 出入境国家费用标准-移动端 List
  9246. /// </summary>
  9247. /// <returns></returns>
  9248. [HttpPost]
  9249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9250. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9251. {
  9252. Stopwatch sw = new Stopwatch();
  9253. sw.Start();
  9254. int provinceId = dto.ProvinceId;
  9255. if (provinceId < 1) provinceId = 122; // 默认四川
  9256. RefAsync<int> total = 0;
  9257. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9258. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9259. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9260. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9261. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9262. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9263. .Select((ntf, sd, u, sd1) => new
  9264. {
  9265. Id = ntf.Id,
  9266. Area = $"{ntf.Country}-{ntf.City}",
  9267. Currency = ntf.Currency,
  9268. CurrencyCode = sd.Name,
  9269. CurrencyName = sd.Remark,
  9270. RoomCost = ntf.RoomCost,
  9271. FoodCost = ntf.FoodCost,
  9272. PublicCost = ntf.PublicCost,
  9273. TrainCost = ntf.TrainCost,
  9274. LastUpdateUserId = ntf.LastUpdateUserId,
  9275. LastUpdateUserName = u.CnName,
  9276. LastUpdateTime = ntf.LastUpdateTime
  9277. })
  9278. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9279. sw.Stop();
  9280. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9281. }
  9282. /// <summary>
  9283. /// 团组模块 - 出入境费用-移动端 - Info
  9284. /// </summary>
  9285. /// <returns></returns>
  9286. [HttpPost]
  9287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9288. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9289. {
  9290. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9291. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9292. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9293. return Ok(data);
  9294. }
  9295. /// <summary>
  9296. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9297. /// </summary>
  9298. /// <returns></returns>
  9299. [HttpPost]
  9300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9301. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9302. {
  9303. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9304. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9305. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9306. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9307. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9308. mobileInfo.DiId = dto.DiId;
  9309. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9310. if (eecInfo == null) return Ok(mobileInfo);
  9311. //验证查看权限
  9312. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9313. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9314. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9315. mobileInfo.IsAssignPerm = isSet;
  9316. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9317. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9318. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9319. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9320. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9321. {
  9322. SubId = dac.Id,
  9323. DiId = dac.DiId,
  9324. Type = dac.Type,
  9325. Days = dac.Days,
  9326. NationalTravelFeeId = dac.NationalTravelFeeId,
  9327. Arae = $"{ntf.Country}-{ntf.City}",
  9328. Cost = dac.Cost,
  9329. Currency = dac.Currency,
  9330. CurrencyName = sd.Name,
  9331. SubTotal = dac.SubTotal,
  9332. })
  9333. .ToList();
  9334. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9335. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9336. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9337. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9338. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9339. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9340. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9341. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9342. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9343. //其他款项
  9344. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9345. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9346. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9347. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9348. .OrderBy((dop, sd1, sd2) => dop.Index)
  9349. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9350. {
  9351. SubId = dop.Id,
  9352. DiId = dop.Diid,
  9353. Index = dop.Index,
  9354. SetDataId = dop.SetDataId,
  9355. SetDataName = sd1.Name,
  9356. Cost = dop.Cost,
  9357. Currency = dop.Currency,
  9358. CurrencyName = sd2.Remark,
  9359. SubTotal = dop.SubTotal,
  9360. Remark = dop.Remark,
  9361. })
  9362. .ToArray();
  9363. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9364. return Ok(mobileInfo);
  9365. }
  9366. /// <summary>
  9367. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9368. /// </summary>
  9369. /// <returns></returns>
  9370. [HttpPost]
  9371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9372. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9373. {
  9374. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9375. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9376. //验证查看权限
  9377. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9378. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9379. var userIds = await _sqlSugar
  9380. .Queryable<Grp_EnterExitCostPermission>()
  9381. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9382. .Select(x => x.UserId)
  9383. .ToArrayAsync();
  9384. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9385. var perUsersView = new List<dynamic>();
  9386. foreach (var item in perUsers)
  9387. {
  9388. bool isView1 = false;
  9389. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9390. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9391. }
  9392. return Ok(JsonView(perUsersView));
  9393. }
  9394. /// <summary>
  9395. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9396. /// </summary>
  9397. /// <returns></returns>
  9398. [HttpPost]
  9399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9400. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9401. {
  9402. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9403. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9404. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9405. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9406. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9407. //验证查看权限
  9408. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9409. //if (!isView) return Ok(JsonView(false, msg));
  9410. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9411. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9412. var subType = dto.SubType;
  9413. if (subType == 1) //1:境内费用
  9414. {
  9415. var oneData = new ChoiceOneMobileSubInfoView()
  9416. {
  9417. Id = eecInfo.Id,
  9418. ChoiceOne = eecInfo.ChoiceOne,
  9419. ChoiceOneTotalCost = eecInfo.InsidePay,
  9420. Visa = eecInfo.Visa,
  9421. VisaRemark = eecInfo.VisaRemark,
  9422. YiMiao = eecInfo.YiMiao,
  9423. HeSuan = eecInfo.HeSuan,
  9424. Service = eecInfo.Service,
  9425. Ticket = eecInfo.Ticket,
  9426. Safe = eecInfo.Safe,
  9427. FirstItemRemark = eecInfo.FirstItemRemark
  9428. };
  9429. return Ok(JsonView(oneData));
  9430. }
  9431. else if (subType == 2) //2:国际旅费
  9432. {
  9433. var twoData = new ChoiceTwoMobileSubInfoView()
  9434. {
  9435. Id = eecInfo.Id,
  9436. ChoiceTwoJJ = eecInfo.SumJJC,
  9437. OutsideJJPay = eecInfo.OutsideJJPay,
  9438. ChoiceTwoGW = eecInfo.SumGWC,
  9439. OutsideGWPay = eecInfo.OutsideGWPay,
  9440. ChoiceTwoTD = eecInfo.SumTDC,
  9441. OutsideTDPay = eecInfo.OutsideTDPay,
  9442. AirJJ = eecInfo.AirJJ,
  9443. AirGW = eecInfo.AirGW,
  9444. AirTD = eecInfo.AirTD,
  9445. CityTranffic = eecInfo.CityTranffic,
  9446. TwoItemRemark = eecInfo.TwoItemRemark
  9447. };
  9448. return Ok(JsonView(twoData));
  9449. }
  9450. else if (subType == 3) //3:住宿费
  9451. {
  9452. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9453. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9454. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9455. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9456. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9457. {
  9458. SubId = dac.Id,
  9459. DiId = dac.DiId,
  9460. Type = dac.Type,
  9461. Days = dac.Days,
  9462. NationalTravelFeeId = dac.NationalTravelFeeId,
  9463. Arae = $"{ntf.Country}-{ntf.City}",
  9464. Cost = dac.Cost,
  9465. Currency = dac.Currency,
  9466. CurrencyName = sd.Name,
  9467. SubTotal = dac.SubTotal,
  9468. })
  9469. .ToArray();
  9470. var data = new ChoiceMobileSubInfo3To6View()
  9471. {
  9472. ParentId = eecInfo.Id,
  9473. Choice = eecInfo.ChoiceThree,
  9474. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9475. Details = dayAndCostDatas
  9476. };
  9477. return Ok(JsonView(data));
  9478. }
  9479. else if (subType == 4) //4:伙食费
  9480. {
  9481. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9482. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9483. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9484. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9485. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9486. {
  9487. SubId = dac.Id,
  9488. DiId = dac.DiId,
  9489. Type = dac.Type,
  9490. Days = dac.Days,
  9491. NationalTravelFeeId = dac.NationalTravelFeeId,
  9492. Arae = $"{ntf.Country}-{ntf.City}",
  9493. Cost = dac.Cost,
  9494. Currency = dac.Currency,
  9495. CurrencyName = sd.Name,
  9496. SubTotal = dac.SubTotal,
  9497. })
  9498. .ToArray();
  9499. var data = new ChoiceMobileSubInfo3To6View()
  9500. {
  9501. ParentId = eecInfo.Id,
  9502. Choice = eecInfo.ChoiceFour,
  9503. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9504. Details = dayAndCostDatas
  9505. };
  9506. return Ok(JsonView(data));
  9507. }
  9508. else if (subType == 5) //5:公杂费
  9509. {
  9510. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9511. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9512. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9513. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9514. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9515. {
  9516. SubId = dac.Id,
  9517. DiId = dac.DiId,
  9518. Type = dac.Type,
  9519. Days = dac.Days,
  9520. NationalTravelFeeId = dac.NationalTravelFeeId,
  9521. Arae = $"{ntf.Country}-{ntf.City}",
  9522. Cost = dac.Cost,
  9523. Currency = dac.Currency,
  9524. CurrencyName = sd.Name,
  9525. SubTotal = dac.SubTotal,
  9526. })
  9527. .ToArray();
  9528. var data = new ChoiceMobileSubInfo3To6View()
  9529. {
  9530. ParentId = eecInfo.Id,
  9531. Choice = eecInfo.ChoiceFive,
  9532. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9533. Details = dayAndCostDatas
  9534. };
  9535. return Ok(JsonView(data));
  9536. }
  9537. else if (subType == 6) //6:培训费
  9538. {
  9539. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9540. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9541. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9542. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9543. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9544. {
  9545. SubId = dac.Id,
  9546. DiId = dac.DiId,
  9547. Type = dac.Type,
  9548. Days = dac.Days,
  9549. NationalTravelFeeId = dac.NationalTravelFeeId,
  9550. Arae = $"{ntf.Country}-{ntf.City}",
  9551. Cost = dac.Cost,
  9552. Currency = dac.Currency,
  9553. CurrencyName = sd.Name,
  9554. SubTotal = dac.SubTotal,
  9555. })
  9556. .ToArray();
  9557. var data = new ChoiceMobileSubInfo3To6View()
  9558. {
  9559. ParentId = eecInfo.Id,
  9560. Choice = eecInfo.ChoiceSix,
  9561. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9562. Details = dayAndCostDatas
  9563. };
  9564. return Ok(JsonView(data));
  9565. }
  9566. else if (subType == 7) //7:其他
  9567. {
  9568. //其他款项
  9569. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9570. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9571. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9572. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9573. .OrderBy((dop, sd1, sd2) => dop.Index)
  9574. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9575. {
  9576. SubId = dop.Id,
  9577. DiId = dop.Diid,
  9578. Index = dop.Index,
  9579. SetDataId = dop.SetDataId,
  9580. SetDataName = sd1.Name,
  9581. Cost = dop.Cost,
  9582. Currency = dop.Currency,
  9583. CurrencyName = sd2.Name,
  9584. SubTotal = dop.SubTotal,
  9585. Remark = dop.Remark,
  9586. })
  9587. .ToArray();
  9588. var data = new ChoiceSevenMobileSubInfoView()
  9589. {
  9590. ParentId = eecInfo.Id,
  9591. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9592. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9593. Details = otherData
  9594. };
  9595. return Ok(JsonView(data));
  9596. }
  9597. return Ok(JsonView(false));
  9598. }
  9599. #region op
  9600. /// <summary>
  9601. /// 移动端更新费用消息通知
  9602. /// </summary>
  9603. /// <param name="diid"></param>
  9604. /// <param name="id"></param>
  9605. /// <param name="currUserId"></param>
  9606. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9607. {
  9608. try
  9609. {
  9610. ////生成默认文件pdf并且通知人员
  9611. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9612. //{
  9613. // DiId = diid,
  9614. // ExportType = 1,
  9615. // SubTypeId = 1005
  9616. //}, "pdf");
  9617. ////发送通知
  9618. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9619. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9620. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9621. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9622. ////汇率信息记录
  9623. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9624. }
  9625. catch (Exception ex)
  9626. {
  9627. //记录日志
  9628. throw;
  9629. }
  9630. }
  9631. /// <summary>
  9632. /// 验证出入境费用数据是否存在
  9633. /// 不存在添加
  9634. /// </summary>
  9635. /// <param name="diId"></param>
  9636. /// <param name="currUserId"></param>
  9637. /// <returns></returns>
  9638. /// <exception cref="CustomException"></exception>
  9639. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9640. {
  9641. var parentId = 0;
  9642. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9643. if (info != null)
  9644. {
  9645. parentId = info.Id;
  9646. }
  9647. else
  9648. {
  9649. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9650. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9651. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9652. parentId = addId;
  9653. }
  9654. return parentId;
  9655. }
  9656. /// <summary>
  9657. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9658. /// </summary>
  9659. /// <returns></returns>
  9660. [HttpPost]
  9661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9662. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9663. {
  9664. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9665. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9666. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9667. //验证编辑权限
  9668. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9669. //if (!isEdit) return Ok(JsonView(false, msg));
  9670. var permissions = new List<Grp_EnterExitCostPermission>();
  9671. foreach (var userId in dto.UserIds)
  9672. {
  9673. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9674. }
  9675. if (permissions.Any())
  9676. {
  9677. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9678. {
  9679. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9680. }
  9681. _sqlSugar.BeginTran();
  9682. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9683. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9684. if (result < 1)
  9685. {
  9686. _sqlSugar.RollbackTran();
  9687. return Ok(JsonView(false));
  9688. }
  9689. _sqlSugar.CommitTran();
  9690. return Ok(JsonView(true));
  9691. }
  9692. return Ok(JsonView(false));
  9693. }
  9694. /// <summary>
  9695. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9696. /// </summary>
  9697. /// <returns></returns>
  9698. [HttpPost]
  9699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9700. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9701. {
  9702. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9703. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9704. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9705. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9706. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9707. int id = dto.Id;
  9708. if (id <= 0) //add
  9709. {
  9710. //int provinceId = dto.ProvinceId;
  9711. int groupId = dto.DiId;
  9712. //if (provinceId < 1) provinceId = 122;
  9713. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9714. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9715. if (add < 1) return Ok(JsonView(false));
  9716. id = add;
  9717. }
  9718. else //update
  9719. {
  9720. ////验证编辑权限
  9721. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9722. //if (!isEdit) return Ok(JsonView(false, msg));
  9723. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9724. if (upd < 1) return Ok(JsonView(false));
  9725. }
  9726. #region 汇率变更时更改币种相关费用
  9727. var opDayCosts = new List<Grp_DayAndCost>();
  9728. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9729. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9730. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9731. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9732. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9733. .Select((dac, sd) => new
  9734. {
  9735. dac.Id,
  9736. dac.DiId,
  9737. CurrencyCode = sd.Name,
  9738. dac.Cost
  9739. })
  9740. .ToList();
  9741. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9742. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9743. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9744. .Select((dop, sd) => new
  9745. {
  9746. dop.Id,
  9747. dop.Diid,
  9748. CurrencyCode = sd.Name,
  9749. dop.Cost
  9750. })
  9751. .ToList();
  9752. if (dayCosts.Count > 0)
  9753. {
  9754. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9755. foreach (var dc in new_dayCosts)
  9756. {
  9757. var thisCurrency = dc.Key.ToUpper();
  9758. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9759. if (thisRate == 0.00M) continue;
  9760. foreach (var dcSub in dc)
  9761. {
  9762. opDayCosts.Add(new Grp_DayAndCost()
  9763. {
  9764. Id = dcSub.Id,
  9765. DiId = dcSub.DiId,
  9766. Cost = dcSub.Cost,
  9767. SubTotal = dcSub.Cost * thisRate,
  9768. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9769. });
  9770. }
  9771. }
  9772. if (opDayCosts.Count > 0)
  9773. {
  9774. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9775. }
  9776. }
  9777. if (dayOtherCosts.Count > 0)
  9778. {
  9779. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9780. foreach (var dc in new_dayOtherCosts)
  9781. {
  9782. var thisCurrency = dc.Key.ToUpper();
  9783. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9784. if (thisRate == 0.00M) continue;
  9785. foreach (var dcSub in dc)
  9786. {
  9787. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9788. {
  9789. Id = dcSub.Id,
  9790. Diid = dcSub.Diid,
  9791. Cost = dcSub.Cost,
  9792. SubTotal = dcSub.Cost * thisRate,
  9793. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9794. });
  9795. }
  9796. }
  9797. if (opDayOtherCosts.Count > 0)
  9798. {
  9799. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9800. }
  9801. }
  9802. #endregion
  9803. //消息通知
  9804. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9805. //汇率信息记录
  9806. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9807. return Ok(JsonView(new { parentId = id }));
  9808. }
  9809. /// <summary>
  9810. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9811. /// </summary>
  9812. /// <returns></returns>
  9813. [HttpPost]
  9814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9815. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9816. {
  9817. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9818. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9819. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9820. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9821. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9822. int id = dto.Id;
  9823. if (id <= 0) //add
  9824. {
  9825. checkboxInfo.CreateUserId = dto.CurrUserId;
  9826. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9827. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9828. if (add < 1) return Ok(JsonView(false));
  9829. }
  9830. else //update
  9831. {
  9832. ////验证编辑权限
  9833. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9834. //if (!isEdit) return Ok(JsonView(false, msg));
  9835. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9836. .UpdateColumns(x => new
  9837. {
  9838. x.ChoiceOne,
  9839. x.ChoiceTwo,
  9840. x.SumJJC,
  9841. x.SumGWC,
  9842. x.SumTDC,
  9843. x.ChoiceThree,
  9844. x.ChoiceFour,
  9845. x.ChoiceFive,
  9846. x.ChoiceSix,
  9847. x.OtherExpenses_Checked
  9848. })
  9849. .Where(x => x.Id == id)
  9850. .ExecuteCommandAsync();
  9851. if (upd < 1) return Ok(JsonView(false));
  9852. }
  9853. return Ok(JsonView(new { parentId = id }));
  9854. }
  9855. /// <summary>
  9856. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9857. /// </summary>
  9858. /// <returns></returns>
  9859. [HttpPost]
  9860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9861. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9862. {
  9863. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9864. // if (provinceId < 1) provinceId = 122;
  9865. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9866. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9867. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9868. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9869. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9870. var checkboxInfo = new Grp_EnterExitCost()
  9871. {
  9872. Id = id,
  9873. //ProvinceId = provinceId,
  9874. DiId = diId,
  9875. CreateUserId = currUserId
  9876. };
  9877. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9878. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9879. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9880. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9881. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9882. if (id <= 0) //add
  9883. {
  9884. checkboxInfo.CreateUserId = dto.CurrUserId;
  9885. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9886. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9887. if (add < 1) return Ok(JsonView(false));
  9888. }
  9889. else //update
  9890. {
  9891. ////验证编辑权限
  9892. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9893. //if (!isEdit) return Ok(JsonView(false, msg));
  9894. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9895. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9896. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9897. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9898. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9899. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9900. .Where(x => x.Id == id)
  9901. .ExecuteCommandAsync();
  9902. if (upd < 1) return Ok(JsonView(false));
  9903. }
  9904. return Ok(JsonView(new { parentId = id }));
  9905. }
  9906. /// <summary>
  9907. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9908. /// </summary>
  9909. /// <returns></returns>
  9910. [HttpPost]
  9911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9912. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9913. {
  9914. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9915. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9916. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9917. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9918. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9919. info.FirstItemRemark = dto.FirstItemRemark;
  9920. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9921. int id = dto.Id;
  9922. if (id <= 0) //add
  9923. {
  9924. info.CreateUserId = dto.CurrUserId;
  9925. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9926. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9927. if (add < 1) return Ok(JsonView(false));
  9928. id = add;
  9929. }
  9930. else //update
  9931. {
  9932. ////验证编辑权限
  9933. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9934. //if (!isEdit) return Ok(JsonView(false, msg));
  9935. var upd = await _sqlSugar.Updateable(info)
  9936. .UpdateColumns(x => new
  9937. {
  9938. x.ChoiceOne,
  9939. x.InsidePay,
  9940. x.VisaRemark,
  9941. x.Visa,
  9942. x.Service,
  9943. x.Safe,
  9944. x.Ticket,
  9945. x.HeSuan,
  9946. x.YiMiao,
  9947. x.FirstItemRemark
  9948. })
  9949. .Where(x => x.Id == id)
  9950. .ExecuteCommandAsync();
  9951. if (upd < 1) return Ok(JsonView(false));
  9952. }
  9953. //消息通知
  9954. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9955. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9956. }
  9957. /// <summary>
  9958. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9959. /// </summary>
  9960. /// <returns></returns>
  9961. [HttpPost]
  9962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9963. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9964. {
  9965. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9966. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9967. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9968. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9969. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9970. info.DiId = dto.DiId;
  9971. //info.ProvinceId = dto.ProvinceId;
  9972. info.OutsideJJPay = dto.OutsideJJPay;
  9973. info.OutsideGWPay = dto.OutsideGWPay;
  9974. info.OutsideTDPay = dto.OutsideTDPay;
  9975. info.AirJJ = dto.AirJJ;
  9976. info.AirGW = dto.AirGW;
  9977. info.AirTD = dto.AirTD;
  9978. info.CityTranffic = dto.CityTranffic;
  9979. info.TwoItemRemark = dto.TwoItemRemark;
  9980. info.SumJJC = dto.ChoiceTwoJJ;
  9981. info.SumGWC = dto.ChoiceTwoGW;
  9982. info.SumTDC = dto.ChoiceTwoTD;
  9983. int id = dto.Id;
  9984. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9985. if (id <= 0) //add
  9986. {
  9987. info.CreateUserId = dto.CurrUserId;
  9988. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9989. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9990. if (addId <= 0) return Ok(JsonView(false));
  9991. id = addId;
  9992. }
  9993. else //update
  9994. {
  9995. ////验证编辑权限
  9996. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9997. //if (!isEdit) return Ok(JsonView(false, msg));
  9998. var upd = await _sqlSugar.Updateable(info)
  9999. .UpdateColumns(x => new
  10000. {
  10001. x.SumJJC,
  10002. x.OutsideJJPay,
  10003. x.SumGWC,
  10004. x.OutsideGWPay,
  10005. x.SumTDC,
  10006. x.OutsideTDPay,
  10007. x.AirJJ,
  10008. x.AirGW,
  10009. x.AirTD,
  10010. x.CityTranffic,
  10011. x.TwoItemRemark
  10012. })
  10013. .Where(x => x.Id == id)
  10014. .ExecuteCommandAsync();
  10015. if (upd < 1) return Ok(JsonView(false));
  10016. }
  10017. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10018. gwcItemTotal = info.AirGW + info.CityTranffic;
  10019. tdcItemTotal = info.AirTD + info.CityTranffic;
  10020. //消息通知
  10021. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10022. return Ok(JsonView(new
  10023. {
  10024. parentId = id,
  10025. choiceTwoJJ = dto.ChoiceTwoJJ,
  10026. jjcItemTotal = jjcItemTotal,
  10027. choiceTwoGW = dto.ChoiceTwoGW,
  10028. gwcItemTotal = gwcItemTotal,
  10029. choiceTwoTD = dto.ChoiceTwoTD,
  10030. tdcItemTotal = tdcItemTotal
  10031. }));
  10032. }
  10033. /// <summary>
  10034. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10035. /// </summary>
  10036. /// <returns></returns>
  10037. [HttpPost]
  10038. [ApiExplorerSettings(IgnoreApi = true)]
  10039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10040. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10041. {
  10042. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10043. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10044. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10045. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10046. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10047. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10048. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10049. var infos = infos1.Select(x => new Grp_DayAndCost
  10050. {
  10051. Id = x.Id,
  10052. DiId = dto.DiId,
  10053. Type = dto.FeeType,
  10054. Days = x.Days,
  10055. NationalTravelFeeId = x.NationalTravelFeeId,
  10056. Cost = x.Cost,
  10057. Currency = x.Currency,
  10058. SubTotal = x.SubTotal,
  10059. CreateUserId = dto.CurrUserId
  10060. })
  10061. .ToList();
  10062. var adds = infos.Where(x => x.Id <= 0).ToList();
  10063. var upds = infos.Where(x => x.Id > 0).ToList();
  10064. if (adds.Count > 0)
  10065. {
  10066. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10067. if (add < 1) return Ok(JsonView(false));
  10068. }
  10069. if (upds.Count > 0)
  10070. {
  10071. var upd = await _sqlSugar.Updateable(adds)
  10072. .UpdateColumns(x => new
  10073. {
  10074. x.Days,
  10075. x.NationalTravelFeeId,
  10076. x.Cost,
  10077. x.Currency,
  10078. x.SubTotal
  10079. })
  10080. .WhereColumns(x => new { x.Id })
  10081. .ExecuteCommandAsync();
  10082. if (upd < 1) return Ok(JsonView(false));
  10083. }
  10084. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10085. //消息通知
  10086. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10087. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10088. return Ok(JsonView(new { itemTotal = itemTotal }));
  10089. }
  10090. /// <summary>
  10091. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10092. /// </summary>
  10093. /// <returns></returns>
  10094. [HttpPost]
  10095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10096. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10097. {
  10098. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10099. int subId = dto.SubId, feeType = dto.FeeType;
  10100. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10101. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10102. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10103. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10104. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10105. subInfo.Id = subId;
  10106. subInfo.DiId = dto.DiId;
  10107. if (feeType == 3) subInfo.Type = 1;
  10108. else if (feeType == 4) subInfo.Type = 2;
  10109. else if (feeType == 5) subInfo.Type = 3;
  10110. else if (feeType == 6) subInfo.Type = 4;
  10111. subInfo.CreateUserId = dto.CurrUserId;
  10112. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10113. if (parentId < 1) return Ok(JsonView(false));
  10114. //子表op
  10115. if (subId < 1)
  10116. {
  10117. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10118. if (subAdd < 1) return Ok(JsonView(false));
  10119. }
  10120. else
  10121. {
  10122. ////验证编辑权限
  10123. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10124. //if (!isEdit) return Ok(JsonView(false, msg));
  10125. var subUpd = await _sqlSugar.Updateable(subInfo)
  10126. .UpdateColumns(x => new
  10127. {
  10128. x.Days,
  10129. x.NationalTravelFeeId,
  10130. x.Cost,
  10131. x.Currency,
  10132. x.SubTotal
  10133. })
  10134. .WhereColumns(x => new { x.Id })
  10135. .ExecuteCommandAsync();
  10136. if (subUpd < 1) return Ok(JsonView(false));
  10137. }
  10138. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10139. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10140. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10141. }
  10142. /// <summary>
  10143. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10144. /// </summary>
  10145. /// <returns></returns>
  10146. [HttpPost]
  10147. [ApiExplorerSettings(IgnoreApi = true)]
  10148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10149. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10150. {
  10151. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10152. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10153. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10154. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10155. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10156. {
  10157. Id = x.Id,
  10158. Diid = dto.DiId,
  10159. SetDataId = x.SetDataId,
  10160. Index = x.Index,
  10161. Cost = x.Cost,
  10162. Currency = x.Currency,
  10163. SubTotal = x.SubTotal,
  10164. CreateUserId = dto.CurrUserId,
  10165. Remark = x.Remark
  10166. }).ToList();
  10167. var adds = infos.Where(x => x.Id <= 0).ToList();
  10168. var upds = infos.Where(x => x.Id > 0).ToList();
  10169. if (adds.Count > 0)
  10170. {
  10171. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10172. if (add < 1) return Ok(JsonView(false));
  10173. }
  10174. if (upds.Count > 0)
  10175. {
  10176. var upd = await _sqlSugar.Updateable(adds)
  10177. .UpdateColumns(x => new
  10178. {
  10179. x.Index,
  10180. x.SetDataId,
  10181. x.Cost,
  10182. x.Currency,
  10183. x.SubTotal,
  10184. x.Remark
  10185. })
  10186. .WhereColumns(x => new { x.Id })
  10187. .ExecuteCommandAsync();
  10188. if (upd < 1) return Ok(JsonView(false));
  10189. }
  10190. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10191. //消息通知
  10192. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10193. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10194. return Ok(JsonView(new { itemTotal = itemTotal }));
  10195. }
  10196. /// <summary>
  10197. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10198. /// </summary>
  10199. /// <returns></returns>
  10200. [HttpPost]
  10201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10202. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10203. {
  10204. int subId = dto.SubId;
  10205. int diId = dto.Diid;
  10206. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10207. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10208. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10209. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10210. subInfo.Id = subId;
  10211. subInfo.Diid = dto.Diid;
  10212. subInfo.CreateUserId = dto.CurrUserId;
  10213. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10214. if (parentId < 1) return Ok(JsonView(false));
  10215. #region 子表op
  10216. if (subId < 1)//add
  10217. {
  10218. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10219. if (subAdd < 1) return Ok(JsonView(false));
  10220. }
  10221. else //upd
  10222. {
  10223. ////验证编辑权限
  10224. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10225. //if (!isEdit) return Ok(JsonView(false, msg));
  10226. var subUpd = await _sqlSugar.Updateable(subInfo)
  10227. .UpdateColumns(x => new
  10228. {
  10229. x.Index,
  10230. x.SetDataId,
  10231. x.Cost,
  10232. x.Currency,
  10233. x.SubTotal,
  10234. x.Remark
  10235. })
  10236. .WhereColumns(x => new { x.Id })
  10237. .ExecuteCommandAsync();
  10238. if (subUpd < 1) return Ok(JsonView(false));
  10239. }
  10240. #endregion
  10241. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10242. //消息通知
  10243. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10244. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10245. }
  10246. /// <summary>
  10247. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10248. /// </summary>
  10249. /// <returns></returns>
  10250. [HttpPost]
  10251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10252. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10253. {
  10254. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10255. if (data.Code != 0)
  10256. {
  10257. return Ok(JsonView(false, data.Msg));
  10258. }
  10259. return Ok(JsonView(true, "操作成功!", data.Data));
  10260. }
  10261. /// <summary>
  10262. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10263. /// </summary>
  10264. /// <param name="dto"></param>
  10265. /// <returns></returns>
  10266. [HttpPost]
  10267. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10268. {
  10269. var data = new Grp_DayOtherPrice()
  10270. {
  10271. Id = dto.Id,
  10272. IsDel = 1,
  10273. DeleteUserId = dto.DeleteUserId,
  10274. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10275. };
  10276. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10277. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10278. return Ok(JsonView(false, "删除失败!"));
  10279. }
  10280. #endregion
  10281. #endregion
  10282. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10283. /// <summary>
  10284. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10285. /// </summary>
  10286. /// <returns></returns>
  10287. [HttpGet]
  10288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10289. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10290. {
  10291. var provData = await _groupRepository.ProvinceBasicSource();
  10292. return Ok(JsonView(true, "查询成功!", provData));
  10293. }
  10294. /// <summary>
  10295. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10296. /// </summary>
  10297. /// <returns></returns>
  10298. [HttpPost]
  10299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10300. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10301. {
  10302. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10303. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10304. RefAsync<int> total = 0;
  10305. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10306. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10307. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10308. .Select(x => new
  10309. {
  10310. Id = x.Id,
  10311. DraftName = x.DraftName,
  10312. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10313. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10314. .Any()
  10315. })
  10316. .OrderByDescending(x => x.Id)
  10317. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10318. return Ok(JsonView(true, "查询成功!", data, total));
  10319. }
  10320. /// <summary>
  10321. /// 出入境费用-草稿 移动端
  10322. /// 获取币种基础数据(含逻辑处理)
  10323. /// </summary>
  10324. /// <returns></returns>
  10325. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10326. {
  10327. return await GeneralMethod.EnterExitCostInitRate();
  10328. }
  10329. /// <summary>
  10330. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10331. /// </summary>
  10332. /// <returns></returns>
  10333. [HttpPost]
  10334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10335. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10336. {
  10337. //验证城市归属并给默认值
  10338. int provinceId = dto.ProvinceId;
  10339. if (provinceId < 1) provinceId = 122;
  10340. var dataSource = await _sqlSugar
  10341. .Queryable<Sys_SetData>()
  10342. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10343. .ToListAsync();
  10344. //三公费用-Word明细类型
  10345. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10346. .Select(x => new SetDataInfoView
  10347. {
  10348. Id = x.Id,
  10349. Name = x.Name,
  10350. Remark = x.Remark
  10351. })
  10352. .ToList();
  10353. //三公费用-Excel明细类型
  10354. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10355. .Select(x => new SetDataInfoView
  10356. {
  10357. Id = x.Id,
  10358. Name = x.Name,
  10359. Remark = x.Remark
  10360. })
  10361. .ToList();
  10362. //默认币种显示
  10363. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10364. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10365. return Ok(JsonView(true, "查询成功!", new
  10366. {
  10367. WordTypeData = wordTypeData,
  10368. ExcelTypeData = excelTypeData,
  10369. CurrencyInit = _currencyInfos,
  10370. viewPermissionData = viewPermissionData
  10371. }));
  10372. }
  10373. /// <summary>
  10374. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10375. /// </summary>
  10376. /// <returns></returns>
  10377. [HttpPost]
  10378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10379. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10380. {
  10381. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10382. RefAsync<int> total = 0;
  10383. int diId = 0;
  10384. var status = int.TryParse(dto.GroupName, out diId);
  10385. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10386. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10387. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10388. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10389. .OrderByDescending(x => x.VisitStartDate)
  10390. .Select(x => new
  10391. {
  10392. Id = x.Id,
  10393. GroupName = x.TeamName
  10394. })
  10395. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10396. return Ok(JsonView(true, "查询成功!", data, total));
  10397. }
  10398. /// <summary>
  10399. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10400. /// </summary>
  10401. /// <returns></returns>
  10402. [HttpPost]
  10403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10404. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10405. {
  10406. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10407. RefAsync<int> total = 0;
  10408. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10409. .Where(x => x.IsDel == 0 && x.STid == 66)
  10410. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10411. .Select(x => new
  10412. {
  10413. id = x.Id,
  10414. name = x.Name,
  10415. remark = x.Remark,
  10416. })
  10417. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10418. return Ok(JsonView(true, "查询成功!", data, total));
  10419. }
  10420. /// <summary>
  10421. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10422. /// </summary>
  10423. /// <returns></returns>
  10424. [HttpPost]
  10425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10426. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10427. {
  10428. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10429. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10430. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10431. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10432. var groupOtherRateData = groupRateData.TeamRates;
  10433. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10434. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10435. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10436. groupOtherRateData = groupOtherRateData
  10437. .Select(x => new TeamRateDescAddCurrencyIdView
  10438. {
  10439. CurrencyId = x.CurrencyId,
  10440. CurrencyName = x.CurrencyName,
  10441. CurrencyCode = x.CurrencyCode,
  10442. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10443. }).ToList();
  10444. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10445. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10446. }
  10447. /// <summary>
  10448. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10449. /// </summary>
  10450. /// <returns></returns>
  10451. [HttpPost]
  10452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10453. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10454. {
  10455. int portType = dto.PortType;
  10456. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10457. var tipsData = new List<int>() { 1, 2, 3 };
  10458. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10459. if (dto.TipsType == 1)
  10460. {
  10461. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10462. }
  10463. else if (dto.TipsType == 2)
  10464. {
  10465. if (portType == 2)
  10466. {
  10467. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10468. }
  10469. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10470. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10471. .Select(x => x.NationalTravelFeeId)
  10472. .Distinct()
  10473. .ToListAsync();
  10474. if (portType == 2)
  10475. {
  10476. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10477. }
  10478. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10479. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10480. .Select(x => x.Country)
  10481. .Distinct()
  10482. .ToArrayAsync();
  10483. if (portType == 2)
  10484. {
  10485. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10486. }
  10487. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10488. return Ok(JsonView(true, "查询成功!", new
  10489. {
  10490. totalAmt = totalAmt,
  10491. remark = remark
  10492. }));
  10493. }
  10494. else if (dto.TipsType == 3)
  10495. {
  10496. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10497. }
  10498. return Ok(JsonView(false));
  10499. }
  10500. /// <summary>
  10501. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10502. /// </summary>
  10503. /// <returns></returns>
  10504. [HttpPost]
  10505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10506. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10507. {
  10508. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10509. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10510. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10511. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10512. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10513. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10514. var info = new Grp_EnterExitCostDraft()
  10515. {
  10516. ProvinceId = dto.ProvinceId,
  10517. DraftName = dto.DraftName,
  10518. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10519. CreateUserId = dto.CurrUserId
  10520. };
  10521. _sqlSugar.BeginTran();
  10522. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10523. if (draftId < 1)
  10524. {
  10525. _sqlSugar.RollbackTran();
  10526. return Ok(JsonView(false, "草稿创建失败!"));
  10527. }
  10528. //添加默认权限
  10529. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10530. _sqlSugar.CommitTran();
  10531. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10532. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10533. mobileInfo.Id = draftId;
  10534. mobileInfo.DraftName = dto.DraftName;
  10535. mobileInfo.Currencys = rateInfos;
  10536. mobileInfo.IsAssignPerm = assignPerm;
  10537. return Ok(JsonView(mobileInfo));
  10538. }
  10539. /// <summary>
  10540. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10541. /// </summary>
  10542. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10543. /// <summary>
  10544. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10545. /// </summary>
  10546. /// <returns></returns>
  10547. [HttpPost]
  10548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10549. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10550. {
  10551. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10552. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10553. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10554. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10555. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10556. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10557. //验证查看编辑权限
  10558. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10559. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10560. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10561. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10562. mobileInfo.IsAssignPerm = assignPerm;
  10563. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10564. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10565. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10566. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10567. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10568. {
  10569. ParentId = dac.ParentId,
  10570. SubId = dac.Id,
  10571. Type = dac.Type,
  10572. Days = dac.Days,
  10573. NationalTravelFeeId = dac.NationalTravelFeeId,
  10574. Arae = $"{ntf.Country}-{ntf.City}",
  10575. Cost = dac.Cost,
  10576. Currency = dac.Currency,
  10577. CurrencyName = sd.Name,
  10578. SubTotal = dac.SubTotal,
  10579. })
  10580. .ToList();
  10581. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10582. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10583. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10584. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10585. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10586. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10587. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10588. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10589. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10590. //其他款项
  10591. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10592. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10593. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10594. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10595. .OrderBy((dop, sd1, sd2) => dop.Index)
  10596. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10597. {
  10598. ParentId = dop.ParentId,
  10599. SubId = dop.Id,
  10600. Index = dop.Index,
  10601. SetDataId = dop.SetDataId,
  10602. SetDataName = sd1.Name,
  10603. Cost = dop.Cost,
  10604. Currency = dop.Currency,
  10605. CurrencyName = sd2.Remark,
  10606. SubTotal = dop.SubTotal,
  10607. Remark = dop.Remark,
  10608. })
  10609. .ToArray();
  10610. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10611. return Ok(mobileInfo);
  10612. }
  10613. /// <summary>
  10614. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10615. /// </summary>
  10616. /// <returns></returns>
  10617. [HttpPost]
  10618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10619. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10620. {
  10621. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10622. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10623. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10624. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10625. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10626. //验证查看编辑权限
  10627. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10628. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10629. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10630. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10631. var subType = dto.SubType;
  10632. if (subType == 1) //1:境内费用
  10633. {
  10634. var oneData = new ChoiceOneMobileSubInfoView()
  10635. {
  10636. Id = eecInfo.Id,
  10637. ChoiceOne = eecInfo.ChoiceOne,
  10638. ChoiceOneTotalCost = eecInfo.InsidePay,
  10639. Visa = eecInfo.Visa,
  10640. VisaRemark = eecInfo.VisaRemark,
  10641. YiMiao = eecInfo.YiMiao,
  10642. HeSuan = eecInfo.HeSuan,
  10643. Service = eecInfo.Service,
  10644. Ticket = eecInfo.Ticket,
  10645. Safe = eecInfo.Safe,
  10646. FirstItemRemark = eecInfo.FirstItemRemark
  10647. };
  10648. return Ok(JsonView(oneData));
  10649. }
  10650. else if (subType == 2) //2:国际旅费
  10651. {
  10652. var twoData = new ChoiceTwoMobileSubInfoView()
  10653. {
  10654. Id = eecInfo.Id,
  10655. ChoiceTwoJJ = eecInfo.SumJJC,
  10656. OutsideJJPay = eecInfo.OutsideJJPay,
  10657. ChoiceTwoGW = eecInfo.SumGWC,
  10658. OutsideGWPay = eecInfo.OutsideGWPay,
  10659. ChoiceTwoTD = eecInfo.SumTDC,
  10660. OutsideTDPay = eecInfo.OutsideTDPay,
  10661. AirJJ = eecInfo.AirJJ,
  10662. AirGW = eecInfo.AirGW,
  10663. AirTD = eecInfo.AirTD,
  10664. CityTranffic = eecInfo.CityTranffic,
  10665. TwoItemRemark = eecInfo.TwoItemRemark
  10666. };
  10667. return Ok(JsonView(twoData));
  10668. }
  10669. else if (subType == 3) //3:住宿费
  10670. {
  10671. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10672. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10673. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10674. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10675. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10676. {
  10677. ParentId = dac.ParentId,
  10678. SubId = dac.Id,
  10679. Type = dac.Type,
  10680. Days = dac.Days,
  10681. NationalTravelFeeId = dac.NationalTravelFeeId,
  10682. Arae = $"{ntf.Country}-{ntf.City}",
  10683. Cost = dac.Cost,
  10684. Currency = dac.Currency,
  10685. CurrencyName = sd.Name,
  10686. SubTotal = dac.SubTotal,
  10687. })
  10688. .ToArray();
  10689. var data = new ChoiceDraftMobileSubInfo3To6View()
  10690. {
  10691. ParentId = eecInfo.Id,
  10692. Choice = eecInfo.ChoiceThree,
  10693. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10694. Details = dayAndCostDatas
  10695. };
  10696. return Ok(JsonView(data));
  10697. }
  10698. else if (subType == 4) //4:伙食费
  10699. {
  10700. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10701. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10702. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10703. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10704. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10705. {
  10706. ParentId = dac.ParentId,
  10707. SubId = dac.Id,
  10708. Type = dac.Type,
  10709. Days = dac.Days,
  10710. NationalTravelFeeId = dac.NationalTravelFeeId,
  10711. Arae = $"{ntf.Country}-{ntf.City}",
  10712. Cost = dac.Cost,
  10713. Currency = dac.Currency,
  10714. CurrencyName = sd.Name,
  10715. SubTotal = dac.SubTotal,
  10716. })
  10717. .ToArray();
  10718. var data = new ChoiceDraftMobileSubInfo3To6View()
  10719. {
  10720. ParentId = eecInfo.Id,
  10721. Choice = eecInfo.ChoiceFour,
  10722. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10723. Details = dayAndCostDatas
  10724. };
  10725. return Ok(JsonView(data));
  10726. }
  10727. else if (subType == 5) //5:公杂费
  10728. {
  10729. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10730. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10731. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10732. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10733. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10734. {
  10735. ParentId = dac.ParentId,
  10736. SubId = dac.Id,
  10737. Type = dac.Type,
  10738. Days = dac.Days,
  10739. NationalTravelFeeId = dac.NationalTravelFeeId,
  10740. Arae = $"{ntf.Country}-{ntf.City}",
  10741. Cost = dac.Cost,
  10742. Currency = dac.Currency,
  10743. CurrencyName = sd.Name,
  10744. SubTotal = dac.SubTotal,
  10745. })
  10746. .ToArray();
  10747. var data = new ChoiceDraftMobileSubInfo3To6View()
  10748. {
  10749. ParentId = eecInfo.Id,
  10750. Choice = eecInfo.ChoiceFive,
  10751. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10752. Details = dayAndCostDatas
  10753. };
  10754. return Ok(JsonView(data));
  10755. }
  10756. else if (subType == 6) //6:培训费
  10757. {
  10758. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10759. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10760. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10761. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10762. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10763. {
  10764. ParentId = dac.ParentId,
  10765. SubId = dac.Id,
  10766. Type = dac.Type,
  10767. Days = dac.Days,
  10768. NationalTravelFeeId = dac.NationalTravelFeeId,
  10769. Arae = $"{ntf.Country}-{ntf.City}",
  10770. Cost = dac.Cost,
  10771. Currency = dac.Currency,
  10772. CurrencyName = sd.Name,
  10773. SubTotal = dac.SubTotal,
  10774. })
  10775. .ToArray();
  10776. var data = new ChoiceDraftMobileSubInfo3To6View()
  10777. {
  10778. ParentId = eecInfo.Id,
  10779. Choice = eecInfo.ChoiceSix,
  10780. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10781. Details = dayAndCostDatas
  10782. };
  10783. return Ok(JsonView(data));
  10784. }
  10785. else if (subType == 7) //7:其他
  10786. {
  10787. //其他款项
  10788. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10789. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10790. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10791. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10792. .OrderBy((dop, sd1, sd2) => dop.Index)
  10793. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10794. {
  10795. ParentId = dop.ParentId,
  10796. SubId = dop.Id,
  10797. Index = dop.Index,
  10798. SetDataId = dop.SetDataId,
  10799. SetDataName = sd1.Name,
  10800. Cost = dop.Cost,
  10801. Currency = dop.Currency,
  10802. CurrencyName = sd2.Name,
  10803. SubTotal = dop.SubTotal,
  10804. Remark = dop.Remark,
  10805. })
  10806. .ToArray();
  10807. var data = new ChoiceSevenDraftMobileSubInfoView()
  10808. {
  10809. ParentId = eecInfo.Id,
  10810. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10811. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10812. Details = otherData
  10813. };
  10814. return Ok(JsonView(data));
  10815. }
  10816. return Ok(JsonView(false));
  10817. }
  10818. #region op
  10819. /// <summary>
  10820. /// 移动端更新费用消息通知
  10821. /// </summary>
  10822. /// <param name="draftId"></param>
  10823. /// <param name="id"></param>
  10824. /// <param name="currUserId"></param>
  10825. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10826. {
  10827. try
  10828. {
  10829. ////生成默认文件pdf并且通知人员
  10830. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10831. //{
  10832. // DiId = draftId,
  10833. // ExportType = 1,
  10834. // SubTypeId = 1005
  10835. //}, "pdf");
  10836. ////发送通知
  10837. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10838. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10839. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10840. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10841. ////汇率信息记录
  10842. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10843. }
  10844. catch (Exception ex)
  10845. {
  10846. //记录日志
  10847. throw;
  10848. }
  10849. }
  10850. /// <summary>
  10851. /// 验证出入境费用数据是否存在
  10852. /// 不存在添加
  10853. /// </summary>
  10854. /// <param name="draftId"></param>
  10855. /// <param name="currUserId"></param>
  10856. /// <returns></returns>
  10857. /// <exception cref="CustomException"></exception>
  10858. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10859. {
  10860. var parentId = 0;
  10861. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10862. if (info != null) parentId = info.Id;
  10863. else
  10864. {
  10865. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10866. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10867. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10868. parentId = addId;
  10869. }
  10870. return parentId;
  10871. }
  10872. /// <summary>
  10873. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10874. /// </summary>
  10875. /// <returns></returns>
  10876. [HttpPost]
  10877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10878. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10879. {
  10880. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10881. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10882. //验证查看权限
  10883. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10884. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10885. var userIds = await _sqlSugar
  10886. .Queryable<Grp_EnterExitCostDraftPermission>()
  10887. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10888. .Select(x => x.UserId)
  10889. .ToArrayAsync();
  10890. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10891. var perUsersView = new List<dynamic>();
  10892. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10893. var viewPermissionData = new List<PermissionViewUserview>();
  10894. if (feeBasePerm.Any())
  10895. {
  10896. foreach (var item in feeBasePerm)
  10897. {
  10898. if (item.Users.Any())
  10899. {
  10900. viewPermissionData.AddRange(item.Users);
  10901. }
  10902. }
  10903. }
  10904. foreach (var item in perUsers)
  10905. {
  10906. bool isView1 = false;
  10907. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10908. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10909. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10910. }
  10911. return Ok(JsonView(perUsersView));
  10912. }
  10913. /// <summary>
  10914. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10915. /// </summary>
  10916. /// <returns></returns>
  10917. [HttpPost]
  10918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10919. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10920. {
  10921. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10922. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10923. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10924. //验证查看编辑权限
  10925. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10926. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10927. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10928. foreach (var userId in dto.UserIds)
  10929. {
  10930. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10931. }
  10932. if (permissions.Any())
  10933. {
  10934. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10935. {
  10936. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10937. }
  10938. _sqlSugar.BeginTran();
  10939. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10940. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10941. if (result < 1)
  10942. {
  10943. _sqlSugar.RollbackTran();
  10944. return Ok(JsonView(false));
  10945. }
  10946. _sqlSugar.CommitTran();
  10947. return Ok(JsonView(true));
  10948. }
  10949. return Ok(JsonView(false));
  10950. }
  10951. /// <summary>
  10952. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10953. /// </summary>
  10954. /// <returns></returns>
  10955. [HttpPost]
  10956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10957. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10958. {
  10959. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10960. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10961. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10962. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10963. int id = dto.DraftId;
  10964. if (id <= 0) //add
  10965. {
  10966. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10967. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10968. if (add < 1) return Ok(JsonView(false));
  10969. id = add;
  10970. }
  10971. else //update
  10972. {
  10973. //验证查看编辑权限
  10974. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10975. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10976. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10977. if (upd < 1) return Ok(JsonView(false));
  10978. }
  10979. return Ok(JsonView(new { parentId = id }));
  10980. }
  10981. /// <summary>
  10982. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10983. /// </summary>
  10984. /// <returns></returns>
  10985. [HttpPost]
  10986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10987. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10988. {
  10989. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10990. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10991. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10992. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10993. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10994. int id = dto.DraftId;
  10995. if (id <= 0) //add
  10996. {
  10997. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10998. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10999. if (add < 1) return Ok(JsonView(false));
  11000. id = add;
  11001. }
  11002. else //update
  11003. {
  11004. //验证查看编辑权限
  11005. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11006. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11007. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11008. if (upd < 1) return Ok(JsonView(false));
  11009. }
  11010. #region 汇率变更时更改币种相关费用
  11011. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11012. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11013. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11014. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11015. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11016. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11017. .Select((dac, sd) => new
  11018. {
  11019. dac.Id,
  11020. dac.ParentId,
  11021. CurrencyCode = sd.Name,
  11022. dac.Cost
  11023. })
  11024. .ToList();
  11025. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11026. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11027. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11028. .Select((dop, sd) => new
  11029. {
  11030. dop.Id,
  11031. dop.ParentId,
  11032. CurrencyCode = sd.Name,
  11033. dop.Cost
  11034. })
  11035. .ToList();
  11036. if (dayCosts.Count > 0)
  11037. {
  11038. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11039. foreach (var dc in new_dayCosts)
  11040. {
  11041. var thisCurrency = dc.Key.ToUpper();
  11042. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11043. if (thisRate == 0.00M) continue;
  11044. foreach (var dcSub in dc)
  11045. {
  11046. opDayCosts.Add(new Grp_DayAndCostDraft()
  11047. {
  11048. Id = dcSub.Id,
  11049. ParentId = dcSub.ParentId,
  11050. Cost = dcSub.Cost,
  11051. SubTotal = dcSub.Cost * thisRate,
  11052. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11053. });
  11054. }
  11055. }
  11056. if (opDayCosts.Count > 0)
  11057. {
  11058. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11059. }
  11060. }
  11061. if (dayOtherCosts.Count > 0)
  11062. {
  11063. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11064. foreach (var dc in new_dayOtherCosts)
  11065. {
  11066. var thisCurrency = dc.Key.ToUpper();
  11067. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11068. if (thisRate == 0.00M) continue;
  11069. foreach (var dcSub in dc)
  11070. {
  11071. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11072. {
  11073. Id = dcSub.Id,
  11074. ParentId = dcSub.ParentId,
  11075. Cost = dcSub.Cost,
  11076. SubTotal = dcSub.Cost * thisRate,
  11077. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11078. });
  11079. }
  11080. }
  11081. if (opDayOtherCosts.Count > 0)
  11082. {
  11083. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11084. }
  11085. }
  11086. #endregion
  11087. ////消息通知
  11088. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11089. ////汇率信息记录
  11090. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11091. return Ok(JsonView(new { parentId = id }));
  11092. }
  11093. /// <summary>
  11094. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11095. /// </summary>
  11096. /// <returns></returns>
  11097. [HttpPost]
  11098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11099. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11100. {
  11101. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11102. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11103. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11104. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11105. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11106. int id = dto.DraftId;
  11107. if (id <= 0) //add
  11108. {
  11109. checkboxInfo.ProvinceId = dto.ProvinceId;
  11110. checkboxInfo.CreateUserId = dto.CurrUserId;
  11111. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11112. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11113. if (add < 1) return Ok(JsonView(false));
  11114. }
  11115. else //update
  11116. {
  11117. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11118. .UpdateColumns(x => new
  11119. {
  11120. x.ChoiceOne,
  11121. x.ChoiceTwo,
  11122. x.SumJJC,
  11123. x.SumGWC,
  11124. x.SumTDC,
  11125. x.ChoiceThree,
  11126. x.ChoiceFour,
  11127. x.ChoiceFive,
  11128. x.ChoiceSix,
  11129. x.OtherExpenses_Checked
  11130. })
  11131. .Where(x => x.Id == id)
  11132. .ExecuteCommandAsync();
  11133. if (upd < 1) return Ok(JsonView(false));
  11134. }
  11135. return Ok(JsonView(new { parentId = id }));
  11136. }
  11137. /// <summary>
  11138. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11139. /// </summary>
  11140. /// <returns></returns>
  11141. [HttpPost]
  11142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11143. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11144. {
  11145. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11146. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11147. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11148. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11149. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11150. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11151. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11152. var checkboxInfo = new Grp_EnterExitCostDraft()
  11153. {
  11154. Id = draftId,
  11155. ProvinceId = dto.ProvinceId,
  11156. CreateUserId = currUserId
  11157. };
  11158. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11159. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11160. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11161. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11162. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11163. if (draftId <= 0) //add
  11164. {
  11165. checkboxInfo.CreateUserId = dto.CurrUserId;
  11166. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11167. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11168. if (add < 1) return Ok(JsonView(false));
  11169. }
  11170. else //update
  11171. {
  11172. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11173. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11174. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11175. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11176. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11177. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11178. .Where(x => x.Id == draftId)
  11179. .ExecuteCommandAsync();
  11180. if (upd < 1) return Ok(JsonView(false));
  11181. }
  11182. return Ok(JsonView(new { parentId = draftId }));
  11183. }
  11184. /// <summary>
  11185. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11186. /// </summary>
  11187. /// <returns></returns>
  11188. [HttpPost]
  11189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11190. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11191. {
  11192. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11193. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11194. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11195. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11196. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11197. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11198. info.ProvinceId = dto.ProvinceId;
  11199. info.FirstItemRemark = dto.FirstItemRemark;
  11200. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11201. if (id <= 0) //add
  11202. {
  11203. info.CreateUserId = dto.CurrUserId;
  11204. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11205. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11206. if (add < 1) return Ok(JsonView(false));
  11207. id = add;
  11208. }
  11209. else //update
  11210. {
  11211. var upd = await _sqlSugar.Updateable(info)
  11212. .UpdateColumns(x => new
  11213. {
  11214. x.ChoiceOne,
  11215. x.InsidePay,
  11216. x.VisaRemark,
  11217. x.Visa,
  11218. x.Service,
  11219. x.Safe,
  11220. x.Ticket,
  11221. x.HeSuan,
  11222. x.YiMiao,
  11223. x.FirstItemRemark
  11224. })
  11225. .Where(x => x.Id == id)
  11226. .ExecuteCommandAsync();
  11227. if (upd < 1) return Ok(JsonView(false));
  11228. }
  11229. ////消息通知
  11230. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11231. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11232. }
  11233. /// <summary>
  11234. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11235. /// </summary>
  11236. /// <returns></returns>
  11237. [HttpPost]
  11238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11239. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11240. {
  11241. int id = dto.DraftId;
  11242. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11243. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11244. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11245. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11246. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11247. info.ProvinceId = dto.ProvinceId;
  11248. info.OutsideJJPay = dto.OutsideJJPay;
  11249. info.OutsideGWPay = dto.OutsideGWPay;
  11250. info.OutsideTDPay = dto.OutsideTDPay;
  11251. info.AirJJ = dto.AirJJ;
  11252. info.AirGW = dto.AirGW;
  11253. info.AirTD = dto.AirTD;
  11254. info.CityTranffic = dto.CityTranffic;
  11255. info.TwoItemRemark = dto.TwoItemRemark;
  11256. info.SumJJC = dto.ChoiceTwoJJ;
  11257. info.SumGWC = dto.ChoiceTwoGW;
  11258. info.SumTDC = dto.ChoiceTwoTD;
  11259. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11260. if (id <= 0) //add
  11261. {
  11262. info.CreateUserId = dto.CurrUserId;
  11263. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11264. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11265. if (addId <= 0) return Ok(JsonView(false));
  11266. id = addId;
  11267. }
  11268. else //update
  11269. {
  11270. var upd = await _sqlSugar.Updateable(info)
  11271. .UpdateColumns(x => new
  11272. {
  11273. x.SumJJC,
  11274. x.OutsideJJPay,
  11275. x.SumGWC,
  11276. x.OutsideGWPay,
  11277. x.SumTDC,
  11278. x.OutsideTDPay,
  11279. x.AirJJ,
  11280. x.AirGW,
  11281. x.AirTD,
  11282. x.CityTranffic,
  11283. x.TwoItemRemark
  11284. })
  11285. .Where(x => x.Id == id)
  11286. .ExecuteCommandAsync();
  11287. if (upd < 1) return Ok(JsonView(false));
  11288. }
  11289. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11290. gwcItemTotal = info.AirGW + info.CityTranffic;
  11291. tdcItemTotal = info.AirTD + info.CityTranffic;
  11292. ////消息通知
  11293. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11294. return Ok(JsonView(new
  11295. {
  11296. parentId = id,
  11297. choiceTwoJJ = dto.ChoiceTwoJJ,
  11298. jjcItemTotal = jjcItemTotal,
  11299. choiceTwoGW = dto.ChoiceTwoGW,
  11300. gwcItemTotal = gwcItemTotal,
  11301. choiceTwoTD = dto.ChoiceTwoTD,
  11302. tdcItemTotal = tdcItemTotal
  11303. }));
  11304. }
  11305. /// <summary>
  11306. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11307. /// </summary>
  11308. /// <returns></returns>
  11309. [HttpPost]
  11310. [ApiExplorerSettings(IgnoreApi = true)]
  11311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11312. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11313. {
  11314. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11315. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11316. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11317. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11318. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11319. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11320. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11321. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11322. {
  11323. Id = x.Id,
  11324. ParentId = dto.DraftId,
  11325. Type = dto.FeeType,
  11326. Days = x.Days,
  11327. NationalTravelFeeId = x.NationalTravelFeeId,
  11328. Cost = x.Cost,
  11329. Currency = x.Currency,
  11330. SubTotal = x.SubTotal,
  11331. CreateUserId = dto.CurrUserId
  11332. })
  11333. .ToList();
  11334. var adds = infos.Where(x => x.Id <= 0).ToList();
  11335. var upds = infos.Where(x => x.Id > 0).ToList();
  11336. if (adds.Count > 0)
  11337. {
  11338. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11339. if (add < 1) return Ok(JsonView(false));
  11340. }
  11341. if (upds.Count > 0)
  11342. {
  11343. var upd = await _sqlSugar.Updateable(adds)
  11344. .UpdateColumns(x => new
  11345. {
  11346. x.Days,
  11347. x.NationalTravelFeeId,
  11348. x.Cost,
  11349. x.Currency,
  11350. x.SubTotal
  11351. })
  11352. .WhereColumns(x => new { x.Id })
  11353. .ExecuteCommandAsync();
  11354. if (upd < 1) return Ok(JsonView(false));
  11355. }
  11356. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11357. ////消息通知
  11358. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11359. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11360. return Ok(JsonView(new { itemTotal = itemTotal }));
  11361. }
  11362. /// <summary>
  11363. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11364. /// </summary>
  11365. /// <returns></returns>
  11366. [HttpPost]
  11367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11368. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11369. {
  11370. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11371. int subId = dto.SubId, feeType = dto.FeeType;
  11372. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11373. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11374. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11375. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11376. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11377. subInfo.Id = subId;
  11378. subInfo.ParentId = dto.DraftId;
  11379. if (feeType == 3) subInfo.Type = 1;
  11380. else if (feeType == 4) subInfo.Type = 2;
  11381. else if (feeType == 5) subInfo.Type = 3;
  11382. else if (feeType == 6) subInfo.Type = 4;
  11383. subInfo.CreateUserId = dto.CurrUserId;
  11384. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11385. if (parentId < 1) return Ok(JsonView(false));
  11386. //子表op
  11387. if (subId < 1)
  11388. {
  11389. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11390. if (subAdd < 1) return Ok(JsonView(false));
  11391. }
  11392. else
  11393. {
  11394. var subUpd = await _sqlSugar.Updateable(subInfo)
  11395. .UpdateColumns(x => new
  11396. {
  11397. x.Days,
  11398. x.NationalTravelFeeId,
  11399. x.Cost,
  11400. x.Currency,
  11401. x.SubTotal
  11402. })
  11403. .WhereColumns(x => new { x.Id })
  11404. .ExecuteCommandAsync();
  11405. if (subUpd < 1) return Ok(JsonView(false));
  11406. }
  11407. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11408. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11409. }
  11410. /// <summary>
  11411. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11412. /// </summary>
  11413. /// <returns></returns>
  11414. [HttpPost]
  11415. [ApiExplorerSettings(IgnoreApi = true)]
  11416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11417. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11418. {
  11419. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11420. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11421. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11422. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11423. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11424. {
  11425. Id = x.Id,
  11426. ParentId = dto.DraftId,
  11427. SetDataId = x.SetDataId,
  11428. Index = x.Index,
  11429. Cost = x.Cost,
  11430. Currency = x.Currency,
  11431. SubTotal = x.SubTotal,
  11432. CreateUserId = dto.CurrUserId,
  11433. Remark = x.Remark
  11434. }).ToList();
  11435. var adds = infos.Where(x => x.Id <= 0).ToList();
  11436. var upds = infos.Where(x => x.Id > 0).ToList();
  11437. if (adds.Count > 0)
  11438. {
  11439. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11440. if (add < 1) return Ok(JsonView(false));
  11441. }
  11442. if (upds.Count > 0)
  11443. {
  11444. var upd = await _sqlSugar.Updateable(adds)
  11445. .UpdateColumns(x => new
  11446. {
  11447. x.Index,
  11448. x.SetDataId,
  11449. x.Cost,
  11450. x.Currency,
  11451. x.SubTotal,
  11452. x.Remark
  11453. })
  11454. .WhereColumns(x => new { x.Id })
  11455. .ExecuteCommandAsync();
  11456. if (upd < 1) return Ok(JsonView(false));
  11457. }
  11458. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11459. //消息通知
  11460. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11461. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11462. return Ok(JsonView(new { itemTotal = itemTotal }));
  11463. }
  11464. /// <summary>
  11465. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11466. /// </summary>
  11467. /// <returns></returns>
  11468. [HttpPost]
  11469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11470. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11471. {
  11472. int subId = dto.SubId, id = dto.DraftId;
  11473. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11474. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11475. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11476. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11477. subInfo.Id = subId;
  11478. subInfo.ParentId = id;
  11479. subInfo.CreateUserId = dto.CurrUserId;
  11480. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11481. if (parentId < 1) return Ok(JsonView(false));
  11482. #region 子表op
  11483. if (subId < 1)//add
  11484. {
  11485. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11486. if (subAdd < 1) return Ok(JsonView(false));
  11487. }
  11488. else //upd
  11489. {
  11490. var subUpd = await _sqlSugar.Updateable(subInfo)
  11491. .UpdateColumns(x => new
  11492. {
  11493. x.Index,
  11494. x.SetDataId,
  11495. x.Cost,
  11496. x.Currency,
  11497. x.SubTotal,
  11498. x.Remark
  11499. })
  11500. .WhereColumns(x => new { x.Id })
  11501. .ExecuteCommandAsync();
  11502. if (subUpd < 1) return Ok(JsonView(false));
  11503. }
  11504. #endregion
  11505. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11506. ////消息通知
  11507. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11508. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11509. }
  11510. /// <summary>
  11511. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11512. /// </summary>
  11513. /// <returns></returns>
  11514. [HttpPost]
  11515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11516. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11517. {
  11518. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11519. if (data.Code != 0)
  11520. {
  11521. return Ok(JsonView(false, data.Msg));
  11522. }
  11523. return Ok(JsonView(true, "操作成功!", data.Data));
  11524. }
  11525. /// <summary>
  11526. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11527. /// </summary>
  11528. /// <param name="dto"></param>
  11529. /// <returns></returns>
  11530. [HttpPost]
  11531. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11532. {
  11533. var data = new Grp_DayOtherPriceDraft()
  11534. {
  11535. Id = dto.Id,
  11536. IsDel = 1,
  11537. DeleteUserId = dto.DeleteUserId,
  11538. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11539. };
  11540. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11541. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11542. return Ok(JsonView(false, "删除失败!"));
  11543. }
  11544. #endregion
  11545. #endregion
  11546. #region 团组经理模块 出入境费用报价表
  11547. /// <summary>
  11548. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11549. /// </summary>
  11550. /// <returns></returns>
  11551. [HttpPost]
  11552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11553. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11554. {
  11555. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11556. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11557. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11558. initRates.Insert(0, cnyInfo);
  11559. liveRates.Insert(0, cnyInfo);
  11560. return Ok(JsonView(true, "查询成功!", new
  11561. {
  11562. InitRates = initRates,
  11563. LiveRates = liveRates
  11564. }));
  11565. }
  11566. /// <summary>
  11567. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11568. /// </summary>
  11569. /// <returns></returns>
  11570. [HttpPost]
  11571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11572. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11573. {
  11574. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11575. }
  11576. /// <summary>
  11577. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11578. /// </summary>
  11579. /// <returns></returns>
  11580. [HttpPost]
  11581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11582. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11583. {
  11584. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11585. }
  11586. /// <summary>
  11587. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11588. /// </summary>
  11589. /// <returns></returns>
  11590. [HttpPost]
  11591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11592. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11593. {
  11594. int groupId = dto.DiId,
  11595. currUserId = dto.CurrUserId;
  11596. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11597. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11598. //验证报价数据是否存在
  11599. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11600. if (isNull != null)
  11601. {
  11602. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11603. if (!info1.Rates.Any())
  11604. {
  11605. var rates = await GeneralMethod.EnterExitCostInitRate();
  11606. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11607. info1.Rates = rates.ToArray();
  11608. }
  11609. return Ok(JsonView(info1));
  11610. }
  11611. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11612. result.GroupId = groupId;
  11613. //处理报价名称
  11614. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11615. if (groupInfo != null)
  11616. {
  11617. var visitCountry = groupInfo.VisitCountry;
  11618. if (!string.IsNullOrEmpty(visitCountry))
  11619. {
  11620. string quoteName = string.Empty;
  11621. if (visitCountry.Contains("|"))
  11622. {
  11623. var countrys = visitCountry.Split("|");
  11624. quoteName = string.Join("、", countrys);
  11625. }
  11626. else quoteName = visitCountry;
  11627. quoteName += $"团组报价表";
  11628. result.Name = quoteName;
  11629. }
  11630. }
  11631. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11632. if (info.Code != StatusCodes.Status200OK)
  11633. {
  11634. if (!result.Rates.Any())
  11635. {
  11636. var rates = await GeneralMethod.EnterExitCostInitRate();
  11637. result.Rates = rates.ToArray();
  11638. }
  11639. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11640. }
  11641. var infoView = info.Data as EnterExitCostInfoView;
  11642. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11643. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11644. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11645. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11646. var eecRates = infoView.Currencys;
  11647. //默认添加人名币
  11648. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11649. {
  11650. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11651. }
  11652. //处理团组人数
  11653. int pplNum = 1;
  11654. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11655. var views = new List<QuoteSubItemInfo>();
  11656. #region 数据填充
  11657. var intTravelCosts = new List<QuoteSubItemInfo>();
  11658. #region 机票费用 1354
  11659. int intTravelIndex = 1;
  11660. if (infoView.SumJJC == 1)
  11661. {
  11662. intTravelCosts.Add(new QuoteSubItemInfo
  11663. {
  11664. ItemId = 1354,
  11665. Index = intTravelIndex,
  11666. FeeName = "经济舱",
  11667. UnitPrice = infoView.AirJJ,
  11668. Currency = "CNY",
  11669. Quantity = 1,
  11670. PplNum = 1,
  11671. TotalAmt = infoView.AirJJ,
  11672. Remark = "",
  11673. });
  11674. intTravelIndex++;
  11675. }
  11676. if (infoView.SumGWC == 1)
  11677. {
  11678. intTravelCosts.Add(new QuoteSubItemInfo
  11679. {
  11680. ItemId = 1354,
  11681. Index = intTravelIndex,
  11682. FeeName = "公务舱",
  11683. UnitPrice = infoView.AirGW,
  11684. Currency = "CNY",
  11685. Quantity = 1,
  11686. PplNum = 1,
  11687. TotalAmt = infoView.AirGW,
  11688. Remark = "",
  11689. });
  11690. intTravelIndex++;
  11691. }
  11692. if (infoView.SumTDC == 1)
  11693. {
  11694. intTravelCosts.Add(new QuoteSubItemInfo
  11695. {
  11696. ItemId = 1354,
  11697. Index = intTravelIndex,
  11698. FeeName = "头等舱",
  11699. UnitPrice = infoView.AirTD,
  11700. Currency = "CNY",
  11701. Quantity = 1,
  11702. PplNum = 1,
  11703. TotalAmt = infoView.AirTD,
  11704. Remark = "",
  11705. });
  11706. intTravelIndex++;
  11707. }
  11708. intTravelCosts.Add(new QuoteSubItemInfo
  11709. {
  11710. ItemId = 1354,
  11711. Index = intTravelIndex,
  11712. FeeName = "城市间交通费用",
  11713. UnitPrice = infoView.CityTranffic,
  11714. Currency = "CNY",
  11715. Quantity = 1,
  11716. PplNum = pplNum,
  11717. TotalAmt = infoView.CityTranffic * pplNum,
  11718. Remark = "",
  11719. });
  11720. views.AddRange(intTravelCosts);
  11721. #endregion
  11722. var accomCosts = new List<QuoteSubItemInfo>();
  11723. #region 住宿费 1355
  11724. if (infoView.QuarterageData.Any())
  11725. {
  11726. int accomIndex = 1;
  11727. int accomItemTypeId = 1355;
  11728. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11729. foreach (var item in groupData)
  11730. {
  11731. string feeName = string.Empty;
  11732. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11733. if (countryInfo != null)
  11734. {
  11735. feeName = countryInfo.Country;
  11736. var city = countryInfo.City;
  11737. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11738. {
  11739. feeName += $"-{city}";
  11740. }
  11741. }
  11742. var hotelInfo = item.FirstOrDefault();
  11743. if (hotelInfo == null) continue;
  11744. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11745. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11746. int quantity = item.ToList().Count;
  11747. accomCosts.Add(new QuoteSubItemInfo
  11748. {
  11749. ItemId = accomItemTypeId,
  11750. Index = accomIndex,
  11751. FeeName = feeName,
  11752. UnitPrice = hotelInfo.Cost,
  11753. Currency = thisCurrency,
  11754. Quantity = quantity,
  11755. PplNum = pplNum,
  11756. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11757. Remark = "",
  11758. });
  11759. accomIndex++;
  11760. }
  11761. views.AddRange(accomCosts);
  11762. }
  11763. #endregion
  11764. var mealCosts = new List<QuoteSubItemInfo>();
  11765. #region 餐饮费 1356
  11766. if (infoView.BoardWagesData.Any())
  11767. {
  11768. var mealIndex = 1;
  11769. int mealItemTypeId = 1356;
  11770. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11771. foreach (var item in groupData)
  11772. {
  11773. string feeName = string.Empty;
  11774. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11775. if (countryInfo != null)
  11776. {
  11777. feeName = countryInfo.Country;
  11778. var city = countryInfo.City;
  11779. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11780. {
  11781. feeName += $"-{city}";
  11782. }
  11783. }
  11784. var mealInfo = item.FirstOrDefault();
  11785. if (mealInfo == null) continue;
  11786. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11787. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11788. int quantity = item.ToList().Count;
  11789. mealCosts.Add(new QuoteSubItemInfo
  11790. {
  11791. ItemId = mealItemTypeId,
  11792. Index = mealIndex,
  11793. FeeName = feeName,
  11794. UnitPrice = mealInfo.Cost,
  11795. Currency = thisCurrency,
  11796. Quantity = quantity,
  11797. PplNum = pplNum,
  11798. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11799. Remark = "",
  11800. });
  11801. mealIndex++;
  11802. }
  11803. views.AddRange(mealCosts);
  11804. }
  11805. #endregion
  11806. var miscCosts = new List<QuoteSubItemInfo>();
  11807. #region 公杂费 1364
  11808. if (infoView.MiscellaneousFeeData.Any())
  11809. {
  11810. var miscIndex = 1;
  11811. int miscItemTypeId = 1364;
  11812. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11813. foreach (var item in groupData)
  11814. {
  11815. string feeName = string.Empty;
  11816. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11817. if (countryInfo != null)
  11818. {
  11819. feeName = countryInfo.Country;
  11820. var city = countryInfo.City;
  11821. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11822. {
  11823. feeName += $"-{city}";
  11824. }
  11825. }
  11826. var miscInfo = item.FirstOrDefault();
  11827. if (miscInfo == null) continue;
  11828. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11829. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11830. int quantity = item.ToList().Count;
  11831. miscCosts.Add(new QuoteSubItemInfo
  11832. {
  11833. ItemId = miscItemTypeId,
  11834. Index = miscIndex,
  11835. FeeName = feeName,
  11836. UnitPrice = miscInfo.Cost,
  11837. Currency = thisCurrency,
  11838. Quantity = quantity,
  11839. PplNum = pplNum,
  11840. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11841. Remark = "",
  11842. });
  11843. miscIndex++;
  11844. }
  11845. views.AddRange(miscCosts);
  11846. }
  11847. #endregion
  11848. #region 签证+保险 1362
  11849. int visaInsIndex = 1;
  11850. int visaInsItemTypeId = 1362;
  11851. if (infoView.Visa > 0)
  11852. {
  11853. views.Add(new QuoteSubItemInfo()
  11854. {
  11855. ItemId = visaInsItemTypeId,
  11856. Index = visaInsIndex,
  11857. FeeName = $"签证",
  11858. UnitPrice = infoView.Visa,
  11859. Currency = $"CNY",
  11860. Quantity = 1,
  11861. PplNum = pplNum,
  11862. TotalAmt = infoView.Visa * pplNum,
  11863. Remark = "",
  11864. });
  11865. visaInsIndex++;
  11866. }
  11867. if (infoView.Safe > 0)
  11868. {
  11869. views.Add(new QuoteSubItemInfo()
  11870. {
  11871. ItemId = visaInsItemTypeId,
  11872. Index = visaInsIndex,
  11873. FeeName = $"保险",
  11874. UnitPrice = infoView.Safe,
  11875. Currency = $"CNY",
  11876. Quantity = 1,
  11877. PplNum = pplNum,
  11878. TotalAmt = infoView.Safe * pplNum,
  11879. Remark = "",
  11880. });
  11881. }
  11882. #endregion
  11883. #region 服务费 1363
  11884. int serviceFeeIndex = 1;
  11885. int serviceFeeItemTypeId = 1363;
  11886. if (infoView.Service > 0)
  11887. {
  11888. views.Add(new QuoteSubItemInfo()
  11889. {
  11890. ItemId = serviceFeeItemTypeId,
  11891. Index = serviceFeeIndex,
  11892. FeeName = $"服务费",
  11893. UnitPrice = infoView.Service,
  11894. Currency = $"CNY",
  11895. Quantity = 1,
  11896. PplNum = pplNum,
  11897. TotalAmt = infoView.Service * pplNum,
  11898. Remark = "",
  11899. });
  11900. }
  11901. #endregion
  11902. #endregion
  11903. if (result.FeeItems.Any())
  11904. {
  11905. result.FeeItems.Select(x =>
  11906. {
  11907. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11908. if (feeInfos.Any()) x.Infos = feeInfos;
  11909. return x;
  11910. }
  11911. ).OrderBy(x => x.Index)
  11912. .ToList();
  11913. if (!result.Rates.Any())
  11914. {
  11915. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  11916. else
  11917. {
  11918. var rates = await GeneralMethod.EnterExitCostInitRate();
  11919. rates.Insert(0,new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11920. result.Rates = rates.ToArray();
  11921. }
  11922. }
  11923. }
  11924. return Ok(JsonView(result));
  11925. }
  11926. /// <summary>
  11927. /// 团组模块 - 出入境费用报价表 - Info
  11928. /// </summary>
  11929. /// <returns></returns>
  11930. [HttpPost]
  11931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11932. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11933. {
  11934. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11935. if (!info.Rates.Any())
  11936. {
  11937. var rates = await GeneralMethod.EnterExitCostInitRate();
  11938. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11939. info.Rates = rates.ToArray();
  11940. }
  11941. return Ok(JsonView(info));
  11942. }
  11943. /// <summary>
  11944. /// 团组模块 - 出入境费用报价表 - OP
  11945. /// </summary>
  11946. /// <returns></returns>
  11947. [HttpPost]
  11948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11949. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11950. {
  11951. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11952. }
  11953. /// <summary>
  11954. /// 团组模块 - 出入境费用报价表 - 删除 项
  11955. /// </summary>
  11956. /// <returns></returns>
  11957. [HttpPost]
  11958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11959. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11960. {
  11961. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11962. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11963. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11964. }
  11965. /// <summary>
  11966. /// 团组模块 - 出入境费用报价表 - 导出
  11967. /// </summary>
  11968. /// <returns></returns>
  11969. [HttpPost]
  11970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11971. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11972. {
  11973. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11974. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11975. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11976. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11977. var rates = info.Rates;
  11978. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11979. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11980. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11981. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11982. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11983. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11984. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  11985. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  11986. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  11987. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  11988. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  11989. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  11990. //获取模板
  11991. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11992. var designer = new WorkbookDesigner();
  11993. designer.Workbook = new Workbook(tempPath);
  11994. designer.SetDataSource("QuoteName", info.Name);
  11995. designer.SetDataSource("CompanyTitle", "公司名称");
  11996. designer.SetDataSource("CompanyLabel", "");
  11997. #region 国际旅费
  11998. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  11999. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12000. {
  12001. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12002. StringBuilder label = new StringBuilder();
  12003. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12004. if (infos.Any())
  12005. {
  12006. label.Append(infos.Sum(x => x.PplNum));
  12007. label.Append("人全程机票:");
  12008. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12009. label.AppendLine("元");
  12010. }
  12011. foreach (var item in intTravelCosts.Infos)
  12012. {
  12013. label.Append(item.FeeName);
  12014. label.Append(":");
  12015. label.Append(item.UnitPrice.TruncDecimals(2));
  12016. label.Append("元/人*");
  12017. label.Append(item.PplNum);
  12018. label.AppendLine("人");
  12019. }
  12020. if (label.HasValue())
  12021. {
  12022. label.Append("\r\n以上小计:");
  12023. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12024. label.Append("元");
  12025. }
  12026. designer.SetDataSource("IntTravelLabel", label.ToString());
  12027. }
  12028. #endregion
  12029. #region 住宿费
  12030. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12031. if (accomCosts!=null && accomCosts.Infos.Any())
  12032. {
  12033. string currencyName = string.Empty,
  12034. countryName = string.Empty;
  12035. decimal rate = 1.0000M;
  12036. StringBuilder label = new StringBuilder();
  12037. label.AppendLine("全程五星酒店,每人1间房");
  12038. foreach (var item in accomCosts.Infos)
  12039. {
  12040. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12041. string name = string.Empty, thisCountryName = string.Empty;
  12042. if (item.FeeName.Contains("-"))
  12043. {
  12044. var feeName = item.FeeName.Split('-');
  12045. thisCountryName = feeName[0];
  12046. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12047. name = feeName[1];
  12048. }
  12049. else name = item.FeeName;
  12050. string thisFeeName = string.Empty;
  12051. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12052. else thisFeeName = $"\r\n{name}:";
  12053. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12054. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12055. rate = rateInfo?.Rate ?? 1.0000M;
  12056. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12057. label.AppendLine(subLabel);
  12058. }
  12059. if (label.HasValue())
  12060. {
  12061. //以上小计:52440元(美金汇率:7.5 )
  12062. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12063. label.AppendLine(subLabel);
  12064. }
  12065. designer.SetDataSource("AccomLabel", label.ToString());
  12066. }
  12067. #endregion
  12068. #region 餐饮费
  12069. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12070. if (mealCosts != null && mealCosts.Infos.Any())
  12071. {
  12072. string currencyName = string.Empty;
  12073. decimal rate = 1.0000M;
  12074. StringBuilder label = new StringBuilder();
  12075. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12076. foreach (var item in mealCosts.Infos)
  12077. {
  12078. string name = string.Empty;
  12079. if (item.FeeName.Contains("-"))
  12080. {
  12081. var feeName = item.FeeName.Split('-');
  12082. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12083. }
  12084. else name = $"\r\n{item.FeeName}:";
  12085. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12086. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12087. rate = rateInfo?.Rate ?? 1.0000M;
  12088. label.Append(name);
  12089. label.Append(item.UnitPrice.TruncDecimals(2));
  12090. label.Append(currencyName);
  12091. label.Append("/天*");
  12092. label.Append(item.Quantity.ToString("#0"));
  12093. label.Append("*");
  12094. label.Append(item.PplNum);
  12095. label.Append("人\r\n");
  12096. }
  12097. if (label.HasValue())
  12098. {
  12099. label.Append("\r\n以上小计:");
  12100. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12101. label.Append("元\r\n(");
  12102. label.Append("汇率:");
  12103. label.Append(rate.TruncDecimals(4));
  12104. label.Append(")");
  12105. }
  12106. designer.SetDataSource("MealLabel", label.ToString());
  12107. }
  12108. #endregion
  12109. #region 车辆安排
  12110. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12111. if (vehArranges!=null&&vehArranges.Infos.Any())
  12112. {
  12113. string currencyName = string.Empty;
  12114. //decimal rate = 1.0000M;
  12115. StringBuilder label = new StringBuilder();
  12116. foreach (var item in vehArranges.Infos)
  12117. {
  12118. label.AppendLine();
  12119. label.AppendLine();
  12120. label.Append(item.FeeName);
  12121. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12122. }
  12123. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12124. }
  12125. #endregion
  12126. #region 邀请函发放对象
  12127. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12128. designer.SetDataSource("InviteToContent", "");
  12129. #endregion
  12130. #region 邀请函费
  12131. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12132. StringBuilder is_label = new StringBuilder();
  12133. if (inviteCosts != null&&inviteCosts.Infos.Any())
  12134. {
  12135. string currencyName = string.Empty;
  12136. decimal rate = 1.0000M;
  12137. foreach (var item in inviteCosts.Infos)
  12138. {
  12139. //乌兹别克斯坦:2000美金
  12140. currencyName = item.Currency;
  12141. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12142. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12143. is_label.AppendLine(label);
  12144. }
  12145. if (is_label.HasValue())
  12146. {
  12147. //以上小计:28500元(美金汇率:7.5)
  12148. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2),"元", currencyName, rate.TruncDecimals(4));
  12149. is_label.AppendLine(label);
  12150. }
  12151. }
  12152. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12153. #endregion
  12154. #region 邀请函发放时间
  12155. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12156. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12157. #endregion
  12158. #region 公务活动(含翻译)
  12159. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12160. StringBuilder oa_label = new StringBuilder();
  12161. if (officialActs != null && officialActs.Infos.Any())
  12162. {
  12163. string currencyName = string.Empty;
  12164. decimal rate = 1.0000M;
  12165. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12166. foreach (var item in officialActs.Infos)
  12167. {
  12168. //乌兹别克斯坦:1000美金/场
  12169. currencyName = item.Currency;
  12170. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12171. string label_remark = string.Empty;
  12172. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12173. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12174. }
  12175. label_content += "*总费用中未含超出公务活动价格";
  12176. //8场公务活动(以上小计:60000元)
  12177. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12178. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12179. oa_label.AppendLine(label_title);
  12180. oa_label.AppendLine(label_content);
  12181. }
  12182. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12183. #endregion
  12184. #region 签证+保险
  12185. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12186. StringBuilder vi_label = new StringBuilder();
  12187. if (visaIns != null && visaIns.Infos.Any())
  12188. {
  12189. foreach (var item in visaIns.Infos)
  12190. {
  12191. //签证:500元/人
  12192. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12193. vi_label.AppendLine(label);
  12194. }
  12195. if (vi_label.HasValue())
  12196. {
  12197. //以上小计:6000元
  12198. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12199. vi_label.AppendLine(label);
  12200. }
  12201. }
  12202. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12203. #endregion
  12204. #region 服务费
  12205. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12206. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12207. #endregion
  12208. #region 公杂费
  12209. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12210. StringBuilder pm_label = new StringBuilder();
  12211. if (pubMiscs != null && pubMiscs.Infos.Any())
  12212. {
  12213. string currencyName = string.Empty,
  12214. countryName = string.Empty;
  12215. decimal rate = 1.0000M;
  12216. foreach (var item in pubMiscs.Infos)
  12217. {
  12218. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12219. string name = string.Empty, thisCountryName = string.Empty;
  12220. if (item.FeeName.Contains("-"))
  12221. {
  12222. var feeName = item.FeeName.Split('-');
  12223. thisCountryName = feeName[0];
  12224. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12225. name = feeName[1];
  12226. }
  12227. else name = item.FeeName;
  12228. string thisFeeName = string.Empty;
  12229. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12230. else thisFeeName = $"\r\n{name}:";
  12231. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12232. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12233. rate = rateInfo?.Rate ?? 1.0000M;
  12234. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12235. pm_label.AppendLine(label);
  12236. }
  12237. if (pm_label.HasValue())
  12238. {
  12239. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12240. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12241. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12242. pm_label.AppendLine(string.Format("部分发放成员"));
  12243. }
  12244. }
  12245. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12246. #endregion
  12247. #region 税费
  12248. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12249. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12250. #endregion
  12251. #region 合计(单位:元)
  12252. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12253. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12254. #endregion
  12255. #region 汇率 Remark
  12256. var rate_label = new StringBuilder();
  12257. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12258. foreach (var item in rateGroups)
  12259. {
  12260. //美元汇率按\r\n1:7.5
  12261. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12262. rate_label.AppendLine(label);
  12263. }
  12264. designer.SetDataSource("RateLabel", rate_label.ToString());
  12265. #endregion
  12266. designer.Process();
  12267. //文件名
  12268. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12269. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12270. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12271. return Ok(JsonView(true, "成功", url));
  12272. }
  12273. #endregion
  12274. #region 签证费用录入
  12275. /// <summary>
  12276. /// 根据diid查询签证费用列表
  12277. /// </summary>
  12278. /// <param name="dto"></param>
  12279. /// <returns></returns>
  12280. [HttpPost]
  12281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12282. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12283. {
  12284. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12285. if (groupData.Code != 0)
  12286. {
  12287. return Ok(JsonView(false, groupData.Msg));
  12288. }
  12289. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12290. }
  12291. /// <summary>
  12292. /// 根据签证费用Id查询单条数据及c表数据
  12293. /// </summary>
  12294. /// <param name="dto"></param>
  12295. /// <returns></returns>
  12296. [HttpPost]
  12297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12298. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12299. {
  12300. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12301. if (groupData.Code != 0)
  12302. {
  12303. return Ok(JsonView(false, groupData.Msg));
  12304. }
  12305. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12306. }
  12307. /// <summary>
  12308. /// 签证费用删除
  12309. /// </summary>
  12310. /// <param name="dto"></param>
  12311. /// <returns></returns>
  12312. [HttpPost]
  12313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12314. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12315. {
  12316. _sqlSugar.BeginTran();
  12317. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12318. if (!res)
  12319. {
  12320. _sqlSugar.RollbackTran();
  12321. return Ok(JsonView(false, "删除失败"));
  12322. }
  12323. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12324. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12325. .SetColumns(a => new Grp_CreditCardPayment()
  12326. {
  12327. IsDel = 1,
  12328. DeleteUserId = dto.DeleteUserId,
  12329. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12330. })
  12331. .ExecuteCommand();
  12332. if (resSub < 1)
  12333. {
  12334. _sqlSugar.RollbackTran();
  12335. return Ok(JsonView(false, "删除失败"));
  12336. }
  12337. _sqlSugar.CommitTran();
  12338. return Ok(JsonView(true, "删除成功!"));
  12339. }
  12340. /// <summary>
  12341. /// 签证费用录入下拉框初始化
  12342. /// </summary>
  12343. /// <returns></returns>
  12344. [HttpPost]
  12345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12346. public async Task<IActionResult> VisaPriceAddSelect()
  12347. {
  12348. //支付方式
  12349. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12350. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12351. //币种
  12352. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12353. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12354. //乘客类型
  12355. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12356. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12357. //卡类型
  12358. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12359. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12360. //代办费类型
  12361. var agencyFeeTypeData = new List<dynamic>() {
  12362. new { id = 0 , Text = "未选择" },
  12363. new { id = 1 , Text = "小公务" },
  12364. new { id = 2 , Text = "大公务" },
  12365. };
  12366. //签证费用标准国家Data
  12367. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12368. var data = new
  12369. {
  12370. Payment = _Payment,
  12371. CurrencyList = _CurrencyList,
  12372. PassengerType = _PassengerType,
  12373. BankCard = _BankCard,
  12374. AgencyFeeType = agencyFeeTypeData,
  12375. CountryFeeData = visaCountryFeeData
  12376. };
  12377. return Ok(JsonView(true, "查询成功!", data));
  12378. }
  12379. /// <summary>
  12380. /// 签证费用录入操作(Status:1.新增,2.修改)
  12381. /// </summary>
  12382. /// <param name="dto"></param>
  12383. /// <returns></returns>
  12384. [HttpPost]
  12385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12386. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12387. {
  12388. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12389. if (groupData.Code != 0)
  12390. {
  12391. return Ok(JsonView(false, groupData.Msg));
  12392. }
  12393. #region 应用推送
  12394. try
  12395. {
  12396. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12397. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12398. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12399. //2024-10-21 新增LZ UID
  12400. var userIds = new List<int>() { 21 };
  12401. string title = $"系统通知";
  12402. string content = "";
  12403. var diId = dto.DiId;
  12404. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12405. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12406. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12407. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12408. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12409. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12410. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12411. }
  12412. catch (Exception ex)
  12413. {
  12414. }
  12415. #endregion
  12416. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12417. }
  12418. #endregion
  12419. #region 签证提成录入
  12420. /// <summary>
  12421. /// 签证提成录入
  12422. /// 基础数据
  12423. /// </summary>
  12424. /// <returns></returns>
  12425. [HttpGet]
  12426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12427. public async Task<IActionResult> VisaCommissionInit()
  12428. {
  12429. return Ok(await _visaCommissionRep.Init());
  12430. }
  12431. /// <summary>
  12432. /// 签证提成录入
  12433. /// Item
  12434. /// </summary>
  12435. /// <param name="_dto"></param>
  12436. /// <returns></returns>
  12437. [HttpPost]
  12438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12439. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12440. {
  12441. var validator = new VisaCommissionItemDtoValidator();
  12442. var validatorRes = await validator.ValidateAsync(_dto);
  12443. if (!validatorRes.IsValid)
  12444. {
  12445. StringBuilder sb = new StringBuilder();
  12446. foreach (var item in validatorRes.Errors)
  12447. {
  12448. sb.AppendLine(item.ErrorMessage);
  12449. }
  12450. return Ok(JsonView(false, sb.ToString()));
  12451. }
  12452. return Ok(await _visaCommissionRep.Item(_dto));
  12453. }
  12454. /// <summary>
  12455. /// 签证提成录入
  12456. /// Save
  12457. /// </summary>
  12458. /// <param name="_dto"></param>
  12459. /// <returns></returns>
  12460. [HttpPost]
  12461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12462. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12463. {
  12464. //参数验证
  12465. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12466. foreach (var item in _dto.Items)
  12467. {
  12468. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12469. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12470. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12471. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12472. }
  12473. return Ok(await _visaCommissionRep.Save(_dto));
  12474. }
  12475. /// <summary>
  12476. /// 签证提成录入
  12477. /// Create
  12478. /// </summary>
  12479. /// <param name="_dto"></param>
  12480. /// <returns></returns>
  12481. [HttpPost]
  12482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12483. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12484. {
  12485. var validator = new VisaCommissionCreateDtoValidator();
  12486. var validatorRes = await validator.ValidateAsync(_dto);
  12487. if (!validatorRes.IsValid)
  12488. {
  12489. StringBuilder sb = new StringBuilder();
  12490. foreach (var item in validatorRes.Errors)
  12491. {
  12492. sb.AppendLine(item.ErrorMessage);
  12493. }
  12494. return Ok(JsonView(false, sb.ToString()));
  12495. }
  12496. return Ok(await _visaCommissionRep.Create(_dto));
  12497. }
  12498. /// <summary>
  12499. /// 签证提成录入
  12500. /// Put(编辑)
  12501. /// </summary>
  12502. /// <param name="id"></param>
  12503. /// <param name="_dto"></param>
  12504. /// <returns></returns>
  12505. [HttpPut]
  12506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12507. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12508. {
  12509. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12510. var validator = new VisaCommissionCreateDtoValidator();
  12511. var validatorRes = await validator.ValidateAsync(_dto);
  12512. if (!validatorRes.IsValid)
  12513. {
  12514. StringBuilder sb = new StringBuilder();
  12515. foreach (var item in validatorRes.Errors)
  12516. {
  12517. sb.AppendLine(item.ErrorMessage);
  12518. }
  12519. return Ok(JsonView(false, sb.ToString()));
  12520. }
  12521. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12522. }
  12523. /// <summary>
  12524. /// 签证提成录入
  12525. /// Del
  12526. /// </summary>
  12527. /// <param name="id"></param>
  12528. /// <param name="currUserId"></param>
  12529. /// <returns></returns>
  12530. [HttpPost]
  12531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12532. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12533. {
  12534. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12535. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12536. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12537. }
  12538. #endregion
  12539. #region op费用录入
  12540. /// <summary>
  12541. /// 根据diid查询op费用列表
  12542. /// </summary>
  12543. /// <param name="dto"></param>
  12544. /// <returns></returns>
  12545. [HttpPost]
  12546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12547. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12548. {
  12549. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12550. if (groupData.Code != 0)
  12551. {
  12552. return Ok(JsonView(false, groupData.Msg));
  12553. }
  12554. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12555. }
  12556. /// <summary>
  12557. /// 根据op费用Id查询单条数据及c表数据
  12558. /// </summary>
  12559. /// <param name="dto"></param>
  12560. /// <returns></returns>
  12561. [HttpPost]
  12562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12563. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12564. {
  12565. try
  12566. {
  12567. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12568. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12569. var data = new
  12570. {
  12571. CarTouristGuideGround = _groupData,
  12572. CreditCardPayment = _creditCardPayment
  12573. };
  12574. return Ok(JsonView(true, "查询成功!", data));
  12575. }
  12576. catch (Exception ex)
  12577. {
  12578. return Ok(JsonView(false, "程序错误!"));
  12579. }
  12580. }
  12581. /// <summary>
  12582. /// op费用删除
  12583. /// </summary>
  12584. /// <param name="dto"></param>
  12585. /// <returns></returns>
  12586. [HttpPost]
  12587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12588. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12589. {
  12590. try
  12591. {
  12592. _sqlSugar.BeginTran();
  12593. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12594. if (!res)
  12595. {
  12596. return Ok(JsonView(false, "删除失败"));
  12597. }
  12598. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12599. {
  12600. IsDel = 1,
  12601. DeleteUserId = dto.DeleteUserId,
  12602. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12603. }).ExecuteCommandAsync();
  12604. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12605. {
  12606. IsDel = 1,
  12607. DeleteUserId = dto.DeleteUserId,
  12608. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12609. }).ExecuteCommandAsync();
  12610. #region 删除超支相关数据
  12611. //删除导入的超支数据
  12612. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12613. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12614. {
  12615. IsDel = 1,
  12616. DeleteUserId = dto.DeleteUserId,
  12617. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12618. }).ExecuteCommand();
  12619. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12620. {
  12621. IsDel = 1,
  12622. DeleteUserId = dto.DeleteUserId,
  12623. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12624. }).ExecuteCommand();
  12625. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12626. {
  12627. IsDel = 1,
  12628. DeleteUserId = dto.DeleteUserId,
  12629. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12630. }).ExecuteCommand();
  12631. #endregion
  12632. _sqlSugar.CommitTran();
  12633. return Ok(JsonView(true, "删除成功!"));
  12634. }
  12635. catch (Exception ex)
  12636. {
  12637. _sqlSugar.RollbackTran();
  12638. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12639. }
  12640. }
  12641. /// <summary>
  12642. /// op费用录入操作(Status:1.新增,2.修改)
  12643. /// </summary>
  12644. /// <param name="dto"></param>
  12645. /// <returns></returns>
  12646. [HttpPost]
  12647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12648. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12649. {
  12650. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12651. if (groupData.Code != 0)
  12652. {
  12653. return Ok(JsonView(false, groupData.Msg));
  12654. }
  12655. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12656. }
  12657. /// <summary>
  12658. /// 填写费用详细页面初始化绑定
  12659. /// </summary>
  12660. /// <param name="dto"></param>
  12661. /// <returns></returns>
  12662. [HttpPost]
  12663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12664. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12665. {
  12666. try
  12667. {
  12668. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12669. if (groupData.Code != 0)
  12670. {
  12671. return Ok(JsonView(false, groupData.Msg));
  12672. }
  12673. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12674. }
  12675. catch (Exception ex)
  12676. {
  12677. return Ok(JsonView(false, ex.Message));
  12678. }
  12679. }
  12680. /// <summary>
  12681. /// 根据op费用Id查询详细数据
  12682. /// </summary>
  12683. /// <param name="dto"></param>
  12684. /// <returns></returns>
  12685. [HttpPost]
  12686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12687. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12688. {
  12689. try
  12690. {
  12691. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12692. if (groupData.Code != 0)
  12693. {
  12694. return Ok(JsonView(false, groupData.Msg));
  12695. }
  12696. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12697. }
  12698. catch (Exception ex)
  12699. {
  12700. return Ok(JsonView(false, ex.Message));
  12701. }
  12702. }
  12703. /// <summary>
  12704. /// OP费用录入填写详情
  12705. /// </summary>
  12706. /// <param name="dto"></param>
  12707. /// <returns></returns>
  12708. [HttpPost]
  12709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12710. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12711. {
  12712. try
  12713. {
  12714. #region 参数校验
  12715. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12716. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12717. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12718. #endregion
  12719. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12720. if (groupData.Code != 0)
  12721. {
  12722. return Ok(JsonView(false, groupData.Msg));
  12723. }
  12724. //自动审核
  12725. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12726. #region 应用推送
  12727. try
  12728. {
  12729. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12730. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12731. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12732. //2024-10-21 新增LZ UID
  12733. var userIds = new List<int>() { 21 };
  12734. string title = $"系统通知";
  12735. var diId = dto.DiId;
  12736. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12737. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12738. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12739. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12740. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12741. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12742. }
  12743. catch (Exception ex)
  12744. {
  12745. }
  12746. #endregion
  12747. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12748. }
  12749. catch (Exception ex)
  12750. {
  12751. return Ok(JsonView(false, ex.Message));
  12752. }
  12753. }
  12754. /// <summary>
  12755. /// 获取三公详细所有城市
  12756. /// </summary>
  12757. /// <returns></returns>
  12758. [HttpGet]
  12759. public IActionResult OpCarCityResult()
  12760. {
  12761. var jw = JsonView(false);
  12762. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12763. {
  12764. x.Id,
  12765. x.Country,
  12766. x.City,
  12767. }).ToList();
  12768. if (data.Count > 0)
  12769. {
  12770. jw = JsonView(true, "获取成功!", data);
  12771. }
  12772. else
  12773. {
  12774. jw.Msg = "城市数据为空!";
  12775. jw.Data = new string[0];
  12776. }
  12777. return Ok(jw);
  12778. }
  12779. /// <summary>
  12780. /// 导出地接费用明细
  12781. /// </summary>
  12782. /// <param name="dto"></param>
  12783. /// <returns></returns>
  12784. [HttpPost]
  12785. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12786. {
  12787. var jw = JsonView(false);
  12788. if (dto.Diid < 1)
  12789. {
  12790. jw.Msg = "请输入正确的diid!";
  12791. return Ok(jw);
  12792. }
  12793. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12794. if (group == null)
  12795. {
  12796. jw.Msg = "未找到团组信息!";
  12797. return Ok(jw);
  12798. }
  12799. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12800. if (localGuideArr.Count == 0)
  12801. {
  12802. jw.Msg = "该团组暂无地接信息!";
  12803. return Ok(jw);
  12804. }
  12805. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12806. var overspendSoure = new Dictionary<int, int>
  12807. {
  12808. { 91, 982 }, //车
  12809. { 92 , 1059} ,//导游
  12810. { 994 , 1073}, //翻译
  12811. { 988 , 1074 }, //早餐
  12812. { 93 , 1075 }, //午餐
  12813. { 989 , 1076 }, //晚餐
  12814. };
  12815. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12816. foreach (var groupArr in localGroup)
  12817. {
  12818. var keyValue = groupArr.Key;
  12819. if (int.TryParse(keyValue, out int cityid))
  12820. {
  12821. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12822. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12823. }
  12824. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12825. foreach (var item in groupArr)
  12826. {
  12827. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12828. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12829. new Grp_CarTouristGuideGroundReservationsContentExtend
  12830. {
  12831. Count = a.Count,
  12832. CreateTime = a.CreateTime,
  12833. CreateUserId = a.CreateUserId,
  12834. CTGGRId = a.CTGGRId,
  12835. Currency = a.Currency,
  12836. DatePrice = a.DatePrice,
  12837. DeleteTime = a.DeleteTime,
  12838. DeleteUserId = a.DeleteUserId,
  12839. DiId = a.DiId,
  12840. Id = a.Id,
  12841. IsDel = a.IsDel,
  12842. Price = a.Price,
  12843. PriceContent = a.PriceContent,
  12844. Remark = a.Remark,
  12845. SId = a.SId,
  12846. SidName = b.Name,
  12847. Units = a.Units,
  12848. }
  12849. ).ToList();
  12850. if (content.Count > 0)
  12851. {
  12852. contentArr.Add(content);
  12853. }
  12854. }
  12855. //open excel
  12856. //set excel
  12857. //save excel
  12858. try
  12859. {
  12860. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12861. IWorkbook workbook;
  12862. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12863. {
  12864. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12865. }
  12866. else
  12867. {
  12868. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12869. }
  12870. ISheet sheet = workbook.GetSheetAt(0);
  12871. var rowStartIndex = 2;
  12872. var clounmCount = 10;
  12873. var initStyleRow = sheet.GetRow(2);
  12874. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12875. //var overspendArrDetail =
  12876. var existsId = new List<CarCompare>();
  12877. var lastElem = arr.Last();
  12878. var thisSid = -1;
  12879. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12880. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12881. {
  12882. Name = "未知币种!",
  12883. Remark = "未知币种!",
  12884. };
  12885. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12886. Action cloneRowFn = () =>
  12887. {
  12888. rowStartIndex++;
  12889. var cloneRow = sheet.CreateRow(rowStartIndex);
  12890. // 复制样式
  12891. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12892. {
  12893. ICell sourceCell = initStyleRow.GetCell(i);
  12894. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12895. // 确保单元格存在样式
  12896. if (sourceCell.CellStyle != null)
  12897. {
  12898. targetCell.CellStyle = sourceCell.CellStyle;
  12899. }
  12900. }
  12901. };
  12902. var mergeRow = () =>
  12903. {
  12904. for (int i = 2; i < sheet.LastRowNum; i++)
  12905. {
  12906. var row = sheet.GetRow(i);
  12907. var cellFirst = row.GetCell(0);
  12908. var thisIndex = i + 1;
  12909. while (thisIndex < sheet.LastRowNum)
  12910. {
  12911. var nextRow = sheet.GetRow(thisIndex);
  12912. var nextCellFirst = nextRow.GetCell(0);
  12913. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12914. {
  12915. thisIndex++;
  12916. }
  12917. else
  12918. {
  12919. break;
  12920. }
  12921. }
  12922. thisIndex--;
  12923. if (thisIndex != i)
  12924. {
  12925. //合并row
  12926. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12927. i, // 起始行索引(0-based)
  12928. thisIndex, // 结束行索引(0-based)
  12929. 0, // 起始列索引(0-based)
  12930. 0 // 结束列索引(0-based)
  12931. );
  12932. sheet.AddMergedRegion(cellRangeAddress);
  12933. i = thisIndex;
  12934. }
  12935. }
  12936. };
  12937. var chaoshiNumber = 0;
  12938. var totalNumber = 0.00M;
  12939. string lastStr = "";
  12940. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12941. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12942. {
  12943. b.IsAuditGM,
  12944. x.Id,
  12945. x.Area,
  12946. b.PayPercentage,
  12947. b.PayMoney,
  12948. }).ToList();
  12949. string yesPayment = "", noPayment = "";
  12950. foreach (var item in queryCarArrByCityAndDiid)
  12951. {
  12952. if (item.IsAuditGM == 1)
  12953. {
  12954. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12955. }
  12956. else
  12957. {
  12958. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12959. }
  12960. }
  12961. lastStr = yesPayment + noPayment;
  12962. foreach (var item in arr)
  12963. {
  12964. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12965. {
  12966. if (thisSid != item.SId)
  12967. {
  12968. if (thisSid == -1)
  12969. {
  12970. thisSid = item.SId;
  12971. }
  12972. else
  12973. {
  12974. //合并小计行
  12975. //创建合并区域的实例
  12976. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12977. rowStartIndex, // 起始行索引(0-based)
  12978. rowStartIndex, // 结束行索引(0-based)
  12979. 0, // 起始列索引(0-based)
  12980. 3 // 结束列索引(0-based)
  12981. );
  12982. sheet.AddMergedRegion(cellRangeAddress);
  12983. var CellStyle = workbook.CreateCellStyle();
  12984. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12985. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12986. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12987. for (int i = 0; i <= clounmCount; i++)
  12988. {
  12989. if (i > 6)
  12990. {
  12991. var CellStyle1 = workbook.CreateCellStyle();
  12992. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12993. IFont Font = workbook.CreateFont(); // 创建字体
  12994. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12995. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12996. CellStyle1.SetFont(Font);
  12997. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12998. }
  12999. else
  13000. {
  13001. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13002. }
  13003. }
  13004. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13005. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13006. //超时合计
  13007. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13008. //超时数
  13009. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13010. //超时合计费用
  13011. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13012. thisSid = item.SId;
  13013. cloneRowFn();
  13014. chaoshiNumber = 0;
  13015. totalNumber = 0;
  13016. }
  13017. }
  13018. IRow row = sheet.GetRow(rowStartIndex);
  13019. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13020. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  13021. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13022. if (isOpenOverspendSoure)
  13023. {
  13024. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13025. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13026. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13027. }
  13028. for (int i = 0; i <= clounmCount; i++)
  13029. {
  13030. var cell = row.GetCell(i);
  13031. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13032. if (cell == null)
  13033. {
  13034. cell = row.CreateCell(i);
  13035. }
  13036. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13037. fontRed.CloneStyleFrom(cell.CellStyle);
  13038. IFont Font = workbook.CreateFont(); // 创建字体
  13039. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13040. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13041. fontRed.SetFont(Font);
  13042. byte[] rgb = new byte[3] { 255, 242, 204 };
  13043. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13044. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13045. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13046. if (workbook is XSSFWorkbook)
  13047. {
  13048. BackgroundColor255_242_204.FillForegroundColor = 0;
  13049. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13050. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13051. }
  13052. else
  13053. {
  13054. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13055. }
  13056. if (i == 1 || i > 6)
  13057. {
  13058. if (i > 6)
  13059. {
  13060. fontRed.FillForegroundColor = 0;
  13061. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13062. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13063. }
  13064. cell.CellStyle = fontRed;
  13065. }
  13066. if (i > 2 && i < 7)
  13067. {
  13068. cell.CellStyle = BackgroundColor255_242_204;
  13069. }
  13070. cell.SetCellValue(setCellValue); //写入单元格
  13071. }
  13072. if (overspendSoure.ContainsKey(thisSid))
  13073. {
  13074. var overspendId = overspendSoure[thisSid];
  13075. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13076. }
  13077. cloneRowFn();
  13078. existsId.Add(new CarCompare
  13079. {
  13080. DataPrice = item.DatePrice.ObjToDate(),
  13081. Sid = item.SId
  13082. });
  13083. }
  13084. if (item.Equals(lastElem))
  13085. {
  13086. //合并小计行
  13087. //创建合并区域的实例
  13088. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13089. rowStartIndex, // 起始行索引(0-based)
  13090. rowStartIndex, // 结束行索引(0-based)
  13091. 0, // 起始列索引(0-based)
  13092. 3 // 结束列索引(0-based)
  13093. );
  13094. sheet.AddMergedRegion(cellRangeAddress);
  13095. var CellStyle = workbook.CreateCellStyle();
  13096. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13097. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13098. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13099. for (int i = 0; i <= clounmCount; i++)
  13100. {
  13101. if (i > 6)
  13102. {
  13103. var CellStyle1 = workbook.CreateCellStyle();
  13104. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13105. IFont Font = workbook.CreateFont(); // 创建字体
  13106. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13107. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13108. CellStyle1.SetFont(Font);
  13109. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13110. }
  13111. else
  13112. {
  13113. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13114. }
  13115. }
  13116. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13117. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13118. //超时合计
  13119. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13120. //超时数
  13121. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13122. //超时合计费用
  13123. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13124. cloneRowFn();
  13125. // 创建合并区域的实例
  13126. cellRangeAddress = new CellRangeAddress(
  13127. rowStartIndex, // 起始行索引(0-based)
  13128. rowStartIndex, // 结束行索引(0-based)
  13129. 0, // 起始列索引(0-based)
  13130. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13131. );
  13132. // 添加合并区域
  13133. sheet.AddMergedRegion(cellRangeAddress);
  13134. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13135. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13136. }
  13137. }
  13138. mergeRow();
  13139. // 保存修改后的Excel文件到新文件
  13140. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13141. // new FileStream(newFilePath, FileMode.CreateNew)
  13142. using (var stream = new MemoryStream())
  13143. {
  13144. workbook.Write(stream, true);
  13145. stream.Flush();
  13146. stream.Seek(0, SeekOrigin.Begin);
  13147. MemoryStream memoryStream = new MemoryStream();
  13148. stream.CopyTo(memoryStream);
  13149. memoryStream.Seek(0, SeekOrigin.Begin);
  13150. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13151. }
  13152. workbook.Close();
  13153. workbook.Dispose();
  13154. }
  13155. catch (Exception ex)
  13156. {
  13157. jw.Msg = "出现异常!" + ex.Message;
  13158. return Ok(jw);
  13159. }
  13160. }
  13161. if (Zips.Count > 0)
  13162. {
  13163. IOOperatorHelper io = new IOOperatorHelper();
  13164. var byts = io.ConvertZipStream(Zips);
  13165. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13166. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13167. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13168. }
  13169. else
  13170. {
  13171. jw.Msg = "暂无生成文件!";
  13172. }
  13173. return Ok(jw);
  13174. }
  13175. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13176. {
  13177. string outStr = string.Empty;
  13178. switch (i)
  13179. {
  13180. case 0:
  13181. outStr = arr[0].SidName;
  13182. break;
  13183. case 1:
  13184. outStr = arr[0].DataPriceStr;
  13185. break;
  13186. case 2:
  13187. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13188. break;
  13189. case 4:
  13190. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13191. break;
  13192. case 7:
  13193. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13194. {
  13195. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13196. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13197. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13198. }
  13199. break;
  13200. case 8:
  13201. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13202. {
  13203. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13204. }
  13205. break;
  13206. case 9:
  13207. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13208. {
  13209. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13210. }
  13211. break;
  13212. case 10:
  13213. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13214. {
  13215. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13216. }
  13217. break;
  13218. }
  13219. return outStr;
  13220. }
  13221. #region OP行程单
  13222. /// <summary>
  13223. /// OP行程单初始化
  13224. /// </summary>
  13225. /// <param name="dto"></param>
  13226. /// <returns></returns>
  13227. [HttpPost]
  13228. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13229. {
  13230. var jw = JsonView(false);
  13231. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13232. var group = groupList.First();
  13233. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13234. if (group == null)
  13235. {
  13236. jw.Msg = "暂无团组!";
  13237. return Ok(jw);
  13238. }
  13239. group = groupList.Find(x => x.Id == diid);
  13240. if (group == null)
  13241. {
  13242. jw.Msg = "请输入正确的团组ID!";
  13243. return Ok(jw);
  13244. }
  13245. string city = string.Empty;
  13246. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13247. if (blackCode.Count > 0)
  13248. {
  13249. var black = blackCode.First();
  13250. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13251. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13252. if (blackSp.Length > 0)
  13253. {
  13254. try
  13255. {
  13256. var cityArrCode = new List<string>(20);
  13257. foreach (var item in blackSp)
  13258. {
  13259. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13260. var IndexSelect = itemSp[2];
  13261. var cityArrCodeLength = cityArrCode.Count - 1;
  13262. var startCity = IndexSelect.Substring(0, 3);
  13263. if (cityArrCodeLength > 0)
  13264. {
  13265. var arrEndCity = cityArrCode[cityArrCodeLength];
  13266. if (arrEndCity != startCity)
  13267. {
  13268. cityArrCode.Add(startCity.ToUpper());
  13269. }
  13270. }
  13271. else
  13272. {
  13273. cityArrCode.Add(startCity.ToUpper());
  13274. }
  13275. var endCity = IndexSelect.Substring(3, 3);
  13276. cityArrCode.Add(endCity.ToUpper());
  13277. }
  13278. var cityThree = string.Empty;
  13279. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13280. cityThree = cityThree.TrimEnd(',');
  13281. if (string.IsNullOrWhiteSpace(cityThree))
  13282. {
  13283. throw new
  13284. Exception("error");
  13285. }
  13286. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13287. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13288. foreach (var item in cityArrCode)
  13289. {
  13290. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13291. if (find != null)
  13292. {
  13293. city += find.City + "/";
  13294. }
  13295. else
  13296. {
  13297. city += item + "三字码未收入/";
  13298. }
  13299. }
  13300. city = city.TrimEnd('/');
  13301. }
  13302. catch (Exception e)
  13303. {
  13304. city = "黑屏代码格式不正确!";
  13305. }
  13306. }
  13307. }
  13308. else
  13309. {
  13310. city = "未录入黑屏代码";
  13311. }
  13312. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13313. {
  13314. Date = x.Date,
  13315. Days = x.Days,
  13316. Diffgroup = x.Diffgroup,
  13317. Diid = x.Diid,
  13318. Traffic_First = x.Traffic_First,
  13319. Traffic_Second = x.Traffic_Second,
  13320. Trip = x.Trip,
  13321. WeekDay = x.WeekDay,
  13322. Id = x.Id
  13323. }).ToList();
  13324. jw.Data = new
  13325. {
  13326. groupList = groupList.Select(x => new
  13327. {
  13328. x.Id,
  13329. x.TeamName,
  13330. x.TourCode
  13331. }).ToList(),
  13332. groupInfo = new
  13333. {
  13334. group.VisitDays,
  13335. group.TourCode,
  13336. group.VisitPNumber,
  13337. group.TeamName,
  13338. city
  13339. },
  13340. OpTravelList
  13341. };
  13342. jw.Code = 200;
  13343. jw.Msg = "操作成功!";
  13344. return Ok(jw);
  13345. }
  13346. /// <summary>
  13347. /// 删除团组行程单
  13348. /// </summary>
  13349. /// <returns></returns>
  13350. [HttpPost]
  13351. public IActionResult DelTravel(DelOpTravelDto dto)
  13352. {
  13353. var jw = JsonView(false);
  13354. if (dto.UserId <= 0 || dto.Diid <= 0)
  13355. {
  13356. jw.Msg = "请输入正确的参数!";
  13357. return Ok(jw);
  13358. }
  13359. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13360. .SetColumns(x => new Grp_TravelList
  13361. {
  13362. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13363. DeleteUserId = dto.UserId,
  13364. IsDel = 1,
  13365. }).ExecuteCommand();
  13366. jw = JsonView(true);
  13367. return Ok(jw);
  13368. }
  13369. /// <summary>
  13370. /// 行程单保存
  13371. /// </summary>
  13372. /// <returns></returns>
  13373. [HttpPost]
  13374. public IActionResult TravelSave(TravelSaveDto dto)
  13375. {
  13376. var jw = JsonView(false);
  13377. if (dto.Arr.Count > 0)
  13378. {
  13379. try
  13380. {
  13381. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13382. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13383. .ToList();
  13384. _sqlSugar.BeginTran();
  13385. foreach (var item in dto.Arr)
  13386. {
  13387. if (item.Id == 0)
  13388. {
  13389. throw new Exception("请传入正确的Id");
  13390. }
  13391. //比较上一次的差异
  13392. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13393. if (findTravel != null)
  13394. {
  13395. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13396. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13397. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13398. }
  13399. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13400. .SetColumns(x => new Grp_TravelList
  13401. {
  13402. Trip = item.Trip
  13403. }).ExecuteCommand();
  13404. }
  13405. _sqlSugar.CommitTran();
  13406. jw = JsonView(true);
  13407. }
  13408. catch (Exception ex)
  13409. {
  13410. _sqlSugar.RollbackTran();
  13411. jw.Msg = "程序异常!" + ex.Message;
  13412. }
  13413. }
  13414. else
  13415. {
  13416. jw.Msg = "请传入正确的参数!";
  13417. }
  13418. return Ok(jw);
  13419. }
  13420. private string CheckStr(string original, string changed)
  13421. {
  13422. // 创建diff_match_patch对象
  13423. var dmp = new diff_match_patch();
  13424. // 计算差异
  13425. List<Diff> diffs = dmp.diff_main(original, changed);
  13426. // 清理和合并差异
  13427. dmp.diff_cleanupSemantic(diffs);
  13428. // 使用StringBuilder构建最终的字符串
  13429. StringBuilder finalString = new StringBuilder();
  13430. // 输出差异结果,并构建变动后的字符串
  13431. foreach (Diff diff in diffs)
  13432. {
  13433. switch (diff.operation)
  13434. {
  13435. case Operation.EQUAL:
  13436. // 相等的部分,直接添加到最终字符串
  13437. finalString.Append(diff.text);
  13438. break;
  13439. case Operation.INSERT:
  13440. // 插入的部分,添加标记并添加到最终字符串
  13441. finalString.Append("[++]" + diff.text + "[++]");
  13442. break;
  13443. case Operation.DELETE:
  13444. // 删除的部分,不添加到最终字符串
  13445. //finalString.Append("[++]" + diff.text + "[++]");
  13446. break;
  13447. }
  13448. }
  13449. // 输出变动后的字符串
  13450. return finalString.ToString();
  13451. }
  13452. private class tagContent
  13453. {
  13454. public DateTime Date { get; set; }
  13455. public string StartTag { get; set; }
  13456. public string EndTag { get; set; }
  13457. public string Content { get; set; }
  13458. public static int tagLength { get { return 3; } }
  13459. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13460. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13461. public bool IsFinally { get; set; }
  13462. }
  13463. private List<string> ExtractContentBetweenTags(string input, string tag)
  13464. {
  13465. List<string> results = new List<string>();
  13466. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13467. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13468. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13469. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13470. string[] strValueArr = new string[1];
  13471. foreach (System.Text.RegularExpressions.Match match in matches)
  13472. {
  13473. var strValue = match.Groups[1].Value;
  13474. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13475. }
  13476. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13477. return results;
  13478. }
  13479. /// <summary>
  13480. /// 导出行程单
  13481. /// </summary>
  13482. /// <param name="dto"></param>
  13483. /// <returns></returns>
  13484. [HttpPost]
  13485. public IActionResult ExportTravel(ExportTravelDto dto)
  13486. {
  13487. var jw = JsonView(false);
  13488. jw.Data = "";
  13489. int diid = 0;
  13490. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13491. if (Find == null)
  13492. {
  13493. jw.Msg = "请选择正确的团组!";
  13494. return Ok(jw);
  13495. }
  13496. else
  13497. {
  13498. diid = Find.Id;
  13499. }
  13500. //数据源
  13501. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13502. DataTable dtBlack = null;
  13503. try
  13504. {
  13505. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13506. }
  13507. catch (Exception)
  13508. {
  13509. jw.Msg = "机票黑屏代码有误!";
  13510. return Ok(jw);
  13511. }
  13512. string CityStr = string.Empty;
  13513. if (dtBlack.Rows.Count == 0)
  13514. {
  13515. jw.Msg = "机票黑屏代码有误!";
  13516. return Ok(jw);
  13517. }
  13518. else
  13519. {
  13520. foreach (DataRow row in dtBlack.Rows)
  13521. {
  13522. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13523. {
  13524. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13525. return Ok(jw);
  13526. }
  13527. }
  13528. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13529. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13530. }
  13531. // 指定的文字
  13532. var targetTextDic = new Dictionary<string, List<string>>();
  13533. //创建数据源Table
  13534. DataTable dtSource = new DataTable();
  13535. dtSource.Columns.Add("Days", typeof(string));
  13536. dtSource.Columns.Add("Date", typeof(string));
  13537. dtSource.Columns.Add("Week", typeof(string));
  13538. dtSource.Columns.Add("Traffic", typeof(string));
  13539. dtSource.Columns.Add("Trip", typeof(string));
  13540. //获取数据,放到datatable
  13541. foreach (var item in _travelList)
  13542. {
  13543. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13544. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13545. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13546. .Replace("[++]", string.Empty);
  13547. DataRow dr = dtSource.NewRow();
  13548. dr["Days"] = item.Days;
  13549. dr["Date"] = item.Date;
  13550. dr["Week"] = item.WeekDay;
  13551. dr["Traffic"] = item.Traffic_First
  13552. + "\r\n"
  13553. + item.Traffic_Second;
  13554. dr["Trip"] = item.Trip;
  13555. dtSource.Rows.Add(dr);
  13556. }
  13557. Dictionary<string, string> dic = new Dictionary<string, string>();
  13558. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13559. dic.Add("City", CityStr);
  13560. dic.Add("Days", Find.VisitDays.ToString());
  13561. dic.Add("DeleCode", Find.TourCode);
  13562. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13563. //模板路径
  13564. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13565. //载入模板
  13566. Document doc = null;
  13567. DocumentBuilder builder = null;
  13568. try
  13569. {
  13570. //载入模板
  13571. doc = new Document(tempPath);
  13572. builder = new DocumentBuilder(doc);
  13573. }
  13574. catch (Exception)
  13575. {
  13576. jw.Msg = "模板位置不存在!";
  13577. return Ok(jw);
  13578. }
  13579. foreach (var key in dic.Keys)
  13580. {
  13581. Bookmark bookmark = doc.Range.Bookmarks[key];
  13582. if (bookmark != null)
  13583. {
  13584. builder.MoveToBookmark(key);
  13585. builder.Write(dic[key]);
  13586. }
  13587. }
  13588. //获取word里所有表格
  13589. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13590. //获取所填表格的序数
  13591. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13592. try
  13593. {
  13594. //循环赋值
  13595. for (int i = 0; i < dtSource.Rows.Count; i++)
  13596. {
  13597. builder.MoveToCell(0, i + 1, 0, 0);
  13598. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13599. builder.MoveToCell(0, i + 1, 1, 0);
  13600. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13601. builder.MoveToCell(0, i + 1, 2, 0);
  13602. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13603. var trip = dtSource.Rows[i]["Trip"].ToString();
  13604. builder.MoveToCell(0, i + 1, 3, 0);
  13605. builder.Write(trip);
  13606. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13607. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13608. // 获取特定索引的段落
  13609. Paragraph paragraph = (Paragraph)paragraphs[0];
  13610. Run run = paragraph.Runs[0];
  13611. Aspose.Words.Font font = run.Font;
  13612. font.Name = "黑体";
  13613. //设置双休红色
  13614. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13615. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13616. paragraph = (Paragraph)paragraphs[1];
  13617. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13618. {
  13619. run = paragraph.Runs[0];
  13620. font = run.Font;
  13621. font.Color = Color.Red;
  13622. }
  13623. }
  13624. }
  13625. catch (Exception ex)
  13626. {
  13627. }
  13628. //删除多余行
  13629. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13630. {
  13631. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13632. }
  13633. var targetTextList = new List<string>();
  13634. // 遍历文档中的表格
  13635. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13636. {
  13637. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13638. {
  13639. var cellIndex = 0;
  13640. foreach (Cell cell in row.Cells)
  13641. {
  13642. if (cellIndex == 1 && row.Cells.Count == 4)
  13643. {
  13644. foreach (var target in targetTextDic.Keys)
  13645. {
  13646. if (cell.GetText().Contains(target))
  13647. {
  13648. targetTextList = targetTextDic[target];
  13649. break;
  13650. }
  13651. }
  13652. }
  13653. // 遍历单元格中的所有段落
  13654. foreach (Paragraph paragraph in cell.Paragraphs)
  13655. {
  13656. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13657. List<Run> runs = new List<Run>();
  13658. foreach (Run run in paragraph.Runs)
  13659. {
  13660. runs.Add(run);
  13661. }
  13662. foreach (Run run in runs)
  13663. {
  13664. foreach (var targetText in targetTextList)
  13665. {
  13666. // 检查文字是否包含指定文字
  13667. if (run.Text.Contains(targetText))
  13668. {
  13669. // 将包含的部分设置为红色
  13670. HighlightText(run, targetText, Color.Red);
  13671. }
  13672. }
  13673. }
  13674. }
  13675. cellIndex++;
  13676. }
  13677. }
  13678. }
  13679. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13680. if (!Directory.Exists(savePath))
  13681. {
  13682. try
  13683. {
  13684. Directory.CreateDirectory(savePath);
  13685. }
  13686. catch
  13687. {
  13688. }
  13689. }
  13690. string path = savePath + Find.TeamName + "出访日程";
  13691. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13692. try
  13693. {
  13694. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13695. string postfix = ".docx";
  13696. if (dto.IsPDF == 1)
  13697. {
  13698. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13699. postfix = ".pdf";
  13700. }
  13701. doc.Save(path + postfix, saveFormat);
  13702. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13703. }
  13704. catch (Exception)
  13705. {
  13706. jw = JsonView(false);
  13707. }
  13708. return Ok(jw);
  13709. }
  13710. /// <summary>
  13711. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13712. /// </summary>
  13713. /// <param name="num"></param>
  13714. /// <returns></returns>
  13715. string GetNum(string num)
  13716. {
  13717. string str = "";
  13718. switch (num)
  13719. {
  13720. case "1":
  13721. str = "一";
  13722. break;
  13723. case "2":
  13724. str = "二";
  13725. break;
  13726. case "3":
  13727. str = "三";
  13728. break;
  13729. case "4":
  13730. str = "四";
  13731. break;
  13732. case "5":
  13733. str = "五";
  13734. break;
  13735. case "6":
  13736. str = "六";
  13737. break;
  13738. case "7":
  13739. str = "七";
  13740. break;
  13741. case "8":
  13742. str = "八";
  13743. break;
  13744. case "9":
  13745. str = "九";
  13746. break;
  13747. case "10":
  13748. str = "十";
  13749. break;
  13750. case "11":
  13751. str = "十一";
  13752. break;
  13753. case "12":
  13754. str = "十二";
  13755. break;
  13756. case "一":
  13757. str = "1";
  13758. break;
  13759. case "二":
  13760. str = "2";
  13761. break;
  13762. case "三":
  13763. str = "3";
  13764. break;
  13765. case "四":
  13766. str = "4";
  13767. break;
  13768. case "五":
  13769. str = "5";
  13770. break;
  13771. case "六":
  13772. str = "6";
  13773. break;
  13774. case "七":
  13775. str = "7";
  13776. break;
  13777. case "八":
  13778. str = "8";
  13779. break;
  13780. case "九":
  13781. str = "9";
  13782. break;
  13783. case "十":
  13784. str = "10";
  13785. break;
  13786. case "十一":
  13787. str = "11";
  13788. break;
  13789. case "十二":
  13790. str = "12";
  13791. break;
  13792. }
  13793. return str;
  13794. }
  13795. // 高亮包含指定文字的部分
  13796. void HighlightText(Run run, string targetText, Color color)
  13797. {
  13798. string text = run.Text;
  13799. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13800. if (startIndex >= 0)
  13801. {
  13802. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13803. // 前部分
  13804. if (startIndex > 0)
  13805. {
  13806. Run beforeRun = (Run)run.Clone(true);
  13807. beforeRun.Text = text.Substring(0, startIndex);
  13808. parentParagraph.InsertBefore(beforeRun, run);
  13809. }
  13810. // 匹配部分
  13811. Run matchRun = (Run)run.Clone(true);
  13812. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13813. matchRun.Font.Color = color;
  13814. parentParagraph.InsertBefore(matchRun, run);
  13815. // 后部分
  13816. if (startIndex + targetText.Length < text.Length)
  13817. {
  13818. Run afterRun = (Run)run.Clone(true);
  13819. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13820. parentParagraph.InsertBefore(afterRun, run);
  13821. }
  13822. // 删除原始Run
  13823. run.Remove();
  13824. }
  13825. }
  13826. #endregion
  13827. #endregion
  13828. #region 团组成本
  13829. /// <summary>
  13830. /// 团组成本数据初始化
  13831. /// </summary>
  13832. /// <param name="dto"></param>
  13833. /// <returns></returns>
  13834. [HttpPost]
  13835. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13836. {
  13837. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13838. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13839. WHEN COUNT(*) >= 0 THEN 'True'
  13840. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13841. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13842. ").ToList(); //团组列表
  13843. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13844. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13845. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13846. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13847. if (groupinfoValue != null)
  13848. {
  13849. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13850. var spArr = new string[1] { countryArr };
  13851. if (countryArr.Contains("|"))
  13852. {
  13853. spArr = countryArr.Split("|");
  13854. }
  13855. else if (countryArr.Contains("、"))
  13856. {
  13857. spArr = countryArr.Split("、");
  13858. }
  13859. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13860. {
  13861. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13862. if (dbQueryCountry != null)
  13863. {
  13864. visaCountryInfoArr.Add(dbQueryCountry);
  13865. }
  13866. }
  13867. }
  13868. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13869. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13870. #region 屏蔽黑屏代码生成
  13871. //var create = _GroupCostRepository.
  13872. // CreateGroupCostByBlackCode(dto.Diid);
  13873. //if (groupCost.Count == 0 && create.Code == 0)
  13874. //{
  13875. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13876. //}
  13877. #endregion
  13878. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13879. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13880. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13881. groupCostMap = groupCostMap.Select(x =>
  13882. {
  13883. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13884. {
  13885. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13886. }
  13887. return x;
  13888. }).ToList();
  13889. //GroupCostParameter.Add(new
  13890. // Grp_GroupCostParameter());
  13891. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13892. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13893. return Ok(JsonView(new
  13894. {
  13895. groupList,
  13896. groupInfo,
  13897. groupChecks,
  13898. groupCost = groupCostMap,
  13899. hotelNumber,
  13900. GroupCostParameter = GroupCostParameterMap,
  13901. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13902. {
  13903. x.VisaCountry,
  13904. x.VisaPrice,
  13905. x.Id,
  13906. }).ToList(),
  13907. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13908. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  13909. hotelIsTrue = hotelIsTrue,
  13910. }));
  13911. }
  13912. /// <summary>
  13913. /// 团组成本信息保存
  13914. /// </summary>
  13915. /// <param name="dto"></param>
  13916. /// <returns></returns>
  13917. [HttpPost]
  13918. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13919. {
  13920. if (dto.Diid <= 0 || dto.Userid <= 0)
  13921. {
  13922. return Ok(JsonView(false));
  13923. }
  13924. JsonView jw = null;
  13925. bool isTrue = false;
  13926. #region 复制团组成本
  13927. //if (dto.Diid == 2581)
  13928. //{
  13929. // dto.Diid = 2599;
  13930. // dto.CheckBoxs.ForEach(x =>
  13931. // {
  13932. // x.Diid = 2599;
  13933. // });
  13934. // dto.GroupCosts.ForEach(x =>
  13935. // {
  13936. // x.Diid = 2599;
  13937. // });
  13938. // dto.CostTypeHotelNumbers.ForEach(x =>
  13939. // {
  13940. // x.Diid = 2599;
  13941. // });
  13942. // dto.GroupCostParameters.ForEach(x =>
  13943. // {
  13944. // x.DiId = 2599;
  13945. // });
  13946. //}
  13947. #endregion
  13948. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13949. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13950. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13951. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13952. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13953. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13954. try
  13955. {
  13956. _sqlSugar.BeginTran();
  13957. isTrue = await _GroupCostRepository.
  13958. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13959. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13960. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13961. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13962. _sqlSugar.CommitTran();
  13963. jw = JsonView(true, "保存成功!", isTrue);
  13964. }
  13965. catch (Exception)
  13966. {
  13967. _sqlSugar.RollbackTran();
  13968. jw = JsonView(false);
  13969. }
  13970. return Ok(jw);
  13971. }
  13972. /// <summary>
  13973. /// 复制团组成本信息
  13974. /// </summary>
  13975. /// <param name="dto"></param>
  13976. /// <returns></returns>
  13977. [HttpPost]
  13978. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  13979. {
  13980. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  13981. {
  13982. return Ok(JsonView(false,"参数有误!"));
  13983. }
  13984. #region 复制团组成本
  13985. dto.Diid = dto.ToGroupId;
  13986. dto.CheckBoxs.ForEach(x =>
  13987. {
  13988. x.Diid = dto.ToGroupId;
  13989. });
  13990. dto.GroupCosts.ForEach(x =>
  13991. {
  13992. x.Diid = dto.ToGroupId;
  13993. });
  13994. dto.CostTypeHotelNumbers.ForEach(x =>
  13995. {
  13996. x.Diid = dto.ToGroupId;
  13997. });
  13998. dto.GroupCostParameters.ForEach(x =>
  13999. {
  14000. x.DiId = dto.ToGroupId;
  14001. });
  14002. #endregion
  14003. JsonView jw = null;
  14004. bool isTrue = false;
  14005. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14006. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14007. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14008. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14009. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14010. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14011. try
  14012. {
  14013. _sqlSugar.BeginTran();
  14014. isTrue = await _GroupCostRepository.
  14015. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14016. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14017. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14018. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14019. _sqlSugar.CommitTran();
  14020. jw = JsonView(true, "保存成功!", isTrue);
  14021. }
  14022. catch (Exception)
  14023. {
  14024. _sqlSugar.RollbackTran();
  14025. jw = JsonView(false);
  14026. }
  14027. return Ok(jw);
  14028. }
  14029. /// <summary>
  14030. /// 司兼导数据
  14031. /// </summary>
  14032. /// <param name="dto"></param>
  14033. /// <returns></returns>
  14034. [HttpPost]
  14035. public IActionResult GetCarGuides(CarGuidesDto dto)
  14036. {
  14037. JsonView jw = null;
  14038. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14039. jw = JsonView(true, "获取成功!", Data);
  14040. return Ok(jw);
  14041. }
  14042. /// <summary>
  14043. /// 导游数据
  14044. /// </summary>
  14045. /// <param name="dto"></param>
  14046. /// <returns></returns>
  14047. [HttpPost]
  14048. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14049. {
  14050. JsonView jw = null;
  14051. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14052. // 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
  14053. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14054. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14055. jw = JsonView(true, "获取成功!", Data);
  14056. return Ok(jw);
  14057. }
  14058. /// <summary>
  14059. /// 成本车数据
  14060. /// </summary>
  14061. /// <param name="dto"></param>
  14062. /// <returns></returns>
  14063. [HttpPost]
  14064. public IActionResult GetCarInfo(CarGuidesDto dto)
  14065. {
  14066. JsonView jw = null;
  14067. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14068. jw = JsonView(true, "获取成功!", Data);
  14069. return Ok(jw);
  14070. }
  14071. /// <summary>
  14072. /// 景点数据
  14073. /// </summary>
  14074. /// <param name="dto"></param>
  14075. /// <returns></returns>
  14076. [HttpPost]
  14077. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14078. {
  14079. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14080. return Ok(JsonView(true, "获取成功!", Data));
  14081. }
  14082. /// <summary>
  14083. /// 成本通知
  14084. /// </summary>
  14085. /// <param name="dto"></param>
  14086. /// <returns></returns>
  14087. [HttpPost]
  14088. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14089. {
  14090. if (dto.Diid < 0)
  14091. {
  14092. return Ok(JsonView(false));
  14093. }
  14094. JsonView jw = null;
  14095. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14096. if (GroupCostParameter != null)
  14097. {
  14098. int IsShare = 0;
  14099. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14100. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14101. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14102. string msg = string.Empty;
  14103. if (isTrue)
  14104. {
  14105. if (IsShare == 0)
  14106. {
  14107. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14108. }
  14109. else
  14110. {
  14111. #region 企微通知对应岗位用户
  14112. try
  14113. {
  14114. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14115. }
  14116. catch (Exception ex)
  14117. {
  14118. }
  14119. #endregion
  14120. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14121. }
  14122. jw = JsonView(isTrue, msg, new { IsShare });
  14123. }
  14124. else
  14125. {
  14126. msg = "修改失败!";
  14127. jw = JsonView(isTrue, msg);
  14128. }
  14129. }
  14130. else
  14131. {
  14132. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14133. }
  14134. return Ok(jw);
  14135. }
  14136. /// <summary>
  14137. /// 导出报价单
  14138. /// </summary>
  14139. /// <param name="dto"></param>
  14140. /// <returns></returns>
  14141. [HttpPost]
  14142. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14143. {
  14144. if (dto.Diid == 0)
  14145. {
  14146. return Ok(JsonView(false, "请传递团组id"));
  14147. }
  14148. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14149. if (deleInfo.Code != 0)
  14150. {
  14151. return Ok(JsonView(false, "团组信息查询失败!"));
  14152. }
  14153. var di = deleInfo.Data as DelegationInfoWebView;
  14154. if (di != null)
  14155. {
  14156. di.TeamName = di.TeamName.Replace("|", "、");
  14157. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14158. //文件名
  14159. string strFileName = di.TeamName + "-收款账单.doc";
  14160. //获取模板
  14161. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14162. //载入模板
  14163. Document doc = new Document(tmppath);
  14164. decimal TotalPrice = 0.00M;
  14165. string itemStr = string.Empty;
  14166. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14167. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14168. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14169. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14170. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14171. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14172. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14173. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14174. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14175. foreach (var cost in groupCostType)
  14176. {
  14177. var List = cost.ToList();
  14178. if (cost.Key == "A")
  14179. {
  14180. foreach (var ListItem in List)
  14181. {
  14182. if (ListItem.number > 0)
  14183. {
  14184. if (ListItem.code.Contains("TBR"))
  14185. {
  14186. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14187. }
  14188. else
  14189. {
  14190. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14191. }
  14192. TotalPrice += (ListItem.number * ListItem.price);
  14193. }
  14194. }
  14195. }
  14196. else
  14197. {
  14198. itemStr = itemStr.Insert(0, "A段\r\n");
  14199. itemStr += "B段\r\n";
  14200. foreach (var ListItem in List)
  14201. {
  14202. if (ListItem.number > 0)
  14203. {
  14204. if (ListItem.code.Contains("TBR"))
  14205. {
  14206. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14207. }
  14208. else
  14209. {
  14210. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14211. }
  14212. TotalPrice += (ListItem.number * ListItem.price);
  14213. }
  14214. }
  14215. }
  14216. }
  14217. #region 替换Word模板书签内容
  14218. Dictionary<string, string> marks = new Dictionary<string, string>();
  14219. marks.Add("To", di.ClientUnit);//付款方
  14220. marks.Add("ToTel", di.TellPhone);//付款方电话
  14221. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14222. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14223. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14224. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14225. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14226. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14227. marks.Add("PayItemContent", itemStr);//详细信息
  14228. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14229. #endregion
  14230. ////注
  14231. //if (doc.Range.Bookmarks["Attention"] != null)
  14232. //{
  14233. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14234. // mark.Text = frList[0].Attention;
  14235. //}
  14236. foreach (var item in marks.Keys)
  14237. {
  14238. if (doc.Range.Bookmarks[item] != null)
  14239. {
  14240. Bookmark mark = doc.Range.Bookmarks[item];
  14241. mark.Text = marks[item];
  14242. }
  14243. }
  14244. byte[] bytes = null;
  14245. using (MemoryStream stream = new MemoryStream())
  14246. {
  14247. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14248. bytes = stream.ToArray();
  14249. }
  14250. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14251. return Ok(JsonView(true, "", new
  14252. {
  14253. Data = bytes,
  14254. strFileName,
  14255. }));
  14256. }
  14257. else
  14258. {
  14259. return Ok(JsonView(false, "团组信息不存在!"));
  14260. }
  14261. }
  14262. /// <summary>
  14263. /// 导出团组成本
  14264. /// </summary>
  14265. /// <param name="dto"></param>
  14266. /// <returns></returns>
  14267. [HttpPost]
  14268. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14269. {
  14270. var jw = JsonView(false);
  14271. if (dto.Diid == 0)
  14272. {
  14273. return Ok(JsonView(false, "请传递团组id"));
  14274. }
  14275. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14276. if (deleInfo.Code != 0)
  14277. {
  14278. return Ok(JsonView(false, "团组信息查询失败!"));
  14279. }
  14280. var di = deleInfo.Data as DelegationInfoWebView;
  14281. if (di == null)
  14282. {
  14283. return Ok(JsonView(false, "团组信息查询失败!"));
  14284. }
  14285. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14286. WorkbookDesigner designer = new WorkbookDesigner();
  14287. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14288. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14289. for (int i = 0; i < List_GC.Count; i++)
  14290. {
  14291. GroupCost_Excel gc = new GroupCost_Excel();
  14292. gc.Id = List_GC[i].Id;
  14293. gc.Diid = List_GC[i].Diid.ToString();
  14294. gc.DAY = List_GC[i].DAY;
  14295. string week = "";
  14296. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14297. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14298. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14299. gc.ITIN = List_GC[i].ITIN;
  14300. gc.CarType = List_GC[i].CarType;
  14301. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14302. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14303. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14304. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14305. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14306. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14307. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14308. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14309. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14310. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14311. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14312. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14313. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14314. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14315. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14316. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14317. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14318. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14319. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14320. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14321. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14322. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14323. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14324. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14325. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14326. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14327. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14328. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14329. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14330. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14331. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14332. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14333. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14334. List_GC1.Add(gc);
  14335. }
  14336. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14337. dt.TableName = "TB";
  14338. //报表标题等不用dt的值
  14339. designer.SetDataSource("TeamName", dto.title.TeamName);
  14340. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14341. designer.SetDataSource("Tax", dto.title.Tax);
  14342. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14343. designer.SetDataSource("Currency", dto.title.Currency);
  14344. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14345. designer.SetDataSource("Rate", dto.title.Rate);
  14346. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14347. var Aparams = hotels.Find(x => x.Type == "Default");
  14348. if (Aparams == null)
  14349. {
  14350. return Ok(jw);
  14351. }
  14352. //酒店数量
  14353. var txtSGRNumber = Aparams.SGR.ToString();
  14354. var txtTBRNumber = Aparams.TBR.ToString();
  14355. var txtJSESNumber = Aparams.JSES.ToString();
  14356. var txtSUITENumbe = Aparams.SUITE.ToString();
  14357. if (dto.costType == "B")
  14358. {
  14359. Aparams = hotels.Find(x => x.Type == "A");
  14360. var Bparams = hotels.Find(x => x.Type == "B");
  14361. if (Aparams == null || Bparams == null)
  14362. {
  14363. return Ok(jw);
  14364. }
  14365. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14366. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14367. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14368. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14369. }
  14370. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14371. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14372. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14373. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14374. var ws = designer.Workbook.Worksheets[0];
  14375. int Row = List_GC.Count;
  14376. int startIndex = 11;
  14377. int HideRows = 0;
  14378. List<int> hideRowsList = new List<int>();
  14379. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14380. #region A段left数据
  14381. var left = dto.leftInfo.Find(x => x.Type == "A");
  14382. if (left == null)
  14383. {
  14384. return Ok(jw);
  14385. }
  14386. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14387. if (leftBindData != null)
  14388. {
  14389. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14390. designer.SetDataSource("VisaRS", leftBindData.rs);
  14391. designer.SetDataSource("VisaXS", leftBindData.xs);
  14392. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14393. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14394. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14395. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14396. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14397. }
  14398. else
  14399. {
  14400. hideRowsList.Add(Row + startIndex + HideRows);
  14401. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14402. }
  14403. HideRows += 2;
  14404. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14405. if (leftBindData != null)
  14406. {
  14407. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14408. designer.SetDataSource("BXRS", leftBindData.rs);
  14409. designer.SetDataSource("BXXS", leftBindData.xs);
  14410. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14411. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14412. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14413. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14414. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14415. }
  14416. else
  14417. {
  14418. hideRowsList.Add(Row + startIndex + HideRows);
  14419. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14420. }
  14421. HideRows += 2;
  14422. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14423. if (leftBindData != null)
  14424. {
  14425. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14426. designer.SetDataSource("HSRS", leftBindData.rs);
  14427. designer.SetDataSource("HSXS", leftBindData.xs);
  14428. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14429. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14430. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14431. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14432. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14433. }
  14434. else
  14435. {
  14436. hideRowsList.Add(Row + startIndex + HideRows);
  14437. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14438. }
  14439. HideRows += 2;
  14440. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14441. if (leftBindData != null)
  14442. {
  14443. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14444. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14445. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14446. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14447. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14448. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14449. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14450. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14451. }
  14452. else
  14453. {
  14454. hideRowsList.Add(Row + startIndex + HideRows);
  14455. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14456. }
  14457. HideRows += 2;
  14458. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14459. if (leftBindData != null)
  14460. {
  14461. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14462. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14463. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14464. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14465. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14466. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14467. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14468. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14469. }
  14470. else
  14471. {
  14472. hideRowsList.Add(Row + startIndex + HideRows);
  14473. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14474. }
  14475. HideRows += 2;
  14476. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14477. if (leftBindData != null)
  14478. {
  14479. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14480. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14481. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14482. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14483. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14484. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14485. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14486. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14487. }
  14488. else
  14489. {
  14490. hideRowsList.Add(Row + startIndex + HideRows);
  14491. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14492. }
  14493. HideRows += 2;
  14494. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14495. if (leftBindData != null)
  14496. {
  14497. ////TBR
  14498. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14499. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14500. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14501. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14502. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14503. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14504. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14505. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14506. }
  14507. else
  14508. {
  14509. hideRowsList.Add(Row + startIndex + HideRows);
  14510. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14511. }
  14512. HideRows += 2;
  14513. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14514. if (leftBindData != null)
  14515. {
  14516. ////SGR
  14517. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14518. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14519. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14520. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14521. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14522. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14523. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14524. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14525. }
  14526. else
  14527. {
  14528. hideRowsList.Add(Row + startIndex + HideRows);
  14529. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14530. }
  14531. HideRows += 2;
  14532. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14533. if (leftBindData != null)
  14534. {
  14535. ////JS/ES
  14536. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14537. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14538. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14539. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14540. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14541. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14542. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14543. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14544. }
  14545. else
  14546. {
  14547. hideRowsList.Add(Row + startIndex + HideRows);
  14548. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14549. }
  14550. HideRows += 2;
  14551. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14552. if (leftBindData != null)
  14553. {
  14554. ////SUITE
  14555. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14556. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14557. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14558. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14559. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14560. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14561. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14562. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14563. }
  14564. else
  14565. {
  14566. hideRowsList.Add(Row + startIndex + HideRows);
  14567. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14568. }
  14569. HideRows += 2;
  14570. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14571. if (leftBindData != null)
  14572. {
  14573. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14574. designer.SetDataSource("DJRS", leftBindData.rs);
  14575. designer.SetDataSource("DJXS", leftBindData.xs);
  14576. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14577. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14578. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14579. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14580. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14581. }
  14582. else
  14583. {
  14584. hideRowsList.Add(Row + startIndex + HideRows);
  14585. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14586. }
  14587. HideRows += 2;
  14588. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14589. if (leftBindData != null)
  14590. {
  14591. designer.SetDataSource("HCPCB", leftBindData.cb);
  14592. designer.SetDataSource("HCPRS", leftBindData.rs);
  14593. designer.SetDataSource("HCPXS", leftBindData.xs);
  14594. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14595. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14596. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14597. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14598. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14599. }
  14600. else
  14601. {
  14602. hideRowsList.Add(Row + startIndex + HideRows);
  14603. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14604. }
  14605. HideRows += 2;
  14606. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14607. if (leftBindData != null)
  14608. {
  14609. designer.SetDataSource("CPCB", leftBindData.cb);
  14610. designer.SetDataSource("CPRS", leftBindData.rs);
  14611. designer.SetDataSource("CPXS", leftBindData.xs);
  14612. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14613. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14614. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14615. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14616. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14617. }
  14618. else
  14619. {
  14620. hideRowsList.Add(Row + startIndex + HideRows);
  14621. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14622. }
  14623. HideRows += 2;
  14624. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14625. if (leftBindData != null)
  14626. {
  14627. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14628. designer.SetDataSource("GWRS", leftBindData.rs);
  14629. designer.SetDataSource("GWXS", leftBindData.xs);
  14630. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14631. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14632. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14633. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14634. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14635. }
  14636. else
  14637. {
  14638. hideRowsList.Add(Row + startIndex + HideRows);
  14639. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14640. }
  14641. HideRows += 2;
  14642. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14643. if (leftBindData != null)
  14644. {
  14645. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14646. designer.SetDataSource("LYJRS", leftBindData.rs);
  14647. designer.SetDataSource("LYJXS", leftBindData.xs);
  14648. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14649. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14650. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14651. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14652. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14653. }
  14654. else
  14655. {
  14656. hideRowsList.Add(Row + startIndex + HideRows);
  14657. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14658. }
  14659. #endregion
  14660. #region A段Right信息
  14661. var right = dto.rightInfo.Find(x => x.Type == "A");
  14662. if (right == null)
  14663. {
  14664. return Ok(jw);
  14665. }
  14666. HideRows += 4;
  14667. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14668. if (rightBindData != null)
  14669. {
  14670. //经济舱 + 双人间 TBR
  14671. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14672. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14673. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14674. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14675. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14676. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14677. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14678. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14679. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14680. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14681. }
  14682. else
  14683. {
  14684. hideRowsList.Add(Row + startIndex + HideRows);
  14685. }
  14686. HideRows += 2;
  14687. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14688. if (rightBindData != null)
  14689. {
  14690. //经济舱 + 单人间 SGR
  14691. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14692. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14693. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14694. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14695. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14696. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14697. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14698. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14699. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14700. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14701. }
  14702. else
  14703. {
  14704. hideRowsList.Add(Row + startIndex + HideRows);
  14705. }
  14706. HideRows += 2;
  14707. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14708. if (rightBindData != null)
  14709. {
  14710. //公务舱 + 单人间 SGR
  14711. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14712. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14713. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14714. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14715. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14716. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14717. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14718. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14719. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14720. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14721. }
  14722. else
  14723. {
  14724. hideRowsList.Add(Row + startIndex + HideRows);
  14725. }
  14726. HideRows += 2;
  14727. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14728. if (rightBindData != null)
  14729. {
  14730. //公务舱 + 小套房 JSES
  14731. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14732. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14733. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14734. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14735. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14736. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14737. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14738. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14739. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14740. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14741. }
  14742. else
  14743. {
  14744. hideRowsList.Add(Row + startIndex + HideRows);
  14745. }
  14746. HideRows += 2;
  14747. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14748. if (rightBindData != null)
  14749. {
  14750. //公务舱 + 小套房 JSES
  14751. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14752. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14753. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14754. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14755. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14756. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14757. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14758. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14759. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14760. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14761. }
  14762. else
  14763. {
  14764. hideRowsList.Add(Row + startIndex + HideRows);
  14765. }
  14766. HideRows += 2;
  14767. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14768. if (rightBindData != null)
  14769. {
  14770. //经济舱 + 大套房
  14771. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14772. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14773. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14774. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14775. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14776. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14777. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14778. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14779. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14780. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14781. }
  14782. else
  14783. {
  14784. hideRowsList.Add(Row + startIndex + HideRows);
  14785. }
  14786. HideRows += 2;
  14787. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14788. if (rightBindData != null)
  14789. {
  14790. //头等舱 + 小套房 JSES
  14791. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14792. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14793. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14794. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14795. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14796. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14797. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14798. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14799. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14800. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14801. }
  14802. else
  14803. {
  14804. hideRowsList.Add(Row + startIndex + HideRows);
  14805. }
  14806. HideRows += 2;
  14807. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14808. if (rightBindData != null)
  14809. {
  14810. //头等舱 + 大套房
  14811. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14812. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14813. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14814. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14815. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14816. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14817. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14818. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14819. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14820. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14821. }
  14822. else
  14823. {
  14824. hideRowsList.Add(Row + startIndex + HideRows);
  14825. }
  14826. #endregion
  14827. #region B段标题清空
  14828. designer.SetDataSource("CostBDRCB", "");
  14829. designer.SetDataSource("CostBRS", "");
  14830. designer.SetDataSource("CostBXS", "");
  14831. designer.SetDataSource("CostBZCB", "");
  14832. designer.SetDataSource("CostBDRBJ", "");
  14833. designer.SetDataSource("CostBZBJ", "");
  14834. designer.SetDataSource("CostBDRLR", "");
  14835. designer.SetDataSource("CostBZLR", "");
  14836. designer.SetDataSource("CostBDRCBOM", "");
  14837. designer.SetDataSource("CostBRSOM", "");
  14838. designer.SetDataSource("CostBZCBOM", "");
  14839. designer.SetDataSource("CostBDRBJOM", "");
  14840. designer.SetDataSource("CostBZBJOM", "");
  14841. designer.SetDataSource("CostBDRLROM", "");
  14842. designer.SetDataSource("CostBZLROM", "");
  14843. #endregion
  14844. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14845. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14846. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14847. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14848. designer.SetDataSource("DJName", "地接(CNY)");
  14849. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14850. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14851. designer.SetDataSource("GWName", "公务(CNY)");
  14852. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14853. designer.SetDataSource("LYJName", "零用金(CNY)");
  14854. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14855. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14856. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14857. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14858. designer.SetDataSource("BXName", "保险(CNY)");
  14859. designer.SetDataSource("VisaName", "签证(CNY)");
  14860. #region B段基本数据
  14861. if (dto.costType == "B")
  14862. {
  14863. left = dto.leftInfo.Find(x => x.Type == "B");
  14864. if (left == null)
  14865. {
  14866. return Ok(jw);
  14867. }
  14868. #region B段left数据
  14869. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14870. if (leftBindData != null)
  14871. {
  14872. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14873. designer.SetDataSource("BHSRS", leftBindData.rs);
  14874. designer.SetDataSource("BHSXS", leftBindData.xs);
  14875. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14876. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14877. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14878. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14879. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14880. }
  14881. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14882. if (leftBindData != null)
  14883. {
  14884. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14885. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14886. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14887. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14888. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14889. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14890. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14891. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14892. }
  14893. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14894. if (leftBindData != null)
  14895. {
  14896. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14897. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14898. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14899. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14900. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14901. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14902. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14903. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14904. }
  14905. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14906. if (leftBindData != null)
  14907. {
  14908. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14909. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14910. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14911. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14912. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14913. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14914. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14915. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14916. }
  14917. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14918. if (leftBindData != null)
  14919. {
  14920. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14921. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14922. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14923. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14924. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14925. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14926. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14927. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14928. }
  14929. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14930. if (leftBindData != null)
  14931. {
  14932. designer.SetDataSource("BCPCB", leftBindData.cb);
  14933. designer.SetDataSource("BCPRS", leftBindData.rs);
  14934. designer.SetDataSource("BCPXS", leftBindData.xs);
  14935. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14936. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14937. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14938. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14939. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14940. }
  14941. //TBR
  14942. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14943. if (leftBindData != null)
  14944. {
  14945. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14946. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14947. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14948. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14949. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14950. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14951. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14952. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14953. }
  14954. //SGR
  14955. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14956. if (leftBindData != null)
  14957. {
  14958. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  14959. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  14960. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  14961. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14962. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14963. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14964. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14965. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14966. }
  14967. //JS/ES
  14968. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14969. if (leftBindData != null)
  14970. {
  14971. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  14972. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14973. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14974. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14975. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14976. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14977. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14978. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14979. }
  14980. //SUITE
  14981. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14982. if (leftBindData != null)
  14983. {
  14984. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14985. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14986. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14987. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14988. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14989. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14990. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14991. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14992. }
  14993. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14994. if (leftBindData != null)
  14995. {
  14996. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14997. designer.SetDataSource("BDJRS", leftBindData.rs);
  14998. designer.SetDataSource("BDJXS", leftBindData.xs);
  14999. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15000. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15001. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15002. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15003. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15004. }
  15005. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15006. if (leftBindData != null)
  15007. {
  15008. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15009. designer.SetDataSource("BGWRS", leftBindData.rs);
  15010. designer.SetDataSource("BGWXS", leftBindData.xs);
  15011. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15012. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15013. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15014. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15015. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15016. }
  15017. #region 优化方案
  15018. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15019. //excelBind.Add("零用金", new {
  15020. //cb="",
  15021. //rs="",
  15022. //xs ="",
  15023. //zcb = "",
  15024. //});
  15025. #endregion
  15026. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15027. if (leftBindData != null)
  15028. {
  15029. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15030. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15031. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15032. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15033. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15034. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15035. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15036. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15037. }
  15038. #endregion
  15039. #region B段Right信息
  15040. right = dto.rightInfo.Find(x => x.Type == "B");
  15041. if (right == null)
  15042. {
  15043. return Ok(jw);
  15044. }
  15045. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15046. if (rightBindData != null)
  15047. {
  15048. //经济舱 + 双人间 TBR
  15049. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15050. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15051. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15052. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15053. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15054. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15055. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15056. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15057. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15058. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15059. }
  15060. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15061. if (rightBindData != null)
  15062. {
  15063. //经济舱 + 单人间 SGR
  15064. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15065. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15066. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15067. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15068. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15069. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15070. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15071. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15072. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15073. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15074. }
  15075. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15076. if (rightBindData != null)
  15077. {
  15078. //公务舱 + 单人间 SGR
  15079. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15080. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15081. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15082. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15083. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15084. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15085. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15086. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15087. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15088. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15089. }
  15090. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15091. if (rightBindData != null)
  15092. {
  15093. //公务舱 + 小套房 JSES
  15094. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15095. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15096. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15097. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15098. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15099. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15100. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15101. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15102. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15103. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15104. }
  15105. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15106. if (rightBindData != null)
  15107. {
  15108. //公务舱 + 小套房 JSES
  15109. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15110. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15111. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15112. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15113. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15114. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15115. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15116. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15117. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15118. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15119. }
  15120. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15121. if (rightBindData != null)
  15122. {
  15123. //经济舱 + 大套房
  15124. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15125. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15126. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15127. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15128. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15129. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15130. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15131. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15132. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15133. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15134. }
  15135. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15136. if (rightBindData != null)
  15137. {
  15138. //头等舱 + 小套房 JSES
  15139. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15140. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15141. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15142. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15143. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15144. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15145. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15146. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15147. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15148. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15149. }
  15150. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15151. if (rightBindData != null)
  15152. {
  15153. //头等舱 + 大套房
  15154. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15155. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15156. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15157. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15158. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15159. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15160. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15161. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15162. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15163. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15164. }
  15165. #endregion
  15166. #region 标题
  15167. designer.SetDataSource("CostBDRCB", "单人成本");
  15168. designer.SetDataSource("CostBRS", "人数");
  15169. designer.SetDataSource("CostBXS", "系数");
  15170. designer.SetDataSource("CostBZCB", "总成本");
  15171. designer.SetDataSource("CostBDRBJ", "单人报价");
  15172. designer.SetDataSource("CostBZBJ", "总报价");
  15173. designer.SetDataSource("CostBDRLR", "单人利润");
  15174. designer.SetDataSource("CostBZLR", "总利润");
  15175. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15176. designer.SetDataSource("CostBRSOM", "人数");
  15177. designer.SetDataSource("CostBZCBOM", "总成本");
  15178. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15179. designer.SetDataSource("CostBZBJOM", "总报价");
  15180. designer.SetDataSource("CostBDRLROM", "单人利润");
  15181. designer.SetDataSource("CostBZLROM", "总利润");
  15182. #endregion
  15183. }
  15184. #endregion
  15185. designer.SetDataSource("TzZCB2", TzZCB2);
  15186. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15187. designer.SetDataSource("TzZLR2", TzZLR2);
  15188. string[] dataSourceKeys = new string[]
  15189. {
  15190. "VF",
  15191. "TGS",
  15192. "TGOF",
  15193. "TGM",
  15194. "TGA",
  15195. "TGTF",
  15196. "TGEF",
  15197. "CFM",
  15198. "CFOF",
  15199. "B",
  15200. "L",
  15201. "D",
  15202. "TBR",
  15203. "SGR",
  15204. "JSES",
  15205. "Suite",
  15206. "TV",
  15207. "1L",
  15208. "IF",
  15209. "EF",
  15210. "BRF",
  15211. "TE",
  15212. "TGT",
  15213. "DRVT",
  15214. "PC",
  15215. "TLF",
  15216. "ECT"
  15217. };
  15218. foreach (var item in dataSourceKeys)
  15219. {
  15220. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15221. if (find != null)
  15222. {
  15223. designer.SetDataSource(item, find.text);
  15224. }
  15225. else
  15226. {
  15227. designer.SetDataSource(item, 0);
  15228. }
  15229. }
  15230. designer.SetDataSource(dt);
  15231. //根据数据源处理生成报表内容
  15232. designer.Process();
  15233. designer.Workbook.Worksheets[0].Name = "清单";
  15234. Worksheet sheet = designer.Workbook.Worksheets[0];
  15235. foreach (var Rowindex in hideRowsList)
  15236. {
  15237. ws.Cells.HideRows(Rowindex, 2);
  15238. }
  15239. byte[] bytes = null;
  15240. string strFileName = di.TeamName + "-团组-成本.xls";
  15241. using (MemoryStream stream = new MemoryStream())
  15242. {
  15243. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15244. bytes = stream.ToArray();
  15245. }
  15246. return Ok(JsonView(true, "", new
  15247. {
  15248. Data = bytes,
  15249. strFileName,
  15250. }));
  15251. }
  15252. /// <summary>
  15253. /// 导出客户报表
  15254. /// </summary>
  15255. /// <returns></returns>
  15256. [HttpPost]
  15257. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15258. {
  15259. var jw = JsonView(false);
  15260. if (dto.Diid == 0)
  15261. {
  15262. return Ok(JsonView(false, "请传递团组id"));
  15263. }
  15264. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15265. if (deleInfo.Code != 0)
  15266. {
  15267. return Ok(JsonView(false, "团组信息查询失败!"));
  15268. }
  15269. var di = deleInfo.Data as DelegationInfoWebView;
  15270. if (di == null)
  15271. {
  15272. return Ok(JsonView(false, "团组信息查询失败!"));
  15273. }
  15274. //文件名
  15275. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15276. //获取模板
  15277. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15278. //载入模板
  15279. Document doc = new Document(tmppath);
  15280. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15281. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15282. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15283. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15284. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15285. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15286. if (AParameter == null)
  15287. {
  15288. return Ok(JsonView(false, "系数不存在!"));
  15289. }
  15290. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15291. , TzAirDesc, TzZCost;
  15292. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15293. = TzAirDesc = TzZCost = string.Empty;
  15294. TzNumber = AParameter.CostTypenumber.ToString();
  15295. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15296. CarGuides1 = dto.CarGuides1;
  15297. Meal = dto.Meal;
  15298. SubsidizedMeals = dto.SubsidizedMeals;
  15299. NightRepair = dto.NightRepair;
  15300. AttractionsTickets = dto.AttractionsTickets;
  15301. MiscellaneousFees = dto.MiscellaneousFees;
  15302. ATip = dto.ATip;
  15303. TzHotelDesc = "";
  15304. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15305. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15306. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15307. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15308. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15309. TzAirDesc = "";
  15310. TzZCost = dto.TzZCost;
  15311. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15312. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15313. var index = 1;
  15314. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15315. foreach (var item in TzHotelDescArr)
  15316. {
  15317. if (AinfoArr != null)
  15318. {
  15319. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15320. if (Ainfo != null)
  15321. {
  15322. if (int.Parse(Ainfo.rs) <= 0)
  15323. {
  15324. continue;
  15325. }
  15326. var hotelText = string.Empty;
  15327. switch (item)
  15328. {
  15329. case "SGR":
  15330. hotelText = "单人间";
  15331. break;
  15332. case "JSES":
  15333. hotelText = "小套房";
  15334. break;
  15335. case "SUITE":
  15336. hotelText = "套房";
  15337. break;
  15338. case "TBR":
  15339. hotelText = "双人间";
  15340. break;
  15341. }
  15342. if (item != "TBR")
  15343. {
  15344. 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";
  15345. }
  15346. else
  15347. {
  15348. 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";
  15349. }
  15350. index++;
  15351. }
  15352. }
  15353. }
  15354. index = 1;
  15355. foreach (var item in TzAirDescArr)
  15356. {
  15357. if (AinfoArr != null)
  15358. {
  15359. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15360. if (Ainfo != null)
  15361. {
  15362. if (int.Parse(Ainfo.rs) <= 0)
  15363. {
  15364. continue;
  15365. }
  15366. 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";
  15367. index++;
  15368. }
  15369. }
  15370. }
  15371. if (dto.costType == "B")
  15372. {
  15373. if (BParameter == null)
  15374. {
  15375. return Ok(JsonView(false, "B段系数不存在!"));
  15376. }
  15377. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15378. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15379. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15380. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15381. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15382. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15383. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15384. foreach (var item in TzHotelDescArr)
  15385. {
  15386. if (AinfoArr != null)
  15387. {
  15388. TzHotelDesc += "B段信息 \r\n";
  15389. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15390. if (Ainfo != null)
  15391. {
  15392. if (int.Parse(Ainfo.rs) <= 0)
  15393. {
  15394. continue;
  15395. }
  15396. var hotelText = string.Empty;
  15397. switch (item)
  15398. {
  15399. case "SGR":
  15400. hotelText = "单人间";
  15401. break;
  15402. case "JSES":
  15403. hotelText = "小套房";
  15404. break;
  15405. case "SUITE":
  15406. hotelText = "套房";
  15407. break;
  15408. case "TBR":
  15409. hotelText = "双人间";
  15410. break;
  15411. }
  15412. if (item != "TBR")
  15413. {
  15414. 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";
  15415. }
  15416. else
  15417. {
  15418. 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";
  15419. }
  15420. index++;
  15421. }
  15422. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15423. }
  15424. }
  15425. index = 1;
  15426. foreach (var item in TzAirDescArr)
  15427. {
  15428. if (AinfoArr != null)
  15429. {
  15430. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15431. if (Ainfo != null)
  15432. {
  15433. if (int.Parse(Ainfo.rs) <= 0)
  15434. {
  15435. continue;
  15436. }
  15437. 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";
  15438. index++;
  15439. }
  15440. }
  15441. }
  15442. }
  15443. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15444. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15445. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15446. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15447. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15448. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15449. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15450. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15451. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15452. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15453. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15454. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15455. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15456. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15457. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15458. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15459. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15460. DickeyValue.Add("TzZCost", TzZCost);
  15461. foreach (var key in DickeyValue.Keys)
  15462. {
  15463. if (doc.Range.Bookmarks[key] != null)
  15464. {
  15465. Bookmark mark = doc.Range.Bookmarks[key];
  15466. mark.Text = DickeyValue[key];
  15467. }
  15468. }
  15469. byte[] bytes = null;
  15470. string strFileName = di.TeamName + "-客户报价.doc";
  15471. using (MemoryStream stream = new MemoryStream())
  15472. {
  15473. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15474. bytes = stream.ToArray();
  15475. }
  15476. return Ok(JsonView(true, "", new
  15477. {
  15478. Data = bytes,
  15479. strFileName,
  15480. }));
  15481. }
  15482. /// <summary>
  15483. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15484. /// </summary>
  15485. /// <param name="dto"></param>
  15486. /// <returns></returns>
  15487. [HttpPost]
  15488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15489. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15490. {
  15491. try
  15492. {
  15493. #region 参数验证
  15494. if (dto.DiId < 0)
  15495. {
  15496. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15497. }
  15498. List<int> cTableIds = new List<int>() {
  15499. 76 ,//酒店预订
  15500. 77 ,//行程
  15501. 79 ,//车/导游地接
  15502. 80 ,//签证
  15503. 81 ,//邀请/公务活
  15504. 82 ,//团组客户保险
  15505. 85 ,//机票预订
  15506. 98 ,//其他款项
  15507. 285 ,//收款退还
  15508. 751 ,//酒店早餐
  15509. 1015 // 超支费用
  15510. };
  15511. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15512. {
  15513. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15514. }
  15515. #endregion
  15516. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15517. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15518. if (_GroupCostParameters.Count <= 0)
  15519. {
  15520. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15521. }
  15522. if (_GroupCostParameters[0].IsShare == 0)
  15523. {
  15524. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15525. }
  15526. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15527. //处理date为空问题
  15528. if (_GroupCosts.Count > 0)
  15529. {
  15530. for (int i = 0; i < _GroupCosts.Count; i++)
  15531. {
  15532. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15533. {
  15534. if (i > 0)
  15535. {
  15536. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15537. }
  15538. }
  15539. }
  15540. }
  15541. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15542. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15543. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15544. string currCode = "";
  15545. #region currCode 验证
  15546. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15547. if (isInt)
  15548. {
  15549. var currData = currDatas.Find(it => it.Id == intCurrency);
  15550. if (currData != null)
  15551. {
  15552. currCode = currData.Name;
  15553. }
  15554. }
  15555. else
  15556. {
  15557. currCode = _GroupCostParameters[0].Currency.Trim();
  15558. }
  15559. #endregion
  15560. //op,酒店单段模式存储
  15561. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15562. {
  15563. CurrencyCode = currCode,
  15564. Rate = _GroupCostParameters[0].Rate,
  15565. CostType = _GroupCostParameters[0].CostType,
  15566. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15567. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15568. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15569. };
  15570. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15571. if (_GroupCostParameters.Count == 2)
  15572. {
  15573. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15574. }
  15575. foreach (var item in _GroupCostParameters)
  15576. {
  15577. decimal _rate = 1;
  15578. decimal _rate1 = item.Rate;
  15579. decimal _scale = 1;
  15580. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15581. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15582. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15583. //if (userInfo != null)
  15584. //{
  15585. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15586. // {
  15587. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15588. // {
  15589. // _scale = 1.00M;
  15590. // }
  15591. // }
  15592. //}
  15593. #endregion
  15594. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15595. {
  15596. CurrencyCode = currCode,
  15597. Rate = _rate1,
  15598. CostType = item.CostType,
  15599. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15600. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15601. CostTypeNumber = item.CostTypenumber
  15602. };
  15603. if (_GroupCostParameters.Count > 1)
  15604. {
  15605. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15606. }
  15607. else
  15608. {
  15609. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15610. }
  15611. if (dto.CTable == 79)//
  15612. {
  15613. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15614. modulePromptInfo.TotalCost = item.DJCB;
  15615. }
  15616. List<string> costTypes = new List<string>() { "A", "B" };
  15617. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15618. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15619. if (_GroupCostsDuplicates.Count() == 1)
  15620. {
  15621. _GroupCostsTypeData = _GroupCosts;
  15622. }
  15623. else
  15624. {
  15625. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15626. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15627. }
  15628. /*
  15629. * 76 酒店预订
  15630. * 77 行程
  15631. * 79 车/导游地接
  15632. * 80 签证
  15633. * 81 邀请/公务活动
  15634. * 82 团组客户保险
  15635. * 85 机票预订
  15636. * 98 其他款项
  15637. * 285 收款退还
  15638. * 751 酒店早餐
  15639. * 1015 超支费用
  15640. */
  15641. switch (dto.CTable)
  15642. {
  15643. case 76: // 酒店预订
  15644. _ModuleSubPromptInfo.AddRange(
  15645. _GroupCostsTypeData.Select(it => new
  15646. {
  15647. it.DAY,
  15648. it.Date,
  15649. it.ACCON,
  15650. it.ITIN,
  15651. it.SGR,
  15652. it.TBR,
  15653. it.JS_ES,
  15654. it.Suite
  15655. })
  15656. );
  15657. break;
  15658. case 79: // 车/导游地接
  15659. _ModuleSubPromptInfo.AddRange(
  15660. _GroupCostsTypeData.Select(it => new
  15661. {
  15662. Date = it.Date, //日期
  15663. CarFee = it.CarCost * _rate * _scale, //车费用
  15664. CarType = it.CarType, //车型
  15665. DriverFee = it.CFS * _rate * _scale, //司机工资
  15666. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15667. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15668. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15669. GuideFee = it.TGS * _rate * _scale, //导游费用
  15670. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15671. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15672. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15673. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15674. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15675. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15676. Breakfast = it.B * _rate * _scale, //早餐费
  15677. Lunch = it.L * _rate * _scale, //午餐费
  15678. Dinner = it.D * _rate * _scale, //晚餐费
  15679. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15680. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15681. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15682. TicketFee = it.EF * _rate * _scale, //门票费
  15683. TicketRemark = it.EFR, //门票费描述
  15684. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15685. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15686. SpentCash = it.PC * _rate * _scale, //零用金
  15687. LeadersFee = it.TLF * _rate * _scale, //领队费
  15688. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15689. })
  15690. );
  15691. break;
  15692. case 85: // 机票
  15693. List<dynamic> datas = new List<dynamic>();
  15694. datas.Add(
  15695. new
  15696. {
  15697. AirType = "经济舱",
  15698. AirNum = item.JJCRS,
  15699. AirDRCB = item.JJCCB,
  15700. AirZCB = (item.JJCRS * item.JJCCB)
  15701. }
  15702. );
  15703. datas.Add(
  15704. new
  15705. {
  15706. AirType = "公务舱",
  15707. AirNum = item.GWCRS,
  15708. AirDRCB = item.GWCCB,
  15709. AirZCB = (item.GWCRS * item.GWCCB)
  15710. }
  15711. );
  15712. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15713. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15714. modulePromptInfo.Data = new
  15715. {
  15716. airFeeData = datas,
  15717. airInitData = initDatas
  15718. };
  15719. _ModulePromptInfos.Add(modulePromptInfo);
  15720. break;
  15721. default:
  15722. break;
  15723. }
  15724. }
  15725. if (dto.CTable != 85)
  15726. {
  15727. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15728. _ModulePromptInfos.Add(_ModulePromptInfo);
  15729. }
  15730. _view.ModulePromptInfos = _ModulePromptInfos;
  15731. return Ok(JsonView(true, "操作成功!", _view));
  15732. }
  15733. catch (Exception ex)
  15734. {
  15735. return Ok(JsonView(false, ex.Message));
  15736. }
  15737. }
  15738. /// <summary>
  15739. /// 根据黑屏代码重新生成行程
  15740. /// </summary>
  15741. /// <param name="dto"></param>
  15742. /// <returns></returns>
  15743. [HttpPost]
  15744. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15745. {
  15746. var jw = JsonView(false,"Error");
  15747. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15748. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15749. .Select(x=> new
  15750. {
  15751. x.Id,
  15752. x.Title
  15753. })
  15754. .ToList();
  15755. if (Create.Any())
  15756. {
  15757. jw.Msg = "获取成功!";
  15758. jw.Code = 200;
  15759. jw.Data = new
  15760. {
  15761. BlackCodeListSelect = Create,
  15762. blackCodeIsTrue = true
  15763. };
  15764. }
  15765. else
  15766. {
  15767. jw.Code = 400;
  15768. jw.Data = new
  15769. {
  15770. BlackCodeListSelect = Create,
  15771. blackCodeIsTrue = false,
  15772. };
  15773. }
  15774. return Ok(jw);
  15775. }
  15776. /// <summary>
  15777. /// 根据黑屏代码Id重新生成行程
  15778. /// </summary>
  15779. /// <param name="dto"></param>
  15780. /// <returns></returns>
  15781. [HttpPost]
  15782. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15783. {
  15784. var jw = JsonView(false, "Error");
  15785. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15786. if (result.Code == 0)
  15787. {
  15788. jw.Msg = "获取成功!";
  15789. jw.Code = 200;
  15790. jw.Data = new
  15791. {
  15792. groupCost = result.Data,
  15793. blackCodeIsTrue = true
  15794. };
  15795. }
  15796. else
  15797. {
  15798. jw.Code = 400;
  15799. jw.Data = new
  15800. {
  15801. groupCost = result.Data,
  15802. blackCodeIsTrue = false,
  15803. };
  15804. }
  15805. return Ok(jw);
  15806. }
  15807. /// <summary>
  15808. /// 成本获取OP历史车费用
  15809. /// </summary>
  15810. /// <param name="dto"></param>
  15811. /// <returns></returns>
  15812. [HttpPost]
  15813. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15814. {
  15815. var jw = JsonView(false);
  15816. try
  15817. {
  15818. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15819. //获取现有所有车的数据
  15820. if (!dto.Param.IsNullOrWhiteSpace())
  15821. {
  15822. string sql = $@"
  15823. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15824. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15825. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15826. 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
  15827. AND gctggr.ServiceEndTime is not NULL
  15828. ORDER by gctggrc.id DESC
  15829. ";
  15830. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15831. var numeberResult = await Task.Run(() =>
  15832. {
  15833. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15834. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15835. return numberArr;
  15836. });
  15837. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15838. foreach (var item in numeberResult)
  15839. {
  15840. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15841. {
  15842. Country = "数据异常!",
  15843. City = string.Empty,
  15844. };
  15845. item.Area = find.Country + " " + find.City;
  15846. }
  15847. dbResult.AddRange(numeberResult);
  15848. if (dto.Param.Contains("、"))
  15849. {
  15850. var sp = dto.Param.Split("、");
  15851. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15852. .Where(x =>
  15853. {
  15854. return System.Array.Exists(sp, e =>
  15855. {
  15856. bool where = false;
  15857. if (x.Area != null)
  15858. {
  15859. where = x.Area.Contains(e);
  15860. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15861. {
  15862. return false;
  15863. }
  15864. }
  15865. if (x.PriceName != null && !where)
  15866. {
  15867. where = x.PriceName.Contains(e);
  15868. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15869. {
  15870. return false;
  15871. }
  15872. }
  15873. return where;
  15874. });
  15875. }).ToList();
  15876. }
  15877. else
  15878. {
  15879. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15880. .Where(x =>
  15881. {
  15882. bool where = false;
  15883. if (x.Area != null)
  15884. {
  15885. where = x.Area.Contains(dto.Param);
  15886. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15887. {
  15888. return false;
  15889. }
  15890. }
  15891. if (x.PriceName != null && !where)
  15892. {
  15893. where = x.PriceName.Contains(dto.Param);
  15894. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15895. {
  15896. return false;
  15897. }
  15898. }
  15899. return where;
  15900. }
  15901. )
  15902. .ToList();
  15903. }
  15904. }
  15905. var view = dbResult.Select(x =>
  15906. {
  15907. decimal dp = 0.00M;
  15908. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15909. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15910. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15911. {
  15912. if (startB && endB)
  15913. {
  15914. var timesp = endD.Subtract(startD);
  15915. if ((timesp.Days + 1) != 0)
  15916. {
  15917. dp = x.Price / (timesp.Days + 1);
  15918. }
  15919. }
  15920. }
  15921. else
  15922. {
  15923. dp = x.Price;
  15924. }
  15925. return new
  15926. {
  15927. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15928. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15929. x.Area,
  15930. x.id,
  15931. price = x.Price.ToString("F2"),
  15932. x.PriceName,
  15933. x.PriceContent,
  15934. x.TeamName,
  15935. x.DatePrice,
  15936. dayPrice = dp.ToString("F2"),
  15937. };
  15938. }).OrderByDescending(x => x.id).ToList();
  15939. jw = JsonView(true, "获取成功!", view);
  15940. }
  15941. catch (Exception e)
  15942. {
  15943. jw = JsonView(false, e.Message);
  15944. }
  15945. return Ok(jw);
  15946. }
  15947. [HttpPost]
  15948. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15949. {
  15950. var jw = JsonView(true);
  15951. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15952. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15953. {
  15954. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15955. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15956. WHEN COUNT(*) >= 0 THEN 'True'
  15957. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15958. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15959. ")
  15960. .ToList();
  15961. }
  15962. else
  15963. {
  15964. string likeKey = string.Empty;
  15965. foreach (var item in dto.Keyword)
  15966. {
  15967. likeKey += "%" + item;
  15968. }
  15969. likeKey += "%";
  15970. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15971. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15972. WHEN COUNT(*) >= 0 THEN 'True'
  15973. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15974. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15975. ")
  15976. .ToList();
  15977. }
  15978. if (matches.Any())
  15979. {
  15980. jw.Data = matches;
  15981. }
  15982. else
  15983. {
  15984. jw.Code = 201;
  15985. jw.Msg = "empty list";
  15986. jw.Data = new List<string>(1);
  15987. }
  15988. return Ok(jw);
  15989. }
  15990. /// <summary>
  15991. /// 报价Word下载
  15992. /// </summary>
  15993. /// <param name="dto"></param>
  15994. /// <returns></returns>
  15995. [HttpPost]
  15996. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  15997. {
  15998. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  15999. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16000. if (di == null)
  16001. {
  16002. return Ok(JsonView(false, "团组不存在!"));
  16003. }
  16004. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16005. if (mainPrice == null || mainPrice.IsShare == 0)
  16006. {
  16007. return Ok(JsonView(false, "团组成本不存在!"));
  16008. }
  16009. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16010. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16011. if (costTypeHotelNumbers == null)
  16012. {
  16013. return Ok(JsonView(false, "团组成本不存在!"));
  16014. }
  16015. //文件名
  16016. string strFileName = di.TeamName + "-收款账单.doc";
  16017. //获取模板
  16018. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16019. //载入模板
  16020. Document doc = new Document(tmppath);
  16021. decimal allPrice = 0.00M;
  16022. string itemStr = string.Empty;
  16023. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16024. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16025. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16026. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16027. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16028. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16029. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16030. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16031. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16032. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16033. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16034. {
  16035. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16036. ("BXRS", "BXCB", "BXXS", "bx"),
  16037. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16038. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16039. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16040. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16041. ("CPRS", "CPCB", "CPXS", "cp"),
  16042. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16043. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16044. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16045. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16046. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16047. ("DJRS", "DJCB", "DJXS", "dj"),
  16048. ("GWRS", "GWCB", "GWXS", "gw"),
  16049. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16050. };
  16051. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16052. var rightSum = 0.00M;
  16053. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16054. {
  16055. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16056. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16057. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16058. if (prefix == "tbr")
  16059. {
  16060. rsValue *= 2;
  16061. cbValue /= 2;
  16062. }
  16063. if (OtherCostPropertyBJ.Contains(prefix))
  16064. {
  16065. rightSum += cbValue * xsValue;
  16066. }
  16067. }
  16068. var hotelRooms = new Dictionary<string, int>
  16069. {
  16070. { "SGR", costTypeHotelNumbers.SGR },
  16071. { "TBR", costTypeHotelNumbers.TBR },
  16072. { "JSES", costTypeHotelNumbers.JSES },
  16073. { "SUITE", costTypeHotelNumbers.SUITE }
  16074. };
  16075. var flights = new Dictionary<string, int>
  16076. {
  16077. { "经济舱", mainPrice.JJCRS },
  16078. { "公务舱", mainPrice.GWCRS },
  16079. { "头等舱", mainPrice.TDCRS }
  16080. };
  16081. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16082. {
  16083. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16084. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16085. { "头等舱", new[] { "SUITE", "JSES" } }
  16086. };
  16087. var result = new Dictionary<string, int>();
  16088. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16089. foreach (var flight in flights.Keys)
  16090. {
  16091. // 获取当前舱位的匹配规则
  16092. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16093. {
  16094. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16095. }
  16096. }
  16097. #region right计算
  16098. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16099. {
  16100. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16101. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16102. airHotelPriceList.Add(new
  16103. AirHotelPrice
  16104. {
  16105. Name = "经济舱TBR",
  16106. Price = rightSum + air + hotel,
  16107. Count = result["经济舱TBR"] * 2
  16108. });
  16109. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16110. }
  16111. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16112. {
  16113. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16114. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16115. airHotelPriceList.Add(new
  16116. AirHotelPrice
  16117. {
  16118. Name = "经济舱SGR",
  16119. Price = rightSum + air + hotel,
  16120. Count = result["经济舱SGR"]
  16121. });
  16122. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16123. }
  16124. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16125. {
  16126. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16127. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16128. airHotelPriceList.Add(new
  16129. AirHotelPrice
  16130. {
  16131. Name = "公务舱SGR",
  16132. Price = rightSum + air + hotel,
  16133. Count = result["公务舱SGR"]
  16134. });
  16135. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16136. }
  16137. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16138. {
  16139. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16140. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16141. airHotelPriceList.Add(new
  16142. AirHotelPrice
  16143. {
  16144. Name = "公务舱JSES",
  16145. Price = rightSum + air + hotel,
  16146. Count = result["公务舱JSES"]
  16147. });
  16148. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16149. }
  16150. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16151. {
  16152. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16153. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16154. airHotelPriceList.Add(new
  16155. AirHotelPrice
  16156. {
  16157. Name = "公务舱SUITE",
  16158. Price = rightSum + air + hotel,
  16159. Count = result["公务舱SUITE"]
  16160. });
  16161. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16162. }
  16163. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16164. {
  16165. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16166. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16167. airHotelPriceList.Add(new
  16168. AirHotelPrice
  16169. {
  16170. Name = "经济舱SUITE",
  16171. Price = rightSum + air + hotel,
  16172. Count = result["经济舱SUITE"]
  16173. });
  16174. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16175. }
  16176. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16177. {
  16178. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16179. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16180. airHotelPriceList.Add(new
  16181. AirHotelPrice
  16182. {
  16183. Name = "头等舱JSES",
  16184. Price = rightSum + air + hotel,
  16185. Count = result["头等舱JSES"]
  16186. });
  16187. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16188. }
  16189. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16190. {
  16191. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16192. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16193. airHotelPriceList.Add(new
  16194. AirHotelPrice
  16195. {
  16196. Name = "头等舱SUITE",
  16197. Price = rightSum + air + hotel,
  16198. Count = result["头等舱SUITE"]
  16199. });
  16200. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16201. }
  16202. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16203. {
  16204. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16205. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16206. airHotelPriceList.Add(new
  16207. AirHotelPrice
  16208. {
  16209. Name = "经济舱JSES",
  16210. Price = rightSum + air + hotel,
  16211. Count = result["经济舱JSES"]
  16212. });
  16213. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16214. }
  16215. #endregion
  16216. foreach (var item in airSouer.Keys)
  16217. {
  16218. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16219. if (find != null && find.Count > 0)
  16220. {
  16221. if (item.Contains("TBR"))
  16222. {
  16223. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16224. }
  16225. else
  16226. {
  16227. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16228. }
  16229. }
  16230. }
  16231. #region 替换Word模板书签内容
  16232. Dictionary<string, string> marks = new Dictionary<string, string>();
  16233. marks.Add("To", di.ClientUnit);//付款方
  16234. marks.Add("ToTel", di.TellPhone);//付款方电话
  16235. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16236. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16237. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16238. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16239. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16240. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16241. marks.Add("PayItemContent", itemStr);//详细信息
  16242. marks.Add("Total", allPrice.ToString("F2"));//合计
  16243. #endregion
  16244. foreach (var item in marks.Keys)
  16245. {
  16246. if (doc.Range.Bookmarks[item] != null)
  16247. {
  16248. Bookmark mark = doc.Range.Bookmarks[item];
  16249. mark.Text = marks[item];
  16250. }
  16251. }
  16252. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16253. doc.Save(savePaht);
  16254. var jw = new JsonView();
  16255. jw.Msg = "生成成功!";
  16256. jw.Code = 200;
  16257. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16258. return Ok(jw);
  16259. }
  16260. /// <summary>
  16261. /// 详细报价费用Excel下载
  16262. /// </summary>
  16263. /// <param name="dto"></param>
  16264. /// <returns></returns>
  16265. [HttpPost]
  16266. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16267. {
  16268. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16269. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16270. if (di == null)
  16271. {
  16272. return Ok(JsonView(false, "团组不存在!"));
  16273. }
  16274. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16275. if (mainPrice == null || mainPrice.IsShare == 0)
  16276. {
  16277. return Ok(JsonView(false, "团组成本不存在!"));
  16278. }
  16279. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16280. .FirstAsync(x=>x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16281. if (costTypeHotelNumbers == null)
  16282. {
  16283. return Ok(JsonView(false, "团组成本不存在!"));
  16284. }
  16285. WorkbookDesigner designer = new WorkbookDesigner();
  16286. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16287. List<int> hideRowsList = new List<int>();
  16288. int conterStartIndex = 3;
  16289. int rowIndex = conterStartIndex;
  16290. designer.SetDataSource("GroupName", di.TeamName);
  16291. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16292. {
  16293. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16294. ("BXRS", "BXCB", "BXXS", "bx"),
  16295. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16296. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16297. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16298. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16299. ("CPRS", "CPCB", "CPXS", "cp") ,
  16300. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16301. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16302. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16303. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16304. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16305. ("DJRS", "DJCB", "DJXS", "dj") ,
  16306. ("GWRS", "GWCB", "GWXS", "gw") ,
  16307. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16308. };
  16309. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16310. var rightSum = 0.00M;
  16311. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16312. {
  16313. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16314. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16315. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16316. if (prefix == "tbr")
  16317. {
  16318. rsValue *= 2;
  16319. cbValue /= 2;
  16320. }
  16321. if (OtherCostPropertyBJ.Contains(prefix))
  16322. {
  16323. rightSum += cbValue * xsValue;
  16324. }
  16325. if (rsValue == 0)
  16326. {
  16327. hideRowsList.Add(rowIndex);
  16328. }
  16329. else
  16330. {
  16331. designer.SetDataSource($"{prefix}rs", rsValue);
  16332. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16333. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16334. }
  16335. rowIndex += 2;
  16336. }
  16337. var hotelRooms = new Dictionary<string, int>
  16338. {
  16339. { "SGR", costTypeHotelNumbers.SGR },
  16340. { "TBR", costTypeHotelNumbers.TBR },
  16341. { "JSES", costTypeHotelNumbers.JSES },
  16342. { "SUITE", costTypeHotelNumbers.SUITE }
  16343. };
  16344. var flights = new Dictionary<string, int>
  16345. {
  16346. { "经济舱", mainPrice.JJCRS },
  16347. { "公务舱", mainPrice.GWCRS },
  16348. { "头等舱", mainPrice.TDCRS }
  16349. };
  16350. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16351. {
  16352. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16353. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16354. { "头等舱", new[] { "SUITE", "JSES" } }
  16355. };
  16356. var result = new Dictionary<string, int>();
  16357. foreach (var flight in flights.Keys)
  16358. {
  16359. // 获取当前舱位的匹配规则
  16360. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16361. {
  16362. MatchRooms(ref hotelRooms,ref flights, roomTypes, flight,ref result);
  16363. }
  16364. }
  16365. var allPrice = 0.00M;
  16366. #region right计算
  16367. int airRowIndex = 35;
  16368. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16369. {
  16370. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16371. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16372. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16373. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16374. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16375. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16376. }
  16377. else
  16378. {
  16379. hideRowsList.Add(airRowIndex);
  16380. }
  16381. airRowIndex += 2;
  16382. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16383. {
  16384. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16385. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16386. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16387. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16388. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16389. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16390. }
  16391. else
  16392. {
  16393. hideRowsList.Add(airRowIndex);
  16394. }
  16395. airRowIndex += 2;
  16396. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16397. {
  16398. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16399. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16400. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16401. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16402. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16403. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16404. }
  16405. else
  16406. {
  16407. hideRowsList.Add(airRowIndex);
  16408. }
  16409. airRowIndex += 2;
  16410. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16411. {
  16412. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16413. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16414. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16415. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16416. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16417. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16418. }
  16419. else
  16420. {
  16421. hideRowsList.Add(airRowIndex);
  16422. }
  16423. airRowIndex += 2;
  16424. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16425. {
  16426. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16427. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16428. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16429. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16430. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16431. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16432. }
  16433. else
  16434. {
  16435. hideRowsList.Add(airRowIndex);
  16436. }
  16437. airRowIndex += 2;
  16438. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16439. {
  16440. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16441. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16442. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16443. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16444. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16445. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16446. }
  16447. else
  16448. {
  16449. hideRowsList.Add(airRowIndex);
  16450. }
  16451. airRowIndex += 2;
  16452. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16453. {
  16454. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16455. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16456. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16457. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16458. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16459. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16460. }
  16461. else
  16462. {
  16463. hideRowsList.Add(airRowIndex);
  16464. }
  16465. airRowIndex += 2;
  16466. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16467. {
  16468. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16469. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16470. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16471. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16472. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16473. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16474. }
  16475. else
  16476. {
  16477. hideRowsList.Add(airRowIndex);
  16478. }
  16479. airRowIndex += 2;
  16480. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16481. {
  16482. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16483. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16484. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16485. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16486. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16487. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16488. }
  16489. else
  16490. {
  16491. hideRowsList.Add(airRowIndex);
  16492. }
  16493. #endregion
  16494. designer.SetDataSource("AllPrice","总金额:" + allPrice.ToString("#0.00"));
  16495. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName +"_详细报批费用.xls";
  16496. var ws = designer.Workbook.Worksheets[0];
  16497. foreach (var Rowindex in hideRowsList)
  16498. {
  16499. ws.Cells.HideRows(Rowindex, 2);
  16500. }
  16501. designer.Process();
  16502. designer.Workbook.Save(savePaht);
  16503. return Ok(JsonView(true, "生成成功!", new
  16504. {
  16505. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16506. }));
  16507. }
  16508. private void MatchRooms(ref Dictionary<string, int> hotelRooms,ref Dictionary<string, int> flights, string[] roomTypes, string flightType,ref Dictionary<string, int> result)
  16509. {
  16510. foreach (var roomType in roomTypes)
  16511. {
  16512. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16513. {
  16514. hotelRooms[roomType]--;
  16515. flights[flightType]--;
  16516. if (roomType == "TBR")
  16517. {
  16518. flights[flightType]--; // 双人间在减少1
  16519. }
  16520. string key = flightType + roomType;
  16521. if (result.Keys.Contains(key))
  16522. {
  16523. result[key]++;
  16524. }
  16525. else
  16526. {
  16527. result.Add(key, 1);
  16528. }
  16529. }
  16530. }
  16531. }
  16532. private class AirHotelPrice
  16533. {
  16534. public string Name { get; set; }
  16535. public decimal Price { get; set; }
  16536. public int Count { get; set; }
  16537. }
  16538. #endregion
  16539. #region 酒店预订 New 2023-12-28 17:45
  16540. /// <summary>
  16541. /// 酒店预订
  16542. /// 酒店费用列表 根据团组Id查询
  16543. /// </summary>
  16544. /// <param name="_dto"></param>
  16545. /// <returns></returns>
  16546. [HttpPost]
  16547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16548. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16549. {
  16550. #region 参数验证
  16551. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16552. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16553. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16554. #region 团组操作权限验证 76 酒店预定模块
  16555. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16556. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16557. #endregion
  16558. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16559. #region 页面操作权限验证
  16560. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16561. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16562. #endregion
  16563. #endregion
  16564. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16565. }
  16566. /// <summary>
  16567. /// 酒店预订
  16568. /// 基础数据
  16569. /// </summary>
  16570. /// <param name="_dto"></param>
  16571. /// <returns></returns>
  16572. [HttpPost]
  16573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16574. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16575. {
  16576. #region 参数验证
  16577. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16578. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16579. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16580. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16581. #region 页面操作权限验证
  16582. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16583. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16584. #endregion
  16585. #region 团组操作权限验证 76 酒店预定模块
  16586. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16587. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16588. #endregion
  16589. #endregion
  16590. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16591. }
  16592. /// <summary>
  16593. /// 酒店预订
  16594. /// 创建 入住卷号码
  16595. /// </summary>
  16596. /// <param name="_dto"></param>
  16597. /// <returns></returns>
  16598. [HttpPost]
  16599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16600. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16601. {
  16602. #region 参数验证
  16603. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16604. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16605. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16606. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16607. #region 页面操作权限验证
  16608. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16609. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16610. #endregion
  16611. #region 团组操作权限验证 76 酒店预定模块
  16612. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16613. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16614. #endregion
  16615. #endregion
  16616. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16617. if (data.Code != 0)
  16618. {
  16619. return Ok(JsonView(false, data.Msg));
  16620. }
  16621. return Ok(JsonView(true, data.Msg, data.Data));
  16622. }
  16623. /// <summary>
  16624. /// 酒店预订
  16625. /// 详情
  16626. /// </summary>
  16627. /// <param name="_dto"></param>
  16628. /// <returns></returns>
  16629. [HttpPost]
  16630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16631. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16632. {
  16633. #region 参数验证
  16634. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16635. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16636. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16637. #region 团组操作权限验证 76 酒店预定模块
  16638. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16639. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16640. #endregion
  16641. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16642. #region 页面操作权限验证
  16643. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16644. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16645. #endregion
  16646. #endregion
  16647. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16648. }
  16649. /// <summary>
  16650. /// 酒店预订
  16651. /// Add Or Edit
  16652. /// </summary>
  16653. /// <param name="_dto"></param>
  16654. /// <returns></returns>
  16655. [HttpPost]
  16656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16657. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16658. {
  16659. #region 参数验证
  16660. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16661. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16662. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16663. #region 团组操作权限验证 76 酒店预定模块
  16664. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16665. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16666. #endregion
  16667. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16668. #region 页面操作权限验证
  16669. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16670. if (_dto.Id == 0) // Add
  16671. {
  16672. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16673. }
  16674. else if (_dto.Id > 1) // Edit
  16675. {
  16676. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16677. }
  16678. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16679. #endregion
  16680. #endregion
  16681. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16682. if (_view.Code != 200)
  16683. {
  16684. return Ok(_view);
  16685. }
  16686. #region 成本无酒店价格数据进入超支
  16687. _sqlSugar.BeginTran();
  16688. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16689. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16690. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16691. for (int i = 0; i < groupCost.Count; i++)
  16692. {
  16693. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16694. {
  16695. groupCost[i].Date = groupCost[i - 1].Date;
  16696. }
  16697. }
  16698. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16699. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16700. List<Fin_GroupExtraCostDto_OP>();
  16701. if (start_Bool && end_Bool)
  16702. {
  16703. while (start_Time < end_Time)
  16704. {
  16705. foreach (var item in groupCost_Grp)
  16706. {
  16707. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16708. {
  16709. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16710. {
  16711. extraCostList.Add(new
  16712. Fin_GroupExtraCostDto_OP
  16713. {
  16714. Area = _dto.AreaId,
  16715. coefficient = 1.5M,
  16716. createUser = _dto.UserId,
  16717. currency = _dto.CardPriceCurrency,
  16718. diId = _dto.DiId,
  16719. ManagerConfirm = 0,
  16720. SupervisorConfirm = 0,
  16721. SYsupervisorConfirm = 0,
  16722. editType = 1,
  16723. PortType = 1,
  16724. price = _dto.CardPrice,
  16725. PriceCount = 1,
  16726. priceType = 1027,
  16727. priceDetailType = 1044,
  16728. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16729. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16730. });
  16731. }
  16732. }
  16733. }
  16734. start_Time = start_Time.AddDays(1);
  16735. }
  16736. }
  16737. if (extraCostList.Any())
  16738. {
  16739. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16740. }
  16741. _sqlSugar.CommitTran();
  16742. #endregion
  16743. #region 应用推送
  16744. try
  16745. {
  16746. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16747. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16748. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16749. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16750. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16751. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16752. var diId = _dto.DiId;
  16753. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16754. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16755. #region 操作记录
  16756. var opInfo = new Crm_TableOperationRecord()
  16757. {
  16758. TableName = "Grp_HotelReservations",
  16759. PortType = _dto.PortType,
  16760. DataId = hotelId,
  16761. CreateUserId = _dto.UserId
  16762. };
  16763. //var opStatus = OperationEnum.NoOperation;
  16764. if (_dto.Id < 1) //添加操作
  16765. {
  16766. opInfo.OperationItem = OperationEnum.Add;
  16767. }
  16768. else if (_dto.Id > 0)
  16769. {
  16770. opInfo.OperationItem = OperationEnum.Edit;
  16771. }
  16772. string opRemark = string.Empty;
  16773. if (ccpInfo != null)
  16774. {
  16775. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16776. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16777. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16778. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16779. }
  16780. opInfo.Remark = opRemark;
  16781. await _tableorRep.AddAsync(opInfo);
  16782. #endregion
  16783. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16784. //2024-10-21 新增LZ UID
  16785. var userIds = new List<int>() { 21 };
  16786. string title = $"费用审核";
  16787. string content = "";
  16788. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16789. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16790. try
  16791. {
  16792. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  16793. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  16794. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  16795. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  16796. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  16797. }
  16798. catch (Exception ex)
  16799. {
  16800. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  16801. }
  16802. }
  16803. catch (Exception ex)
  16804. {
  16805. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  16806. }
  16807. try
  16808. {
  16809. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16810. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16811. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16812. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16813. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16814. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16815. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16816. //自动审核
  16817. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  16818. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  16819. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  16820. //2024-10-21 新增LZ UID
  16821. var userIds = new List<int>() { 21 };
  16822. string title = $"系统通知";
  16823. var diId = _dto.DiId;
  16824. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16825. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16826. string content = "";
  16827. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16828. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16829. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16830. }
  16831. catch (Exception ex)
  16832. {
  16833. }
  16834. #endregion
  16835. return Ok(_view);
  16836. }
  16837. /// <summary>
  16838. /// 酒店自动审核测试
  16839. /// Add Or Edit
  16840. /// </summary>
  16841. /// <param name="diid"></param>
  16842. /// <param name="dataId"></param>
  16843. /// <returns></returns>
  16844. [HttpPost]
  16845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16846. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  16847. {
  16848. #region 应用推送
  16849. try
  16850. {
  16851. //自动审核
  16852. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  16853. }
  16854. catch (Exception ex)
  16855. {
  16856. return Ok(JsonView(false, "操作失败"));
  16857. }
  16858. #endregion
  16859. return Ok(JsonView(false, "操作成功"));
  16860. }
  16861. /// <summary>
  16862. /// 酒店预订
  16863. /// Del
  16864. /// </summary>
  16865. /// <param name="_dto"></param>
  16866. /// <returns></returns>
  16867. [HttpPost]
  16868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16869. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  16870. {
  16871. #region 参数验证
  16872. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16873. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16874. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16875. #region 团组操作权限验证 76 酒店预定模块
  16876. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16877. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16878. #endregion
  16879. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16880. #region 页面操作权限验证
  16881. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16882. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16883. #endregion
  16884. #endregion
  16885. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  16886. #region 操作记录
  16887. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  16888. {
  16889. TableName = "Grp_HotelReservations",
  16890. PortType = _dto.PortType,
  16891. OperationItem = OperationEnum.Del,
  16892. DataId = _dto.Id,
  16893. CreateUserId = _dto.UserId
  16894. });
  16895. #endregion
  16896. return Ok(data);
  16897. }
  16898. /// <summary>
  16899. /// 酒店预订
  16900. /// 生成VOUCHER
  16901. /// 2024.05.06 之前版本
  16902. /// </summary>
  16903. /// <param name="_dto"></param>
  16904. /// <returns></returns>
  16905. [HttpPost]
  16906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16907. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  16908. {
  16909. try
  16910. {
  16911. #region 参数验证
  16912. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16913. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16914. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16915. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  16916. #region 团组操作权限验证 76 酒店预定模块
  16917. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16918. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16919. #endregion
  16920. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16921. #region 页面操作权限验证
  16922. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16923. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16924. #endregion
  16925. #endregion
  16926. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  16927. //判断数据是否完整
  16928. if (hr != null)
  16929. {
  16930. if (!string.IsNullOrEmpty(hr.DetermineNo))
  16931. {
  16932. string strFileName = "HotelStatement/";
  16933. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16934. if (dele != null)
  16935. strFileName += dele.TourCode;
  16936. //载入模板
  16937. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  16938. Document doc = new Document(sss);
  16939. DocumentBuilder builder = new DocumentBuilder(doc);
  16940. #region 替换Word模板书签内容
  16941. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  16942. //入住卷预定号码
  16943. if (doc.Range.Bookmarks["VNO"] != null)
  16944. {
  16945. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16946. mark.Text = hr.CheckNumber;
  16947. }
  16948. //酒店时间
  16949. if (doc.Range.Bookmarks["Date"] != null)
  16950. {
  16951. Bookmark mark = doc.Range.Bookmarks["Date"];
  16952. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16953. }
  16954. //团号
  16955. if (doc.Range.Bookmarks["TNo"] != null)
  16956. {
  16957. Bookmark mark = doc.Range.Bookmarks["TNo"];
  16958. mark.Text = dele.TourCode;
  16959. }
  16960. //预定号码
  16961. if (doc.Range.Bookmarks["BookingId"] != null)
  16962. {
  16963. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  16964. mark.Text = hr.ReservationsNo;
  16965. }
  16966. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  16967. {
  16968. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  16969. mark.Text = hr.DetermineNo;
  16970. }
  16971. //酒店城市
  16972. if (doc.Range.Bookmarks["City"] != null)
  16973. {
  16974. Bookmark mark = doc.Range.Bookmarks["City"];
  16975. mark.Text = hr.City;
  16976. }
  16977. //酒店名称
  16978. if (doc.Range.Bookmarks["HName"] != null)
  16979. {
  16980. Bookmark mark = doc.Range.Bookmarks["HName"];
  16981. mark.Text = hr.HotelName;
  16982. }
  16983. //酒店地址
  16984. if (doc.Range.Bookmarks["Address"] != null)
  16985. {
  16986. Bookmark mark = doc.Range.Bookmarks["Address"];
  16987. mark.Text = hr.HotelAddress;
  16988. }
  16989. //酒店电话
  16990. if (doc.Range.Bookmarks["Tel"] != null)
  16991. {
  16992. Bookmark mark = doc.Range.Bookmarks["Tel"];
  16993. mark.Text = hr.HotelTel;
  16994. }
  16995. //酒店传真
  16996. if (doc.Range.Bookmarks["Fax"] != null)
  16997. {
  16998. Bookmark mark = doc.Range.Bookmarks["Fax"];
  16999. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17000. {
  17001. mark.Text = hr.HotelFax;
  17002. }
  17003. }
  17004. //入住时间
  17005. if (doc.Range.Bookmarks["CIn"] != null)
  17006. {
  17007. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17008. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17009. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17010. }
  17011. //退房时间
  17012. if (doc.Range.Bookmarks["COut"] != null)
  17013. {
  17014. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17015. Bookmark mark = doc.Range.Bookmarks["COut"];
  17016. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17017. }
  17018. //客户名称
  17019. if (doc.Range.Bookmarks["GName"] != null)
  17020. {
  17021. string guestName = "";
  17022. string[] clients = new string[] { };
  17023. if (hr.GuestName.Contains(","))
  17024. {
  17025. clients = hr.GuestName.Split(",");
  17026. }
  17027. else
  17028. {
  17029. clients = new string[] { hr.GuestName };
  17030. }
  17031. List<int> clientIds_int = new List<int>();
  17032. if (clients.Length > 0)
  17033. {
  17034. foreach (var item in clients)
  17035. {
  17036. if (item.IsNumeric())
  17037. {
  17038. clientIds_int.Add(int.Parse(item));
  17039. }
  17040. }
  17041. }
  17042. if (clientIds_int.Count > 0)
  17043. {
  17044. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17045. foreach (var client in _clientDatas)
  17046. {
  17047. //男
  17048. if (client.Sex == 0) guestName += $"Mr.";
  17049. //女
  17050. else if (client.Sex == 1) guestName += $"Ms.";
  17051. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17052. {
  17053. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17054. }
  17055. //guestName += $"{client.Pinyin},";
  17056. }
  17057. if (guestName.Length > 0)
  17058. {
  17059. guestName = guestName.Substring(0, guestName.Length - 1);
  17060. }
  17061. }
  17062. else
  17063. {
  17064. guestName = hr.GuestName;
  17065. }
  17066. Bookmark mark = doc.Range.Bookmarks["GName"];
  17067. mark.Text = guestName;
  17068. }
  17069. //房间介绍
  17070. if (doc.Range.Bookmarks["ROOM"] != null)
  17071. {
  17072. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17073. mark.Text = hr.RoomExplanation;
  17074. }
  17075. //报价描述
  17076. if (doc.Range.Bookmarks["NOTE"] != null)
  17077. {
  17078. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17079. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17080. if (ss != null)
  17081. mark.Text = ss.Name;
  17082. }
  17083. //入住时间
  17084. if (doc.Range.Bookmarks["CheckIn"] != null)
  17085. {
  17086. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17087. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17088. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17089. }
  17090. //退房时间
  17091. if (doc.Range.Bookmarks["CheckOut"] != null)
  17092. {
  17093. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17094. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17095. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17096. }
  17097. //日期
  17098. if (doc.Range.Bookmarks["DT"] != null)
  17099. {
  17100. Bookmark mark = doc.Range.Bookmarks["DT"];
  17101. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17102. }
  17103. //名称
  17104. if (doc.Range.Bookmarks["VName"] != null)
  17105. {
  17106. Bookmark mark = doc.Range.Bookmarks["VName"];
  17107. mark.Text = hr.HotelName;
  17108. }
  17109. //号码
  17110. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17111. {
  17112. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17113. mark.Text = hr.CheckNumber;
  17114. }
  17115. #endregion
  17116. strFileName += "VOUCHER.doc";
  17117. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17118. doc.Save(fileDir);
  17119. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17120. return Ok(JsonView(true, "操作成功!", Url));
  17121. }
  17122. else
  17123. {
  17124. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17125. }
  17126. }
  17127. else
  17128. {
  17129. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17130. }
  17131. }
  17132. catch (Exception ex)
  17133. {
  17134. return Ok(JsonView(false, ex.Message));
  17135. }
  17136. }
  17137. /// <summary>
  17138. /// 酒店预订
  17139. /// 生成VOUCHER
  17140. /// 2024.05.06 之后版本
  17141. /// </summary>
  17142. /// <param name="_dto"></param>
  17143. /// <returns></returns>
  17144. [HttpPost]
  17145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17146. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17147. {
  17148. #region 参数验证
  17149. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17150. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17151. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17152. #region 团组操作权限验证 76 酒店预定模块
  17153. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17154. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17155. #endregion
  17156. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17157. #region 页面操作权限验证
  17158. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17159. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17160. #endregion
  17161. #endregion
  17162. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17163. //判断数据是否完整
  17164. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17165. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17166. string strFileName = "HotelStatement/";
  17167. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17168. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17169. #region 数据处理
  17170. List<int> guestIds = new List<int>();
  17171. //int index = 0;
  17172. foreach (var item in hrDtas)
  17173. {
  17174. if (item.GuestName.Contains(","))
  17175. {
  17176. string[] guestIdArr = item.GuestName.Split(',');
  17177. foreach (var guestIdStr in guestIdArr)
  17178. {
  17179. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17180. if (guestBool)
  17181. {
  17182. guestIds.Add(guestId);
  17183. }
  17184. }
  17185. }
  17186. else guestNames += item.GuestName;
  17187. var voucherInfo = new HotelVoucherInfoView()
  17188. {
  17189. HotelName = item.HotelName,
  17190. CheckInDate = item.CheckInDate,
  17191. CheckOutDate = item.CheckOutDate,
  17192. ConfirmationNumber = item.DetermineNo.Trim(),
  17193. RoomType = item.RoomExplanation
  17194. };
  17195. vouchers.Add(voucherInfo);
  17196. }
  17197. if (guestIds.Count > 0)
  17198. {
  17199. guestIds = guestIds.Distinct().ToList();
  17200. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17201. if (guestDatas.Count > 0)
  17202. {
  17203. guestNames = "";
  17204. foreach (var guest in guestDatas)
  17205. {
  17206. string guestName = "";
  17207. if (guest.Sex == 0) guestName += @"MR.";
  17208. else if (guest.Sex == 1) guestName += @"MS.";
  17209. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17210. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17211. guestNames += @$"{guestName.Trim()}、";
  17212. }
  17213. if (guestNames.Length > 0)
  17214. {
  17215. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17216. }
  17217. }
  17218. }
  17219. #endregion
  17220. //载入模板
  17221. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17222. Document doc = new Document(sss);
  17223. DocumentBuilder builder = new DocumentBuilder(doc);
  17224. if (doc.Range.Bookmarks["GuestName"] != null)
  17225. {
  17226. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17227. mark.Text = guestNames;
  17228. }
  17229. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17230. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17231. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17232. for (int i = 1; i <= vouchers.Count; i++)
  17233. {
  17234. HotelVoucherInfoView hviv = vouchers[i - 1];
  17235. builder.MoveToCell(0, i, 0, 0);
  17236. builder.Write(hviv.HotelName);
  17237. builder.MoveToCell(0, i, 1, 0);
  17238. builder.Write(hviv.CheckInDate);
  17239. builder.MoveToCell(0, i, 2, 0);
  17240. builder.Write(hviv.CheckOutDate);
  17241. builder.MoveToCell(0, i, 3, 0);
  17242. builder.Write(hviv.RoomType);
  17243. builder.MoveToCell(0, i, 4, 0);
  17244. builder.Write(hviv.ConfirmationNumber);
  17245. }
  17246. //删除多余行
  17247. int currRowIndex = vouchers.Count + 1;
  17248. int delRows = 21 - currRowIndex;
  17249. if (delRows > 0)
  17250. {
  17251. for (int i = 0; i < delRows; i++)
  17252. {
  17253. table.Rows.RemoveAt(currRowIndex);
  17254. //cultivateRowIndex++;
  17255. }
  17256. }
  17257. strFileName += "VOUCHER.docx";
  17258. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17259. doc.Save(fileDir);
  17260. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17261. return Ok(JsonView(true, "操作成功!", Url));
  17262. }
  17263. /// <summary>
  17264. /// 酒店预订
  17265. /// 生成VOUCHER 批量生成
  17266. /// New
  17267. /// </summary>
  17268. /// <param name="_dto"></param>
  17269. /// <returns></returns>
  17270. [HttpPost]
  17271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17272. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17273. {
  17274. #region 参数验证
  17275. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17276. if (_dto.PageId < 1) _dto.PageId = 28;
  17277. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17278. #region 团组操作权限验证 76 酒店预定模块
  17279. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17280. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17281. #endregion
  17282. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17283. #region 页面操作权限验证
  17284. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17285. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17286. #endregion
  17287. #endregion
  17288. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17289. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17290. .OrderBy(x => x.CheckInDate)
  17291. .ToListAsync();
  17292. //判断数据是否完整
  17293. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17294. string strFileName = "HotelStatement/";
  17295. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17296. if (dele != null)
  17297. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17298. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17299. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17300. .Where(it => it.IsDel == 0)
  17301. .ToListAsync();
  17302. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17303. for (int i = 0; i < hrDtas.Count; i++)
  17304. {
  17305. string guestNames = string.Empty;
  17306. List<int> guestIds = new List<int>();
  17307. var item = hrDtas[i];
  17308. //处理客户姓名
  17309. if (item.GuestName.Contains(","))
  17310. {
  17311. string[] guestIdArr = item.GuestName.Split(',');
  17312. foreach (var guestIdStr in guestIdArr)
  17313. if (int.TryParse(guestIdStr, out int guestId))
  17314. guestIds.Add(guestId);
  17315. }
  17316. else
  17317. {
  17318. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17319. if (guestIdBool)
  17320. {
  17321. guestIds.Add(guestId);
  17322. }
  17323. //NaN
  17324. if (item.GuestName.Contains("NaN"))
  17325. {
  17326. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17327. }
  17328. }
  17329. if (guestIds.Count > 0)
  17330. {
  17331. guestIds = guestIds.Distinct().ToList();
  17332. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17333. if (guestDatas1.Count > 0)
  17334. {
  17335. guestNames = "";
  17336. foreach (var guest in guestDatas1)
  17337. {
  17338. string guestName = "";
  17339. if (guest.Sex == 0) guestName += @"MR.";
  17340. else if (guest.Sex == 1) guestName += @"MS.";
  17341. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17342. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17343. guestNames += @$"{guestName.Trim()}、";
  17344. }
  17345. if (guestNames.Length > 0)
  17346. {
  17347. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17348. }
  17349. }
  17350. }
  17351. //if (!string.IsNullOrEmpty(guestNames))
  17352. //{
  17353. hrDtas[i].GuestName = guestNames;
  17354. //}
  17355. }
  17356. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17357. Document doc = new Document();
  17358. DocumentBuilder builder = new DocumentBuilder(doc);
  17359. try
  17360. {
  17361. builder.MoveToDocumentStart();
  17362. foreach (var item in hrDtas)
  17363. {
  17364. //标题
  17365. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17366. builder.ParagraphFormat.LineSpacing = 1;
  17367. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17368. builder.ParagraphFormat.Style.Font.Size = 9;
  17369. builder.ParagraphFormat.Style.Font.Bold = true;
  17370. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17371. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17372. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17373. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17374. builder.ParagraphFormat.LineSpacing = 1;
  17375. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17376. builder.ParagraphFormat.Style.Font.Size = 9;
  17377. builder.ParagraphFormat.Style.Font.Bold = true;
  17378. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17379. builder.StartTable();
  17380. // 设置边框颜色
  17381. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17382. //设置边框样式
  17383. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17384. //表格
  17385. #region 第一行
  17386. builder.InsertCell();
  17387. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17388. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17389. //builder.CellFormat.AllowAutoFit = false;
  17390. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17391. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17392. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17393. builder.CellFormat.WrapText = true; //自动换行
  17394. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17395. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17396. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17397. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17398. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17399. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17400. builder.Write("TOUR NO:");
  17401. builder.InsertCell();
  17402. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17403. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17404. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17405. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17406. builder.ParagraphFormat.Style.Font.Bold = false;
  17407. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17408. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17409. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17410. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17411. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17412. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17413. builder.Write($"{dele?.TourCode ?? "-"}");
  17414. builder.InsertCell();
  17415. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17416. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17417. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17418. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17419. builder.ParagraphFormat.Style.Font.Bold = false;
  17420. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17421. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17422. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17423. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17424. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17425. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17426. builder.Write($"CITY:");
  17427. builder.InsertCell();
  17428. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17429. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17430. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17431. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17432. builder.ParagraphFormat.Style.Font.Bold = false;
  17433. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17434. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17435. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17436. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17437. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17438. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17439. builder.Write($"{item.City}");
  17440. builder.EndRow();
  17441. #endregion
  17442. #region 第二行
  17443. builder.InsertCell();
  17444. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17445. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17446. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17447. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17448. builder.ParagraphFormat.Style.Font.Bold = false;
  17449. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17450. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17451. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17452. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17453. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17454. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17455. builder.Write("CONFIRMATION NO:");
  17456. builder.InsertCell();
  17457. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17458. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17459. builder.ParagraphFormat.Style.Font.Size = 8;
  17460. builder.ParagraphFormat.Style.Font.Bold = false;
  17461. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17462. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17463. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17464. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17465. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17466. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17467. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17468. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17469. builder.Write($"{item.DetermineNo}");
  17470. builder.InsertCell();
  17471. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17472. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17473. builder.InsertCell();
  17474. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17475. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17476. builder.EndRow();
  17477. #endregion
  17478. #region 第三行
  17479. builder.InsertCell();
  17480. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17481. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17482. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17483. builder.ParagraphFormat.Style.Font.Bold = false;
  17484. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17485. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17486. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17487. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17488. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17489. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17490. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17491. builder.Write($"HOTEL NAME:");
  17492. builder.InsertCell();
  17493. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17494. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17495. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17496. builder.ParagraphFormat.Style.Font.Bold = false;
  17497. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17498. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17499. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17500. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17501. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17502. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17503. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17504. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17505. builder.Write($"{item.HotelName}");
  17506. builder.InsertCell();
  17507. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17508. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17509. builder.InsertCell();
  17510. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17511. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17512. builder.EndRow();
  17513. #endregion
  17514. #region 第四行
  17515. builder.InsertCell();
  17516. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17517. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17518. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17519. builder.ParagraphFormat.Style.Font.Bold = false;
  17520. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17521. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17522. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17523. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17524. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17525. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17526. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17527. builder.Write($"HOTEL ADDRESS:");
  17528. builder.InsertCell();
  17529. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17530. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17531. builder.ParagraphFormat.Style.Font.Size = 8;
  17532. builder.ParagraphFormat.Style.Font.Bold = false;
  17533. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17534. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17535. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17536. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17537. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17538. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17539. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17540. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17541. builder.Write($"{item.HotelAddress}");
  17542. builder.InsertCell();
  17543. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17544. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17545. builder.InsertCell();
  17546. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17547. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17548. builder.EndRow();
  17549. #endregion
  17550. #region 第五行
  17551. builder.InsertCell();
  17552. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17553. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17554. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17555. builder.ParagraphFormat.Style.Font.Bold = false;
  17556. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17557. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17558. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17559. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17560. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17561. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17562. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17563. builder.Write("TEL:");
  17564. builder.InsertCell();
  17565. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17566. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17567. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17568. builder.ParagraphFormat.Style.Font.Bold = false;
  17569. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17570. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17571. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17572. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17573. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17574. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17575. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17576. builder.Write($"{item.HotelTel}");
  17577. builder.InsertCell();
  17578. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17579. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17580. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17581. builder.ParagraphFormat.Style.Font.Bold = false;
  17582. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17583. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17584. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17585. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17586. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17587. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17588. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17589. builder.Write($"FAX:");
  17590. builder.InsertCell();
  17591. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17592. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17593. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17594. builder.ParagraphFormat.Style.Font.Bold = false;
  17595. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17596. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17597. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17598. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17599. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17600. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17601. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17602. builder.Write($"{item.HotelFax}");
  17603. builder.EndRow();
  17604. #endregion
  17605. #region 第六行
  17606. builder.InsertCell();
  17607. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17608. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17609. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17610. builder.ParagraphFormat.Style.Font.Bold = false;
  17611. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17612. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17613. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17614. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17615. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17616. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17617. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17618. builder.Write("CHECK IN:");
  17619. builder.InsertCell();
  17620. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17621. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17622. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17623. builder.ParagraphFormat.Style.Font.Bold = false;
  17624. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17625. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17626. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17627. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17628. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17629. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17630. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17631. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17632. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17633. builder.Write($"{checkInStr}");
  17634. builder.InsertCell();
  17635. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17636. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17637. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17638. builder.ParagraphFormat.Style.Font.Bold = false;
  17639. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17640. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17641. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17642. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17643. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17644. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17645. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17646. builder.Write($"CHECK OUT:");
  17647. builder.InsertCell();
  17648. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17649. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17650. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17651. builder.ParagraphFormat.Style.Font.Bold = false;
  17652. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17653. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17654. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17655. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17656. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17657. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17658. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17659. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17660. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17661. builder.Write($"{checkOutStr}");
  17662. builder.EndRow();
  17663. #endregion
  17664. #region 第七行
  17665. builder.InsertCell();
  17666. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17667. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17668. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17669. builder.ParagraphFormat.Style.Font.Bold = false;
  17670. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17671. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17672. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17673. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17674. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17675. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17676. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17677. builder.Write($"GUEST NAME:");
  17678. builder.InsertCell();
  17679. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17680. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17681. builder.ParagraphFormat.Style.Font.Size = 8;
  17682. builder.ParagraphFormat.Style.Font.Bold = false;
  17683. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17684. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17685. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17686. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17687. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17688. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17689. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17690. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17691. builder.Write($"{item.GuestName.Trim()}");
  17692. builder.InsertCell();
  17693. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17694. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17695. builder.InsertCell();
  17696. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17697. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17698. builder.EndRow();
  17699. #endregion
  17700. #region 第八行
  17701. builder.InsertCell();
  17702. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17703. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17704. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17705. builder.ParagraphFormat.Style.Font.Bold = false;
  17706. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17707. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17708. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17709. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17710. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17711. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17712. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17713. builder.Write($"ROOM TYPE:");
  17714. builder.InsertCell();
  17715. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17716. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17717. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17718. builder.ParagraphFormat.Style.Font.Bold = false;
  17719. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17720. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17721. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17722. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17723. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17724. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17725. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17726. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17727. builder.Write($"{item.RoomExplanation}");
  17728. builder.InsertCell();
  17729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17730. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17731. builder.InsertCell();
  17732. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17733. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17734. builder.EndRow();
  17735. #endregion
  17736. #region 第九行
  17737. builder.InsertCell();
  17738. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17739. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17740. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17741. builder.ParagraphFormat.Style.Font.Bold = false;
  17742. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17743. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17744. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17745. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17746. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17747. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17748. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17749. builder.Write($"NOTE:");
  17750. builder.InsertCell();
  17751. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17752. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17753. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17754. builder.ParagraphFormat.Style.Font.Bold = false;
  17755. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17756. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17757. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17758. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17759. 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.");
  17760. builder.InsertCell();
  17761. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17762. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17763. builder.InsertCell();
  17764. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17765. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17766. builder.EndRow();
  17767. #endregion
  17768. builder.EndTable();
  17769. //换行
  17770. builder.Writeln("");
  17771. builder.Writeln("");
  17772. }
  17773. #region 获取文档中的所有表格 设置文字自适应
  17774. // 获取文档中的所有表格。
  17775. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17776. {
  17777. // 遍历表格中的所有行。
  17778. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17779. {
  17780. foreach (Cell cell in row.Cells)
  17781. {
  17782. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17783. cellFormat.Width = 0;
  17784. }
  17785. }
  17786. }
  17787. #endregion
  17788. #region 设置页眉
  17789. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  17790. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  17791. if (System.IO.File.Exists(voucherHeaderPath))
  17792. {
  17793. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  17794. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  17795. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  17796. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  17797. // 调整图片位置
  17798. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  17799. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  17800. shape.Top = 50; // 将图片距离页眉上边缘的距离
  17801. shape.Left = 0; // 将图片距离页面左边缘的距离
  17802. shape.Width = 81; // 设置图片宽度
  17803. shape.Height = 36; // 设置图片高度
  17804. }
  17805. //靠右
  17806. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17807. //// 设置页脚上下边距
  17808. //builder.PageSetup.HeaderDistance = 42;
  17809. // 添加页眉线
  17810. Aspose.Words.Border borderHeader = null;
  17811. try
  17812. {
  17813. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  17814. }
  17815. catch (Exception e)
  17816. {
  17817. // TODO Auto-generated catch block
  17818. //e.printStackTrace();
  17819. }
  17820. borderHeader.Shadow = true;
  17821. borderHeader.DistanceFromText = 2;
  17822. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  17823. #endregion
  17824. }
  17825. catch (Exception ex)
  17826. {
  17827. }
  17828. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17829. doc.Save(fileDir);
  17830. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17831. return Ok(JsonView(true, "操作成功!", Url));
  17832. }
  17833. /// <summary>
  17834. /// 酒店预订
  17835. /// 生成 预定成本 Excel
  17836. /// </summary>
  17837. /// <param name="_dto"></param>
  17838. /// <returns></returns>
  17839. [HttpPost]
  17840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17841. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  17842. {
  17843. #region 参数验证
  17844. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  17845. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  17846. if (!vadalitorRes.IsValid)
  17847. {
  17848. var errors = new StringBuilder();
  17849. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  17850. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  17851. }
  17852. #region 团组操作权限验证 76 酒店预定模块
  17853. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17854. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17855. #endregion
  17856. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17857. #region 页面操作权限验证
  17858. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17859. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17860. #endregion
  17861. #endregion
  17862. decimal _rate = 1.00M;
  17863. string _currency = string.Empty;
  17864. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  17865. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17866. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  17867. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17868. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  17869. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  17870. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  17871. if (_GroupCostParameter == null)
  17872. {
  17873. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  17874. bool isIntType = int.TryParse(_currency, out int currId);
  17875. if (isIntType)
  17876. {
  17877. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17878. }
  17879. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17880. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17881. if (currInfo == null)
  17882. {
  17883. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17884. }
  17885. else _rate = currInfo.Rate;
  17886. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  17887. {
  17888. _rate = _GroupCostParameter.Rate;
  17889. }
  17890. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17891. //string strFileName = "HotelStatement/";
  17892. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17893. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17894. var rateDatas = new List<dynamic>();
  17895. #region 数据处理
  17896. foreach (var item in hrDtas)
  17897. {
  17898. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17899. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17900. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17901. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17902. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17903. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  17904. {
  17905. continue;
  17906. }
  17907. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17908. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  17909. string singleRoomFeeStr = string.Empty,
  17910. doubleRoomFeeStr = string.Empty,
  17911. suiteRoomFeeStr = string.Empty,
  17912. otherRoomFeeStr = string.Empty,
  17913. payMoneyStr = string.Empty,
  17914. cardPriceStr = string.Empty;
  17915. if (roomCurr.Equals("CNY"))
  17916. {
  17917. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  17918. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17919. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17920. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17921. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17922. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  17923. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  17924. }
  17925. else
  17926. {
  17927. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17928. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17929. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17930. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17931. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17932. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17933. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17934. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17935. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17936. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17937. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  17938. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  17939. if (ccpPaymentCurrency.Equals("CNY"))
  17940. {
  17941. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  17942. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17943. }
  17944. else
  17945. {
  17946. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17947. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17948. }
  17949. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17950. if (hotelcardPriceCurrency.Equals("CNY"))
  17951. {
  17952. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17953. }
  17954. else
  17955. {
  17956. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  17957. }
  17958. }
  17959. string breakfastPriceStr = string.Empty,
  17960. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17961. governmentRentStr = string.Empty,
  17962. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17963. cityTaxStr = string.Empty,
  17964. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17965. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  17966. if (!string.IsNullOrEmpty(breakfastCurrency1))
  17967. {
  17968. if (breakfastCurrency1.Equals("CNY"))
  17969. {
  17970. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17971. }
  17972. else
  17973. {
  17974. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  17975. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  17976. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  17977. }
  17978. }
  17979. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17980. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  17981. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  17982. {
  17983. if (governmentRentCurrency.Equals("CNY"))
  17984. {
  17985. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17986. }
  17987. else
  17988. {
  17989. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  17990. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  17991. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  17992. }
  17993. }
  17994. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17995. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  17996. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  17997. {
  17998. if (cityTaxStrCurrency1.Equals("CNY"))
  17999. {
  18000. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18001. }
  18002. else
  18003. {
  18004. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18005. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18006. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18007. }
  18008. }
  18009. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18010. int payDId = roomInfo?.PayDId ?? 0;
  18011. pcfds.Add(new HotelReservations_PCFD_View()
  18012. {
  18013. City = item.City,
  18014. HotelName = item.HotelName,
  18015. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18016. // SingleRoomCount = item.SingleRoomCount,
  18017. SingleRoomPrice = singleRoomFeeStr,
  18018. // DoubleRoomCount = item.DoubleRoomCount,
  18019. DoubleRoomPrice = doubleRoomFeeStr,
  18020. //SuiteRoomCount = item.SuiteRoomCount,
  18021. SuiteRoomPrice = suiteRoomFeeStr,
  18022. OtherRoomPrice = otherRoomFeeStr,
  18023. //OtherRoomCount = item.OtherRoomCount,
  18024. BreakfastPrice = breakfastPriceStr,
  18025. GovernmentRent = governmentRentStr,
  18026. CityTax = cityTaxStr,
  18027. RoomExplanation = item.RoomExplanation,
  18028. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18029. PayTime = roomInfo?.ConsumptionDate,
  18030. BankNo = roomInfo?.BankNo,
  18031. PayMoney = payMoneyStr,
  18032. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18033. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18034. CardPrice = cardPriceStr,
  18035. Remark = ccpInfo.Remark
  18036. });
  18037. }
  18038. #endregion
  18039. //载入模板
  18040. WorkbookDesigner designer = new WorkbookDesigner();
  18041. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18042. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18043. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18044. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18045. var rateDatas1 = rateDatas.Distinct();
  18046. var rateStr = string.Empty;
  18047. foreach (var item in rateDatas1)
  18048. {
  18049. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18050. }
  18051. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18052. designer.SetDataSource("Opertor", userInfo.CnName);
  18053. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18054. dt.TableName = "ViewMyHotelReservations";
  18055. designer.SetDataSource(dt);
  18056. designer.Process();
  18057. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18058. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18059. designer.Workbook.Save(serverPath);
  18060. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18061. #region 删除指定行
  18062. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18063. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18064. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18065. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18066. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18067. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18068. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18069. cssIndex = dt.Columns["CityTax"].Ordinal,
  18070. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18071. remarkIndex = dt.Columns["Remark"].Ordinal;
  18072. //删除指定列
  18073. foreach (DataRow item in dt.Rows)
  18074. {
  18075. string singleStr = item["SingleRoomPrice"].ToString();
  18076. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18077. if (containsDigitButNotZero1) singleDel = false;
  18078. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18079. string doubleStr = item["DoubleRoomPrice"].ToString();
  18080. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18081. if (containsDigitButNotZero2) doubleDel = false;
  18082. string suiteStr = item["SuiteRoomPrice"].ToString();
  18083. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18084. if (containsDigitButNotZero3) suiteDel = false;
  18085. string otherStr = item["OtherRoomPrice"].ToString();
  18086. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18087. if (containsDigitButNotZero4) otherDel = false;
  18088. string zcStr = item["BreakfastPrice"].ToString();
  18089. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18090. if (containsDigitButNotZero5) zcDel = false;
  18091. string dsStr = item["GovernmentRent"].ToString();
  18092. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18093. if (containsDigitButNotZero6) dsDel = false;
  18094. string cssStr = item["CityTax"].ToString();
  18095. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18096. if (containsDigitButNotZero7) cssDel = false;
  18097. string cpStr = item["ConsumptionPatterns"].ToString();
  18098. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18099. string remarkStr = item["Remark"].ToString();
  18100. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18101. }
  18102. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18103. DeleteColumn(serverPath, cpIndex, cpDel);
  18104. DeleteColumn(serverPath, dsIndex, dsDel);
  18105. DeleteColumn(serverPath, cssIndex, cssDel);
  18106. DeleteColumn(serverPath, zcIndex, zcDel);
  18107. DeleteColumn(serverPath, otherIndex, otherDel);
  18108. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18109. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18110. DeleteColumn(serverPath, singleIndex, singleDel);
  18111. #endregion
  18112. //只保留第一个表格
  18113. DeleteSheet(serverPath);
  18114. return Ok(JsonView(true, "操作成功", url = rst));
  18115. }
  18116. else
  18117. {
  18118. _currency = _GroupCostParameter.Currency;
  18119. bool isIntType = int.TryParse(_currency, out int currId);
  18120. if (isIntType)
  18121. {
  18122. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18123. }
  18124. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18125. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18126. if (currInfo == null)
  18127. {
  18128. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18129. }
  18130. if (!_currency.ToUpper().Equals("CNY"))
  18131. {
  18132. _rate = _GroupCostParameter.Rate;
  18133. }
  18134. _rate = currInfo.Rate;
  18135. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18136. //string strFileName = "HotelStatement/";
  18137. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18138. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18139. #region 数据处理
  18140. foreach (var item in hrDtas)
  18141. {
  18142. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18143. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18144. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18145. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18146. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18147. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18148. string singleRoomFeeStr = string.Empty,
  18149. doubleRoomFeeStr = string.Empty,
  18150. suiteRoomFeeStr = string.Empty,
  18151. otherRoomFeeStr = string.Empty,
  18152. payMoneyStr = string.Empty,
  18153. cardPriceStr = string.Empty;
  18154. if (roomCurr.Equals(_currency))
  18155. {
  18156. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18157. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18158. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18159. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18160. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18161. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18162. }
  18163. else
  18164. {
  18165. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18166. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18167. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18168. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18169. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18170. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18171. }
  18172. string breakfastPriceStr = string.Empty,
  18173. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18174. governmentRentStr = string.Empty,
  18175. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18176. cityTaxStrStr = string.Empty,
  18177. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18178. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18179. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18180. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18181. int payDId = roomInfo?.PayDId ?? 0;
  18182. pcfds.Add(new HotelReservations_PCFD_View()
  18183. {
  18184. City = item.City,
  18185. HotelName = item.HotelName,
  18186. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18187. // SingleRoomCount = item.SingleRoomCount,
  18188. SingleRoomPrice = singleRoomFeeStr,
  18189. // DoubleRoomCount = item.DoubleRoomCount,
  18190. DoubleRoomPrice = doubleRoomFeeStr,
  18191. //SuiteRoomCount = item.SuiteRoomCount,
  18192. SuiteRoomPrice = suiteRoomFeeStr,
  18193. OtherRoomPrice = otherRoomFeeStr,
  18194. //OtherRoomCount = item.OtherRoomCount,
  18195. BreakfastPrice = breakfastPriceStr,
  18196. GovernmentRent = governmentRentStr,
  18197. CityTax = cityTaxStrStr,
  18198. RoomExplanation = item.RoomExplanation,
  18199. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18200. PayTime = roomInfo?.ConsumptionDate,
  18201. BankNo = roomInfo?.BankNo,
  18202. PayMoney = payMoneyStr,
  18203. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18204. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18205. CardPrice = cardPriceStr,
  18206. Remark = ccpInfo.Remark
  18207. });
  18208. }
  18209. #endregion
  18210. //载入模板
  18211. WorkbookDesigner designer = new WorkbookDesigner();
  18212. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18213. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18214. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18215. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18216. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18217. designer.SetDataSource("Opertor", userInfo.CnName);
  18218. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18219. dt.TableName = "ViewMyHotelReservations";
  18220. designer.SetDataSource(dt);
  18221. designer.Process();
  18222. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18223. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18224. designer.Workbook.Save(serverPath);
  18225. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18226. #region 删除指定行
  18227. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18228. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18229. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18230. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18231. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18232. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18233. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18234. cssIndex = dt.Columns["CityTax"].Ordinal,
  18235. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18236. remarkIndex = dt.Columns["Remark"].Ordinal;
  18237. //删除指定列
  18238. foreach (DataRow item in dt.Rows)
  18239. {
  18240. string singleStr = item["SingleRoomPrice"].ToString();
  18241. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18242. if (containsDigitButNotZero1) singleDel = false;
  18243. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18244. string doubleStr = item["DoubleRoomPrice"].ToString();
  18245. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18246. if (containsDigitButNotZero2) doubleDel = false;
  18247. string suiteStr = item["SuiteRoomPrice"].ToString();
  18248. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18249. if (containsDigitButNotZero3) suiteDel = false;
  18250. string otherStr = item["OtherRoomPrice"].ToString();
  18251. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18252. if (containsDigitButNotZero4) otherDel = false;
  18253. string zcStr = item["BreakfastPrice"].ToString();
  18254. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18255. if (containsDigitButNotZero5) zcDel = false;
  18256. string dsStr = item["GovernmentRent"].ToString();
  18257. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18258. if (containsDigitButNotZero6) dsDel = false;
  18259. string cssStr = item["CityTax"].ToString();
  18260. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18261. if (containsDigitButNotZero7) cssDel = false;
  18262. string cpStr = item["ConsumptionPatterns"].ToString();
  18263. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18264. string remarkStr = item["Remark"].ToString();
  18265. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18266. }
  18267. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18268. DeleteColumn(serverPath, cpIndex, cpDel);
  18269. DeleteColumn(serverPath, dsIndex, dsDel);
  18270. DeleteColumn(serverPath, cssIndex, cssDel);
  18271. DeleteColumn(serverPath, zcIndex, zcDel);
  18272. DeleteColumn(serverPath, otherIndex, otherDel);
  18273. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18274. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18275. DeleteColumn(serverPath, singleIndex, singleDel);
  18276. #endregion
  18277. //只保留第一个表格
  18278. DeleteSheet(serverPath);
  18279. return Ok(JsonView(true, "操作成功", url = rst));
  18280. }
  18281. //return Ok(JsonView(false));
  18282. }
  18283. /// <summary>
  18284. /// 删除指定列
  18285. /// </summary>
  18286. /// <param name="file"></param>
  18287. /// <param name="columnIndex"></param>
  18288. /// <param name="isDel"></param>
  18289. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18290. {
  18291. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18292. //wb.Save(file);
  18293. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18294. if (sheet1 != null)
  18295. {
  18296. if (isDel)
  18297. {
  18298. Cells cells = sheet1.Cells;
  18299. cells.DeleteColumn(columnIndex);
  18300. }
  18301. }
  18302. wb.Save(file);
  18303. }
  18304. /// <summary>
  18305. /// 删除sheet
  18306. /// </summary>
  18307. /// <param name="file"></param>
  18308. /// <param name="sheetName"></param>
  18309. private void DeleteSheet(string file, string sheetName = "")
  18310. {
  18311. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18312. //wb.Save(file);
  18313. List<string> sheets = new List<string>();
  18314. foreach (var item in wb.Worksheets)
  18315. {
  18316. sheets.Add(item.Name);
  18317. }
  18318. if (sheets.Count > 0)
  18319. {
  18320. sheets.RemoveAt(0);//不删除第一个sheet
  18321. foreach (var item in sheets)
  18322. {
  18323. wb.Worksheets.RemoveAt(item);
  18324. }
  18325. }
  18326. wb.Save(file);
  18327. }
  18328. /// <summary>
  18329. /// 酒店预订
  18330. /// 确认单
  18331. /// </summary>
  18332. /// <param name="_dto"></param>
  18333. /// <returns></returns>
  18334. [HttpPost]
  18335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18336. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18337. {
  18338. try
  18339. {
  18340. #region 参数验证
  18341. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18342. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18343. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18344. #region 团组操作权限验证 76 酒店预定模块
  18345. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18346. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18347. #endregion
  18348. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18349. #region 页面操作权限验证
  18350. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18351. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18352. #endregion
  18353. #endregion
  18354. //团组信息
  18355. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18356. //酒店数据
  18357. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18358. if (listhoteldata.Count < 0)
  18359. {
  18360. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18361. }
  18362. //利datatable存储
  18363. DataTable dt = new DataTable();
  18364. dt.Columns.Add("CheckInDate", typeof(string));
  18365. dt.Columns.Add("City", typeof(string));
  18366. dt.Columns.Add("Hotel", typeof(string));
  18367. dt.Columns.Add("Room", typeof(string));
  18368. for (int i = 0; i < listhoteldata.Count; i++)
  18369. {
  18370. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18371. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18372. while (dayStart < dayEnd)
  18373. {
  18374. string temp = "";
  18375. DataRow row = dt.NewRow();
  18376. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18377. row["City"] = listhoteldata[i].City;
  18378. row["Hotel"] = listhoteldata[i].HotelName;
  18379. if (listhoteldata[i].SingleRoomCount > 0)
  18380. {
  18381. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18382. }
  18383. if (listhoteldata[i].DoubleRoomCount > 0)
  18384. {
  18385. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18386. }
  18387. if (listhoteldata[i].SuiteRoomCount > 0)
  18388. {
  18389. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18390. }
  18391. if (listhoteldata[i].OtherRoomCount > 0)
  18392. {
  18393. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18394. }
  18395. row["Room"] = temp;
  18396. dt.Rows.Add(row);
  18397. dayStart = dayStart.AddDays(1);
  18398. }
  18399. }
  18400. Dictionary<string, string> dic = new Dictionary<string, string>();
  18401. dic.Add("Dele", di.TeamName);
  18402. dic.Add("City", di.VisitCountry);
  18403. //模板路径
  18404. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18405. //载入模板
  18406. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18407. DocumentBuilder builder = new DocumentBuilder(doc);
  18408. foreach (var key in dic.Keys)
  18409. {
  18410. builder.MoveToBookmark(key);
  18411. builder.Write(dic[key]);
  18412. }
  18413. //获取word里所有表格
  18414. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18415. //获取所填表格的序数
  18416. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18417. var rowStart = tableOne.Rows[0]; //获取第1行
  18418. //循环赋值
  18419. for (int i = 0; i < dt.Rows.Count; i++)
  18420. {
  18421. builder.MoveToCell(0, i + 1, 0, 0);
  18422. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18423. builder.MoveToCell(0, i + 1, 1, 0);
  18424. builder.Write(dt.Rows[i]["City"].ToString());
  18425. builder.MoveToCell(0, i + 1, 2, 0);
  18426. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18427. builder.MoveToCell(0, i + 1, 3, 0);
  18428. builder.Write(dt.Rows[i]["Room"].ToString());
  18429. }
  18430. //删除多余行
  18431. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18432. {
  18433. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18434. }
  18435. string strFileName = di.TeamName + "酒店确认单.doc";
  18436. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18437. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18438. return Ok(JsonView(true, "成功", url));
  18439. }
  18440. catch (Exception ex)
  18441. {
  18442. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18443. }
  18444. }
  18445. #endregion
  18446. #region 团组状态
  18447. /// <summary>
  18448. /// 团组状态列表 Page
  18449. /// </summary>
  18450. /// <param name="dto">团组列表请求dto</param>
  18451. /// <returns></returns>
  18452. [HttpPost]
  18453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18454. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18455. {
  18456. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18457. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18458. {
  18459. string sqlWhere = string.Empty;
  18460. if (dto.IsSure == 0) //未完成
  18461. {
  18462. sqlWhere += string.Format(@" And IsSure = 0");
  18463. }
  18464. else if (dto.IsSure == 1) //已完成
  18465. {
  18466. sqlWhere += string.Format(@" And IsSure = 1");
  18467. }
  18468. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18469. {
  18470. string tj = dto.SearchCriteria;
  18471. 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}%')",
  18472. tj, tj, tj, tj, tj);
  18473. }
  18474. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18475. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18476. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18477. From (
  18478. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18479. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18480. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18481. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18482. From Grp_DelegationInfo gdi
  18483. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18484. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18485. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18486. Where gdi.IsDel = 0 {0}
  18487. ) temp ", sqlWhere);
  18488. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18489. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18490. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18491. }
  18492. else
  18493. {
  18494. return Ok(JsonView(false, "查询失败"));
  18495. }
  18496. }
  18497. /// <summary>
  18498. /// 团组状态
  18499. /// 设置操作完成
  18500. /// </summary>
  18501. /// <param name="dto">团组列表请求dto</param>
  18502. /// <returns></returns>
  18503. [HttpPost]
  18504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18505. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18506. {
  18507. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18508. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18509. {
  18510. Id = dto.Id,
  18511. IsSure = 1
  18512. };
  18513. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18514. .UpdateColumns(it => new { it.IsSure })
  18515. .WhereColumns(it => new { it.Id })
  18516. .ExecuteCommandAsync();
  18517. if (result > 0)
  18518. {
  18519. return Ok(JsonView(true, "操作完成!"));
  18520. }
  18521. return Ok(JsonView(false, "操作失败!"));
  18522. }
  18523. #endregion
  18524. #region 保险费用录入
  18525. /// <summary>
  18526. /// 根据团组Id查询保险费用列表
  18527. /// </summary>
  18528. /// <param name="dto"></param>
  18529. /// <returns></returns>
  18530. [HttpPost]
  18531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18532. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18533. {
  18534. Result groupData = await _customersRep.CustomersByDiId(dto);
  18535. if (groupData.Code != 0)
  18536. {
  18537. return Ok(JsonView(false, groupData.Msg));
  18538. }
  18539. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18540. }
  18541. /// <summary>
  18542. /// 根据保险费用Id查询保险费用详细
  18543. /// </summary>
  18544. /// <param name="dto"></param>
  18545. /// <returns></returns>
  18546. [HttpPost]
  18547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18548. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18549. {
  18550. try
  18551. {
  18552. Result groupData = await _customersRep.CustomersById(dto);
  18553. if (groupData.Code != 0)
  18554. {
  18555. return Ok(JsonView(false, groupData.Msg));
  18556. }
  18557. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18558. }
  18559. catch (Exception ex)
  18560. {
  18561. return Ok(JsonView(false, ex.Message));
  18562. }
  18563. }
  18564. /// <summary>
  18565. /// 保险费用录入页面初始化绑定
  18566. /// </summary>
  18567. /// <param name="dto"></param>
  18568. /// <returns></returns>
  18569. [HttpPost]
  18570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18571. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18572. {
  18573. try
  18574. {
  18575. Result groupData = await _customersRep.CustomersInitialize(dto);
  18576. if (groupData.Code != 0)
  18577. {
  18578. return Ok(JsonView(false, groupData.Msg));
  18579. }
  18580. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18581. }
  18582. catch (Exception ex)
  18583. {
  18584. return Ok(JsonView(false, ex.Message));
  18585. }
  18586. }
  18587. /// <summary>
  18588. /// 保险费用操作(Status:1.新增,2.修改)
  18589. /// </summary>
  18590. /// <param name="dto"></param>
  18591. /// <returns></returns>
  18592. [HttpPost]
  18593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18594. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18595. {
  18596. Result groupData = await _customersRep.OpCustomers(dto);
  18597. if (groupData.Code != 0)
  18598. {
  18599. return Ok(JsonView(false, groupData.Msg));
  18600. }
  18601. #region 应用推送
  18602. try
  18603. {
  18604. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18605. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18606. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18607. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18608. //自动审核
  18609. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18610. //2024-10-21 新增LZ UID
  18611. var userIds = new List<int>() { 21 };
  18612. string title = $"系统通知";
  18613. var diId = dto.DiId;
  18614. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18615. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18616. string content = "";
  18617. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18618. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18619. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18620. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18621. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18622. }
  18623. catch (Exception ex)
  18624. {
  18625. }
  18626. #endregion
  18627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18628. }
  18629. /// <summary>
  18630. /// 保险文件上传
  18631. /// </summary>
  18632. /// <param name="file"></param>
  18633. /// <returns></returns>
  18634. [HttpPost]
  18635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18636. public async Task<IActionResult> UploadCus(IFormFile file)
  18637. {
  18638. try
  18639. {
  18640. if (file != null)
  18641. {
  18642. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18643. //文件名称
  18644. string projectFileName = file.FileName;
  18645. //上传的文件的路径
  18646. string filePath = "";
  18647. if (!Directory.Exists(fileDir))
  18648. {
  18649. Directory.CreateDirectory(fileDir);
  18650. }
  18651. //上传的文件的路径
  18652. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18653. using (FileStream fs = System.IO.File.Create(filePath))
  18654. {
  18655. file.CopyTo(fs);
  18656. fs.Flush();
  18657. }
  18658. return Ok(JsonView(true, "上传成功!", projectFileName));
  18659. }
  18660. else
  18661. {
  18662. return Ok(JsonView(false, "上传失败!"));
  18663. }
  18664. }
  18665. catch (Exception ex)
  18666. {
  18667. return Ok(JsonView(false, "程序错误!"));
  18668. throw;
  18669. }
  18670. }
  18671. /// <summary>
  18672. /// 保险删除指定文件
  18673. /// </summary>
  18674. /// <param name="dto"></param>
  18675. /// <returns></returns>
  18676. [HttpPost]
  18677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18678. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18679. {
  18680. try
  18681. {
  18682. string filePath = "";
  18683. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18684. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18685. //int id = 0;
  18686. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18687. // 删除该文件
  18688. try
  18689. {
  18690. System.IO.File.Delete(filePath);
  18691. 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()
  18692. {
  18693. Attachment = "",
  18694. }).ExecuteCommandAsync();
  18695. if (result != 0)
  18696. {
  18697. return Ok(JsonView(true, "成功!"));
  18698. }
  18699. else
  18700. {
  18701. return Ok(JsonView(false, "失败!"));
  18702. }
  18703. }
  18704. catch (Exception)
  18705. {
  18706. 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()
  18707. {
  18708. Attachment = "",
  18709. }).ExecuteCommandAsync();
  18710. if (result != 0)
  18711. {
  18712. return Ok(JsonView(true, "成功!"));
  18713. }
  18714. else
  18715. {
  18716. return Ok(JsonView(false, "失败!"));
  18717. }
  18718. }
  18719. }
  18720. catch (Exception ex)
  18721. {
  18722. return Ok(JsonView(false, "程序错误!"));
  18723. throw;
  18724. }
  18725. }
  18726. /// <summary>
  18727. /// 保险费用操作(删除)
  18728. /// </summary>
  18729. /// <param name="dto"></param>
  18730. /// <returns></returns>
  18731. [HttpPost]
  18732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18733. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18734. {
  18735. try
  18736. {
  18737. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18738. if (!res)
  18739. {
  18740. return Ok(JsonView(false, "删除失败"));
  18741. }
  18742. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18743. {
  18744. IsDel = 1,
  18745. DeleteUserId = dto.DeleteUserId,
  18746. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18747. }).ExecuteCommandAsync();
  18748. return Ok(JsonView(true, "删除成功!"));
  18749. }
  18750. catch (Exception ex)
  18751. {
  18752. return Ok(JsonView(false, "程序错误!"));
  18753. throw;
  18754. }
  18755. }
  18756. #endregion
  18757. #region 接团客户名单 PageId 104
  18758. /// <summary>
  18759. /// 接团客户名单
  18760. /// 迁移数据(慎用!)
  18761. /// </summary>
  18762. /// <returns></returns>
  18763. [HttpPost]
  18764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18765. public async Task<IActionResult> PostTourClientListChange()
  18766. {
  18767. try
  18768. {
  18769. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18770. //var groupClinetData1
  18771. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18772. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18773. int updateCount = 0;
  18774. if (oldOAClientList.Count > 0)
  18775. {
  18776. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18777. _sqlSugar.BeginTran();
  18778. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18779. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18780. foreach (var item in oldOAClientList)
  18781. {
  18782. int comId = 0;
  18783. string format = "yyyy-MM-dd HH:mm:ss";
  18784. string data11 = "1990-01-01 00:00";
  18785. var data1 = IsValidDate(item.OPdate, format);
  18786. if (data1) data11 = item.OPdate;
  18787. //客户公司验证
  18788. if (!string.IsNullOrEmpty(item.Company))
  18789. {
  18790. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  18791. if (clientComInfo == null) // add
  18792. {
  18793. var addInfo = new Crm_CustomerCompany()
  18794. {
  18795. CompanyAbbreviation = "",
  18796. CompanyFullName = item.Company,
  18797. Address = "",
  18798. PostCodes = "",
  18799. LastedOpUserId = item.OPer,
  18800. LastedOpDt = Convert.ToDateTime(data11),
  18801. CreateUserId = item.OPer,
  18802. CreateTime = Convert.ToDateTime(data11),
  18803. IsDel = 0
  18804. };
  18805. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  18806. if (comId1 > 0) comId = comId1;
  18807. }
  18808. else comId = clientComInfo.Id;
  18809. }
  18810. //客户人员验证
  18811. int clientId = 0;
  18812. string name = item.LastName + item.Name;
  18813. if (!string.IsNullOrEmpty(name))
  18814. {
  18815. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  18816. if (clientInfo == null)
  18817. {
  18818. DateTime? dateTime = null;
  18819. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  18820. if (isDt) dateTime = birthDayDt;
  18821. var addInfo1 = new Crm_DeleClient()
  18822. {
  18823. CrmCompanyId = comId,
  18824. DiId = -1,
  18825. LastName = item.LastName,
  18826. FirstName = item.Name,
  18827. OldName = "",
  18828. Pinyin = item.Pinyin,
  18829. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  18830. Marriage = 0,
  18831. Phone = item.Phone,
  18832. Job = item.Job,
  18833. BirthDay = dateTime
  18834. };
  18835. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  18836. if (clientId1 > 0) clientId = clientId1;
  18837. }
  18838. else clientId = clientInfo.Id;
  18839. }
  18840. if (clientId < 1)
  18841. {
  18842. continue;
  18843. }
  18844. int airType = 0;
  18845. if (item.AirType == "超经舱") airType = 459;
  18846. else if (item.AirType == "公务舱") airType = 458;
  18847. else if (item.AirType == "经济舱") airType = 460;
  18848. else if (item.AirType == "其他") airType = 565;
  18849. else if (item.AirType == "头等舱") airType = 457;
  18850. var _TourClientListEntity = new Grp_TourClientList()
  18851. {
  18852. DiId = item.Diid,
  18853. ClientId = clientId,
  18854. CreateUserId = item.OPer,
  18855. CreateTime = Convert.ToDateTime(data11),
  18856. Remark = item.Remark,
  18857. IsDel = item.Isdel,
  18858. ShippingSpaceTypeId = airType,
  18859. ShippingSpaceSpecialNeeds = item.AirRemark,
  18860. HotelSpecialNeeds = item.RoomType
  18861. };
  18862. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  18863. if (_TourClientList > 0)
  18864. {
  18865. updateCount++;
  18866. }
  18867. }
  18868. _sqlSugar.CommitTran();
  18869. }
  18870. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  18871. }
  18872. catch (Exception ex)
  18873. {
  18874. _sqlSugar.RollbackTran();
  18875. return Ok(JsonView(false, ex.Message));
  18876. }
  18877. //return Ok(JsonView(true));
  18878. }
  18879. private bool IsValidDate(string dateString, string format)
  18880. {
  18881. DateTime dateValue;
  18882. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  18883. return valid;
  18884. }
  18885. /// <summary>
  18886. /// 接团客户名单
  18887. /// 根据团组Id查询List
  18888. /// </summary>
  18889. /// <param name="_dto"></param>
  18890. /// <returns></returns>
  18891. [HttpPost]
  18892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18893. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  18894. {
  18895. #region 参数验证
  18896. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  18897. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  18898. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  18899. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18900. #region 页面操作权限验证
  18901. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18902. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18903. #endregion
  18904. #endregion
  18905. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  18906. if (viewData.Code != 0)
  18907. {
  18908. return Ok(JsonView(false, viewData.Msg));
  18909. }
  18910. return Ok(JsonView(viewData.Data));
  18911. }
  18912. /// <summary>
  18913. /// 接团客户名单
  18914. /// 基础数据 Init
  18915. /// </summary>
  18916. /// <param name="_dto"></param>
  18917. /// <returns></returns>
  18918. [HttpPost]
  18919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18920. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  18921. {
  18922. #region 参数验证
  18923. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18924. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18925. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18926. #region 页面操作权限验证
  18927. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18928. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18929. #endregion
  18930. #endregion
  18931. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  18932. }
  18933. /// <summary>
  18934. /// 接团客户名单
  18935. /// 根据 Id查询 Details
  18936. /// </summary>
  18937. /// <param name="_dto"></param>
  18938. /// <returns></returns>
  18939. [HttpPost]
  18940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18941. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  18942. {
  18943. #region 参数验证
  18944. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18945. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18946. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18947. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18948. #region 页面操作权限验证
  18949. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18950. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18951. #endregion
  18952. #endregion
  18953. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18954. if (viewData.Code != 0)
  18955. {
  18956. return Ok(JsonView(false, viewData.Msg));
  18957. }
  18958. return Ok(JsonView(viewData.Data));
  18959. }
  18960. /// <summary>
  18961. /// 接团客户名单
  18962. /// Add Or Edit
  18963. /// </summary>
  18964. /// <param name="_dto"></param>
  18965. /// <returns></returns>
  18966. [HttpPost]
  18967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18968. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  18969. {
  18970. #region 参数验证
  18971. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18972. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18973. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18974. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18975. #region 页面操作权限验证
  18976. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18977. if (_dto.Id == 0) //添加
  18978. {
  18979. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18980. }
  18981. else if (_dto.Id >= 0) //修改
  18982. {
  18983. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18984. }
  18985. #endregion
  18986. #endregion
  18987. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  18988. if (viewData.Code != 0)
  18989. {
  18990. return Ok(JsonView(false, viewData.Msg));
  18991. }
  18992. return Ok(JsonView(true));
  18993. }
  18994. /// <summary>
  18995. /// 接团客户名单
  18996. /// json字符串 AddMultiple(添加多个)
  18997. /// </summary>
  18998. /// <param name="_dto"></param>
  18999. /// <returns></returns>
  19000. [HttpPost]
  19001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19002. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19003. {
  19004. #region 参数验证
  19005. string jsonLabel = _dto.JsonLabel;
  19006. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19007. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19008. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19009. #region 页面操作权限验证
  19010. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19011. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19012. #endregion
  19013. #endregion
  19014. var request = new TourClientListAddMultipleDto();
  19015. request.DiId = _dto.DiId;
  19016. request.UserId = _dto.UserId;
  19017. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19018. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19019. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19020. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19021. var infos = new List<TourClientListInfo>();
  19022. foreach (var data in datas)
  19023. {
  19024. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19025. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19026. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19027. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19028. {
  19029. continue;
  19030. }
  19031. infos.Add(new TourClientListInfo()
  19032. {
  19033. IsAccompany = 1,
  19034. LastName = lastName,
  19035. FirstName = firstName,
  19036. Pinyin = lastNameEn + @"/" + firstNameEn,
  19037. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19038. CompanyFullName = data.CompanyFullName,
  19039. Job = data.Job
  19040. });
  19041. }
  19042. if (infos.Any())
  19043. {
  19044. var viewData = await _tourClientListRep._AddMultiple(request);
  19045. if (viewData.Code != 0)
  19046. {
  19047. return Ok(JsonView(false, viewData.Msg));
  19048. }
  19049. return Ok(JsonView(true));
  19050. }
  19051. return Ok(JsonView(false));
  19052. }
  19053. /// <summary>
  19054. /// 接团客户名单
  19055. /// AddMultiple(添加多个)
  19056. /// </summary>
  19057. /// <param name="_dto"></param>
  19058. /// <returns></returns>
  19059. [HttpPost]
  19060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19061. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19062. {
  19063. #region 参数验证
  19064. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19065. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19066. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19067. #region 页面操作权限验证
  19068. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19069. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19070. #endregion
  19071. #endregion
  19072. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19073. if (viewData.Code != 0)
  19074. {
  19075. return Ok(JsonView(false, viewData.Msg));
  19076. }
  19077. return Ok(JsonView(true));
  19078. }
  19079. /// <summary>
  19080. /// 接团客户名单
  19081. /// Del
  19082. /// </summary>
  19083. /// <param name="_dto"></param>
  19084. /// <returns></returns>
  19085. [HttpPost]
  19086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19087. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19088. {
  19089. #region 参数验证
  19090. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19091. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19092. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19093. #region 页面操作权限验证
  19094. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19095. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19096. #endregion
  19097. #endregion
  19098. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19099. if (viewData.Code != 0)
  19100. {
  19101. return Ok(JsonView(false, viewData.Msg));
  19102. }
  19103. return Ok(JsonView(true));
  19104. }
  19105. /// <summary>
  19106. /// 接团客户名单
  19107. /// 文件下载 客户名单
  19108. /// </summary>
  19109. /// <param name="_dto"></param>
  19110. /// <returns></returns>
  19111. [HttpPost]
  19112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19113. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19114. {
  19115. #region 参数验证
  19116. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19117. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19118. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19119. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19120. #region 页面操作权限验证
  19121. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19122. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19123. #endregion
  19124. #endregion
  19125. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19126. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19127. From Grp_TourClientList tcl
  19128. Left Join
  19129. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19130. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19131. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19132. From Crm_DeleClient dc
  19133. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19134. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19135. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19136. Where dc.IsDel = 0) temp
  19137. On temp.DcId =tcl.ClientId
  19138. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19139. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19140. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19141. //载入模板
  19142. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19143. if (_dto.Language == 1)
  19144. {
  19145. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19146. }
  19147. //载入模板
  19148. var doc = new Document(tempPath);
  19149. DocumentBuilder builder = new DocumentBuilder(doc);
  19150. //获取word里所有表格
  19151. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19152. //获取所填表格的序数
  19153. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19154. var rowStart = tableOne.Rows[0]; //获取第1行
  19155. if (_dto.Language == 0)
  19156. {
  19157. //循环赋值
  19158. for (int i = 0; i < DcList.Count; i++)
  19159. {
  19160. EncryptionProcessor.DecryptProperties(DcList[i]);
  19161. builder.MoveToCell(0, i + 1, 0, 0);
  19162. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19163. builder.MoveToCell(0, i + 1, 1, 0);
  19164. int sex = DcList[i].Sex;
  19165. string sexStr = string.Empty;
  19166. if (sex == 0) sexStr = "男";
  19167. else if (sex == 1) sexStr = "女";
  19168. else sexStr = "未设置";
  19169. builder.Write(sexStr);
  19170. builder.MoveToCell(0, i + 1, 2, 0);
  19171. string birthDay = DcList[i].BirthDay;
  19172. string birthDayStr = string.Empty;
  19173. if (!string.IsNullOrEmpty(birthDay))
  19174. {
  19175. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19176. }
  19177. builder.Write(birthDayStr);
  19178. builder.MoveToCell(0, i + 1, 3, 0);
  19179. string company = "";
  19180. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19181. {
  19182. company = DcList[i].CompanyFullName.ToString();
  19183. }
  19184. builder.Write(company);
  19185. builder.MoveToCell(0, i + 1, 4, 0);
  19186. builder.Write(DcList[i].Job);
  19187. }
  19188. }
  19189. else if (_dto.Language == 1)
  19190. {
  19191. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19192. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19193. List<string> transArrayStr = new List<string>();
  19194. string transStrRes1 = "";
  19195. for (int i = 0; i < DcList.Count; i++)
  19196. {
  19197. var dc = DcList[i];
  19198. EncryptionProcessor.DecryptProperties(dc);
  19199. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19200. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19201. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19202. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19203. else transStrRes1 += $"{str1}|";
  19204. }
  19205. #region AI转英文
  19206. string jsonValue = JsonConvert.SerializeObject(DcList);
  19207. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19208. List<SeedMessages> messages = new List<SeedMessages>()
  19209. {
  19210. new SeedMessages
  19211. {
  19212. Role = KimiRole.user,
  19213. Content = jsonValue + text
  19214. }
  19215. };
  19216. KiMiApiClient client = new KiMiApiClient();
  19217. var kimiApiResult = await client.SeedMessage(messages);
  19218. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19219. string clients = kimiApiResult_JObject["content"].ToString();
  19220. string startStr = "```json", endStr = "```";
  19221. // 判断并清除开头部分
  19222. if (clients.StartsWith(startStr))
  19223. {
  19224. clients = clients.Remove(0, startStr.Length);
  19225. }
  19226. // 判断并清除结尾部分
  19227. if (clients.EndsWith(endStr))
  19228. {
  19229. clients = clients.Remove(clients.Length - endStr.Length);
  19230. }
  19231. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19232. //循环赋值
  19233. for (int i = 0; i < en_Json.Count; i++)
  19234. {
  19235. var dc = en_Json[i];
  19236. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19237. string PYName = dc.FirstName + " " + dc.LastName;
  19238. builder.MoveToCell(0, i + 1, 0, 0);
  19239. builder.Write(PYName);
  19240. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19241. builder.MoveToCell(0, i + 1, 1, 0);
  19242. builder.Write(sex);
  19243. DateTime birthDt;
  19244. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19245. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19246. builder.MoveToCell(0, i + 1, 2, 0);
  19247. builder.Write(birthday);
  19248. string company = string.Empty, job = string.Empty;
  19249. company = dc.CompanyFullName;
  19250. job = dc.Job;
  19251. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName) )
  19252. {
  19253. //查询对照表
  19254. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19255. if (tempCec != null)
  19256. {
  19257. company = tempCec.enName;
  19258. }
  19259. }
  19260. builder.MoveToCell(0, i + 1, 3, 0);
  19261. builder.Write(company);
  19262. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19263. {
  19264. //查询对照表
  19265. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19266. if (tempPec != null)
  19267. {
  19268. job = tempPec.enName;
  19269. }
  19270. }
  19271. builder.MoveToCell(0, i + 1, 4, 0);
  19272. builder.Write(job);
  19273. }
  19274. #endregion
  19275. #region 旧翻译英文处理
  19276. ////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";
  19277. //string transStrRes = "";
  19278. //if (transStrRes1.Length > 0)
  19279. //{
  19280. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19281. //}
  19282. ////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
  19283. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19284. ////List<string> transArray = new List<string> { };
  19285. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19286. //if (transStrRes.Contains("|"))
  19287. //{
  19288. // string[] transArray1 = transStrRes.Split('|');
  19289. // if (transArray1.Length > 0)
  19290. // {
  19291. // foreach (var item in transArray1)
  19292. // {
  19293. // if (item.Contains("&"))
  19294. // {
  19295. // string[] transArray2 = item.Split('&');
  19296. // int index = 0;
  19297. // string companyName = "", job = "";
  19298. // if (transArray2.Length > 0)
  19299. // {
  19300. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19301. // if (1 < transArray2.Length) companyName = transArray2[1];
  19302. // if (2 < transArray2.Length) job = transArray2[2];
  19303. // }
  19304. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19305. // }
  19306. // }
  19307. // }
  19308. //}
  19309. ////循环赋值
  19310. //for (int i = 0; i < DcList.Count; i++)
  19311. //{
  19312. // string PYName = "";
  19313. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19314. // {
  19315. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19316. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19317. // PYName = PY_First + " " + PY_Last;
  19318. // }
  19319. // else
  19320. // {
  19321. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19322. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19323. // PYName = PY_First + " " + PY_Last;
  19324. // }
  19325. // builder.MoveToCell(0, i + 1, 0, 0);
  19326. // builder.Write(PYName);
  19327. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19328. // builder.MoveToCell(0, i + 1, 1, 0);
  19329. // builder.Write(sex);
  19330. // DateTime birthDt;
  19331. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19332. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19333. // builder.MoveToCell(0, i + 1, 2, 0);
  19334. // builder.Write(birthday);
  19335. // string company = string.Empty, job = string.Empty;
  19336. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19337. // if (dcTransInfo != null)
  19338. // {
  19339. // company = dcTransInfo.CompanyName;
  19340. // job = dcTransInfo.Job;
  19341. // }
  19342. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19343. // {
  19344. // //查询对照表
  19345. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19346. // if (tempCec != null)
  19347. // {
  19348. // company = tempCec.enName;
  19349. // }
  19350. // //翻译
  19351. // else
  19352. // {
  19353. // }
  19354. // }
  19355. // builder.MoveToCell(0, i + 1, 3, 0);
  19356. // builder.Write(company);
  19357. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19358. // {
  19359. // //查询对照表
  19360. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19361. // if (tempPec != null)
  19362. // {
  19363. // job = tempPec.enName;
  19364. // }
  19365. // //翻译
  19366. // else
  19367. // {
  19368. // }
  19369. // }
  19370. // builder.MoveToCell(0, i + 1, 4, 0);
  19371. // builder.Write(job);
  19372. //}
  19373. #endregion
  19374. }
  19375. //删除多余行
  19376. while (tableOne.Rows.Count > DcList.Count + 1)
  19377. {
  19378. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19379. }
  19380. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19381. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19382. doc.Save(fileDir);
  19383. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19384. return Ok(JsonView(true, "操作成功!", Url));
  19385. }
  19386. private class TranslateInfo
  19387. {
  19388. public int Index { get; set; }
  19389. public string CompanyName { get; set; }
  19390. public string Job { get; set; }
  19391. }
  19392. [HttpPost]
  19393. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19394. {
  19395. if (files.Count == 0)
  19396. {
  19397. return Ok(JsonView(false, "文件为空"));
  19398. }
  19399. KiMiApiClient KiMiApi = new KiMiApiClient();
  19400. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19401. if (seedConter.Count == 0)
  19402. {
  19403. return Ok(JsonView(false, "上传结果为空!"));
  19404. }
  19405. var messages = new List<SeedMessages>
  19406. {
  19407. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19408. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19409. };
  19410. messages.InsertRange(1, seedConter);
  19411. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19412. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19413. string clients = kimiApiResult_JObject["content"].ToString();
  19414. string startStr = "```json", endStr = "```";
  19415. // 判断并清除开头部分
  19416. if (clients.StartsWith(startStr))
  19417. {
  19418. clients = clients.Remove(0, startStr.Length);
  19419. }
  19420. // 判断并清除结尾部分
  19421. if (clients.EndsWith(endStr))
  19422. {
  19423. clients = clients.Remove(clients.Length - endStr.Length);
  19424. }
  19425. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19426. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19427. {
  19428. {"姓", "LastName" },
  19429. {"名", "FirstName" },
  19430. {"姓名拼音", "Pinyin" },
  19431. {"性别", "Sex" },
  19432. {"单位", "CompanyFullName" },
  19433. {"职务", "Job" },
  19434. {"出生日期", "Birthday" },
  19435. };
  19436. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19437. foreach (var item in clients_JObject)
  19438. {
  19439. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19440. foreach (var field in clientFieldMap.Keys)
  19441. {
  19442. if (item.TryGetValue(field, out JToken value))
  19443. {
  19444. var getValue = value.ToString();
  19445. System.Type type = cdc.GetType();
  19446. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19447. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19448. propertyInfo.SetValue(cdc, propertyValue);
  19449. }
  19450. }
  19451. crmClients.Add(cdc);
  19452. }
  19453. return Ok(JsonView(new
  19454. {
  19455. fileCount = files.Count,
  19456. UploadCount = seedConter.Count,
  19457. ApiResult = clients,
  19458. CrmClients = crmClients
  19459. }));
  19460. }
  19461. #endregion
  19462. #region 团组倒推表
  19463. /// <summary>
  19464. /// 倒推表基础数据
  19465. /// Init
  19466. /// </summary>
  19467. /// <returns></returns>
  19468. [HttpPost]
  19469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19470. public async Task<IActionResult> PostInvertedListInit()
  19471. {
  19472. var viewData = await _invertedListRep._Init();
  19473. if (viewData.Code != 0)
  19474. {
  19475. return Ok(JsonView(false, viewData.Msg));
  19476. }
  19477. return Ok(JsonView(viewData.Data));
  19478. }
  19479. /// <summary>
  19480. /// 倒推表
  19481. /// Info
  19482. /// </summary>
  19483. /// <param name="dto"></param>
  19484. /// <returns></returns>
  19485. [HttpPost]
  19486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19487. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19488. {
  19489. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19490. if (viewData.Code != 0)
  19491. {
  19492. return Ok(JsonView(false, viewData.Msg));
  19493. }
  19494. return Ok(JsonView(viewData.Data));
  19495. }
  19496. /// <summary>
  19497. /// 倒推表
  19498. /// Create
  19499. /// </summary>
  19500. /// <param name="dto"></param>
  19501. /// <returns></returns>
  19502. [HttpPost]
  19503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19504. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19505. {
  19506. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19507. if (viewData.Code != 0)
  19508. {
  19509. return Ok(JsonView(false, viewData.Msg));
  19510. }
  19511. return Ok(JsonView(viewData.Data));
  19512. }
  19513. /// <summary>
  19514. /// 倒推表
  19515. /// Update
  19516. /// </summary>
  19517. /// <param name="dto"></param>
  19518. /// <returns></returns>
  19519. [HttpPost]
  19520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19521. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19522. {
  19523. var viewData = await _invertedListRep._Update(dto);
  19524. if (viewData.Code != 0)
  19525. {
  19526. return Ok(JsonView(false, viewData.Msg));
  19527. }
  19528. return Ok(JsonView(viewData.Data));
  19529. }
  19530. /// <summary>
  19531. /// 倒推表
  19532. /// File Download
  19533. /// </summary>
  19534. /// <param name="dto"></param>
  19535. /// <returns></returns>
  19536. [HttpPost]
  19537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19538. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19539. {
  19540. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19541. if (info2.Code != 0)
  19542. {
  19543. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19544. }
  19545. var info1 = info2.Data as InvertedListInfoView;
  19546. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19547. string teamName = "";
  19548. if (info != null) teamName = info.TeamName;
  19549. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19550. var doc = new Document();
  19551. var builder = new DocumentBuilder(doc);
  19552. #region old insert
  19553. ////载入模板
  19554. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19555. //Document doc = new Document(tempPath);
  19556. //DocumentBuilder builder = new DocumentBuilder(doc);
  19557. //利用键值对存放数据
  19558. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19559. //dic.Add("TeamName", teamName);
  19560. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19561. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19562. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19563. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19564. //dic.Add("SQRemark", info1.ApprovalRemark);
  19565. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19566. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19567. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19568. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19569. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19570. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19571. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19572. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19573. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19574. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19575. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19576. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19577. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19578. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19579. //#region 填充word模板书签内容
  19580. //foreach (var key in dic.Keys)
  19581. //{
  19582. // builder.MoveToBookmark(key);
  19583. // builder.Write(dic[key]);
  19584. //}
  19585. //#endregion
  19586. #endregion
  19587. #region New Insert
  19588. string titleFont = $"仿宋",
  19589. contentFont = $"仿宋";
  19590. var fontColor = Color.FromArgb(64, 64, 64);
  19591. //设置标题 团组名称
  19592. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19593. builder.Font.Name = titleFont;
  19594. builder.Font.Color = fontColor;
  19595. builder.Font.Size = 12;
  19596. builder.Font.Bold = true;
  19597. builder.Writeln(teamName);
  19598. //设置副标题 团组出访时间
  19599. builder.Font.Size = 12;
  19600. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19601. builder.Writeln();
  19602. var backgroundColor = Color.FromArgb(199, 199, 199);
  19603. var table = builder.StartTable();
  19604. builder.InsertCell();
  19605. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19606. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19607. builder.CellFormat.Borders.LineWidth = 1;
  19608. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19609. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19610. builder.RowFormat.Height = 40;
  19611. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19612. builder.Font.Name = contentFont;
  19613. builder.Font.Size = 12;
  19614. builder.Font.Bold = true;
  19615. builder.Font.Color = fontColor;
  19616. builder.Write("时间");
  19617. builder.InsertCell();
  19618. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19619. builder.Write("流程");
  19620. builder.InsertCell();
  19621. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19622. builder.Write("说明");
  19623. builder.EndRow();
  19624. //报批资料准备
  19625. if (info1.IsSelectedAirportd)
  19626. {
  19627. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19628. }
  19629. //报批/提供送签资料
  19630. if (info1.IsSelectedApprovalData)
  19631. {
  19632. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19633. }
  19634. //出批件护照办理
  19635. if (info1.IsSelectedIssueApproval)
  19636. {
  19637. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19638. }
  19639. //签证资料准备
  19640. if (info1.IsSelectedVisaInfo)
  19641. {
  19642. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19643. }
  19644. //送签
  19645. if (info1.IsSelectedSendVisa)
  19646. {
  19647. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19648. }
  19649. //出签
  19650. if (info1.IsSelectedIssueVisa)
  19651. {
  19652. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19653. }
  19654. //机票
  19655. if (info1.IsSelectedAirTicket)
  19656. {
  19657. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19658. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19659. }
  19660. //酒店
  19661. if (info1.IsSelectedHotel)
  19662. {
  19663. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19664. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19665. }
  19666. //开行前会
  19667. if (info1.IsSelectedPreTripMeeting)
  19668. {
  19669. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19670. }
  19671. //送机
  19672. if (info1.IsSelectedAirportdDropOff)
  19673. {
  19674. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19675. }
  19676. builder.EndTable();
  19677. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19678. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19679. for (int i = 0; i < table.Rows.Count; i++)
  19680. {
  19681. var row = table.Rows[i];
  19682. //设置宽度
  19683. row.Cells[0].CellFormat.Width = 20.00;
  19684. row.Cells[1].CellFormat.Width = 30.00;
  19685. row.Cells[2].CellFormat.Width = 50.00;
  19686. if (i != 0)
  19687. {
  19688. //边框设置
  19689. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19690. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19691. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19692. }
  19693. }
  19694. #region 页脚插入图片
  19695. // 创建页脚
  19696. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19697. doc.FirstSection.HeadersFooters.Add(footer);
  19698. Paragraph para = new Paragraph(doc);
  19699. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19700. footer.AppendChild(para);
  19701. builder.MoveTo(para);
  19702. string imagePath = "./Images/FMGJ_Log.png";
  19703. builder.InsertImage(imagePath);
  19704. #endregion
  19705. #endregion
  19706. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19707. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19708. string filePath = fileDir + $@"InvertedList/{fileName}";
  19709. doc.Save(filePath);
  19710. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19711. return Ok(JsonView(true, "操作成功!", Url));
  19712. }
  19713. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19714. {
  19715. var fontColor = Color.FromArgb(64, 64, 64);
  19716. builder.InsertCell();
  19717. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19718. builder.RowFormat.Height = 40;
  19719. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19720. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19721. builder.Font.Name = fontName;
  19722. builder.Font.Size = 8;
  19723. builder.Font.Bold = true;
  19724. builder.Font.Color = fontColor;
  19725. builder.Write(dateTime);
  19726. builder.InsertCell();
  19727. builder.Font.Size = 9;
  19728. builder.Font.Bold = true;
  19729. builder.Font.Color = fontColor;
  19730. builder.Write(content);
  19731. builder.InsertCell();
  19732. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19733. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19734. builder.Font.Size = 9;
  19735. builder.Font.Bold = false;
  19736. builder.Font.Color = fontColor;
  19737. builder.Write(reamrk);
  19738. builder.EndRow();
  19739. }
  19740. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19741. {
  19742. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19743. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19744. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19745. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19746. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19747. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19748. }
  19749. #endregion
  19750. #region 会务倒推表
  19751. /// <summary>
  19752. /// 会务倒推表
  19753. /// Init
  19754. /// </summary>
  19755. /// <returns></returns>
  19756. [HttpPost]
  19757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19758. public async Task<IActionResult> InforRetrogressTableInit()
  19759. {
  19760. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19761. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19762. return Ok(JsonView(false, groupData.Msg));
  19763. }
  19764. /// <summary>
  19765. /// 会务倒推表
  19766. /// ExcelDownload
  19767. /// </summary>
  19768. /// <param name="dto"></param>
  19769. /// <returns></returns>
  19770. [HttpPost]
  19771. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19773. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19774. {
  19775. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19776. var validatorRes = await validator.ValidateAsync(dto);
  19777. if (!validatorRes.IsValid)
  19778. {
  19779. StringBuilder sb = new StringBuilder();
  19780. foreach (var item in validatorRes.Errors)
  19781. {
  19782. sb.AppendLine(item.ErrorMessage);
  19783. }
  19784. return Ok(JsonView(false, sb.ToString()));
  19785. }
  19786. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  19787. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  19788. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  19789. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  19790. #region Excel
  19791. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  19792. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  19793. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  19794. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  19795. var fileNamePrefix = string.Empty;
  19796. if (days >= 30)
  19797. {
  19798. tempPath += $"会务工作倒推进度表(30天).xlsx";
  19799. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  19800. }
  19801. else if (days < 30 && days > 7)
  19802. {
  19803. tempPath += $"会务工作倒推进度表(15天).xlsx";
  19804. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  19805. }
  19806. else if (days <= 7)
  19807. {
  19808. tempPath += $"会务工作倒推进度表(7天).xlsx";
  19809. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  19810. }
  19811. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  19812. fileName = CommonFun.ValidFileName(fileName);
  19813. //载入模板
  19814. WorkbookDesigner designer = new WorkbookDesigner();
  19815. designer.Workbook = new Workbook(tempPath);
  19816. designer.Process();
  19817. if (!Directory.Exists(savePath))
  19818. {
  19819. Directory.CreateDirectory(savePath);
  19820. }
  19821. string serverPath = $"{savePath}{fileName}";
  19822. designer.Workbook.Save(serverPath);
  19823. string rst = $"{servicePath}{ftpPath}{fileName}";
  19824. #endregion
  19825. return Ok(JsonView(new { url = rst }));
  19826. }
  19827. #endregion
  19828. #region 三公签证费用(签证费、代办费)
  19829. /// <summary>
  19830. /// 三公签证费用(签证费、代办费)
  19831. /// List
  19832. /// </summary>
  19833. /// <returns></returns>
  19834. [HttpPost]
  19835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19836. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  19837. {
  19838. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  19839. if (_view.Code != 0)
  19840. {
  19841. return Ok(JsonView(false, _view.Msg));
  19842. }
  19843. return Ok(JsonView(true, "操作成功!", _view.Data));
  19844. }
  19845. /// <summary>
  19846. /// 三公签证费用(签证费、代办费)
  19847. /// Add Or Update
  19848. /// </summary>
  19849. /// <returns></returns>
  19850. [HttpPost]
  19851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19852. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  19853. {
  19854. var _view = await _visaFeeInfoRep._Update(_dto);
  19855. if (_view.Code != 0)
  19856. {
  19857. return Ok(JsonView(false, _view.Msg));
  19858. }
  19859. return Ok(JsonView(true, _view.Msg));
  19860. }
  19861. #endregion
  19862. #region 酒店询价
  19863. /// <summary>
  19864. /// 酒店询价
  19865. /// Init
  19866. /// </summary>
  19867. /// <returns></returns>
  19868. [HttpPost]
  19869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19870. public async Task<IActionResult> PostHotelInquiryInit()
  19871. {
  19872. var res = await _hotelInquiryRep._Init();
  19873. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19874. return Ok(JsonView(true, res.Msg, res.Data));
  19875. }
  19876. /// <summary>
  19877. /// 酒店询价
  19878. /// page Item
  19879. /// </summary>
  19880. /// <param name="_dto"></param>
  19881. /// <returns></returns>
  19882. [HttpPost]
  19883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19884. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  19885. {
  19886. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  19887. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19888. var view = res.Data as PageDataViewBase;
  19889. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  19890. }
  19891. /// <summary>
  19892. /// 酒店询价
  19893. /// info
  19894. /// </summary>
  19895. /// <param name="_dto"></param>
  19896. /// <returns></returns>
  19897. [HttpPost]
  19898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19899. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  19900. {
  19901. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  19902. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19903. return Ok(JsonView(true, res.Msg, res.Data));
  19904. }
  19905. /// <summary>
  19906. /// 酒店询价
  19907. /// Add Or Edit
  19908. /// </summary>
  19909. /// <param name="_dto"></param>
  19910. /// <returns></returns>
  19911. [HttpPost]
  19912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19913. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  19914. {
  19915. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  19916. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19917. return Ok(JsonView(true, res.Msg, res.Data));
  19918. }
  19919. /// <summary>
  19920. /// 酒店询价
  19921. /// Del
  19922. /// </summary>
  19923. /// <param name="_dto"></param>
  19924. /// <returns></returns>
  19925. [HttpPost]
  19926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19927. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  19928. {
  19929. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  19930. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19931. return Ok(JsonView(true, res.Msg, res.Data));
  19932. }
  19933. #endregion
  19934. #region 下载匹配op行程单
  19935. /// <summary>
  19936. /// 匹配op行程单
  19937. /// Init
  19938. /// </summary>
  19939. /// <param name="dto">团组列表请求dto</param>
  19940. /// <returns></returns>
  19941. [HttpPost]
  19942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19943. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  19944. {
  19945. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19946. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19947. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  19948. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  19949. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  19950. .Where(it => it.IsDel == 0)
  19951. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  19952. .OrderByDescending(it => it.VisitStartDate)
  19953. .ToList();
  19954. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  19955. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  19956. var diids = groupInfos.Select(it => it.Id).ToList();
  19957. List<string> countrys = new List<string>();
  19958. foreach (var item in country)
  19959. {
  19960. var data = _groupRepository.FormartTeamName(item);
  19961. var dataArray = _groupRepository.GroupSplitCountry(data);
  19962. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  19963. }
  19964. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  19965. List<string> areaArray = new List<string>(); //GetGroupCityLine
  19966. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  19967. foreach (var item in areaItem)
  19968. {
  19969. string areaStr = item.Value;
  19970. if (!string.IsNullOrEmpty(areaStr))
  19971. {
  19972. string[] str1 = areaStr.Split("-");
  19973. if (str1.Length > 0)
  19974. {
  19975. areaArray.AddRange(str1);
  19976. }
  19977. }
  19978. }
  19979. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  19980. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  19981. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  19982. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  19983. .ToList();
  19984. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  19985. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  19986. .Where(it => countriesIds.Contains(it.Id))
  19987. .Select(it => new { it.Id, Name = it.Name_CN })
  19988. .ToList();
  19989. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  19990. .Select(it => it.TeamName).ToList();
  19991. stopwatch.Stop();
  19992. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  19993. }
  19994. ///// <summary>
  19995. ///// 匹配op行程单
  19996. ///// Init 查询区域数据
  19997. ///// </summary>
  19998. ///// <param name="dto">团组列表请求dto</param>
  19999. ///// <returns></returns>
  20000. //[HttpPost]
  20001. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20002. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20003. //{
  20004. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20005. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20006. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20007. // if (string.IsNullOrEmpty(countriesDataStr))
  20008. // {
  20009. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20010. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20011. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20012. // }
  20013. // else
  20014. // {
  20015. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20016. // }
  20017. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20018. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20019. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20020. // List<dynamic> childList = new List<dynamic>();
  20021. // int parentId = dto.CountriesId;
  20022. // if (provinceData.Count > 1)
  20023. // {
  20024. // foreach (var item1 in provinceData)
  20025. // {
  20026. // List<dynamic> childList1 = new List<dynamic>();
  20027. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20028. // foreach (var item2 in citiesData1)
  20029. // {
  20030. // List<dynamic> childList2 = new List<dynamic>();
  20031. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20032. // foreach (var item3 in countiesData1)
  20033. // {
  20034. // childList2.Add(new
  20035. // {
  20036. // id = item3.Id,
  20037. // parentId = item2.Id,
  20038. // level = "district",
  20039. // name = item3.Name_CN,
  20040. // });
  20041. // }
  20042. // childList1.Add(new
  20043. // {
  20044. // id = item2.Id,
  20045. // parentId = item1.Id,
  20046. // level = "city",
  20047. // name = item2.Name_CN,
  20048. // childList = childList2
  20049. // });
  20050. // }
  20051. // childList.Add(new
  20052. // {
  20053. // id = item1.Id,
  20054. // parentId = parentId,
  20055. // level = "province",
  20056. // name = item1.Name_CN,
  20057. // childList = childList1
  20058. // });
  20059. // }
  20060. // //城市
  20061. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20062. // foreach (var item2 in citiesData2)
  20063. // {
  20064. // List<dynamic> childList22 = new List<dynamic>();
  20065. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20066. // foreach (var item3 in countiesData1)
  20067. // {
  20068. // childList22.Add(new
  20069. // {
  20070. // id = item3.Id,
  20071. // parentId = item2.Id,
  20072. // level = "district",
  20073. // name = item3.Name_CN,
  20074. // });
  20075. // }
  20076. // childList.Add(new
  20077. // {
  20078. // id = item2.Id,
  20079. // parentId = parentId,
  20080. // level = "city",
  20081. // name = item2.Name_CN,
  20082. // childList = childList22
  20083. // });
  20084. // }
  20085. // }
  20086. // else
  20087. // {
  20088. // foreach (var item2 in citiesData)
  20089. // {
  20090. // string cname = item2.Name_CN;
  20091. // List<dynamic> childList1 = new List<dynamic>();
  20092. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20093. // foreach (var item3 in countiesData1)
  20094. // {
  20095. // childList1.Add(new
  20096. // {
  20097. // Id = item3.Id,
  20098. // parentId = item2.Id,
  20099. // level = "district",
  20100. // name = item3.Name_CN
  20101. // });
  20102. // }
  20103. // childList.Add(new
  20104. // {
  20105. // id = item2.Id,
  20106. // parentId = parentId,
  20107. // level = "city",
  20108. // name = item2.Name_CN,
  20109. // childList = childList1
  20110. // });
  20111. // }
  20112. // }
  20113. // stopwatch.Stop();
  20114. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20115. //}
  20116. /// <summary>
  20117. /// 匹配op行程单
  20118. /// 接团信息列表 Page
  20119. /// </summary>
  20120. /// <param name="dto">团组列表请求dto</param>
  20121. /// <returns></returns>
  20122. [HttpPost]
  20123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20124. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20125. {
  20126. var swatch = new Stopwatch();
  20127. swatch.Start();
  20128. #region 参数验证
  20129. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20130. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20131. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20132. #region 页面操作权限验证
  20133. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20134. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20135. #endregion
  20136. #endregion
  20137. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20138. {
  20139. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20140. //string sqlWhere = "";
  20141. if (!string.IsNullOrEmpty(dto.Country))
  20142. {
  20143. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20144. }
  20145. if (!string.IsNullOrEmpty(dto.Area))
  20146. {
  20147. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20148. }
  20149. if (!string.IsNullOrEmpty(dto.TeamName))
  20150. {
  20151. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20152. }
  20153. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20154. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20155. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20156. swatch.Stop();
  20157. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20158. }
  20159. else
  20160. {
  20161. return Ok(JsonView(false, "查询失败"));
  20162. }
  20163. }
  20164. /// <summary>
  20165. /// 匹配op行程单
  20166. /// 行程单下载
  20167. /// </summary>
  20168. /// <param name="dto">团组列表请求dto</param>
  20169. /// <returns></returns>
  20170. [HttpPost]
  20171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20172. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20173. {
  20174. #region 参数验证
  20175. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20176. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20177. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20178. #region 页面操作权限验证
  20179. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20180. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20181. #endregion
  20182. #endregion
  20183. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20184. {
  20185. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20186. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20187. }
  20188. else
  20189. {
  20190. return Ok(JsonView(false, "下载失败!"));
  20191. }
  20192. }
  20193. #endregion
  20194. #region 国家信息 数据 注释
  20195. //[HttpPost]
  20196. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20197. //{
  20198. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20199. // foreach (var item in dto)
  20200. // {
  20201. // infos.Add(new Grp_GroupsTaskAssignment()
  20202. // {
  20203. // DIId = item,
  20204. // CTId = 82,
  20205. // UId = 248,
  20206. // IsEnable = 1,
  20207. // CreateUserId = 233,
  20208. // CreateTime = DateTime.Now,
  20209. // IsDel = 0
  20210. // });
  20211. // infos.Add(new Grp_GroupsTaskAssignment()
  20212. // {
  20213. // DIId = item,
  20214. // CTId = 82,
  20215. // UId = 286,
  20216. // IsEnable = 1,
  20217. // CreateUserId = 233,
  20218. // CreateTime = DateTime.Now,
  20219. // IsDel = 0
  20220. // });
  20221. // }
  20222. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20223. // return Ok("操作成功");
  20224. //}
  20225. //public class paramJsonDto
  20226. //{
  20227. // public List<CountriesInfo> str { get; set; }
  20228. //}
  20229. //[HttpPost]
  20230. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20231. //{
  20232. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20233. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20234. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20235. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20236. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20237. // _sqlSugar.BeginTran();
  20238. // int countitiesIndex = 0;
  20239. // foreach (var item in dto.str)
  20240. // {
  20241. // dynamic data = item.c;
  20242. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20243. // if (data != null)
  20244. // {
  20245. // countitiesIndex++;
  20246. // foreach (var item1 in data)
  20247. // {
  20248. // string cnname = item1.cn;
  20249. // string enname = item1.en;
  20250. // Sys_Cities provinceInfo = new Sys_Cities()
  20251. // {
  20252. // CountriesId = countriesId,
  20253. // Name_CN = cnname,
  20254. // Name_EN = enname,
  20255. // ParentId = 0,
  20256. // IsCapital = 1,
  20257. // CreateUserId = 208,
  20258. // CreateTime = DateTime.Now,
  20259. // IsDel = 0
  20260. // };
  20261. // if (item1.lv == "province") //省份
  20262. // {
  20263. // provinceInfo.Level = 1;
  20264. // int provinceId = 0;
  20265. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20266. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20267. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20268. // var data1 = item1.c;
  20269. // foreach (var item2 in data1)
  20270. // {
  20271. // if (item2.lv == "city")
  20272. // {
  20273. // string citycnname = item2.cn;
  20274. // string cityenname = item2.en;
  20275. // Sys_Cities cityInfo = new Sys_Cities()
  20276. // {
  20277. // CountriesId = countriesId,
  20278. // ParentId = provinceId,
  20279. // Level = 2,
  20280. // Name_CN = citycnname,
  20281. // Name_EN = cityenname,
  20282. // IsCapital = 1,
  20283. // CreateUserId = 208,
  20284. // CreateTime = DateTime.Now,
  20285. // IsDel = 0
  20286. // };
  20287. // if (item2.c != null)
  20288. // {
  20289. // int cityId = 0;
  20290. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20291. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20292. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20293. // foreach (var item3 in item2.c)
  20294. // {
  20295. // if (item3.lv == "district")
  20296. // {
  20297. // var districtInfo = new Sys_Cities()
  20298. // {
  20299. // CountriesId = countriesId,
  20300. // Name_CN = item3.cn,
  20301. // Name_EN = item3.en,
  20302. // Level = 3,
  20303. // ParentId = cityId,
  20304. // IsCapital = 1,
  20305. // CreateUserId = 208,
  20306. // CreateTime = DateTime.Now,
  20307. // IsDel = 0
  20308. // };
  20309. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20310. // //{
  20311. // districts.Add(districtInfo);
  20312. // //}
  20313. // }
  20314. // }
  20315. // }
  20316. // else
  20317. // {
  20318. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20319. // //{
  20320. // cities.Add(cityInfo);
  20321. // //}
  20322. // }
  20323. // }
  20324. // }
  20325. // }
  20326. // else if (item1.lv == "city")//城市
  20327. // {
  20328. // provinceInfo.Level = 2;
  20329. // if (item1.c != null)
  20330. // {
  20331. // int cityId = 0;
  20332. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20333. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20334. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20335. // foreach (var item3 in item1.c)
  20336. // {
  20337. // if (item3.lv == "district")
  20338. // {
  20339. // var districtInfo = new Sys_Cities()
  20340. // {
  20341. // CountriesId = countriesId,
  20342. // Name_CN = item3.cn,
  20343. // Name_EN = item3.en,
  20344. // Level = 3,
  20345. // ParentId = cityId,
  20346. // IsCapital = 1,
  20347. // CreateUserId = 208,
  20348. // CreateTime = DateTime.Now,
  20349. // IsDel = 0
  20350. // };
  20351. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20352. // //{
  20353. // districts.Add(districtInfo);
  20354. // //}
  20355. // }
  20356. // }
  20357. // }
  20358. // else
  20359. // {
  20360. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20361. // //{
  20362. // cities.Add(provinceInfo);
  20363. // //}
  20364. // }
  20365. // }
  20366. // }
  20367. // }
  20368. // }
  20369. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20370. // cities = cities.Distinct().ToList();
  20371. // districts = districts.Distinct().ToList();
  20372. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20373. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20374. // cities.AddRange(districts);
  20375. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20376. // //_sqlSugar.RollbackTran();
  20377. // _sqlSugar.CommitTran();
  20378. // return Ok(JsonView(false, "操作成功!"));
  20379. //}
  20380. //[HttpPost]
  20381. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20382. //{
  20383. // List<CountitiesInfo> infos = dto.MyProperty;
  20384. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20385. // _sqlSugar.BeginTran();
  20386. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20387. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20388. // foreach (var item in infos)
  20389. // {
  20390. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20391. // if (countryInfo != null)
  20392. // {
  20393. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20394. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20395. // if (cityInfo1 != null)
  20396. // {
  20397. // cityInfo1.IsCapital = 0;
  20398. // cityInfos.Add(cityInfo1);
  20399. // }
  20400. // }
  20401. // }
  20402. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20403. // .UpdateColumns(it => it.IsCapital)
  20404. // .WhereColumns(it => it.Id)
  20405. // .ExecuteCommand();
  20406. // //_sqlSugar.RollbackTran();
  20407. // _sqlSugar.CommitTran();
  20408. // return Ok(JsonView(false, "操作成功!"));
  20409. //}
  20410. //public class CounrtiesDto
  20411. //{
  20412. // public List<CountitiesInfo> MyProperty { get; set; }
  20413. //}
  20414. //public class CountitiesInfo
  20415. //{
  20416. // /// <summary>
  20417. // /// 圣约翰
  20418. // /// </summary>
  20419. // public string capital_name_chinese { get; set; }
  20420. // /// <summary>
  20421. // ///
  20422. // /// </summary>
  20423. // public string capital_name { get; set; }
  20424. // /// <summary>
  20425. // ///
  20426. // /// </summary>
  20427. // public string country_type { get; set; }
  20428. // /// <summary>
  20429. // /// 安提瓜和巴布达
  20430. // /// </summary>
  20431. // public string country_name_chinese { get; set; }
  20432. // /// <summary>
  20433. // /// 安提瓜和巴布达
  20434. // /// </summary>
  20435. // public string country_name_chinese_short { get; set; }
  20436. // /// <summary>
  20437. // /// 安提瓜和巴布达
  20438. // /// </summary>
  20439. // public string country_name_chinese_UN { get; set; }
  20440. // /// <summary>
  20441. // ///
  20442. // /// </summary>
  20443. // public string country_name_english_abbreviation { get; set; }
  20444. // /// <summary>
  20445. // ///
  20446. // /// </summary>
  20447. // public string country_name_english_formal { get; set; }
  20448. // /// <summary>
  20449. // ///
  20450. // /// </summary>
  20451. // public string country_name_english_UN { get; set; }
  20452. // /// <summary>
  20453. // ///
  20454. // /// </summary>
  20455. // public string continent_name { get; set; }
  20456. // /// <summary>
  20457. // ///
  20458. // /// </summary>
  20459. // public string subregion_name { get; set; }
  20460. // /// <summary>
  20461. // ///
  20462. // /// </summary>
  20463. // public string country_code2 { get; set; }
  20464. // /// <summary>
  20465. // ///
  20466. // /// </summary>
  20467. // public string country_code3 { get; set; }
  20468. // /// <summary>
  20469. // ///
  20470. // /// </summary>
  20471. // public string phone_code { get; set; }
  20472. //}
  20473. //public class CountriesInfo : BasicInfo
  20474. //{
  20475. // public List<CitiesInfo> c { get; set; }
  20476. //}
  20477. //public class CitiesInfo : BasicInfo
  20478. //{
  20479. // public List<AreaInfo> c { get; set; }
  20480. //}
  20481. //public class AreaInfo : BasicInfo
  20482. //{
  20483. // public List<AreaInfo> c { get; set; }
  20484. //}
  20485. //public class BasicInfo
  20486. //{
  20487. // public string code { get; set; }
  20488. // public string cn { get; set; }
  20489. // public string lv { get; set; }
  20490. // public string en { get; set; }
  20491. //}
  20492. #endregion
  20493. #region 查看邀请方
  20494. /// <summary>
  20495. /// 查看邀请方
  20496. /// 邀请方信息 Init
  20497. /// </summary>
  20498. /// <param name="dto"></param>
  20499. /// <returns></returns>
  20500. [HttpPost]
  20501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20502. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20503. {
  20504. string sqlWhere = string.Empty;
  20505. if (!string.IsNullOrEmpty(dto.Search))
  20506. {
  20507. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20508. }
  20509. string sql = string.Format($@"Select
  20510. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20511. Id,
  20512. UnitName
  20513. From Res_InvitationOfficialActivityData
  20514. Where IsDel = 0
  20515. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20516. RefAsync<int> total = 0;
  20517. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20518. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20519. }
  20520. /// <summary>
  20521. /// 查看邀请方
  20522. /// 国家信息 Init
  20523. /// </summary>
  20524. /// <param name="dto"></param>
  20525. /// <returns></returns>
  20526. [HttpPost]
  20527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20528. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20529. {
  20530. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20531. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20532. var diids = groupInfos.Select(it => it.Id).ToList();
  20533. List<string> countrys = new List<string>();
  20534. foreach (var item in country)
  20535. {
  20536. var data = _groupRepository.FormartTeamName(item);
  20537. var dataArray = _groupRepository.GroupSplitCountry(data);
  20538. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20539. }
  20540. countrys = countrys.Distinct().ToList();
  20541. for (int i = 0; i < countrys.Count; i++)
  20542. {
  20543. string item = countrys[i];
  20544. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20545. {
  20546. countrys.Remove(item);
  20547. i--;
  20548. }
  20549. }
  20550. RefAsync<int> total = 0;
  20551. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20552. .Where(it => countrys.Contains(it.Name_CN))
  20553. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20554. .Select(it => new { id = it.Id, name = it.Name_CN })
  20555. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20556. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20557. }
  20558. /// <summary>
  20559. /// 查看邀请方
  20560. /// 城市信息 Init
  20561. /// </summary>
  20562. /// <param name="dto"></param>
  20563. /// <returns></returns>
  20564. [HttpPost]
  20565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20566. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20567. {
  20568. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20569. RefAsync<int> total = 0;
  20570. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20571. .Where(it => it.CountriesId == dto.CountiesId)
  20572. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20573. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20574. .Select(it => new { id = it.Id, name = it.Name_CN })
  20575. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20576. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20577. }
  20578. /// <summary>
  20579. /// 查看邀请方
  20580. /// 团组名称 Init
  20581. /// </summary>
  20582. /// <param name="dto"></param>
  20583. /// <returns></returns>
  20584. [HttpPost]
  20585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20586. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20587. {
  20588. var watch = new Stopwatch();
  20589. watch.Start();
  20590. RefAsync<int> total = 0;
  20591. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20592. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20593. .Where((oa, di) => oa.IsDel == 0)
  20594. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20595. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20596. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20597. .Distinct()
  20598. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20599. watch.Stop();
  20600. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20601. }
  20602. /// <summary>
  20603. /// 查看邀请方
  20604. /// 团组 & 邀请方信息
  20605. /// </summary>
  20606. /// <param name="dto"></param>
  20607. /// <returns></returns>
  20608. [HttpPost]
  20609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20610. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20611. {
  20612. var watch = new Stopwatch();
  20613. watch.Start();
  20614. RefAsync<int> total = 0;
  20615. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20616. .AS("Grp_DelegationInfo")
  20617. .Includes(x => x.InvitingInfos)
  20618. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20619. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20620. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20621. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20622. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20623. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20624. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20625. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20626. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20627. infos.ForEach(x =>
  20628. {
  20629. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20630. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20631. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20632. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20633. });
  20634. watch.Stop();
  20635. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20636. }
  20637. #endregion
  20638. #region 报批行程
  20639. /// <summary>
  20640. /// 报批行程初始化
  20641. /// </summary>
  20642. /// <param name="dto"></param>
  20643. /// <returns></returns>
  20644. [HttpPost]
  20645. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20646. {
  20647. const int chiNumber = 5;
  20648. var jw = JsonView(false);
  20649. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20650. var group = groupList.First();
  20651. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20652. group = groupList.First(x => x.Id == diid);
  20653. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20654. .Where(x => x.DiId == diid && x.IsDel == 0)
  20655. .ToArray();
  20656. var count = 1;
  20657. foreach (var item in blackCodeList)
  20658. {
  20659. if (string.IsNullOrWhiteSpace(item.Title))
  20660. {
  20661. item.Title = "未设置名称数据" + count;
  20662. }
  20663. count++;
  20664. };
  20665. if (group == null)
  20666. {
  20667. jw.Msg = "暂无团组!";
  20668. return Ok(jw);
  20669. }
  20670. var data = new
  20671. {
  20672. groupList = groupList.Select(x => new
  20673. {
  20674. x.TeamName,
  20675. x.Id
  20676. }),
  20677. content = new ArrayList(),
  20678. groupInfo = new
  20679. {
  20680. group.VisitDays,
  20681. group.TourCode,
  20682. group.VisitPNumber,
  20683. group.TeamName,
  20684. group.Id,
  20685. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20686. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  20687. },
  20688. blackCodeList = blackCodeList.Select(x => new
  20689. {
  20690. x.Title,
  20691. x.Id
  20692. }),
  20693. FileTempList = new ArrayList()
  20694. {
  20695. new { Index = 1,FileName = "旧模板" },
  20696. new { Index = 2,FileName = "省外办" },
  20697. new { Index = 3,FileName = "市外办" },
  20698. }
  20699. };
  20700. var resultArr = new ArrayList();
  20701. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20702. #region 默认不生成行程
  20703. //if (content.Count == 0)
  20704. //{
  20705. // var stay = "-";
  20706. // var cityPath = "-";
  20707. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20708. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20709. // .ToList();
  20710. // //添加城市路径以及住宿地
  20711. // //黑屏代码数据
  20712. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20713. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20714. // {
  20715. // jw = JsonView(true, "黑屏代码有误!", data);
  20716. // return Ok(jw);
  20717. // }
  20718. // data = data with
  20719. // {
  20720. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20721. // {
  20722. // x.Title,
  20723. // x.Id,
  20724. // }).ToArray())
  20725. // };
  20726. // foreach (DataRow row in dtBlack.Rows)
  20727. // {
  20728. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20729. // {
  20730. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20731. // return Ok(jw);
  20732. // }
  20733. // }
  20734. // //黑屏代码获取时间区间
  20735. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20736. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20737. // _sqlSugar.BeginTran();
  20738. // for (int i = 0; i < timeArr.Count; i++)
  20739. // {
  20740. // stay = "-";
  20741. // cityPath = "-";
  20742. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20743. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20744. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20745. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20746. // if (tbSelect.Length > 0)
  20747. // {
  20748. // List<string> threeCodeStr = new List<string>();
  20749. // foreach (var item in tbSelect)
  20750. // {
  20751. // var threeCode = item["Three"].ToString() ?? "";
  20752. // if (threeCode.Length == 6)
  20753. // {
  20754. // var start = threeCode.Substring(0, 3);
  20755. // var end = threeCode.Substring(3, 3);
  20756. // if (threeCodeStr.Count == 0)
  20757. // {
  20758. // threeCodeStr.Add(start);
  20759. // threeCodeStr.Add(end);
  20760. // }
  20761. // else
  20762. // {
  20763. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20764. // {
  20765. // threeCodeStr.Add(end);
  20766. // }
  20767. // else
  20768. // {
  20769. // threeCodeStr.Add(start);
  20770. // threeCodeStr.Add(end);
  20771. // }
  20772. // }
  20773. // }
  20774. // }
  20775. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20776. // var last = threeCodeStr.Last();
  20777. // foreach (var item in threeCodeStr)
  20778. // {
  20779. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20780. // if (item.Equals(last))
  20781. // {
  20782. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20783. // }
  20784. // }
  20785. // cityPath = cityPath.Trim('-');
  20786. // }
  20787. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  20788. // appro.Diid = diid ?? -1;
  20789. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20790. // appro.Id = thisId;
  20791. // appro.CreateUserId = dto.UserId;
  20792. // appro.CreateTime = DateTime.Now;
  20793. // content.Add(appro);
  20794. // }
  20795. // _sqlSugar.CommitTran();
  20796. //}
  20797. #endregion
  20798. foreach (var x in content)
  20799. {
  20800. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  20801. if (chiList.Count < chiNumber)
  20802. {
  20803. for (int i = chiList.Count; i < chiNumber; i++)
  20804. {
  20805. chiList.Add(new Grp_ApprovalTravelDetails());
  20806. }
  20807. }
  20808. resultArr.Add(new
  20809. {
  20810. x.Id,
  20811. x.Date,
  20812. x.Diid,
  20813. chiList = chiList.Select(x1 => new
  20814. {
  20815. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20816. x1.Details,
  20817. x1.ParentId,
  20818. x1.Id
  20819. })
  20820. });
  20821. }
  20822. data = data with
  20823. {
  20824. content = resultArr,
  20825. };
  20826. jw = JsonView(true, "获取成功!", data);
  20827. return Ok(jw);
  20828. }
  20829. /// <summary>
  20830. /// 报批行程删除
  20831. /// </summary>
  20832. /// <param name="dto"></param>
  20833. /// <returns></returns>
  20834. [HttpPost]
  20835. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  20836. {
  20837. var jw = JsonView(false);
  20838. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20839. if (group == null)
  20840. {
  20841. jw.Msg = "团组参数有误!";
  20842. return Ok(jw);
  20843. }
  20844. try
  20845. {
  20846. _sqlSugar.BeginTran();
  20847. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  20848. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  20849. {
  20850. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20851. DeleteUserId = dto.uesrId,
  20852. IsDel = 1
  20853. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  20854. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  20855. {
  20856. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20857. DeleteUserId = dto.uesrId,
  20858. IsDel = 1
  20859. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  20860. _sqlSugar.CommitTran();
  20861. jw = JsonView(true, "删除成功");
  20862. }
  20863. catch (Exception ex)
  20864. {
  20865. jw = JsonView(false, ex.Message);
  20866. }
  20867. return Ok(jw);
  20868. }
  20869. /// <summary>
  20870. /// 报批行程保存
  20871. /// </summary>
  20872. /// <param name="dto"></param>
  20873. /// <returns></returns>
  20874. [HttpPost]
  20875. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  20876. {
  20877. var jw = JsonView(false);
  20878. var Find = dto.Arr.Find(x => x.id == 0);
  20879. if (Find != null)
  20880. {
  20881. jw.Msg = "生成的ID为0!";
  20882. return Ok(jw);
  20883. }
  20884. foreach (var item in dto.Arr)
  20885. {
  20886. foreach (var chi in item.chiList)
  20887. {
  20888. if (chi.parentId == 0)
  20889. {
  20890. chi.parentId = item.id;
  20891. }
  20892. }
  20893. }
  20894. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  20895. _sqlSugar.BeginTran();
  20896. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  20897. {
  20898. var parentIds = dto.Arr.Select(x => x.id).ToList();
  20899. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  20900. {
  20901. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20902. DeleteUserId = dto.UserId,
  20903. IsDel = 1
  20904. }).ExecuteCommand();
  20905. }
  20906. try
  20907. {
  20908. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  20909. {
  20910. CreateTime = DateTime.Now,
  20911. CreateUserId = dto.UserId,
  20912. Details = x.details,
  20913. ParentId = x.parentId,
  20914. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20915. Remark = "",
  20916. IsDel = 0
  20917. }).ToList()).ExecuteCommand();
  20918. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  20919. {
  20920. Id = x.id,
  20921. Details = x.details,
  20922. ParentId = x.parentId,
  20923. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20924. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  20925. {
  20926. Details = x.Details,
  20927. ParentId = x.ParentId,
  20928. Time = x.Time
  20929. }).ExecuteCommand();
  20930. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  20931. {
  20932. Id = x.id,
  20933. Date = x.date,
  20934. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  20935. {
  20936. Date = x.Date
  20937. }).ExecuteCommand();
  20938. _sqlSugar.CommitTran();
  20939. jw = JsonView(true, "保存成功!");
  20940. }
  20941. catch (Exception ex)
  20942. {
  20943. _sqlSugar.RollbackTran();
  20944. jw = JsonView(false, "保存失败!" + ex.Message);
  20945. }
  20946. return Ok(jw);
  20947. }
  20948. /// <summary>
  20949. /// 报批行程生成
  20950. /// </summary>
  20951. /// <param name="dto"></param>
  20952. /// <returns></returns>
  20953. [HttpPost]
  20954. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  20955. {
  20956. var jw = JsonView(false);
  20957. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20958. if (group == null)
  20959. {
  20960. jw.Msg = "暂无该团组!";
  20961. return Ok(jw);
  20962. }
  20963. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  20964. //黑屏代码数据
  20965. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  20966. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20967. {
  20968. jw.Msg = "黑屏代码有误!";
  20969. return Ok(jw);
  20970. }
  20971. foreach (DataRow row in dtBlack.Rows)
  20972. {
  20973. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20974. {
  20975. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  20976. return Ok(jw);
  20977. }
  20978. }
  20979. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  20980. var resultArr = new ArrayList();
  20981. //if (officialActivitiesArr.Count == 0)
  20982. //{
  20983. // jw.Msg = "暂无公务出访信息!";
  20984. // return Ok(jw);
  20985. //}
  20986. try
  20987. {
  20988. _sqlSugar.BeginTran();
  20989. DeleteApprovalJourney(new
  20990. Domain.Dtos.Groups.DeleteApprovalJourney
  20991. {
  20992. Diid = dto.Diid,
  20993. uesrId = dto.Userid
  20994. });
  20995. var stay = "-";
  20996. var cityPath = "-";
  20997. var arriveCountry = string.Empty;
  20998. //添加城市路径以及住宿地
  20999. //黑屏代码获取时间区间
  21000. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21001. var empty = "【未收入该三字码!请机票同事录入】";
  21002. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21003. #region 配置公务活动时间
  21004. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21005. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21006. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21007. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21008. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21009. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21010. {
  21011. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21012. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21013. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21014. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21015. };
  21016. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21017. {
  21018. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21019. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21020. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21021. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21022. };
  21023. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21024. {
  21025. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  21026. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  21027. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21028. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21029. };
  21030. #endregion
  21031. var nextDayNum = 0;
  21032. for (int i = 0; i < timeArr.Count; i++)
  21033. {
  21034. stay = "-";
  21035. cityPath = "-";
  21036. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21037. DateTime NewData = DateTime.Parse(timeArr[i]);
  21038. //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();
  21039. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21040. if (nextDayNum > 0)
  21041. {
  21042. nextDayNum--;
  21043. }
  21044. if (tbSelect.Length > 0)
  21045. {
  21046. List<string> threeCodeStr = new List<string>();
  21047. bool isTrade = false;
  21048. string trip = string.Empty;
  21049. foreach (var item in tbSelect)
  21050. {
  21051. if (nextDayNum == 0)
  21052. {
  21053. nextDayNum = Convert.ToInt32(item["Sign"]);
  21054. }
  21055. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21056. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21057. var takeOffTime = DateTime.Parse(timeArr[i]);
  21058. var fallToTime = DateTime.Parse(timeArr[i]);
  21059. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21060. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21061. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21062. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21063. if (nextDayNum > 0)
  21064. {
  21065. fallToTime = fallToTime.AddDays(nextDayNum);
  21066. }
  21067. trip = string.Empty;
  21068. var start = string.Empty;
  21069. var end = string.Empty;
  21070. var threeCode = item["Three"].ToString() ?? "";
  21071. if (threeCode.Length == 6)
  21072. {
  21073. start = threeCode.Substring(0, 3);
  21074. end = threeCode.Substring(3, 3);
  21075. if (threeCodeStr.Count == 0)
  21076. {
  21077. threeCodeStr.Add(start);
  21078. threeCodeStr.Add(end);
  21079. }
  21080. else
  21081. {
  21082. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21083. {
  21084. threeCodeStr.Add(end);
  21085. }
  21086. else
  21087. {
  21088. threeCodeStr.Add(start);
  21089. threeCodeStr.Add(end);
  21090. }
  21091. }
  21092. }
  21093. //处理机票信息
  21094. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21095. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21096. if (start_Object == null)
  21097. {
  21098. start_Object = new Res_ThreeCode()
  21099. {
  21100. AirPort = empty,
  21101. AirPort_En = empty,
  21102. City = empty,
  21103. Country = empty,
  21104. Four = empty,
  21105. Three = empty,
  21106. };
  21107. }
  21108. if (end_Object == null)
  21109. {
  21110. end_Object = new Res_ThreeCode()
  21111. {
  21112. AirPort = empty,
  21113. AirPort_En = empty,
  21114. City = empty,
  21115. Country = empty,
  21116. Four = empty,
  21117. Three = empty,
  21118. };
  21119. }
  21120. //机型判断
  21121. string airModel = item["AirModel"].ToString();
  21122. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21123. string flightTime = item["FlightTime"].ToString();
  21124. flightTime = ParseBlackTime(flightTime);
  21125. //航班号
  21126. string flightcode = item["Fliagtcode"].ToString();
  21127. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21128. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21129. if (aircompany == null)
  21130. {
  21131. aircompany = new Res_AirCompany
  21132. {
  21133. CnName = hsEmpty,
  21134. EnName = hsEmpty,
  21135. ShortCode = hsEmpty,
  21136. };
  21137. }
  21138. //航班前公务安排
  21139. if (tbSelect.First().Equals(item) && i != 0)
  21140. {
  21141. foreach (var takeoff in takeoffTimes)
  21142. {
  21143. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21144. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21145. {
  21146. foreach (var addTime in takeoff.Item2)
  21147. {
  21148. chiarr.Add(new Grp_ApprovalTravelDetails
  21149. {
  21150. Time = addTime,
  21151. CreateTime = DateTime.Now,
  21152. CreateUserId = dto.Userid,
  21153. ParentId = 0,
  21154. Details = "公务活动"
  21155. });
  21156. }
  21157. break;
  21158. }
  21159. }
  21160. }
  21161. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21162. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21163. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21164. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21165. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21166. if (isTrade)
  21167. {
  21168. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21169. trip += "(转机不出机场)。";
  21170. }
  21171. //else
  21172. //{
  21173. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21174. //}
  21175. chiarr.Add(new Grp_ApprovalTravelDetails
  21176. {
  21177. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21178. CreateTime = DateTime.Now,
  21179. CreateUserId = dto.Userid,
  21180. ParentId = 0,
  21181. Details = trip
  21182. });
  21183. //最后一条到达的时间安排公务
  21184. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21185. {
  21186. bool isCheckCountry = false;
  21187. if (end_Object.Country != arriveCountry)
  21188. {
  21189. arriveCountry = end_Object.Country;
  21190. isCheckCountry = true;
  21191. }
  21192. if (nextDayNum == 0)
  21193. {
  21194. //需要入境的情况
  21195. if (isCheckCountry)
  21196. {
  21197. foreach (var fallTime in fallTimesCheckCountry)
  21198. {
  21199. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21200. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21201. {
  21202. foreach (var addTime in fallTime.Item2)
  21203. {
  21204. chiarr.Add(new Grp_ApprovalTravelDetails
  21205. {
  21206. Time = addTime,
  21207. CreateTime = DateTime.Now,
  21208. CreateUserId = dto.Userid,
  21209. ParentId = 0,
  21210. Details = "公务活动"
  21211. });
  21212. }
  21213. break;
  21214. }
  21215. }
  21216. }
  21217. else
  21218. {
  21219. foreach (var fallTime in fallTimesNotCheckCountry)
  21220. {
  21221. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21222. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21223. {
  21224. foreach (var addTime in fallTime.Item2)
  21225. {
  21226. chiarr.Add(new Grp_ApprovalTravelDetails
  21227. {
  21228. Time = addTime,
  21229. CreateTime = DateTime.Now,
  21230. CreateUserId = dto.Userid,
  21231. ParentId = 0,
  21232. Details = "公务活动"
  21233. });
  21234. }
  21235. break;
  21236. }
  21237. }
  21238. }
  21239. }
  21240. }
  21241. }
  21242. //添加乘车语句
  21243. //chiarr.Add(new Grp_ApprovalTravelDetails
  21244. //{
  21245. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21246. // CreateTime = DateTime.Now,
  21247. // CreateUserId = dto.Userid,
  21248. // ParentId = 0,
  21249. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21250. //});
  21251. //if (i != timeArr.Count - 1)
  21252. //{
  21253. // fallToTime = fallToTime.AddHours(2.5);
  21254. // foreach (var item in Times)
  21255. // {
  21256. // //排列公务时间
  21257. // if (fallToTime.Hour < item.Item1)
  21258. // {
  21259. // chiarr.Add(new Grp_ApprovalTravelDetails
  21260. // {
  21261. // Time = $"{item.Item2} - {item.Item3}",
  21262. // CreateTime = DateTime.Now,
  21263. // CreateUserId = dto.Userid,
  21264. // ParentId = 0,
  21265. // Details = "公务活动"
  21266. // });
  21267. // }
  21268. // }
  21269. //}
  21270. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21271. var last = threeCodeStr.Last();
  21272. foreach (var item in threeCodeStr)
  21273. {
  21274. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21275. if (item.Equals(last))
  21276. {
  21277. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21278. }
  21279. }
  21280. cityPath = cityPath.Trim('-');
  21281. }
  21282. else
  21283. {
  21284. foreach (var item in Times)
  21285. {
  21286. chiarr.Add(new Grp_ApprovalTravelDetails
  21287. {
  21288. Time = $"{item.Item2} - {item.Item3}",
  21289. CreateTime = DateTime.Now,
  21290. CreateUserId = dto.Userid,
  21291. ParentId = 0,
  21292. Details = "公务活动"
  21293. });
  21294. }
  21295. }
  21296. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21297. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21298. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21299. appro.Diid = dto.Diid;
  21300. appro.CreateUserId = dto.Userid;
  21301. appro.CreateTime = DateTime.Now;
  21302. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21303. appro.Id = thisId;
  21304. //foreach (var item in gwinfo)
  21305. //{
  21306. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21307. // chi.Details = "拜访" + item.Client;
  21308. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21309. // {
  21310. // chi.Details += "," + item.ReqSample;
  21311. // }
  21312. // chi.ParentId = thisId;
  21313. // chi.Time = item.Time;
  21314. // chiarr.Add(chi);
  21315. //}
  21316. if (chiarr.Count < 6)
  21317. {
  21318. for (int j = chiarr.Count; j < 6; j++)
  21319. {
  21320. chiarr.Add(new
  21321. Grp_ApprovalTravelDetails());
  21322. }
  21323. }
  21324. resultArr.Add(new
  21325. {
  21326. appro.Id,
  21327. appro.Date,
  21328. appro.Diid,
  21329. chiList = chiarr.Select(x1 => new
  21330. {
  21331. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21332. x1.Details,
  21333. x1.ParentId,
  21334. x1.Id
  21335. })
  21336. });
  21337. }
  21338. _sqlSugar.CommitTran();
  21339. jw = JsonView(true, "生成成功!", resultArr);
  21340. }
  21341. catch (Exception ex)
  21342. {
  21343. jw.Code = 400;
  21344. jw.Msg = "生成失败!" + ex.Message;
  21345. }
  21346. return Ok(jw);
  21347. }
  21348. /// <summary>
  21349. /// 报批行程word导出
  21350. /// </summary>
  21351. /// <param name="dto"></param>
  21352. /// <returns></returns>
  21353. [HttpPost]
  21354. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21355. {
  21356. var jw = JsonView(false);
  21357. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21358. if (group == null)
  21359. {
  21360. jw.Msg = "暂无该团组!";
  21361. return Ok(jw);
  21362. }
  21363. //模板路径
  21364. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21365. var fileName = string.Empty;
  21366. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21367. bool bold = false;
  21368. if (dto.FileIndex == 1)
  21369. {
  21370. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21371. }
  21372. else if (dto.FileIndex == 2)
  21373. {
  21374. fileName = "省外办-报批.docx";
  21375. bold = false;
  21376. titleFont = "方正黑体简体";
  21377. timeFont = "Times New Roman";
  21378. contentFont = "方正仿宋_GBK";
  21379. }
  21380. else if (dto.FileIndex == 3)
  21381. {
  21382. fileName = "市外办-报批.docx";
  21383. titleFont = "方正黑体简体";
  21384. timeFont = "Times New Roman";
  21385. contentFont = "方正仿宋简体";
  21386. }
  21387. tempPath = tempPath + fileName;
  21388. //载入模板
  21389. Document doc = new Document(tempPath);
  21390. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21391. //获取所填表格的序数
  21392. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21393. Aspose.Words.Tables.Row titleRowClone = null;
  21394. Aspose.Words.Tables.Row CenterRowClone = null;
  21395. int index = 0;
  21396. int indexChi = 0;
  21397. int SetIndex = 0;
  21398. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21399. //获取数据,放到datatable
  21400. foreach (var item in ApprovalTravelArr)
  21401. {
  21402. if (index > 0)
  21403. {
  21404. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21405. tableOne.AppendChild(titleRowClone);
  21406. }
  21407. var textTime = item.Date;
  21408. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21409. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21410. SetIndex++;
  21411. if (ChiRep.Count > 0)
  21412. {
  21413. foreach (var itemChi in ChiRep)
  21414. {
  21415. var txtTime = itemChi.Time;
  21416. var txtDetail = itemChi.Details;
  21417. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21418. {
  21419. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21420. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21421. //indexChi++;
  21422. //SetIndex++;
  21423. break;
  21424. }
  21425. if (indexChi > 0)
  21426. {
  21427. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21428. tableOne.AppendChild(CenterRowClone);
  21429. }
  21430. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21431. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21432. indexChi++;
  21433. SetIndex++;
  21434. }
  21435. }
  21436. //else
  21437. //{
  21438. // if (indexChi > 0)
  21439. // {
  21440. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21441. // tableOne.AppendChild(CenterRowClone);
  21442. // }
  21443. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21444. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21445. // indexChi++;
  21446. // SetIndex++;
  21447. //}
  21448. index++;
  21449. }
  21450. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21451. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21452. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21453. jw.Code = 200;
  21454. jw.Msg = "";
  21455. return Ok(jw);
  21456. }
  21457. private string ParseBlackTime(string time)
  21458. {
  21459. // 匹配可能只有分钟的情况
  21460. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21461. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21462. if (match.Success)
  21463. {
  21464. string hours = match.Groups[1].Value;
  21465. string minutes = match.Groups[2].Value;
  21466. // 如果小时部分为空,则只显示分钟
  21467. if (string.IsNullOrEmpty(hours))
  21468. {
  21469. return $"{minutes}分钟";
  21470. }
  21471. // 如果分钟部分为空,则只显示小时
  21472. else if (string.IsNullOrEmpty(minutes))
  21473. {
  21474. return $"{hours}小时";
  21475. }
  21476. // 否则显示完整格式
  21477. else
  21478. {
  21479. return $"{hours}小时{minutes}分钟";
  21480. }
  21481. }
  21482. else
  21483. {
  21484. return "未知时长";
  21485. }
  21486. }
  21487. private string intToString(int numberVal)
  21488. {
  21489. string numberval = numberVal.ToString();
  21490. Dictionary<char, string> Number = new Dictionary<char, string>();
  21491. Number.Add('1', "一");
  21492. Number.Add('2', "二");
  21493. Number.Add('3', "三");
  21494. Number.Add('4', "四");
  21495. Number.Add('5', "五");
  21496. Number.Add('6', "六");
  21497. Number.Add('7', "七");
  21498. Number.Add('8', "八");
  21499. Number.Add('9', "九");
  21500. string stringNumberVal = string.Empty;
  21501. for (int i = 0; i < numberval.Length; i++)
  21502. {
  21503. if (i == 0)
  21504. {
  21505. stringNumberVal += Number[numberval[i]];
  21506. }
  21507. else if (i >= 1)
  21508. {
  21509. if (numberval[i] == '0')
  21510. {
  21511. stringNumberVal = "十";
  21512. }
  21513. else
  21514. {
  21515. stringNumberVal += "十" + Number[numberval[i]];
  21516. }
  21517. }
  21518. }
  21519. return stringNumberVal;
  21520. }
  21521. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21522. {
  21523. //获取table中的某个单元格,从0开始
  21524. Cell lshCell = table.Rows[rows].Cells[cells];
  21525. //将单元格中段落移除
  21526. foreach (Paragraph item in lshCell.Paragraphs)
  21527. {
  21528. lshCell.Paragraphs.Remove(item);
  21529. }
  21530. if (val.Contains("\r\n"))
  21531. {
  21532. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21533. foreach (var item in spArr)
  21534. {
  21535. //新建一个段落
  21536. Paragraph p = new Paragraph(doc);
  21537. var r = new Run(doc, item);
  21538. //设置字体
  21539. if (!string.IsNullOrEmpty(font))
  21540. {
  21541. r.Font.Name = font;
  21542. }
  21543. r.Font.Bold = bold;
  21544. //把设置的值赋给之前新建的段落
  21545. p.AppendChild(r);
  21546. //将此段落加到单元格内
  21547. lshCell.AppendChild(p);
  21548. }
  21549. }
  21550. else
  21551. {
  21552. //新建一个段落
  21553. Paragraph p = new Paragraph(doc);
  21554. var r = new Run(doc, val);
  21555. //设置字体
  21556. if (!string.IsNullOrEmpty(font))
  21557. {
  21558. r.Font.Name = font;
  21559. }
  21560. r.Font.Bold = bold;
  21561. //把设置的值赋给之前新建的段落
  21562. p.AppendChild(r);
  21563. //将此段落加到单元格内
  21564. lshCell.AppendChild(p);
  21565. }
  21566. }
  21567. //[HttpPost]
  21568. //public async Task<IActionResult> ServerHttp(string paramStr)
  21569. //{
  21570. // paramStr = paramStr.TrimEnd('\'');
  21571. // paramStr = paramStr.TrimStart('\'');
  21572. // JsonView jw = JsonView(false);
  21573. // JObject param = JObject.Parse(paramStr);
  21574. // if (!param.ContainsKey("url"))
  21575. // {
  21576. // jw.Msg = "url null";
  21577. // return Ok(jw);
  21578. // }
  21579. // string url = param["url"]!.ToString();
  21580. // var methon = "get";
  21581. // Dictionary<string, string> headValues = null;
  21582. // string bodyStr = string.Empty;
  21583. // if (param.ContainsKey("methon"))
  21584. // {
  21585. // methon = param["methon"]!.ToString().ToLower();
  21586. // }
  21587. // if (param.ContainsKey("header"))
  21588. // {
  21589. // var header = param["header"]!.ToString();
  21590. // JObject headerJobject = JObject.Parse(header);
  21591. // headValues = new Dictionary<string, string>();
  21592. // foreach (JProperty item in headerJobject.Properties())
  21593. // {
  21594. // var value = item.Value.ToString();
  21595. // var head = item.Path;
  21596. // headValues.Add(head, value);
  21597. // }
  21598. // }
  21599. // HttpClient client = new HttpClient();
  21600. // string responseString = string.Empty;
  21601. // StringContent content = null;
  21602. // if (headValues != null)
  21603. // {
  21604. // foreach (var item in headValues.Keys)
  21605. // {
  21606. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  21607. // {
  21608. // if (param.ContainsKey("body"))
  21609. // {
  21610. // bodyStr = param["body"]!.ToString();
  21611. // }
  21612. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  21613. // }
  21614. // else
  21615. // {
  21616. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  21617. // }
  21618. // }
  21619. // }
  21620. // try
  21621. // {
  21622. // if (methon == "get")
  21623. // {
  21624. // responseString = await client.GetStringAsync(url);
  21625. // }
  21626. // else if (methon == "post")
  21627. // {
  21628. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  21629. // {
  21630. // Content = content
  21631. // };
  21632. // var response = await client.SendAsync(request);
  21633. // try
  21634. // {
  21635. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  21636. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  21637. // {
  21638. // using (StreamReader reader = new StreamReader(gzipStream))
  21639. // {
  21640. // responseString = await reader.ReadToEndAsync();
  21641. // }
  21642. // }
  21643. // }
  21644. // catch (Exception)
  21645. // {
  21646. // responseString = await response.Content.ReadAsStringAsync();
  21647. // }
  21648. // }
  21649. // else
  21650. // {
  21651. // responseString = "methon error";
  21652. // }
  21653. // jw = JsonView(true, "success", responseString);
  21654. // }
  21655. // catch (Exception ex)
  21656. // {
  21657. // jw.Msg = "error " + ex.Message;
  21658. // jw.Data = ex.StackTrace;
  21659. // }
  21660. // finally
  21661. // {
  21662. // client.Dispose();
  21663. // }
  21664. // return Ok(jw);
  21665. //}
  21666. #endregion
  21667. #region 团组接待意见调查
  21668. /// <summary>
  21669. /// 团组接待意见调查 - 信息管理
  21670. /// 基础数据(团组)
  21671. /// </summary>
  21672. /// <returns></returns>
  21673. [HttpGet]
  21674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21675. public async Task<IActionResult> OpinionaireInit()
  21676. {
  21677. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21678. .Select(x => new
  21679. {
  21680. x.Id,
  21681. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21682. })
  21683. .OrderByDescending(x => x.Id)
  21684. .ToListAsync();
  21685. return Ok(JsonView(groupData, groupData.Count));
  21686. }
  21687. /// <summary>
  21688. /// 团组接待意见调查 - 信息管理
  21689. /// 列表
  21690. /// </summary>
  21691. /// <param name="groupId"></param>
  21692. /// <returns></returns>
  21693. [HttpGet("{groupId}")]
  21694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21695. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21696. {
  21697. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21698. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21699. .Select(x => new
  21700. {
  21701. x.Id,
  21702. x.TourGuideName,
  21703. x.CityName,
  21704. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21705. x.CreateTime
  21706. })
  21707. .OrderBy(x => x.Id)
  21708. .ToListAsync();
  21709. return Ok(JsonView(data));
  21710. }
  21711. /// <summary>
  21712. /// 团组接待意见调查 - 信息管理
  21713. /// 保存
  21714. /// </summary>
  21715. /// <param name="dto"></param>
  21716. /// <returns></returns>
  21717. [HttpPost]
  21718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21719. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21720. {
  21721. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21722. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21723. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21724. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21725. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21726. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21727. _opinionaireRep.BeginTran();
  21728. if (addData != null && addData.Count > 0)
  21729. {
  21730. foreach (var item in addData)
  21731. {
  21732. item.CreateUserId = currUserInfo.UserId;
  21733. item.DiId = dto.DiId;
  21734. }
  21735. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21736. }
  21737. if (updData != null && updData.Count > 0)
  21738. {
  21739. var upd = await _opinionaireRep._sqlSugar
  21740. .Updateable(updData)
  21741. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21742. .WhereColumns(x => new { x.Id })
  21743. .ExecuteCommandAsync();
  21744. }
  21745. _opinionaireRep.CommitTran();
  21746. return Ok(JsonView("操作成功!"));
  21747. }
  21748. /// <summary>
  21749. /// 团组接待意见调查 - 信息管理
  21750. /// 删除
  21751. /// </summary>
  21752. /// <param name="id"></param>
  21753. /// <returns></returns>
  21754. [HttpDelete("{id}")]
  21755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21756. public async Task<IActionResult> OpinionaireManageDel(int id)
  21757. {
  21758. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21759. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21760. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21761. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21762. if (!del) return Ok(JsonView("操作失败!"));
  21763. return Ok(JsonView("操作成功!"));
  21764. }
  21765. /// <summary>
  21766. /// 团组接待意见调查 - 用户
  21767. /// 列表
  21768. /// </summary>
  21769. /// <param name="diId"></param>
  21770. /// <returns></returns>
  21771. [HttpGet("{diId}")]
  21772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21773. public async Task<IActionResult> OpinionaireUserList(int diId)
  21774. {
  21775. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21776. var sql = string.Format(@"
  21777. SELECT
  21778. o.Id,
  21779. o.DiId,
  21780. di.TeamName AS 'GroupName',
  21781. di.VisitPNumber AS 'PeopleNumber',
  21782. di.ClientName AS 'LeadGroup',
  21783. di.VisitCountry AS 'Travel',
  21784. di.VisitDays AS 'Days',
  21785. o.CityName,
  21786. o.TourGuideName,
  21787. o.Catering,
  21788. o.CateringReason,
  21789. o.Stay,
  21790. o.StayReason,
  21791. o.[Route],
  21792. o.RouteReason,
  21793. o.OfficialActivity,
  21794. o.OfficialActivityReason,
  21795. o.TourGuide,
  21796. o.TourGuideReason,
  21797. o.[Translate],
  21798. o.TranslateReason,
  21799. o.Trip,
  21800. o.TripReason,
  21801. o.ESFileName,
  21802. o.SignatureDate,
  21803. o.Remark
  21804. FROM
  21805. Grp_Opinionaire o
  21806. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21807. WHERE
  21808. o.IsDel = 0
  21809. AND o.DiId = {0}
  21810. ORDER BY
  21811. o.Id ASC", diId);
  21812. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21813. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21814. return Ok(JsonView(data));
  21815. }
  21816. /// <summary>
  21817. /// 团组接待意见调查 - 用户
  21818. /// 保存
  21819. /// </summary>
  21820. /// <param name="dto"></param>
  21821. /// <returns></returns>
  21822. [HttpPost]
  21823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21824. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21825. {
  21826. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21827. foreach (var item in dto)
  21828. {
  21829. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21830. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21831. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21832. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21833. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21834. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21835. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21836. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21837. }
  21838. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21839. if (!Directory.Exists(filePathBase))
  21840. {
  21841. Directory.CreateDirectory(filePathBase);
  21842. }
  21843. #region 上传文件
  21844. var filePaths = new List<string>();
  21845. foreach (var item in dto)
  21846. {
  21847. var file = item.File;
  21848. // 将文件保存到指定位置
  21849. var filePath = Path.Combine(filePathBase, file.FileName);
  21850. using (var stream = new FileStream(filePath, FileMode.Create))
  21851. {
  21852. await file.CopyToAsync(stream);
  21853. }
  21854. //验证文件是否上传成功
  21855. if (!System.IO.File.Exists(filePath))
  21856. {
  21857. foreach (var filePathStr in filePaths)
  21858. {
  21859. System.IO.File.Delete(filePathStr);
  21860. }
  21861. return Ok(JsonView(false, "文件上传失败!"));
  21862. }
  21863. item.ESFileName = file.FileName;
  21864. }
  21865. #endregion
  21866. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  21867. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  21868. .UpdateColumns(x => new
  21869. {
  21870. x.Catering,
  21871. x.CateringReason,
  21872. x.Stay,
  21873. x.StayReason,
  21874. x.Route,
  21875. x.RouteReason,
  21876. x.OfficialActivity,
  21877. x.OfficialActivityReason,
  21878. x.TourGuide,
  21879. x.TourGuideReason,
  21880. x.Translate,
  21881. x.TranslateReason,
  21882. x.Trip,
  21883. x.TripReason,
  21884. x.ESFileName,
  21885. x.SignatureDate,
  21886. x.Remark
  21887. })
  21888. .WhereColumns(x => new { x.Id })
  21889. .ExecuteCommandAsync();
  21890. if (upd < 1)
  21891. {
  21892. foreach (var filePathStr in filePaths)
  21893. {
  21894. System.IO.File.Delete(filePathStr);
  21895. }
  21896. return Ok(JsonView(false));
  21897. }
  21898. return Ok(JsonView(true));
  21899. }
  21900. #endregion
  21901. #region 团组餐厅相关信息
  21902. /// <summary>
  21903. /// 团组相关餐厅信息
  21904. /// 基础数据(团组)
  21905. /// </summary>
  21906. /// <returns></returns>
  21907. [HttpGet]
  21908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21909. public async Task<IActionResult> RestaurantInit()
  21910. {
  21911. return Ok(await _restaurantRep.InitAsync());
  21912. }
  21913. /// <summary>
  21914. /// 团组相关餐厅信息
  21915. /// Item
  21916. /// </summary>
  21917. /// <param name="dto"></param>
  21918. /// <returns></returns>
  21919. [HttpPost]
  21920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21921. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  21922. {
  21923. int portType = dto.PortType,
  21924. groupId = dto.GroupId;
  21925. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21926. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21927. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  21928. }
  21929. /// <summary>
  21930. /// 团组相关餐厅信息
  21931. /// List
  21932. /// </summary>
  21933. /// <param name="dto"></param>
  21934. /// <returns></returns>
  21935. [HttpPost]
  21936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21937. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  21938. {
  21939. int portType = dto.PortType,
  21940. groupId = dto.GroupId;
  21941. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21942. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21943. var sql = string.Format(@" SELECT
  21944. ri.Id,
  21945. ri.GroupId,
  21946. ri.Date,
  21947. ri.StartTime,
  21948. ri.EndTime,
  21949. CASE WHEN ri.Type = 1 THEN '早餐'
  21950. WHEN ri.Type = 2 THEN '午餐'
  21951. WHEN ri.Type = 3 THEN '晚餐'
  21952. ELSE '其他'
  21953. END AS 'Type',
  21954. ri.Name,
  21955. ri.Address,
  21956. ri.Tel,
  21957. ri.Remark,
  21958. ri.CreateTime,
  21959. u.CnName AS CreateUserName
  21960. FROM
  21961. Grp_RestaurantInfo ri
  21962. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  21963. WHERE
  21964. ri.IsDel = 0
  21965. AND ri.GroupId = {0}
  21966. ORDER BY
  21967. ri.Date ASC
  21968. ", groupId);
  21969. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  21970. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  21971. return Ok(JsonView(infos));
  21972. }
  21973. /// <summary>
  21974. /// 团组相关餐厅信息
  21975. /// Info
  21976. /// </summary>
  21977. /// <param name="dto"></param>
  21978. /// <returns></returns>
  21979. [HttpPost]
  21980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21981. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  21982. {
  21983. int portType = dto.PortType,
  21984. id = dto.Id;
  21985. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21986. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21987. return Ok(await _restaurantRep.InfoAsync(portType, id));
  21988. }
  21989. /// <summary>
  21990. /// 团组相关餐厅信息
  21991. /// Op
  21992. /// </summary>
  21993. /// <param name="dto"></param>
  21994. /// <returns></returns>
  21995. [HttpPost]
  21996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21997. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  21998. {
  21999. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22000. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22001. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22002. return Ok(await _restaurantRep.OpAsync(dto));
  22003. }
  22004. /// <summary>
  22005. /// 团组相关餐厅信息
  22006. /// Del
  22007. /// </summary>
  22008. /// <param name="dto"></param>
  22009. /// <returns></returns>
  22010. [HttpPost]
  22011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22012. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22013. {
  22014. int userId = dto.DeleteUserId;
  22015. var id = dto.Id;
  22016. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22017. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22018. return Ok(await _restaurantRep.DelAsync(dto));
  22019. }
  22020. #endregion
  22021. // /// <summary>
  22022. // ///
  22023. // /// </summary>
  22024. // /// <param name="_dto"></param>
  22025. // /// <returns></returns>
  22026. // [HttpPost]
  22027. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22028. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22029. // {
  22030. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22031. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  22032. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  22033. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22034. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  22035. // dic_psg.Add("客人", 974);
  22036. // dic_psg.Add("司机", 975);
  22037. // dic_psg.Add("导游", 976);
  22038. // dic_psg.Add("公司内部人员", 977);
  22039. // dic_psg.Add("司机/导游/公司内部人员", 978);
  22040. // foreach (var item in list_visa)
  22041. // {
  22042. // Grp_VisaInfo temp = new Grp_VisaInfo();
  22043. // temp.Id = item.Id;
  22044. // temp.DIId = item.DIId;
  22045. // temp.VisaClient = item.VisaClient;
  22046. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  22047. // temp.VisaCurrency = item.VisaCurrency;
  22048. // temp.IsThird = item.IsThird;
  22049. // if (dic_psg.ContainsKey(item.PassengerType))
  22050. // {
  22051. // temp.PassengerType = dic_psg[item.PassengerType];
  22052. // }
  22053. // else {
  22054. // temp.PassengerType = -1;
  22055. // }
  22056. // temp.VisaNumber = item.VisaNumber;
  22057. // temp.VisaFreeNumber = item.VisaFreeNumber;
  22058. // temp.CreateUserId = item.Operators;
  22059. // DateTime dt_ct;
  22060. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  22061. // if (b_ct)
  22062. // {
  22063. // temp.CreateTime = dt_ct;
  22064. // }
  22065. // else
  22066. // {
  22067. // temp.CreateTime = DateTime.Now;
  22068. // }
  22069. // temp.DeleteTime = "";
  22070. // temp.DeleteUserId = 0;
  22071. // temp.Remark = item.Remark;
  22072. // if (string.IsNullOrEmpty(temp.Remark)) {
  22073. // temp.Remark = "";
  22074. // }
  22075. // temp.IsDel = item.IsDel;
  22076. // temp.VisaDescription = item.VisaAttachment;
  22077. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  22078. //([Id]
  22079. // ,[DIId]
  22080. // ,[VisaClient]
  22081. // ,[VisaPrice]
  22082. // ,[VisaCurrency]
  22083. // ,[IsThird]
  22084. // ,[PassengerType]
  22085. // ,[VisaNumber]
  22086. // ,[VisaFreeNumber]
  22087. // ,[CreateUserId]
  22088. // ,[CreateTime]
  22089. // ,[DeleteTime]
  22090. // ,[DeleteUserId]
  22091. // ,[Remark]
  22092. // ,[IsDel]
  22093. // ,[visaDescription])
  22094. // VALUES
  22095. // ({0},{1},'{2}',{3},{4}
  22096. //,{5},{6},{7},{8},{9}
  22097. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  22098. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  22099. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  22100. //);
  22101. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  22102. // }
  22103. // return Ok(JsonView(true, "操作成功!"));
  22104. // }
  22105. /// <summary>
  22106. /// 123132123
  22107. /// </summary>
  22108. /// <param name="_dto"></param>
  22109. /// <returns></returns>
  22110. [HttpPost]
  22111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22112. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22113. {
  22114. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22115. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22116. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22117. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22118. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22119. dicDetail.Add(789, 1034);
  22120. dicDetail.Add(790, 1035);
  22121. dicDetail.Add(791, 1036);
  22122. dicDetail.Add(792, 1037);
  22123. dicDetail.Add(793, 1038);
  22124. dicDetail.Add(794, 1039);
  22125. dicDetail.Add(795, 1040);
  22126. dicDetail.Add(796, 1041);
  22127. dicDetail.Add(797, 1042);
  22128. dicDetail.Add(798, 1043);
  22129. dicDetail.Add(801, 1044);
  22130. dicDetail.Add(802, 1045);
  22131. dicDetail.Add(803, 1046);
  22132. Dictionary<int, int> dic = new Dictionary<int, int>();
  22133. dic.Add(806, 1027);
  22134. dic.Add(807, 1028);
  22135. dic.Add(808, 1029);
  22136. dic.Add(809, 1030);
  22137. dic.Add(810, 1031);
  22138. dic.Add(811, 1032);
  22139. dic.Add(812, 1033);
  22140. foreach (var item in list_visa)
  22141. {
  22142. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22143. temp.Coefficient = item.coefficient;
  22144. DateTime dtCrt;
  22145. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22146. if (b1)
  22147. {
  22148. temp.CreateTime = dtCrt;
  22149. }
  22150. else
  22151. {
  22152. temp.CreateTime = DateTime.Now;
  22153. }
  22154. temp.CreateUserId = item.Operators;
  22155. temp.DeleteTime = "";
  22156. temp.DeleteUserId = 0;
  22157. temp.DiId = int.Parse(item.DIID);
  22158. temp.FilePath = item.FilePath;
  22159. temp.IsDel = item.IsDel;
  22160. temp.Price = item.Price;
  22161. temp.PriceCount = 1;
  22162. temp.PriceCurrency = item.Currency;
  22163. int detailId = 0;
  22164. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22165. {
  22166. detailId = dicDetail[item.PriceTypeDetail];
  22167. }
  22168. temp.PriceDetailType = detailId;
  22169. temp.PriceDt = DateTime.Now;
  22170. temp.PriceName = item.PriceName;
  22171. temp.PriceSum = item.Price;
  22172. int tid = 0;
  22173. if (dic.ContainsKey(item.PriceType))
  22174. {
  22175. tid = dic[item.PriceType];
  22176. }
  22177. temp.PriceType = tid;
  22178. temp.Remark = item.Remark;
  22179. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22180. }
  22181. return Ok(JsonView(true, "操作成功!"));
  22182. }
  22183. [HttpPost]
  22184. public IActionResult TimeTest()
  22185. {
  22186. var jw = JsonView(false, "error");
  22187. _sqlSugar.BeginTran();
  22188. try
  22189. {
  22190. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22191. .Select(x => new Crm_NewClientData
  22192. {
  22193. Id = x.Id,
  22194. Client = x.Client,
  22195. Contact = x.Contact,
  22196. Location = x.Location,
  22197. })
  22198. .ToList();
  22199. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22200. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22201. Stopwatch stopwatch = new Stopwatch();
  22202. // 开始计时
  22203. stopwatch.Start();
  22204. foreach (var item in clientList)
  22205. {
  22206. EncryptionProcessor.DecryptProperties(item);
  22207. }
  22208. stopwatch.Stop();
  22209. jw.Code = 200;
  22210. jw.Data = stopwatch.ElapsedMilliseconds;
  22211. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22212. }
  22213. catch (Exception ex)
  22214. {
  22215. jw.Code = 400;
  22216. jw.Msg = ex.Message;
  22217. }
  22218. return Ok(jw);
  22219. }
  22220. }
  22221. }