GroupsController.cs 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596
  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.OCR;
  42. using OASystem.Domain.ViewModels.QiYeWeChat;
  43. using OASystem.Domain.ViewModels.Statistics;
  44. using OASystem.Infrastructure.Repositories.CRM;
  45. using OASystem.Infrastructure.Repositories.Financial;
  46. using OASystem.Infrastructure.Repositories.Groups;
  47. using OASystem.Infrastructure.Tools;
  48. using OASystem.RedisRepository;
  49. using Org.BouncyCastle.Crypto;
  50. using Org.BouncyCastle.Utilities;
  51. using Quartz.Util;
  52. using SqlSugar.Extensions;
  53. using System.Collections;
  54. using System.Collections.Generic;
  55. using System.Data;
  56. using System.Diagnostics;
  57. using System.Drawing.Printing;
  58. using System.Globalization;
  59. using System.IO;
  60. using System.IO.Compression;
  61. using System.Reflection;
  62. using System.Text.Json;
  63. using System.Web;
  64. using System.Xml.Linq;
  65. using TencentCloud.Ocr.V20181119.Models;
  66. using static OASystem.API.OAMethodLib.JWTHelper;
  67. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  68. using Bookmark = Aspose.Words.Bookmark;
  69. using Cell = Aspose.Words.Tables.Cell;
  70. using Table = Aspose.Words.Tables.Table;
  71. namespace OASystem.API.Controllers
  72. {
  73. /// <summary>
  74. /// 团组相关
  75. /// </summary>
  76. //[Authorize]
  77. [Route("api/[controller]/[action]")]
  78. public class GroupsController : ControllerBase
  79. {
  80. private readonly ILogger<GroupsController> _logger;
  81. private readonly GrpScheduleRepository _grpScheduleRep;
  82. private readonly IMapper _mapper;
  83. private readonly DelegationInfoRepository _groupRepository;
  84. private readonly TaskAssignmentRepository _taskAssignmentRep;
  85. private readonly AirTicketResRepository _airTicketResRep;
  86. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  87. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  88. private readonly DelegationEnDataRepository _delegationEnDataRep;
  89. private readonly DelegationVisaRepository _delegationVisaRep;
  90. private readonly VisaPriceRepository _visaPriceRep;
  91. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  92. private readonly HotelPriceRepository _hotelPriceRep;
  93. private readonly CustomersRepository _customersRep;
  94. private readonly MessageRepository _message;
  95. private readonly SqlSugarClient _sqlSugar;
  96. private readonly TourClientListRepository _tourClientListRep;
  97. private readonly TeamRateRepository _teamRateRep;
  98. #region 成本相关
  99. private readonly CheckBoxsRepository _checkBoxs;
  100. private readonly GroupCostRepository _GroupCostRepository;
  101. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  102. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  103. #endregion
  104. private readonly SetDataRepository _setDataRep;
  105. private string url;
  106. private string path;
  107. private readonly EnterExitCostRepository _enterExitCostRep;
  108. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  109. private readonly UsersRepository _usersRep;
  110. private readonly IJuHeApiService _juHeApi;
  111. private readonly InvertedListRepository _invertedListRep;
  112. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  113. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  114. private readonly ThreeCodeRepository _threeCodeRepository;
  115. private readonly HotelInquiryRepository _hotelInquiryRep;
  116. private readonly FeeAuditRepository _feeAuditRep;
  117. private readonly VisaCommissionRepository _visaCommissionRep;
  118. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  119. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  120. private readonly List<CurrencyInfo> _currencyInit;
  121. private readonly List<int> _portTypeData;
  122. private readonly TableOperationRecordRepository _tableorRep;
  123. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  124. private readonly RestaurantRepository _restaurantRep;
  125. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  126. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  127. /// <summary>
  128. /// 构造函数
  129. /// </summary>
  130. /// <param name="logger"></param>
  131. /// <param name="mapper"></param>
  132. /// <param name="hubContext"></param>
  133. /// <param name="sqlSugar"></param>
  134. /// <param name="grpScheduleRep"></param>
  135. /// <param name="groupRepository"></param>
  136. /// <param name="taskAssignmentRep"></param>
  137. /// <param name="airTicketResRep"></param>
  138. /// <param name="decreasePaymentsRep"></param>
  139. /// <param name="InvitationOfficialActivitiesRep"></param>
  140. /// <param name="delegationEnDataRep"></param>
  141. /// <param name="enterExitCostRep"></param>
  142. /// <param name="delegationVisaRep"></param>
  143. /// <param name="message"></param>
  144. /// <param name="visaPriceRep"></param>
  145. /// <param name="carTouristGuideGroundRep"></param>
  146. /// <param name="checkBoxs"></param>
  147. /// <param name="GroupCostRepository"></param>
  148. /// <param name="CostTypeHotelNumberRepository"></param>
  149. /// <param name="GroupCostParameterRepository"></param>
  150. /// <param name="hotelPriceRep"></param>
  151. /// <param name="customersRep"></param>
  152. /// <param name="setDataRep"></param>
  153. /// <param name="tourClientListRep"></param>
  154. /// <param name="teamRateRep"></param>
  155. /// <param name="usersRep"></param>
  156. /// <param name="juHeApi"></param>
  157. /// <param name="invertedListRep"></param>
  158. /// <param name="visaFeeInfoRep"></param>
  159. /// <param name="ticketBlackCodeRep"></param>
  160. /// <param name="hotelInquiryRep"></param>
  161. /// <param name="threeCodeRepository"></param>
  162. /// <param name="feeAuditRep"></param>
  163. /// <param name="visaCommissionRep"></param>
  164. /// <param name="ffrRep"></param>
  165. /// <param name="opinionaireRep"></param>
  166. /// <param name="tableorRep"></param>
  167. /// <param name="enterExitCostDraftRep"></param>
  168. /// <param name="restaurantRep"></param>
  169. /// <param name="enterExitCostQuoteRep"></param>
  170. /// <param name="grpOrderPreInfoRep"></param>
  171. public GroupsController(
  172. ILogger<GroupsController> logger,
  173. IMapper mapper,
  174. IHubContext<ChatHub, IChatClient> hubContext,
  175. SqlSugarClient sqlSugar,
  176. GrpScheduleRepository grpScheduleRep,
  177. DelegationInfoRepository groupRepository,
  178. TaskAssignmentRepository taskAssignmentRep,
  179. AirTicketResRepository airTicketResRep,
  180. DecreasePaymentsRepository decreasePaymentsRep,
  181. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  182. DelegationEnDataRepository delegationEnDataRep,
  183. EnterExitCostRepository enterExitCostRep,
  184. DelegationVisaRepository delegationVisaRep,
  185. MessageRepository message,
  186. VisaPriceRepository visaPriceRep,
  187. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  188. CheckBoxsRepository checkBoxs,
  189. GroupCostRepository GroupCostRepository,
  190. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  191. GroupCostParameterRepository GroupCostParameterRepository,
  192. HotelPriceRepository hotelPriceRep,
  193. CustomersRepository customersRep,
  194. SetDataRepository setDataRep,
  195. TourClientListRepository tourClientListRep,
  196. TeamRateRepository teamRateRep,
  197. UsersRepository usersRep,
  198. IJuHeApiService juHeApi,
  199. InvertedListRepository invertedListRep,
  200. VisaFeeInfoRepository visaFeeInfoRep,
  201. TicketBlackCodeRepository ticketBlackCodeRep,
  202. HotelInquiryRepository hotelInquiryRep,
  203. ThreeCodeRepository threeCodeRepository,
  204. FeeAuditRepository feeAuditRep,
  205. VisaCommissionRepository visaCommissionRep,
  206. ForeignReceivablesRepository ffrRep,
  207. OpinionaireRepository opinionaireRep,
  208. TableOperationRecordRepository tableorRep,
  209. EnterExitCostDraftRepository enterExitCostDraftRep,
  210. RestaurantRepository restaurantRep,
  211. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  212. GroupOrderPreInfoRepository grpOrderPreInfoRep
  213. )
  214. {
  215. _logger = logger;
  216. _mapper = mapper;
  217. _grpScheduleRep = grpScheduleRep;
  218. _groupRepository = groupRepository;
  219. _taskAssignmentRep = taskAssignmentRep;
  220. _airTicketResRep = airTicketResRep;
  221. _sqlSugar = sqlSugar;
  222. url = AppSettingsHelper.Get("ExcelBaseUrl");
  223. path = AppSettingsHelper.Get("ExcelBasePath");
  224. if (!System.IO.Directory.Exists(path))
  225. {
  226. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  227. }
  228. _decreasePaymentsRep = decreasePaymentsRep;
  229. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  230. _delegationEnDataRep = delegationEnDataRep;
  231. _enterExitCostRep = enterExitCostRep;
  232. _delegationVisaRep = delegationVisaRep;
  233. _message = message;
  234. _visaPriceRep = visaPriceRep;
  235. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  236. _checkBoxs = checkBoxs;
  237. _GroupCostRepository = GroupCostRepository;
  238. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  239. _GroupCostParameterRepository = GroupCostParameterRepository;
  240. _hotelPriceRep = hotelPriceRep;
  241. _customersRep = customersRep;
  242. _setDataRep = setDataRep;
  243. _tourClientListRep = tourClientListRep;
  244. _teamRateRep = teamRateRep;
  245. _hubContext = hubContext;
  246. _usersRep = usersRep;
  247. _juHeApi = juHeApi;
  248. _invertedListRep = invertedListRep;
  249. _visaFeeInfoRep = visaFeeInfoRep;
  250. _ticketBlackCodeRep = ticketBlackCodeRep;
  251. _hotelInquiryRep = hotelInquiryRep;
  252. _threeCodeRepository = threeCodeRepository;
  253. _feeAuditRep = feeAuditRep;
  254. _visaCommissionRep = visaCommissionRep;
  255. _ffrRep = ffrRep;
  256. _opinionaireRep = opinionaireRep;
  257. _currencyInit = new List<CurrencyInfo>()
  258. {
  259. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  260. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  261. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  262. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  263. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  264. };
  265. _portTypeData = new List<int>() { 2, 3 };
  266. _tableorRep = tableorRep;
  267. _enterExitCostDraftRep = enterExitCostDraftRep;
  268. _restaurantRep = restaurantRep;
  269. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  270. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  271. }
  272. #region 流程管控
  273. /// <summary>
  274. /// 获取团组流程管控信息
  275. /// </summary>
  276. /// <param name="_jsonDto">查询参数</param>
  277. /// <returns></returns>
  278. [HttpPost]
  279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  280. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  281. {
  282. if (string.IsNullOrEmpty(_jsonDto.Paras))
  283. {
  284. return Ok(JsonView(false, "参数为空"));
  285. }
  286. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  287. if (_ScheduleDto != null)
  288. {
  289. if (_ScheduleDto.SearchType == 2)//获取列表
  290. {
  291. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  292. return Ok(JsonView(_grpScheduleViewList));
  293. }
  294. else//获取对象
  295. {
  296. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  297. if (_grpScheduleView != null)
  298. {
  299. return Ok(JsonView(_grpScheduleView));
  300. }
  301. }
  302. }
  303. else
  304. {
  305. return Ok(JsonView(false, "参数反序列化失败"));
  306. }
  307. return Ok(JsonView(false, "暂无数据!"));
  308. }
  309. /// <summary>
  310. /// 修改团组流程管控详细表数据
  311. /// </summary>
  312. /// <param name="dto"></param>
  313. /// <returns></returns>
  314. [HttpPost]
  315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  316. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  317. {
  318. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  319. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  320. .SetColumns(it => it.Duty == _detail.Duty)
  321. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  322. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  323. .SetColumns(it => it.JobContent == _detail.JobContent)
  324. .SetColumns(it => it.Remark == _detail.Remark)
  325. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  326. .Where(s => s.Id == dto.Id)
  327. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  328. .ExecuteCommandAsync();
  329. if (result > 0)
  330. {
  331. return Ok(JsonView(true, "保存成功!"));
  332. }
  333. return Ok(JsonView(false, "保存失败!"));
  334. }
  335. /// <summary>
  336. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  337. /// </summary>
  338. /// <param name="dto"></param>
  339. /// <returns></returns>
  340. [HttpPost]
  341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  342. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  343. {
  344. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  345. _detail.IsDel = 1;
  346. _detail.DeleteUserId = dto.Duty;
  347. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  348. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  349. .SetColumns(it => it.IsDel == _detail.IsDel)
  350. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  351. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  352. .Where(it => it.Id == dto.Id)
  353. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  354. //.WhereColumns(s => s.Id == dto.Id)
  355. .ExecuteCommandAsync();
  356. if (result > 0)
  357. {
  358. return Ok(JsonView(true, "删除成功!"));
  359. }
  360. return Ok(JsonView(false, "删除失败!"));
  361. }
  362. /// <summary>
  363. /// 增加团组流程管控详细表数据
  364. /// </summary>
  365. /// <param name="dto"></param>
  366. /// <returns></returns>
  367. [HttpPost]
  368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  369. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  370. {
  371. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  372. if (DateTime.Now < _detail.ExpectBeginDt)
  373. {
  374. _detail.StepStatus = 0;
  375. }
  376. else
  377. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  378. _detail.StepStatus = 1;
  379. }
  380. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  381. if (result > 0)
  382. {
  383. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  384. return Ok(JsonView(true, "添加成功!", _result));
  385. }
  386. return Ok(JsonView(false, "添加失败!"));
  387. }
  388. #endregion
  389. #region 团组前期信息
  390. /// <summary>
  391. /// 团组前期信息 List
  392. /// </summary>
  393. /// <returns></returns>
  394. [HttpPost]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  397. {
  398. var search = dto.Search;
  399. int[] nameTempIds = new int[] { 1, 12, 28 },
  400. countryTempIds = new int[] { 2, 13, 29 },
  401. daysTempIds = new int[] { 4, 15, 31 },
  402. ppNumTempIds = new int[] { 6 };
  403. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  404. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  405. .Where((opi, u) => opi.IsDel == 0)
  406. .OrderByDescending((opi, u) => opi.CreateTime)
  407. .Select((opi, u) => new GroupOrderPreInfoListView()
  408. {
  409. Id = opi.Id,
  410. Name = opi.Name,
  411. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains( x.FormTempId)).Select(x => x.Value),
  412. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  413. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  415. Operator = u.CnName,
  416. OperationTime = opi.CreateTime
  417. })
  418. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  419. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  420. .ToListAsync();
  421. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  422. int total = list.Count;
  423. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  424. var listPageData1 = listPageData
  425. .Skip((dto.PageIndex - 1) * dto.PageSize)
  426. .Take(dto.PageSize)
  427. .ToList();
  428. var infoIds = listPageData1.Select(x => x.Id).ToList();
  429. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  430. .Where(x => x.IsDel == 0 && x.STid == 109)
  431. .ToArrayAsync();
  432. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  433. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  434. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  435. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  436. .ToListAsync();
  437. foreach (var item in listPageData1)
  438. {
  439. var typeDatas1 = typeDatas.Select(x => new
  440. {
  441. Id = x.Id,
  442. Name = x.Name,
  443. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  444. }).ToArray();
  445. item.VersionDetails = typeDatas1;
  446. }
  447. return Ok(JsonView(listPageData1, listPageData1.Count));
  448. }
  449. /// <summary>
  450. /// 团组前期信息 Init
  451. /// </summary>
  452. /// <returns></returns>
  453. [HttpGet("{userId}")]
  454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  455. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  456. {
  457. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  458. }
  459. /// <summary>
  460. /// 国家数据源
  461. /// </summary>
  462. /// <param name="pageIndex">当前页码</param>
  463. /// <param name="pageSize">每页条数</param>
  464. /// <param name="search">查询条件</param>
  465. /// <returns></returns>
  466. [HttpGet]
  467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  468. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  469. {
  470. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  471. if (pageIndex == 0 && pageSize == 0)
  472. {
  473. //所有数据
  474. return Ok(JsonView(countrys, countrys.Count));
  475. }
  476. //分页
  477. int skip = (pageIndex - 1) * pageSize;
  478. int take = pageSize;
  479. if (!string.IsNullOrEmpty(search))
  480. {
  481. IEnumerable<char> charSequence = search.Select(c => c);
  482. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  483. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  484. return Ok(JsonView(pageData, pageResult1.Count));
  485. }
  486. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  487. return Ok(JsonView(pageResult2, countrys.Count));
  488. }
  489. /// <summary>
  490. /// 城市数据源
  491. /// </summary>
  492. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  493. /// <param name="pageIndex">当前页码</param>
  494. /// <param name="pageSize">每页条数</param>
  495. /// <param name="search">查询条件</param>
  496. /// <returns></returns>
  497. [HttpGet("{countryLabel}")]
  498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  499. public async Task<IActionResult> CityByCountry(
  500. string countryLabel,
  501. [FromQuery] int pageIndex,
  502. [FromQuery] int pageSize,
  503. [FromQuery] string search)
  504. {
  505. countryLabel = HttpUtility.UrlDecode(countryLabel);
  506. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  507. var citys = Array.Empty<string?>();
  508. if (countryList.Any())
  509. {
  510. var cityDatas = await _sqlSugar
  511. .Queryable<Grp_NationalTravelFee>()
  512. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  513. .ToArrayAsync();
  514. foreach (var item in cityDatas)
  515. {
  516. if (item.City.Contains("城市"))
  517. {
  518. item.City = item.Country + "-所有城市";
  519. }
  520. }
  521. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  522. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  523. }
  524. if (pageIndex == 0 && pageSize == 0)
  525. {
  526. //所有数据
  527. return Ok(JsonView(citys, citys?.Length ?? 0));
  528. }
  529. //分页
  530. int skip = (pageIndex - 1) * pageSize;
  531. int take = pageSize;
  532. if (!string.IsNullOrEmpty(search))
  533. {
  534. IEnumerable<char> charSequence = search.Select(c => c);
  535. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  536. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  537. return Ok(JsonView(pageData, pageResult1.Count()));
  538. }
  539. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  540. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  541. }
  542. /// <summary>
  543. /// 团组前期信息 Info
  544. /// </summary>
  545. /// <param name="dto">Id</param>
  546. /// <param name="portType">Id</param>
  547. /// <returns></returns>
  548. [HttpGet("{Id}/{TempId}")]
  549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  550. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto,int portType=1)
  551. {
  552. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  553. }
  554. /// <summary>
  555. /// 团组前期信息 移动端 Info
  556. /// </summary>
  557. /// <param name="dto">Id</param>
  558. /// <returns></returns>
  559. [HttpGet("{Id}/{TempId}")]
  560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  561. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  562. {
  563. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  564. }
  565. /// <summary>
  566. /// 团组前期信息 Save
  567. /// </summary>
  568. /// <param name="dto">Id</param>
  569. /// <returns></returns>
  570. [HttpPost]
  571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  572. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  573. {
  574. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  575. }
  576. /// <summary>
  577. /// 团组前期信息 Del
  578. /// </summary>
  579. /// <param name="dto">Id</param>
  580. /// <returns></returns>
  581. [HttpPost]
  582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  583. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  584. {
  585. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  586. }
  587. /// <summary>
  588. /// 团组前期信息 文件下载
  589. /// </summary>
  590. /// <param name="dto">Id</param>
  591. /// <returns></returns>
  592. [HttpGet("{Id}/{TempId}")]
  593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  594. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  595. {
  596. int id = dto.Id, tempId = dto.TempId;
  597. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  598. var data = view.Data as GrpOrderPreInfoView;
  599. #region Excel
  600. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  601. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  602. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  603. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  604. var fileNamePrefix = string.Empty;
  605. if (tempId == 1405)
  606. {
  607. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  608. fileNamePrefix = $"{data.Name}_无商邀版";
  609. }
  610. else if (tempId == 1406)
  611. {
  612. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  613. fileNamePrefix = $"{data.Name}_有商邀版";
  614. }
  615. else
  616. {
  617. //tempId == 1404 默认下载
  618. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  619. fileNamePrefix = $"{data.Name}_单接送机";
  620. }
  621. foreach (var item in data.Items)
  622. {
  623. var obj = item.NewValue;
  624. if (obj == null) item.OriginVal = "";
  625. else if (obj.Equals("有") || obj.Equals("无"))
  626. {
  627. item.OriginVal = obj.ToString();
  628. }
  629. else if (obj is object[] objArray)
  630. {
  631. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  632. item.OriginVal = string.Join("、", stringArray);
  633. }
  634. else if (obj is string[] stringArray)
  635. {
  636. item.OriginVal = string.Join("、", stringArray);
  637. }
  638. else if (obj.Equals("-"))
  639. {
  640. item.OriginVal = "";
  641. }
  642. }
  643. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  644. fileName = CommonFun.ValidFileName(fileName);
  645. //载入模板
  646. WorkbookDesigner designer = new WorkbookDesigner();
  647. designer.Workbook = new Workbook(tempPath);
  648. if (tempId == 1406)
  649. {
  650. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  651. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  652. for (int i = 1; i <= view2.Length; i++)
  653. {
  654. view2[i - 1].Index = i;
  655. }
  656. designer.SetDataSource("View1", view1);
  657. designer.SetDataSource("View2", view2);
  658. }
  659. else
  660. {
  661. designer.SetDataSource("View", data.Items);
  662. }
  663. designer.Process();
  664. if (!Directory.Exists(savePath))
  665. {
  666. Directory.CreateDirectory(savePath);
  667. }
  668. string serverPath = $"{savePath}{fileName}";
  669. designer.Workbook.Save(serverPath);
  670. string rst = $"{servicePath}{ftpPath}{fileName}";
  671. #endregion
  672. return Ok(JsonView(new { url = rst }));
  673. }
  674. #endregion
  675. #region 团组基本信息
  676. /// <summary>
  677. /// 接团信息列表
  678. /// </summary>
  679. /// <param name="dto">团组列表请求dto</param>
  680. /// <returns></returns>
  681. [HttpPost]
  682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  683. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  684. {
  685. var groupData = await _groupRepository.GetGroupList(dto);
  686. if (groupData.Code != 0)
  687. {
  688. return Ok(JsonView(false, groupData.Msg));
  689. }
  690. return Ok(JsonView(groupData.Data));
  691. }
  692. /// <summary>
  693. /// 分页查询团组列表
  694. /// </summary>
  695. /// <param name="dto"></param>
  696. /// <returns></returns>
  697. [HttpPost]
  698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  699. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  700. {
  701. var watch = new Stopwatch();
  702. watch.Start();
  703. RefAsync<int> total = 0;
  704. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  705. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  706. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  707. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  708. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  709. .Distinct()
  710. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  711. watch.Stop();
  712. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  713. }
  714. /// <summary>
  715. /// 接团信息列表 Page Init
  716. /// </summary>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> PostGroupPageListInit()
  721. {
  722. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  723. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  724. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  725. var _view = new
  726. {
  727. depData = depDatas,
  728. rankData = rankDatas
  729. };
  730. return Ok(JsonView(true, "查询成功!", _view));
  731. }
  732. /// <summary>
  733. /// 接团信息列表 Page
  734. /// </summary>
  735. /// <param name="dto">团组列表请求dto</param>
  736. /// <returns></returns>
  737. [HttpPost]
  738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  739. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  740. {
  741. #region 参数验证
  742. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  743. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  744. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  745. #region 页面操作权限验证
  746. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  747. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  748. #endregion
  749. #endregion
  750. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  751. {
  752. string sqlWhere = string.Empty;
  753. if (dto.IsSure == 0) //未完成
  754. {
  755. sqlWhere += string.Format(@" And IsSure = 0");
  756. }
  757. else if (dto.IsSure == 1) //已完成
  758. {
  759. sqlWhere += string.Format(@" And IsSure = 1");
  760. }
  761. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  762. {
  763. string tj = dto.SearchCriteria;
  764. 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}%')",
  765. tj, tj, tj, tj, tj);
  766. }
  767. if (int.TryParse(dto.Rank, out int rankId))
  768. {
  769. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  770. }
  771. string sqlWhere1 = string.Empty;
  772. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  773. {
  774. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  775. }
  776. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  777. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  778. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  779. JietuanOperator,IsSure,CreateTime,IsBid
  780. From (
  781. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  782. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  783. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  784. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  785. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  786. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  787. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  788. From Grp_DelegationInfo gdi
  789. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  790. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  791. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  792. Where gdi.IsDel = 0 {0}
  793. ) temp {1}", sqlWhere, sqlWhere1);
  794. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  795. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  796. var _view = new
  797. {
  798. PageFuncAuth = pageFunAuthView,
  799. Data = _DelegationList
  800. };
  801. return Ok(JsonView(true, "查询成功!", _view, total));
  802. }
  803. else
  804. {
  805. return Ok(JsonView(false, "查询失败"));
  806. }
  807. }
  808. /// <summary>
  809. /// 团组列表
  810. /// </summary>
  811. /// <returns></returns>
  812. [HttpPost]
  813. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  814. {
  815. #region 参数验证
  816. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  817. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  818. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  819. #region 页面操作权限验证
  820. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  821. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  822. #endregion
  823. #endregion
  824. if (dto.PortType != 1 && dto.PortType != 2)
  825. {
  826. return Ok(JsonView(false, "查询失败!"));
  827. }
  828. string orderbyStr = "order by gdi.CreateTime Desc";
  829. string sqlWhere = string.Empty;
  830. if (dto.IsSure == 0) //未完成
  831. {
  832. sqlWhere += string.Format(@" And IsSure = 0");
  833. }
  834. else if (dto.IsSure == 1) //已完成
  835. {
  836. sqlWhere += string.Format(@" And IsSure = 1");
  837. }
  838. //团组类型
  839. if (dto.TeamDid > 0)
  840. {
  841. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  842. }
  843. //团组名称
  844. if (!string.IsNullOrEmpty(dto.TeamName))
  845. {
  846. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  847. }
  848. //客户名称
  849. if (!string.IsNullOrEmpty(dto.ClientName))
  850. {
  851. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  852. }
  853. //客户单位
  854. if (!string.IsNullOrEmpty(dto.ClientUnit))
  855. {
  856. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  857. }
  858. //出访时间
  859. if (!string.IsNullOrEmpty(dto.visitDataTime))
  860. {
  861. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  862. orderbyStr = "order by gdi.VisitDate";
  863. }
  864. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  865. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  866. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  867. JietuanOperator,IsSure,CreateTime
  868. From (
  869. Select row_number() over({0}) as Row_Number,
  870. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  871. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  872. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  873. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  874. From Grp_DelegationInfo gdi
  875. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  876. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  877. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  878. Where gdi.IsDel = 0 {1}
  879. ) temp ", orderbyStr, sqlWhere);
  880. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  881. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  882. #region 处理所属部门
  883. /*
  884. * 1.sq 和 gyy 等显示 市场部
  885. * 2.王鸽和主管及张总还有管理员号统一国交部
  886. * 2-1. 4 管理员 ,21 张海麟
  887. */
  888. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  889. List<int> userIds1 = new List<int>() { 4, 21 };
  890. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  891. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  892. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  893. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  894. .ToList();
  895. foreach (var item in _DelegationList)
  896. {
  897. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  898. }
  899. #endregion
  900. var _view = new
  901. {
  902. PageFuncAuth = pageFunAuthView,
  903. Data = _DelegationList
  904. };
  905. return Ok(JsonView(true, "查询成功!", _view, total));
  906. }
  907. /// <summary>
  908. /// 接团信息详情
  909. /// </summary>
  910. /// <param name="dto">团组info请求dto</param>
  911. /// <returns></returns>
  912. [HttpPost]
  913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  914. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  915. {
  916. var groupData = await _groupRepository.GetGroupInfo(dto);
  917. if (groupData.Code != 0)
  918. {
  919. return Ok(JsonView(false, groupData.Msg));
  920. }
  921. return Ok(JsonView(groupData.Data));
  922. }
  923. /// <summary>
  924. /// 接团信息 编辑添加
  925. /// 基础信息数据源
  926. /// </summary>
  927. /// <param name="dto"></param>
  928. /// <returns></returns>
  929. [HttpPost]
  930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  931. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  932. {
  933. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  934. if (groupData.Code != 0)
  935. {
  936. return Ok(JsonView(false, groupData.Msg));
  937. }
  938. return Ok(JsonView(groupData.Data));
  939. }
  940. /// <summary>
  941. /// 接团信息 编辑添加
  942. /// 省份-城市 基础信息数据源
  943. /// </summary>
  944. /// <param name="dto"></param>
  945. /// <returns></returns>
  946. [HttpPost]
  947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  948. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  949. {
  950. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  951. string search = dto.Search;
  952. var data = await _groupRepository.CityBasicSource();
  953. int total = data.Length;
  954. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  955. .Skip((pageIndex - 1) * pageSize)
  956. .Take(pageSize)
  957. .ToArray();
  958. return Ok(JsonView(data, total));
  959. }
  960. /// <summary>
  961. /// 接团信息 操作(增改)
  962. /// </summary>
  963. /// <param name="dto"></param>
  964. /// <returns></returns>
  965. [HttpPost]
  966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  967. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  968. {
  969. // 创建 Stopwatch 实例
  970. Stopwatch stopwatch = Stopwatch.StartNew();
  971. decimal ffrPrice = 0.00M;
  972. DateTime? visitDt = null;
  973. if (dto.Status == 2)
  974. {
  975. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  976. if (groupInfo != null)
  977. {
  978. ffrPrice = groupInfo.PaymentMoney;
  979. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  980. }
  981. }
  982. var groupData = await _groupRepository.GroupOperation(dto);
  983. if (groupData.Code != 0)
  984. {
  985. return Ok(JsonView(false, groupData.Msg));
  986. }
  987. int diId = 0;
  988. try
  989. {
  990. //添加时 默认加入团组汇率
  991. if (dto.Status == 1) //添加
  992. {
  993. diId = groupData.Data;
  994. //添加默认币种
  995. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  996. //默认分配权限
  997. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  998. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  999. var _managerIds = new List<int>() { 22, 32, 21 };
  1000. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1001. if (userIds.Count > 0)
  1002. {
  1003. userIds.Add(208);
  1004. //创建团组管控
  1005. GroupStepForDelegation.CreateWorkStep(diId);
  1006. //发送消息
  1007. string groupName = dto.TeamName;
  1008. string createGroupUser = string.Empty;
  1009. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1010. if (userInfo != null) createGroupUser = userInfo.CnName;
  1011. string title = $"系统通知";
  1012. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1013. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1014. }
  1015. //默认创建倒推表
  1016. await _invertedListRep._Create(dto.UserId, diId);
  1017. }
  1018. else if (dto.Status == 2)
  1019. {
  1020. diId = dto.Id;
  1021. }
  1022. #region 签证人员团组时间通知
  1023. #region 计算出访起止时间
  1024. var startTime = new DateTime();
  1025. var endTime = new DateTime();
  1026. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1027. {
  1028. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1029. }
  1030. #endregion
  1031. #endregion
  1032. #region 团组操作默认添加/修改收款账单
  1033. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1034. {
  1035. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1036. .Where(x => x.IsDel == 0 &&
  1037. x.Diid == diId &&
  1038. x.Remark.Equals("预付款")
  1039. )
  1040. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1041. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1042. .FirstAsync();
  1043. ffrInfo = new Fin_ForeignReceivables()
  1044. {
  1045. Diid = diId,
  1046. PriceName = dto.ClientUnit,
  1047. Price = dto.PaymentMoney,
  1048. Count = 1,
  1049. Unit = $"元",
  1050. ItemSumPrice = dto.PaymentMoney,
  1051. Rate = 1.0000M,
  1052. Currency = 836,
  1053. AddingWay = 0,
  1054. CreateUserId = dto.UserId,
  1055. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1056. Remark = $"预付款"
  1057. };
  1058. if (ffrInfo == null) //Add
  1059. {
  1060. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1061. }
  1062. else //修改
  1063. {
  1064. await _sqlSugar.Updateable(ffrInfo)
  1065. .UpdateColumns(x => new
  1066. {
  1067. x.PriceName,
  1068. x.Price,
  1069. x.ItemSumPrice,
  1070. x.CreateTime,
  1071. x.CreateUserId
  1072. })
  1073. .WhereColumns(x => x.Id)
  1074. .ExecuteCommandAsync();
  1075. }
  1076. }
  1077. #endregion
  1078. if (diId > 0)
  1079. {
  1080. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1081. }
  1082. // 停止计时
  1083. stopwatch.Stop();
  1084. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1085. }
  1086. catch (Exception ex)
  1087. {
  1088. // 停止计时
  1089. stopwatch.Stop();
  1090. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1091. Logs(ex.Message);
  1092. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1093. }
  1094. // 停止计时
  1095. stopwatch.Stop();
  1096. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1097. }
  1098. /// <summary>
  1099. /// 接团流程操作(增改)
  1100. /// 安卓端使用 建团时添加客户名单
  1101. /// </summary>
  1102. /// <param name="dto"></param>
  1103. /// <returns></returns>
  1104. [HttpPost]
  1105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1106. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1107. {
  1108. #region 参数验证
  1109. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1110. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1111. #region 页面操作权限验证
  1112. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1113. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1114. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1115. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1116. #endregion
  1117. #endregion
  1118. try
  1119. {
  1120. //_sqlSugar.BeginTran();
  1121. decimal ffrPrice = 0.00M;
  1122. DateTime? visitDt = null;
  1123. if (dto.Status == 2)
  1124. {
  1125. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1126. if (groupInfo != null)
  1127. {
  1128. ffrPrice = groupInfo.PaymentMoney;
  1129. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1130. }
  1131. }
  1132. var _dto = new GroupOperationDto();
  1133. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1134. var groupData = await _groupRepository.GroupOperation(_dto);
  1135. if (groupData.Code != 0)
  1136. {
  1137. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1138. }
  1139. int diId = 0;
  1140. //添加时 默认加入团组汇率
  1141. if (dto.Status == 1) //添加
  1142. {
  1143. diId = groupData.Data;
  1144. //添加默认币种
  1145. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1146. //默认分配权限
  1147. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1148. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1149. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1150. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1151. if (userIds.Count > 0)
  1152. {
  1153. userIds.Add(208);
  1154. //创建团组管控
  1155. GroupStepForDelegation.CreateWorkStep(diId);
  1156. //发送消息
  1157. string groupName = dto.TeamName;
  1158. string createGroupUser = string.Empty;
  1159. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1160. if (userInfo != null) createGroupUser = userInfo.CnName;
  1161. string title = $"系统通知";
  1162. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1163. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1164. }
  1165. #region 应用推送
  1166. try
  1167. {
  1168. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1169. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1170. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1171. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1172. {
  1173. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1174. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1175. }
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. }
  1180. #endregion
  1181. //默认创建倒推表
  1182. await _invertedListRep._Create(dto.UserId, diId);
  1183. }
  1184. if (dto.Status == 2)
  1185. {
  1186. diId = dto.Id;
  1187. if (diId == 0)
  1188. {
  1189. //_sqlSugar.RollbackTran();
  1190. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1191. }
  1192. }
  1193. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1194. if (viewData.Code != 0)
  1195. {
  1196. //_sqlSugar.RollbackTran();
  1197. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1198. }
  1199. #region 团组操作默认添加/修改收款账单
  1200. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1201. {
  1202. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1203. .Where(x => x.IsDel == 0 &&
  1204. x.Diid == diId &&
  1205. x.Remark.Equals("预付款")
  1206. )
  1207. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1208. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1209. .FirstAsync();
  1210. ffrInfo = new Fin_ForeignReceivables()
  1211. {
  1212. Diid = diId,
  1213. PriceName = dto.ClientUnit,
  1214. Price = dto.PaymentMoney,
  1215. Count = 1,
  1216. Unit = $"元",
  1217. ItemSumPrice = dto.PaymentMoney,
  1218. Rate = 1.0000M,
  1219. Currency = 836,
  1220. AddingWay = 0,
  1221. CreateUserId = dto.UserId,
  1222. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1223. Remark = $"预付款"
  1224. };
  1225. if (ffrInfo == null) //Add
  1226. {
  1227. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1228. }
  1229. else //修改
  1230. {
  1231. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1232. .UpdateColumns(x => new
  1233. {
  1234. x.PriceName,
  1235. x.Price,
  1236. x.ItemSumPrice,
  1237. x.CreateTime,
  1238. x.CreateUserId
  1239. })
  1240. .WhereColumns(x => x.Id)
  1241. .ExecuteCommandAsync();
  1242. }
  1243. }
  1244. #endregion
  1245. #region 签证人员团组时间通知
  1246. #region 计算出访起止时间
  1247. var startTime = new DateTime();
  1248. var endTime = new DateTime();
  1249. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1250. {
  1251. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1252. }
  1253. #endregion
  1254. if (diId > 0)
  1255. {
  1256. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1257. }
  1258. #endregion
  1259. //_sqlSugar.CommitTran();
  1260. return Ok(JsonView(true, "添加成功"));
  1261. }
  1262. catch (Exception ex)
  1263. {
  1264. _sqlSugar.RollbackTran();
  1265. return Ok(JsonView(false, ex.Message));
  1266. }
  1267. }
  1268. /// <summary>
  1269. /// 接团流程操作(增改)
  1270. /// 安卓端使用 建团时添加客户名单
  1271. /// </summary>
  1272. /// <param name="dto"></param>
  1273. /// <returns></returns>
  1274. [HttpPost]
  1275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1276. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1277. {
  1278. #region 参数验证
  1279. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1280. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1281. #region 页面操作权限验证
  1282. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1283. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1284. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1285. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1286. #endregion
  1287. #endregion
  1288. _sqlSugar.BeginTran();
  1289. decimal ffrPrice = 0.00M;
  1290. DateTime? visitDt = null;
  1291. if (dto.Status == 2)
  1292. {
  1293. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1294. if (groupInfo != null)
  1295. {
  1296. ffrPrice = groupInfo.PaymentMoney;
  1297. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1298. }
  1299. }
  1300. var _dto = new GroupOperationDto();
  1301. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1302. var groupData = await _groupRepository.GroupOperation(_dto);
  1303. if (groupData.Code != 0)
  1304. {
  1305. _sqlSugar.RollbackTran();
  1306. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1307. }
  1308. try
  1309. {
  1310. int diId = 0;
  1311. //添加时 默认加入团组汇率
  1312. if (dto.Status == 1) //添加
  1313. {
  1314. diId = groupData.Data;
  1315. //添加默认币种
  1316. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1317. //默认分配权限
  1318. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1319. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1320. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1321. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1322. if (userIds.Count > 0)
  1323. {
  1324. userIds.Add(208);
  1325. //创建团组管控
  1326. GroupStepForDelegation.CreateWorkStep(diId);
  1327. //发送消息
  1328. string groupName = dto.TeamName;
  1329. string createGroupUser = string.Empty;
  1330. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1331. if (userInfo != null) createGroupUser = userInfo.CnName;
  1332. string title = $"系统通知";
  1333. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1334. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1335. }
  1336. #region 应用推送
  1337. try
  1338. {
  1339. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1340. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1341. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1342. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1343. {
  1344. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1345. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1346. }
  1347. }
  1348. catch (Exception ex)
  1349. {
  1350. _sqlSugar.CommitTran();
  1351. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1352. }
  1353. #endregion
  1354. //默认创建倒推表
  1355. await _invertedListRep._Create(dto.UserId, diId);
  1356. }
  1357. else if (dto.Status == 2)
  1358. {
  1359. diId = dto.Id;
  1360. if (diId == 0)
  1361. {
  1362. _sqlSugar.RollbackTran();
  1363. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1364. }
  1365. }
  1366. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1367. if (viewData.Code != 0)
  1368. {
  1369. _sqlSugar.RollbackTran();
  1370. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1371. }
  1372. #region 团组操作默认添加/修改收款账单
  1373. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1374. {
  1375. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1376. .Where(x => x.IsDel == 0 &&
  1377. x.Diid == diId &&
  1378. x.Remark.Equals("预付款")
  1379. )
  1380. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1381. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1382. .FirstAsync();
  1383. ffrInfo = new Fin_ForeignReceivables()
  1384. {
  1385. Diid = diId,
  1386. PriceName = dto.ClientUnit,
  1387. Price = dto.PaymentMoney,
  1388. Count = 1,
  1389. Unit = $"元",
  1390. ItemSumPrice = dto.PaymentMoney,
  1391. Rate = 1.0000M,
  1392. Currency = 836,
  1393. AddingWay = 0,
  1394. CreateUserId = dto.UserId,
  1395. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1396. Remark = $"预付款"
  1397. };
  1398. if (ffrInfo == null) //Add
  1399. {
  1400. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1401. }
  1402. else //修改
  1403. {
  1404. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1405. .UpdateColumns(x => new
  1406. {
  1407. x.PriceName,
  1408. x.Price,
  1409. x.ItemSumPrice,
  1410. x.CreateTime,
  1411. x.CreateUserId
  1412. })
  1413. .WhereColumns(x => x.Id)
  1414. .ExecuteCommandAsync();
  1415. }
  1416. }
  1417. #endregion
  1418. #region 签证人员团组时间通知
  1419. #region 计算出访起止时间
  1420. var startTime = new DateTime();
  1421. var endTime = new DateTime();
  1422. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1423. {
  1424. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1425. }
  1426. #endregion
  1427. if (diId > 0)
  1428. {
  1429. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1430. }
  1431. #endregion
  1432. _sqlSugar.CommitTran();
  1433. return Ok(JsonView(true));
  1434. }
  1435. catch (Exception ex)
  1436. {
  1437. _sqlSugar.RollbackTran();
  1438. return Ok(JsonView(false, ex.Message));
  1439. }
  1440. }
  1441. /// <summary>
  1442. /// 接团信息 操作(删除)
  1443. /// </summary>
  1444. /// <param name="dto"></param>
  1445. /// <returns></returns>
  1446. [HttpPost]
  1447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1448. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1449. {
  1450. var diId = dto.Id;
  1451. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1452. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1453. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1454. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1455. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1456. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1457. #endregion
  1458. var groupData = await _groupRepository.GroupDel(dto);
  1459. if (groupData.Code != 0)
  1460. {
  1461. return Ok(JsonView(false, groupData.Msg));
  1462. }
  1463. return Ok(JsonView(true));
  1464. }
  1465. /// <summary>
  1466. /// 获取团组销售报价号
  1467. /// 团组添加时 使用
  1468. /// </summary>
  1469. /// <returns></returns>
  1470. [HttpPost]
  1471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1472. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1473. {
  1474. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1475. if (groupData.Code != 0)
  1476. {
  1477. return Ok(JsonView(false, groupData.Msg));
  1478. }
  1479. object salesQuoteNo = new
  1480. {
  1481. SalesQuoteNo = groupData.Data
  1482. };
  1483. return Ok(JsonView(salesQuoteNo));
  1484. }
  1485. /// <summary>
  1486. /// 设置确认出团
  1487. /// </summary>
  1488. /// <param name="dto"></param>
  1489. /// <returns></returns>
  1490. [HttpPost]
  1491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1492. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1493. {
  1494. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1495. if (groupData.Code != 0)
  1496. {
  1497. return Ok(JsonView(false, groupData.Msg));
  1498. }
  1499. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1500. #region OA消息推送
  1501. try
  1502. {
  1503. string groupName = groupInfo.TeamName;
  1504. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1505. string title = $"系统通知";
  1506. string content = $"团组[{groupName}]已确认出团!";
  1507. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1508. }
  1509. catch (Exception ex)
  1510. {
  1511. }
  1512. #endregion
  1513. #region 应用推送
  1514. try
  1515. {
  1516. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1517. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1518. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1519. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1520. {
  1521. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1522. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1523. }
  1524. }
  1525. catch (Exception ex)
  1526. {
  1527. }
  1528. #endregion
  1529. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1530. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1531. }
  1532. /// <summary>
  1533. /// 获取团组名称data And 签证国别Data
  1534. /// </summary>
  1535. /// <param name="dto"></param>
  1536. /// <returns></returns>
  1537. [HttpPost]
  1538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1539. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1540. {
  1541. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1542. if (groupData.Code != 0)
  1543. {
  1544. return Ok(JsonView(false, groupData.Msg));
  1545. }
  1546. return Ok(JsonView(groupData.Data));
  1547. }
  1548. /// <summary>
  1549. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1550. /// </summary>
  1551. /// <returns></returns>
  1552. [HttpPost]
  1553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1554. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1555. {
  1556. try
  1557. {
  1558. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1559. if (groupData.Code != 0)
  1560. {
  1561. return Ok(JsonView(false, groupData.Msg));
  1562. }
  1563. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1564. }
  1565. catch (Exception ex)
  1566. {
  1567. return Ok(JsonView(false, "程序错误!"));
  1568. throw;
  1569. }
  1570. }
  1571. /// <summary>
  1572. /// 团组清单 Excel
  1573. /// </summary>
  1574. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1575. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1576. /// <returns></returns>
  1577. [HttpGet]
  1578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1579. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1580. {
  1581. DateTime _beginDt, _endDt;
  1582. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1583. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1584. if (!beginBool && !endBool)
  1585. {
  1586. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1587. }
  1588. string sql = string.Format(@"
  1589. SELECT
  1590. ROW_NUMBER,
  1591. Id,
  1592. SalesQuoteNo,
  1593. TourCode,
  1594. TeamTypeId,
  1595. TeamType,
  1596. TeamLevId,
  1597. TeamLev,
  1598. TeamName,
  1599. ClientName,
  1600. ClientUnit,
  1601. VisitDate,
  1602. VisitDays,
  1603. VisitPNumber,
  1604. JietuanOperatorId,
  1605. JietuanOperator,
  1606. IsSure,
  1607. CreateUserName,
  1608. IsBid
  1609. FROM
  1610. (
  1611. SELECT
  1612. ROW_NUMBER() OVER(
  1613. ORDER BY
  1614. gdi.VisitDate Desc
  1615. ) AS ROW_NUMBER,
  1616. gdi.Id,
  1617. SalesQuoteNo,
  1618. TourCode,
  1619. ssd.Id TeamTypeId,
  1620. ssd.Name TeamType,
  1621. ssd1.Id TeamLevId,
  1622. ssd1.Name TeamLev,
  1623. TeamName,
  1624. ClientName,
  1625. ClientUnit,
  1626. VisitDate,
  1627. VisitDays,
  1628. VisitPNumber,
  1629. JietuanOperator JietuanOperatorId,
  1630. su.CnName JietuanOperator,
  1631. IsSure,
  1632. gdi.CreateTime,
  1633. su1.CnName As CreateUserName,
  1634. gdi.IsBid
  1635. FROM
  1636. Grp_DelegationInfo gdi
  1637. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1638. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1639. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1640. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1641. WHERE
  1642. gdi.IsDel = 0
  1643. AND gdi.IsBid = 0
  1644. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1645. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1646. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1647. #region 处理所属部门
  1648. /*
  1649. * 1.sq 和 gyy 等显示 市场部
  1650. * 2.王鸽和主管及张总还有管理员号统一国交部
  1651. * 2-1. 4 管理员 ,21 张海麟
  1652. */
  1653. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1654. List<int> userIds1 = new List<int>() { 4, 21 };
  1655. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1656. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1657. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1658. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1659. .ToListAsync();
  1660. var droupIds = groupList.Select(it => it.Id).ToList();
  1661. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1662. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1663. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1664. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1665. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1666. {
  1667. DiId = tcl.DiId,
  1668. LastName = dc.LastName,
  1669. FirstName = dc.FirstName,
  1670. Sex = dc.Sex,
  1671. Birthday = dc.BirthDay,
  1672. Company = cc.CompanyFullName,
  1673. Job = dc.Job,
  1674. CreateTime = tcl.CreateTime,
  1675. })
  1676. .ToList();
  1677. foreach (var item in groupList)
  1678. {
  1679. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1680. string groupFirstName = "";
  1681. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1682. if (currDatas.Any())
  1683. {
  1684. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1685. }
  1686. item.GroupFirst = groupFirstName;
  1687. }
  1688. #endregion
  1689. #region Excel
  1690. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1691. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1692. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1693. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1694. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1695. //载入模板
  1696. WorkbookDesigner designer = new WorkbookDesigner();
  1697. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1698. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1699. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1700. dt.TableName = "GroupList";
  1701. designer.SetDataSource(dt);
  1702. designer.Process();
  1703. if (!Directory.Exists(savePath))
  1704. {
  1705. Directory.CreateDirectory(savePath);
  1706. }
  1707. string serverPath = $"{savePath}{fileName}";
  1708. designer.Workbook.Save(serverPath);
  1709. string rst = $"{servicePath}{ftpPath}{fileName}";
  1710. #endregion
  1711. return Ok(JsonView(true, "操作成功!", rst));
  1712. }
  1713. /// <summary>
  1714. /// 团组合同下载(1.付款80% 2.付全款)
  1715. /// </summary>
  1716. /// <param name="dto"></param>
  1717. /// <returns></returns>
  1718. /// <exception cref="Exception"></exception>
  1719. [HttpPost]
  1720. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1721. {
  1722. var jw = JsonView(false);
  1723. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1724. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1725. if (di == null)
  1726. {
  1727. jw.Msg = "团组Id有误!";
  1728. return Ok(jw);
  1729. }
  1730. #region 权限校验
  1731. var allDownFile = new List<int>() { 21 };
  1732. try
  1733. {
  1734. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1735. .First(x => x.Id == 1418 && x.IsDel == 0);
  1736. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1737. }
  1738. catch (Exception)
  1739. { }
  1740. var guojiaoDownFile = new List<int>() { 330 };
  1741. var shichangDownFile = new List<int>() { 95 };
  1742. if (allDownFile.Contains(dto.UserId))
  1743. {
  1744. }
  1745. else if (guojiaoDownFile.Contains(dto.UserId))
  1746. {
  1747. var guojiaobuDi = new List<int>() { 4, 21 };
  1748. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1749. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1750. .Where((d, u) => u.Id == di.JietuanOperator)
  1751. .Select((d, u) => d.DepName)
  1752. .First();
  1753. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1754. {
  1755. jw.Msg = "暂无下载权限!";
  1756. return Ok(jw);
  1757. }
  1758. }
  1759. else if (shichangDownFile.Contains(dto.UserId))
  1760. {
  1761. var dic = new Dictionary<int, int[]>()
  1762. {
  1763. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1764. };
  1765. try
  1766. {
  1767. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1768. if (sqSetting != null)
  1769. {
  1770. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1771. foreach (var item in result.Keys)
  1772. {
  1773. if (dic.Keys.Contains(item))
  1774. {
  1775. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1776. Array.Copy(dic[item], dilatation, dic[item].Length);
  1777. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1778. dic[item] = dilatation;
  1779. }
  1780. else
  1781. {
  1782. dic.Add(item, result[item]);
  1783. }
  1784. }
  1785. }
  1786. if (!dic[95].Contains(di.CreateUserId))
  1787. {
  1788. jw.Msg = "暂无下载权限!";
  1789. return Ok(jw);
  1790. }
  1791. }
  1792. catch (Exception)
  1793. { }
  1794. }
  1795. else if (dto.UserId == di.CreateUserId)
  1796. {
  1797. }
  1798. else
  1799. {
  1800. jw.Msg = "暂无下载权限!";
  1801. return Ok(jw);
  1802. }
  1803. #endregion
  1804. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1805. .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
  1806. .ToListAsync();
  1807. if (!blackCodeList.Any())
  1808. {
  1809. jw.Msg = "该团无机票行程代码!";
  1810. return Ok(jw);
  1811. }
  1812. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1813. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1814. if (groupEnterExitCost == null)
  1815. {
  1816. jw.Msg = "暂无三公费用信息!";
  1817. return Ok(jw);
  1818. }
  1819. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1820. rateList ??= new List<CurrencyInfo>();
  1821. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1822. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1823. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1824. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1825. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1826. .Select((x, a, b) => new
  1827. {
  1828. x.Index,
  1829. itemName = a.Name,
  1830. CurrencyStr = b.Name,
  1831. x.Cost,
  1832. x.SubTotal,
  1833. x.Remark
  1834. })
  1835. .OrderBy((x) => x.Index)
  1836. .ToList();
  1837. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1838. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1839. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1840. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1841. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1842. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1843. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1844. decimal subJJC = 0.00M,
  1845. subGWC = 0.00M,
  1846. subTDC = 0.00M;
  1847. //经济舱
  1848. if (groupEnterExitCost.SumJJC == 1)
  1849. {
  1850. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1851. }
  1852. //公务舱
  1853. if (groupEnterExitCost.SumGWC == 1)
  1854. {
  1855. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1856. }
  1857. //头等舱
  1858. if (groupEnterExitCost.SumTDC == 1)
  1859. {
  1860. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1861. }
  1862. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1863. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1864. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1865. .LeftJoin<Crm_CustomerCompany>((x, s, dc,cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1866. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1867. .Select((x, s, dc, cc) => new groupClints
  1868. {
  1869. Id =x.Id,
  1870. Name =s.Name,
  1871. IsAccompany =x.IsAccompany,
  1872. CompanyFullName =cc.CompanyFullName
  1873. })
  1874. .ToListAsync();
  1875. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1876. //获取舱位人数
  1877. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1878. .GroupBy(x => x.Name)
  1879. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1880. .ToList();
  1881. string cityPath = string.Empty;
  1882. string startCity = string.Empty;
  1883. string endCity = string.Empty;
  1884. foreach (var item in blackCodeList)
  1885. {
  1886. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1887. cityPath += city + "\r\n";
  1888. if (item.Equals(blackCodeList.First()))
  1889. {
  1890. var sp = city.Split('-');
  1891. startCity = sp[0];
  1892. endCity = sp[sp.Length - 1];
  1893. }
  1894. }
  1895. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1896. bookMarkDic.Add("ClientUnit",di.ClientUnit);
  1897. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1898. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1899. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1900. bookMarkDic.Add("CityPath", cityPath);
  1901. bookMarkDic.Add("StartCity", startCity);
  1902. bookMarkDic.Add("EndCity", endCity);
  1903. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
  1904. Document doc = null;
  1905. var percentage = 0.8M;
  1906. var fileNameadd = "预付";
  1907. if (dto.FileType == 1)
  1908. {
  1909. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1910. }
  1911. else if (dto.FileType == 2)
  1912. {
  1913. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1914. percentage = 1;
  1915. fileNameadd = "全款";
  1916. }
  1917. else
  1918. {
  1919. throw new Exception("FileType有误!");
  1920. }
  1921. DocumentBuilder builder = new DocumentBuilder(doc);
  1922. decimal totalPrice = 0.00M;
  1923. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1924. if (firstTable != null)
  1925. {
  1926. // 遍历表格的行和单元格
  1927. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1928. {
  1929. for (int i = 0; i < row.Cells.Count; i++)
  1930. {
  1931. var cell = row.Cells[i];
  1932. // 读取单元格内容
  1933. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  1934. if (cellTextFirst.Contains("舱位"))
  1935. {
  1936. break;
  1937. }
  1938. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  1939. {
  1940. if (i == 2)
  1941. {
  1942. if (cellTextFirst == "经济舱")
  1943. {
  1944. // 设置单元格内容
  1945. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1946. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  1947. }
  1948. else
  1949. {
  1950. // 设置单元格内容
  1951. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1952. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  1953. }
  1954. }
  1955. if (i == 3)
  1956. {
  1957. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1958. if (count != null)
  1959. {
  1960. // 设置单元格内容
  1961. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1962. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  1963. }
  1964. }
  1965. if (i == 4)
  1966. {
  1967. var rowPrice = 0.00M;
  1968. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1969. count ??= 0;
  1970. if (cellTextFirst == "经济舱")
  1971. {
  1972. rowPrice = subJJC * (int)count;
  1973. }
  1974. else
  1975. {
  1976. rowPrice = subGWC * (int)count;
  1977. }
  1978. totalPrice += rowPrice;
  1979. // 设置单元格内容
  1980. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1981. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  1982. }
  1983. }
  1984. }
  1985. }
  1986. }
  1987. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  1988. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  1989. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  1990. //--合同表格部分
  1991. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  1992. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  1993. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  1994. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  1995. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日")+"-"+di.VisitEndDate.ToString("yyyy年MM月dd日"));
  1996. bookMarkDic.Add("CityPath1", cityPath);
  1997. bookMarkDic.Add("CityPath2", cityPath);
  1998. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  1999. if (contractTable != null)
  2000. {
  2001. //数据源
  2002. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2003. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2004. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2005. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2006. .Select((it, y, s) => new
  2007. {
  2008. it.Cost,
  2009. it.SubTotal,
  2010. it.Type,
  2011. y.Id,
  2012. y.City,
  2013. s.Name,
  2014. CurrencyCodeCn = s.Remark
  2015. })
  2016. .ToList()
  2017. .Select(x => new
  2018. {
  2019. CurrencyCode = x.Name,
  2020. CityId = x.Id,
  2021. x.City,
  2022. VisitPNumber = di.VisitPNumber,
  2023. x.Type,
  2024. x.Cost,
  2025. x.SubTotal,
  2026. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2027. x.CurrencyCodeCn,
  2028. });
  2029. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2030. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2031. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2032. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2033. List<tableSetting> tableSettings = new List<tableSetting>()
  2034. {
  2035. new tableSetting{ Index = 1 , Property = "City"},
  2036. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  2037. new tableSetting{ Index = 3 , Property = "Cost"},
  2038. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  2039. //new tableSetting{ Index = 5 , Property = ""},
  2040. //new tableSetting{ Index = 6 , Property = ""},
  2041. new tableSetting{ Index = 7 , Property = "Rate"},
  2042. //new tableSetting{ Index = 8 , Property = ""},
  2043. };
  2044. //1.住宿费
  2045. int cloneRow = 8;
  2046. int startDayPrice = 8; //写入index
  2047. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2048. foreach (var dac in dac1)
  2049. {
  2050. var first = dac.First();
  2051. var dayCount = dac.Count();
  2052. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2053. for (int i = 1; i < row.Cells.Count; i++)
  2054. {
  2055. var cell = row.Cells[i];
  2056. var findProperty = tableSettings.Find(x => x.Index == i);
  2057. if (findProperty != null)
  2058. {
  2059. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2060. // 设置单元格内容
  2061. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2062. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2063. }
  2064. else
  2065. {
  2066. switch (i)
  2067. {
  2068. case 5:
  2069. cell.FirstParagraph.Runs.Clear();
  2070. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2071. break;
  2072. case 6:
  2073. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2074. cell.FirstParagraph.Runs.Clear();
  2075. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2076. break;
  2077. case 8:
  2078. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2079. cell.FirstParagraph.Runs.Clear();
  2080. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2081. ZSPriceSum += xiaojiRMB;
  2082. break;
  2083. default:
  2084. break;
  2085. }
  2086. }
  2087. }
  2088. startDayPrice++;
  2089. if (!dac1.Last().Equals(dac))
  2090. {
  2091. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2092. // 将克隆的行追加到原行后面
  2093. contractTable.Rows.Insert(startDayPrice, newRow);
  2094. }
  2095. else
  2096. {
  2097. cloneRow += dac1.Count() + 1;
  2098. startDayPrice = cloneRow;
  2099. }
  2100. }
  2101. //2.伙食费
  2102. foreach (var dac in dac2)
  2103. {
  2104. var first = dac.First();
  2105. var dayCount = dac.Count();
  2106. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2107. for (int i = 1; i < row.Cells.Count; i++)
  2108. {
  2109. var cell = row.Cells[i];
  2110. var findProperty = tableSettings.Find(x => x.Index == i);
  2111. if (findProperty != null)
  2112. {
  2113. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2114. // 设置单元格内容
  2115. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2116. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2117. }
  2118. else
  2119. {
  2120. switch (i)
  2121. {
  2122. case 5:
  2123. cell.FirstParagraph.Runs.Clear();
  2124. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2125. break;
  2126. case 6:
  2127. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2128. cell.FirstParagraph.Runs.Clear();
  2129. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2130. break;
  2131. case 8:
  2132. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2133. cell.FirstParagraph.Runs.Clear();
  2134. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2135. HSPriceSum += xiaojiRMB;
  2136. break;
  2137. default:
  2138. break;
  2139. }
  2140. }
  2141. }
  2142. startDayPrice++;
  2143. if (!dac2.Last().Equals(dac))
  2144. {
  2145. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2146. // 将克隆的行追加到原行后面
  2147. contractTable.Rows.Insert(startDayPrice, newRow);
  2148. }
  2149. else
  2150. {
  2151. cloneRow += dac2.Count() + 1;
  2152. startDayPrice = cloneRow;
  2153. }
  2154. }
  2155. //3.公杂费
  2156. foreach (var dac in dac3)
  2157. {
  2158. var first = dac.First();
  2159. var dayCount = dac.Count();
  2160. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2161. for (int i = 1; i < row.Cells.Count; i++)
  2162. {
  2163. var cell = row.Cells[i];
  2164. var findProperty = tableSettings.Find(x => x.Index == i);
  2165. if (findProperty != null)
  2166. {
  2167. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2168. // 设置单元格内容
  2169. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2170. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2171. }
  2172. else
  2173. {
  2174. switch (i)
  2175. {
  2176. case 5:
  2177. cell.FirstParagraph.Runs.Clear();
  2178. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2179. break;
  2180. case 6:
  2181. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2182. cell.FirstParagraph.Runs.Clear();
  2183. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2184. break;
  2185. case 8:
  2186. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2187. cell.FirstParagraph.Runs.Clear();
  2188. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2189. GZPriceSum += xiaojiRMB;
  2190. break;
  2191. default:
  2192. break;
  2193. }
  2194. }
  2195. }
  2196. startDayPrice++;
  2197. if (!dac3.Last().Equals(dac))
  2198. {
  2199. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2200. // 将克隆的行追加到原行后面
  2201. contractTable.Rows.Insert(startDayPrice, newRow);
  2202. }
  2203. else
  2204. {
  2205. cloneRow += dac3.Count() + 1;
  2206. startDayPrice = cloneRow;
  2207. }
  2208. }
  2209. //合并单元格
  2210. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2211. {
  2212. var currentRow = contractTable.Rows[i];
  2213. var nextRow = contractTable.Rows[i + 1];
  2214. // 获取当前行和下一行的第一个单元格
  2215. Cell currentCell = currentRow.Cells[0];
  2216. Cell nextCell = nextRow.Cells[0];
  2217. // 检查单元格内容是否一致(去除尾部的换行符)
  2218. string currentText = currentCell.GetText().Trim();
  2219. string nextText = nextCell.GetText().Trim();
  2220. if (currentText == nextText)
  2221. {
  2222. // 如果当前单元格已经被合并,找到合并的起始单元格
  2223. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2224. {
  2225. // 找到合并的起始单元格
  2226. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2227. // 将下一行的单元格设置为合并的后续单元格
  2228. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2229. }
  2230. else
  2231. {
  2232. // 如果当前单元格是合并的起始单元格
  2233. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2234. // 将下一行的单元格设置为合并的后续单元格
  2235. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2236. }
  2237. }
  2238. else
  2239. {
  2240. // 如果内容不一致,重置当前单元格的合并属性
  2241. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2242. {
  2243. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2244. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2245. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2246. }
  2247. else
  2248. {
  2249. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2250. }
  2251. }
  2252. }
  2253. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2254. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2255. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2256. }
  2257. foreach (var bookmarkName in bookMarkDic.Keys)
  2258. {
  2259. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2260. if (bookmark != null)
  2261. {
  2262. if (bookmarkName == "ClientUnit")
  2263. {
  2264. // 移动到书签位置
  2265. builder.MoveTo(bookmark.BookmarkStart);
  2266. // 设置字体样式为下划线
  2267. builder.Font.Underline = Aspose.Words.Underline.Single;
  2268. // 插入书签值
  2269. builder.Write(bookMarkDic[bookmarkName]);
  2270. // 清除字体格式,避免影响后续文本
  2271. builder.Font.ClearFormatting();
  2272. }
  2273. else
  2274. {
  2275. builder.MoveToBookmark(bookmarkName);
  2276. builder.Write(bookMarkDic[bookmarkName]);
  2277. }
  2278. }
  2279. }
  2280. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2281. doc.Save(savePaht);
  2282. jw.Msg = "生成成功!";
  2283. jw.Code = 200;
  2284. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
  2285. return Ok(jw);
  2286. }
  2287. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2288. {
  2289. int index = rowIndex;
  2290. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2291. {
  2292. index--;
  2293. }
  2294. return index;
  2295. }
  2296. #endregion
  2297. #region 团组&签证
  2298. /// <summary>
  2299. /// 根据团组Id获取签证客户信息List
  2300. /// </summary>
  2301. /// <param name="dto">请求dto</param>
  2302. /// <returns></returns>
  2303. [HttpPost]
  2304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2305. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2306. {
  2307. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2308. if (groupData.Code != 0)
  2309. {
  2310. return Ok(JsonView(false, groupData.Msg));
  2311. }
  2312. return Ok(JsonView(groupData.Data));
  2313. }
  2314. /// <summary>
  2315. /// IOS获取团组签证拍照上传进度01(团组列表)
  2316. /// </summary>
  2317. /// <param name="dto">请求dto</param>
  2318. /// <returns></returns>
  2319. [HttpPost]
  2320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2321. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2322. {
  2323. if (dto == null)
  2324. {
  2325. return Ok(JsonView(false, "参数为空"));
  2326. }
  2327. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2328. return Ok(JsonView(visaList));
  2329. }
  2330. /// <summary>
  2331. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2332. /// </summary>
  2333. /// <returns></returns>
  2334. [HttpPost]
  2335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2336. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2337. {
  2338. if (dto == null)
  2339. {
  2340. return Ok(JsonView(false, "请求错误:"));
  2341. }
  2342. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2343. return Ok(JsonView(list));
  2344. }
  2345. /// <summary>
  2346. /// IOS获取团组签证拍照上传进度03(相册)
  2347. /// </summary>
  2348. /// <returns></returns>
  2349. [HttpPost]
  2350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2351. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2352. {
  2353. if (dto == null)
  2354. {
  2355. return Ok(JsonView(false, "请求错误:"));
  2356. }
  2357. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2358. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2359. list.ForEach(s => s.url = url);
  2360. return Ok(JsonView(list));
  2361. }
  2362. /// <summary>
  2363. /// IOS获取团组签证拍照上传进度04(图片上传)
  2364. /// </summary>
  2365. /// <param name="dto"></param>
  2366. /// <returns></returns>
  2367. [HttpPost]
  2368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2369. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2370. {
  2371. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2372. //if (!string.IsNullOrEmpty(result))
  2373. //{
  2374. //}
  2375. //else {
  2376. // return Ok(JsonView(false, "上传失败"));
  2377. //}
  2378. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2379. int sucNum = 0;
  2380. try
  2381. {
  2382. foreach (var item in dto.base64DataList)
  2383. {
  2384. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2385. string result = DecodeBase64ToImage(item, imageName);
  2386. if (!string.IsNullOrEmpty(result))
  2387. {
  2388. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2389. pic.CreateUserId = dto.CreateUserId;
  2390. pic.PicName = imageName;
  2391. pic.PicPath = result;
  2392. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2393. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2394. if (insertResult > 0)
  2395. {
  2396. sucNum++;
  2397. }
  2398. }
  2399. }
  2400. }
  2401. catch (Exception ex)
  2402. {
  2403. return Ok(JsonView(false, ex.Message));
  2404. }
  2405. string msg = string.Format(@"成功上传{0}张", sucNum);
  2406. return Ok(JsonView(true, msg));
  2407. }
  2408. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2409. {
  2410. string filename = "";//声明一个string类型的相对路径
  2411. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2412. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2413. try//会有异常抛出,try,catch一下
  2414. {
  2415. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2416. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2417. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2418. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2419. //文件名称
  2420. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2421. //上传的文件的路径
  2422. string filePath = "";
  2423. if (!Directory.Exists(fileDir))
  2424. {
  2425. Directory.CreateDirectory(fileDir);
  2426. }
  2427. //上传的文件的路径
  2428. filePath = fileDir + filename;
  2429. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2430. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2431. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2432. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2433. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2434. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2435. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2436. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2437. bitmap.Dispose();
  2438. }
  2439. catch (Exception e)
  2440. {
  2441. string massage = e.Message;
  2442. Logs("IOS图片上传Error:" + massage);
  2443. //filename = e.Message;
  2444. }
  2445. return filename;//返回相对路径
  2446. }
  2447. /// <summary>
  2448. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2449. /// </summary>
  2450. /// <param name="dto"></param>
  2451. /// <returns></returns>
  2452. [HttpPost]
  2453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2454. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2455. {
  2456. if (dto == null)
  2457. {
  2458. return Ok(JsonView(false, "请求错误:"));
  2459. }
  2460. string msg = "参数错误";
  2461. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2462. {
  2463. try
  2464. {
  2465. //_delegationVisaRep.BeginTran();
  2466. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2467. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2468. .Where(s => s.Id == dto.visaProgressCustomerId)
  2469. .ExecuteCommandAsync();
  2470. if (updCount > 0 && dto.publishCode == 1)
  2471. {
  2472. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2473. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2474. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2475. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2476. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2477. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2478. if (groupData == null)
  2479. {
  2480. _delegationVisaRep.RollbackTran();
  2481. }
  2482. string title = string.Format(@"[签证进度更新]");
  2483. string content = string.Format(@"测试文本");
  2484. bool rst = await _message.AddMsg(new MessageDto()
  2485. {
  2486. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2487. IssuerId = dto.publisher,
  2488. Title = title,
  2489. Content = content,
  2490. ReleaseTime = DateTime.Now,
  2491. UIdList = new List<int> {
  2492. 234
  2493. }
  2494. });
  2495. if (rst)
  2496. {
  2497. return Ok(JsonView(true, "发送通知成功"));
  2498. }
  2499. }
  2500. //_delegationVisaRep.CommitTran();
  2501. }
  2502. catch (Exception)
  2503. {
  2504. //_delegationVisaRep.RollbackTran();
  2505. }
  2506. }
  2507. return Ok(JsonView(true, msg));
  2508. }
  2509. #endregion
  2510. #region 团组任务分配
  2511. /// <summary>
  2512. /// 团组任务分配初始化
  2513. /// </summary>
  2514. /// <returns></returns>
  2515. [HttpPost]
  2516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2517. public async Task<IActionResult> GetTaskAssignmen()
  2518. {
  2519. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2520. if (groupData.Code != 0)
  2521. {
  2522. return Ok(JsonView(false, groupData.Msg));
  2523. }
  2524. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2525. }
  2526. /// <summary>
  2527. /// 团组任务分配查询
  2528. /// </summary>
  2529. /// <param name="dto"></param>
  2530. /// <returns></returns>
  2531. [HttpPost]
  2532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2533. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2534. {
  2535. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2536. if (groupData.Code != 0)
  2537. {
  2538. return Ok(JsonView(false, groupData.Msg));
  2539. }
  2540. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2541. }
  2542. /// <summary>
  2543. /// 团组任务分配操作
  2544. /// </summary>
  2545. /// <param name="dto"></param>
  2546. /// <returns></returns>
  2547. [HttpPost]
  2548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2549. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2550. {
  2551. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2552. if (groupData.Code != 0)
  2553. {
  2554. return Ok(JsonView(false, groupData.Msg));
  2555. }
  2556. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2557. }
  2558. /// <summary>
  2559. /// 团组任务分配
  2560. /// 批量分配
  2561. /// 查询团组
  2562. /// </summary>
  2563. /// <param name="dto"></param>
  2564. /// <returns></returns>
  2565. [HttpPost]
  2566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2567. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2568. {
  2569. //参数验证
  2570. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2571. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2572. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2573. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2574. }
  2575. /// <summary>
  2576. /// 团组任务分配
  2577. /// 批量分配
  2578. /// </summary>
  2579. /// <param name="dto"></param>
  2580. /// <returns></returns>
  2581. [HttpPost]
  2582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2583. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2584. {
  2585. //参数验证
  2586. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2587. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2588. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2589. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2590. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2591. }
  2592. #endregion
  2593. #region 团组费用审核
  2594. /// <summary>
  2595. /// 费用审核
  2596. /// 团组列表 Page
  2597. /// </summary>
  2598. /// <param name="_dto">团组列表请求dto</param>
  2599. /// <returns></returns>
  2600. [HttpPost]
  2601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2602. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2603. {
  2604. #region 参数验证
  2605. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2606. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2607. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2608. #region 页面操作权限验证
  2609. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2610. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2611. #endregion
  2612. #endregion
  2613. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2614. {
  2615. string sqlWhere = string.Empty;
  2616. if (_dto.IsSure == 0) //未完成
  2617. {
  2618. sqlWhere += string.Format(@" And IsSure = 0");
  2619. }
  2620. else if (_dto.IsSure == 1) //已完成
  2621. {
  2622. sqlWhere += string.Format(@" And IsSure = 1");
  2623. }
  2624. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2625. {
  2626. string tj = _dto.SearchCriteria;
  2627. 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}%')",
  2628. tj, tj, tj, tj, tj);
  2629. }
  2630. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2631. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2632. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2633. From (
  2634. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2635. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2636. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2637. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2638. From Grp_DelegationInfo gdi
  2639. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2640. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2641. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2642. Where gdi.IsDel = 0 {0}
  2643. ) temp ", sqlWhere);
  2644. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2645. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2646. var _view = new
  2647. {
  2648. PageFuncAuth = pageFunAuthView,
  2649. Data = _DelegationList
  2650. };
  2651. return Ok(JsonView(true, "查询成功!", _view, total));
  2652. }
  2653. else
  2654. {
  2655. return Ok(JsonView(false, "查询失败"));
  2656. }
  2657. }
  2658. /// <summary>
  2659. /// 获取团组费用审核
  2660. /// </summary>
  2661. /// <param name="_dto"></param>
  2662. /// <returns></returns>
  2663. [HttpPost]
  2664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2665. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2666. {
  2667. try
  2668. {
  2669. #region 参数验证
  2670. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2671. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2672. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2673. #region 页面操作权限验证
  2674. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2675. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2676. #endregion
  2677. #endregion
  2678. var _view = new Grp_CreditCardPaymentView();
  2679. var clientNameList = getSimplClientList(_dto.DiId);
  2680. #region 费用清单
  2681. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2682. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2683. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2684. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2685. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2686. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2687. /*
  2688. * 76://酒店预订
  2689. */
  2690. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2691. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2692. /*
  2693. * 79://车/导游地接
  2694. */
  2695. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2696. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2697. /*
  2698. * 80: //签证
  2699. */
  2700. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2701. /*
  2702. *81: //邀请/公务活动
  2703. */
  2704. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2705. /*
  2706. * 82: //团组客户保险
  2707. */
  2708. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2709. /*
  2710. * Lable = 85 机票预订
  2711. */
  2712. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2713. /*
  2714. * 85 机票预定
  2715. */
  2716. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2717. /*
  2718. * 98 其他款项
  2719. */
  2720. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2721. /*
  2722. * 285:收款退还
  2723. */
  2724. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2725. /*
  2726. * 1015: //超支费用
  2727. */
  2728. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2729. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2730. /*
  2731. * 币种信息
  2732. */
  2733. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2734. /*
  2735. * 车/导游地接 费用类型
  2736. */
  2737. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2738. /*
  2739. * 车/导游地接 费用类型
  2740. */
  2741. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2742. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2743. /*
  2744. * 用户信息
  2745. */
  2746. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2747. /*
  2748. * 费用模块
  2749. */
  2750. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2751. string priceModule = string.Empty;
  2752. if (sdPriceName != null)
  2753. {
  2754. priceModule = sdPriceName.Name;
  2755. }
  2756. /*
  2757. * 成本信息
  2758. */
  2759. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2760. decimal _groupRate = 0.0000M;
  2761. string _groupCurrencyCode = "-";
  2762. if (groupCost != null)
  2763. {
  2764. _groupRate = groupCost.Rate;
  2765. if (int.TryParse(groupCost.Currency, out int _currency))
  2766. {
  2767. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2768. }
  2769. else _groupCurrencyCode = groupCost.Currency;
  2770. }
  2771. string costContentSql = $"Select * From Grp_GroupCost";
  2772. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2773. //处理日期为空的天数
  2774. for (int i = 0; i < groupCostDetails.Count; i++)
  2775. if (i != 0)
  2776. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2777. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2778. /*
  2779. * 处理详情数据
  2780. */
  2781. foreach (var entity in entityList)
  2782. {
  2783. var _detail = new Grp_CreditCardPaymentDetailView();
  2784. _detail.Id = entity.Id;
  2785. _detail.PriceName = priceModule;
  2786. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2787. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2788. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2789. //处理金额
  2790. if (entity.CTable == 1015)
  2791. {
  2792. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2793. if (czInfo != null)
  2794. {
  2795. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2796. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2797. }
  2798. }
  2799. /*
  2800. * 应付款金额
  2801. */
  2802. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2803. string PaymentCurrency_WaitPay = "Unknown";
  2804. string hotelCurrncyCode = "Unknown";
  2805. string hotelCurrncyName = "Unknown";
  2806. if (sdPaymentCurrency_WaitPay != null)
  2807. {
  2808. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2809. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2810. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2811. if (hotelCurrncyCode.Equals("CNY"))
  2812. {
  2813. entity.DayRate = 1.0000M;
  2814. }
  2815. }
  2816. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2817. /*
  2818. * 此次付款金额
  2819. */
  2820. decimal CurrPayStr = 0.00M,
  2821. OriginalCurrPay = 0.00M;
  2822. if (entity.PayPercentage == 0)
  2823. {
  2824. if (entity.PayThenMoney != 0)
  2825. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2826. }
  2827. else
  2828. {
  2829. if (entity.PayMoney != 0)
  2830. {
  2831. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2832. }
  2833. }
  2834. //if (_dto.Label == 79)
  2835. //{
  2836. // string original = string.Empty;
  2837. // if (hotelCurrncyCode.Equals("CNY"))
  2838. // {
  2839. // OriginalCurrPay = CurrPayStr;
  2840. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2841. // }
  2842. // else
  2843. // {
  2844. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2845. // //760 EUR(7600.00 CNY)
  2846. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2847. // }
  2848. //}
  2849. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2850. string original = string.Empty;
  2851. if (hotelCurrncyCode.Equals("CNY"))
  2852. {
  2853. OriginalCurrPay = CurrPayStr;
  2854. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2855. }
  2856. else
  2857. {
  2858. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2859. //760 EUR(7600.00 CNY)
  2860. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2861. }
  2862. /*
  2863. * 剩余尾款
  2864. */
  2865. decimal BalanceStr = 0;
  2866. if (CurrPayStr != 0)
  2867. {
  2868. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2869. BalanceStr = 0;
  2870. else
  2871. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2872. }
  2873. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2874. /*
  2875. * Bus名称
  2876. */
  2877. _detail.BusName = "待增加";
  2878. /*
  2879. *费用所属
  2880. */
  2881. switch (entity.CTable)
  2882. {
  2883. case 76://酒店预订
  2884. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2885. if (hotelReservations != null)
  2886. {
  2887. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2888. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2889. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2890. string roomFeeStr = "", roomFeestr1 = "";
  2891. //是否比较房型价格
  2892. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2893. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2894. roomFeeStr += $"<br/>";
  2895. var roomTotal = 0.00M;
  2896. if (hotelReservations.SingleRoomPrice > 0)
  2897. {
  2898. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2899. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee:#0.00}<br/>";
  2900. //__isSingle = true;
  2901. roomTotal += fee;
  2902. }
  2903. if (hotelReservations.DoubleRoomPrice > 0)
  2904. {
  2905. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2906. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee:#0.00}<br/>";
  2907. // __isDouble = true;
  2908. roomTotal += fee;
  2909. }
  2910. if (hotelReservations.SuiteRoomPrice > 0)
  2911. {
  2912. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2913. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee:#0.00}<br/>";
  2914. //__isSuite = true;
  2915. roomTotal += fee;
  2916. }
  2917. if (hotelReservations.OtherRoomPrice > 0)
  2918. {
  2919. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2920. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee:#0.00}<br/>";
  2921. //__isOther = true;
  2922. roomTotal += fee;
  2923. }
  2924. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  2925. else roomFeeStr += " 0.00 * 0";
  2926. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2927. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2928. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2929. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2930. /*
  2931. * 费用类型
  2932. * 1:房费
  2933. * 2:早餐
  2934. * 3:地税
  2935. * 4:城市税
  2936. * </summary>
  2937. */
  2938. //地税
  2939. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2940. if (governmentRentData != null)
  2941. {
  2942. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2943. governmentRentFee = governmentRentData.Price;
  2944. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2945. if (governmentRentCurrData != null)
  2946. {
  2947. governmentRentCode = governmentRentCurrData.Name;
  2948. governmentRentName = $"({governmentRentCurrData.Remark})";
  2949. }
  2950. }
  2951. //城市税
  2952. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2953. if (cityTaxData != null)
  2954. {
  2955. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2956. cityTaxFee = cityTaxData.Price;
  2957. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2958. if (cityTaxCurrData != null)
  2959. {
  2960. cityTaxCode = cityTaxCurrData.Name;
  2961. cityTaxName = $"({cityTaxCurrData.Remark})";
  2962. }
  2963. }
  2964. //酒店早餐
  2965. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2966. if (breakfastData != null)
  2967. {
  2968. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2969. breakfastFee = breakfastData.Price;
  2970. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2971. if (breakfastCurrData != null)
  2972. {
  2973. breakfastCode = breakfastCurrData.Name;
  2974. breakfastName = $"({breakfastCurrData.Remark})";
  2975. }
  2976. }
  2977. //房间费用
  2978. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2979. if (roomData != null)
  2980. {
  2981. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2982. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2983. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2984. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2985. roomFee = roomData.Price;
  2986. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2987. if (roomCurrData != null)
  2988. {
  2989. roomCode = roomCurrData.Name;
  2990. roomName = $"({roomCurrData.Remark})";
  2991. }
  2992. }
  2993. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2994. string hotelCostStr = "";
  2995. decimal hotelCsotTotal = 0.00M;
  2996. if (groupCost != null)
  2997. {
  2998. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2999. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3000. }
  3001. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3002. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3003. string hotelCost_day = "";
  3004. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3005. foreach (var item in hotelCostDetails1)
  3006. {
  3007. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3008. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3009. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3010. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3011. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3012. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3013. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3014. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3015. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3016. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3017. hotelCost_day += @$"<br/>";
  3018. }
  3019. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3020. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3021. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3022. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3023. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3024. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3025. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3026. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3027. $"房间说明: {hotelReservations.Remark} <br/>" +
  3028. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3029. $"{hotelBreakfastStr}" +
  3030. $"{hotelGovernmentRentStr}" +
  3031. $"{hotelCityTaxStr}";
  3032. _detail.PriceNameContent = hotelReservations.HotelName;
  3033. }
  3034. break;
  3035. case 79://车/导游地接
  3036. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3037. if (touristGuideGroundReservations != null)
  3038. {
  3039. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3040. {
  3041. _detail.BusName = touristGuideGroundReservations.BusName;
  3042. }
  3043. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3044. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3045. //if (isInt)
  3046. //{
  3047. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3048. // if (cityInfo != null)
  3049. // {
  3050. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3051. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3052. // if (carFeeItem != null)
  3053. // {
  3054. // nameContent += $@"({carFeeItem.Name})";
  3055. // }
  3056. // _detail.PriceNameContent = nameContent;
  3057. // }
  3058. //}
  3059. //else
  3060. //{
  3061. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3062. //}
  3063. var touristGuideGroundReservationsContents =
  3064. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3065. var opContent_sb = new StringBuilder();
  3066. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3067. opContent_sb.AppendLine(contetTitle);
  3068. foreach (var item in touristGuideGroundReservationsContents)
  3069. {
  3070. string typeName = "Unknown";
  3071. string carCurrencyCode = "Unknown";
  3072. string carCurrencyName = "Unknown";
  3073. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3074. if (carTypeData != null) typeName = carTypeData.Name;
  3075. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3076. if (currencyData != null)
  3077. {
  3078. carCurrencyCode = currencyData.Name;
  3079. carCurrencyName = currencyData.Remark;
  3080. }
  3081. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3082. bool IsCurrencyAgreement = false;
  3083. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3084. string opCostStr = string.Empty;
  3085. decimal opCostTypePrice = 0.00M;
  3086. #region 处理成本各项费用
  3087. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3088. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3089. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3090. costOPFeeCNY = 0.00M, //团组成本 op费用
  3091. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3092. if (opCost.Count > 0)
  3093. {
  3094. switch (item.SId)
  3095. {
  3096. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3097. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3098. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3099. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3100. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3101. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3102. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3103. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3104. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3105. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3106. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3107. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3108. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3109. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3110. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3111. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3112. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3113. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3114. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3115. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3116. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3117. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3118. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3119. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3120. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3121. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3122. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3123. }
  3124. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3125. costOPFeeCNY = opCostTypePrice * _groupRate;
  3126. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3127. }
  3128. #endregion
  3129. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3130. aduitOPFeeCNY = item.Price * entity.DayRate;
  3131. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3132. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3133. $"{opTypeStr} {opCostStr}<br/>" +
  3134. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3135. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3136. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3137. {
  3138. if (IsCurrencyAgreement)
  3139. {
  3140. if (item.Price > opCostTypePrice)
  3141. {
  3142. opContent_sb.Append("<span style='color:red;'>");
  3143. opContent_sb.Append(opContent);
  3144. opContent_sb.Append("</span>");
  3145. opContent_sb.AppendLine();
  3146. }
  3147. else
  3148. {
  3149. opContent_sb.Append(opContent);
  3150. opContent_sb.AppendLine();
  3151. }
  3152. }
  3153. else
  3154. {
  3155. //验证是否超成本 按付款比例计算
  3156. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3157. {
  3158. opContent_sb.Append("<span style='color:red;'>");
  3159. opContent_sb.Append(opContent);
  3160. opContent_sb.Append("</span>");
  3161. opContent_sb.AppendLine();
  3162. }
  3163. else
  3164. {
  3165. opContent_sb.Append(opContent);
  3166. opContent_sb.AppendLine();
  3167. }
  3168. }
  3169. }
  3170. else
  3171. {
  3172. opContent_sb.Append(opContent);
  3173. opContent_sb.AppendLine();
  3174. }
  3175. }
  3176. _detail.PriceMsgContent = opContent_sb.ToString();
  3177. }
  3178. break;
  3179. case 80: //签证
  3180. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3181. if (visaInfo != null)
  3182. {
  3183. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3184. _detail.PriceNameContent = visaInfo.VisaDescription;
  3185. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3186. }
  3187. break;
  3188. case 81: //邀请/公务活动
  3189. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3190. if (_ioa != null)
  3191. {
  3192. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3193. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3194. sendCurrName = "Unknown", //快递费用币种 Name
  3195. sendCurrCode = "Unknown", //快递费用币种 Code
  3196. eventsCurrName = "Unknown", //公务活动费币种 Name
  3197. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3198. translateCurrName = "Unknown", //公务翻译费 Name
  3199. translateCurrCode = "Unknown"; //公务翻译费 Code
  3200. #region 处理费用币种
  3201. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3202. if (inviteCurrData != null)
  3203. {
  3204. inviteCurrName = inviteCurrData.Remark;
  3205. inviteCurrCode = inviteCurrData.Name;
  3206. }
  3207. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3208. if (sendCurrData != null)
  3209. {
  3210. sendCurrName = sendCurrData.Remark;
  3211. sendCurrCode = sendCurrData.Name;
  3212. }
  3213. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3214. if (eventsCurrData != null)
  3215. {
  3216. eventsCurrName = eventsCurrData.Remark;
  3217. eventsCurrCode = eventsCurrData.Name;
  3218. }
  3219. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3220. if (translateCurrData != null)
  3221. {
  3222. translateCurrName = translateCurrData.Remark;
  3223. translateCurrCode = translateCurrData.Name;
  3224. }
  3225. #endregion
  3226. _detail.PriceNameContent = _ioa.InviterArea;
  3227. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3228. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3229. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3230. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3231. $@"备注:" + _ioa.Remark + "<br/>";
  3232. }
  3233. break;
  3234. case 82: //团组客户保险
  3235. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3236. if (customers != null)
  3237. {
  3238. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3239. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3240. }
  3241. break;
  3242. case 85: //机票预订
  3243. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3244. if (jpRes != null)
  3245. {
  3246. string FlightsDescription = jpRes.FlightsDescription;
  3247. string PriceDescription = jpRes.PriceDescription;
  3248. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3249. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3250. }
  3251. break;
  3252. case 98://其他款项
  3253. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3254. if (gdpRes != null)
  3255. {
  3256. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3257. _detail.PriceNameContent = gdpRes.PriceName;
  3258. }
  3259. break;
  3260. case 285://收款退还
  3261. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3262. if (refundAndOtherMoney != null)
  3263. {
  3264. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3265. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3266. }
  3267. break;
  3268. case 751://酒店早餐
  3269. break;
  3270. case 1015://超支费用
  3271. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3272. if (groupExtraCost != null)
  3273. {
  3274. _detail.PriceNameContent = groupExtraCost.PriceName;
  3275. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3276. }
  3277. break;
  3278. default:
  3279. break;
  3280. }
  3281. /*
  3282. * 申请人
  3283. */
  3284. string operatorName = " - ";
  3285. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3286. if (_opUser != null)
  3287. {
  3288. operatorName = _opUser.CnName;
  3289. }
  3290. _detail.OperatorName = operatorName;
  3291. /*
  3292. * 审核人
  3293. */
  3294. string auditOperatorName = "Unknown";
  3295. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3296. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3297. else
  3298. {
  3299. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3300. if (_adUser != null)
  3301. {
  3302. auditOperatorName = _adUser.CnName;
  3303. }
  3304. }
  3305. _detail.AuditOperatorName = auditOperatorName;
  3306. /*
  3307. * 超预算比例
  3308. */
  3309. string overBudgetStr = "";
  3310. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3311. else if (entity.ExceedBudget == 0)
  3312. {
  3313. if (entity.CTable == 76 || entity.CTable == 79)
  3314. {
  3315. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3316. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3317. }
  3318. else
  3319. {
  3320. overBudgetStr = "未超预算";
  3321. }
  3322. }
  3323. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3324. _detail.OverBudget = overBudgetStr;
  3325. decimal auditFee = 0.00M; //已审核金额 人名币
  3326. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3327. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3328. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3329. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3330. {
  3331. auditedFeeOriginal = entity.PayMoney;
  3332. auditFee = CurrPayStr;
  3333. }
  3334. else if (entity.IsAuditGM == 0)
  3335. {
  3336. unAuditFeeCNY = CurrPayStr;
  3337. unAuditFeeOriginal = OriginalCurrPay;
  3338. OriginalCurrPay = 0.00M;
  3339. }
  3340. /*
  3341. * 费用总计
  3342. */
  3343. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3344. {
  3345. CurrencyId = entity.PaymentCurrency,
  3346. CurrencyName = PaymentCurrency_WaitPay,
  3347. AmountPayable = entity.PayMoney,
  3348. ThisPayment = OriginalCurrPay,
  3349. BalancePayment = BalanceStr,
  3350. AuditedFunds = auditFee,
  3351. AuditedFundsOriginal = auditedFeeOriginal,
  3352. UnAuditFundsCNY = unAuditFeeCNY,
  3353. UnAuditFundsOriginal = unAuditFeeOriginal
  3354. });
  3355. _detail.IsAuditGM = entity.IsAuditGM;
  3356. detailList.Add(_detail);
  3357. }
  3358. #endregion
  3359. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3360. /*
  3361. * 下方描述处理
  3362. */
  3363. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3364. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3365. if (ccpCurrencyPrice != null)
  3366. {
  3367. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3368. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3369. }
  3370. else
  3371. {
  3372. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3373. }
  3374. string amountPayableStr = string.Format(@"应付款总金额: ");
  3375. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3376. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3377. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3378. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3379. foreach (var item in nonDuplicat)
  3380. {
  3381. var currencyName = item.CurrencyName;
  3382. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3383. if (strs.Count > 0)
  3384. {
  3385. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3386. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3387. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3388. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3389. //单独处理此次付款金额
  3390. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3391. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3392. //单独处理已审核费用
  3393. //if (item.CurrencyId == 836) //人民币
  3394. //{
  3395. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3396. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3397. //}
  3398. //else
  3399. //{
  3400. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3401. //}
  3402. if (currencyName.Equals("CNY"))
  3403. {
  3404. //已审核费用
  3405. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3406. //未审核费用
  3407. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3408. }
  3409. else
  3410. {
  3411. //已审核费用
  3412. 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"));
  3413. //未审核费用
  3414. 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"));
  3415. }
  3416. }
  3417. }
  3418. _view.TotalStr1 = amountPayableStr[..^1];
  3419. _view.TotalStr2 = thisPaymentStr[..^1];
  3420. _view.TotalStr3 = balancePaymentStr[..^1];
  3421. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3422. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3423. var _view1 = new
  3424. {
  3425. PageFuncAuth = pageFunAuthView,
  3426. Data = _view
  3427. };
  3428. return Ok(JsonView(_view1));
  3429. }
  3430. catch (Exception ex)
  3431. {
  3432. return Ok(JsonView(false, ex.Message));
  3433. }
  3434. }
  3435. /// <summary>
  3436. /// 费用审核
  3437. /// 修改团组费用审核状态
  3438. /// </summary>
  3439. /// <param name="_dto">参数Json字符串</param>
  3440. /// <returns></returns>
  3441. [HttpPost]
  3442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3443. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3444. {
  3445. #region 参数验证
  3446. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3447. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3448. #endregion
  3449. #region 页面操作权限验证
  3450. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3451. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3452. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3453. #endregion
  3454. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3455. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3456. DateTime dtNow = DateTime.Now;
  3457. _groupRepository.BeginTran();
  3458. int rst = 0;
  3459. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3460. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3461. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3462. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3463. List<dynamic> msgDatas = new List<dynamic>();
  3464. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3465. foreach (var item in idList)
  3466. {
  3467. int CreditId = int.Parse(item);
  3468. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3469. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3470. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3471. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3472. .Where(s => s.Id == CreditId)
  3473. .ExecuteCommandAsync();
  3474. if (result < 1)
  3475. {
  3476. rst = -1;
  3477. _groupRepository.RollbackTran();
  3478. return Ok(JsonView(false, "操作失败并回滚!"));
  3479. }
  3480. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3481. if (creditData != null)
  3482. {
  3483. #region 应用通知配置
  3484. try
  3485. {
  3486. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3487. }
  3488. catch (Exception ex)
  3489. {
  3490. }
  3491. #endregion
  3492. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3493. string groupNameStr = string.Empty;
  3494. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3495. if (groupData != null) groupNameStr = groupData.TeamName;
  3496. string creditTypeStr = string.Empty;
  3497. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3498. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3499. string creditCurrency = string.Empty;
  3500. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3501. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3502. if (creditCurrency.Equals("CNY"))
  3503. {
  3504. creditData.DayRate = 1.0000M;
  3505. }
  3506. if (creditData.PayPercentage == 0.00M)
  3507. {
  3508. creditData.PayPercentage = 100M;
  3509. }
  3510. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3511. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3512. string msgContent = "";
  3513. if (creditCurrency.Equals("CNY"))
  3514. {
  3515. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3516. }
  3517. else
  3518. {
  3519. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3520. }
  3521. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3522. }
  3523. }
  3524. if (rst == 0)
  3525. {
  3526. _groupRepository.CommitTran();
  3527. foreach (var item in msgDatas)
  3528. {
  3529. //发送消息
  3530. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3531. }
  3532. #region 应用推送
  3533. try
  3534. {
  3535. foreach (var ccpId in dic_ccp_user.Keys)
  3536. {
  3537. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3538. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3539. }
  3540. }
  3541. catch (Exception)
  3542. {
  3543. }
  3544. #endregion
  3545. return Ok(JsonView(true, "操作成功!"));
  3546. }
  3547. return Ok(JsonView(false, "操作失败!"));
  3548. }
  3549. #endregion
  3550. #region 机票费用录入
  3551. /// <summary>
  3552. /// 机票录入当前登录人可操作团组
  3553. /// </summary>
  3554. /// <param name="dto"></param>
  3555. /// <returns></returns>
  3556. [HttpPost]
  3557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3558. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3559. {
  3560. try
  3561. {
  3562. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3563. if (groupData.Code != 0)
  3564. {
  3565. return Ok(JsonView(false, groupData.Msg));
  3566. }
  3567. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3568. }
  3569. catch (Exception ex)
  3570. {
  3571. return Ok(JsonView(false, "程序错误!"));
  3572. throw;
  3573. }
  3574. }
  3575. /// <summary>
  3576. /// 机票费用录入列表
  3577. /// </summary>
  3578. /// <param name="dto"></param>
  3579. /// <returns></returns>
  3580. [HttpPost]
  3581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3582. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3583. {
  3584. try
  3585. {
  3586. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3587. if (groupData.Code != 0)
  3588. {
  3589. return Ok(JsonView(false, groupData.Msg));
  3590. }
  3591. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3592. }
  3593. catch (Exception ex)
  3594. {
  3595. return Ok(JsonView(false, ex.Message));
  3596. throw;
  3597. }
  3598. }
  3599. /// <summary>
  3600. /// 根据id查询费用录入信息
  3601. /// </summary>
  3602. /// <param name="dto"></param>
  3603. /// <returns></returns>
  3604. [HttpPost]
  3605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3606. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3607. {
  3608. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3609. if (groupData.Code != 0)
  3610. {
  3611. return Ok(JsonView(false, groupData.Msg));
  3612. }
  3613. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3614. }
  3615. /// <summary>
  3616. /// 机票费用录入操作(Status:1.新增,2.修改)
  3617. /// </summary>
  3618. /// <param name="dto"></param>
  3619. /// <returns></returns>
  3620. [HttpPost]
  3621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3622. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3623. {
  3624. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3625. if (groupData.Code != 0)
  3626. {
  3627. return Ok(JsonView(false, groupData.Msg));
  3628. }
  3629. #region 应用推送
  3630. try
  3631. {
  3632. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3633. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3634. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3635. //2024-10-21 新增LZ UID
  3636. var userIds = new List<int>() { 21 };
  3637. string title = $"系统通知";
  3638. string content = "";
  3639. var diId = dto.AirTicketResOpData.DiId;
  3640. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3641. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3642. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3643. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3644. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3645. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3646. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3647. }
  3648. catch (Exception ex)
  3649. {
  3650. }
  3651. #endregion
  3652. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3653. }
  3654. /// <summary>
  3655. /// 根据舱位类型查询接团客户名单信息
  3656. /// </summary>
  3657. /// <param name="dto"></param>
  3658. /// <returns></returns>
  3659. [HttpPost]
  3660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3661. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3662. {
  3663. try
  3664. {
  3665. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3666. if (crm_Groups.Count != 0)
  3667. {
  3668. List<dynamic> Customer = new List<dynamic>();
  3669. foreach (var item in crm_Groups)
  3670. {
  3671. var data = new
  3672. {
  3673. Id = item.Id,
  3674. Pinyin = item.Pinyin,
  3675. Name = item.LastName + item.FirstName
  3676. };
  3677. Customer.Add(data);
  3678. }
  3679. return Ok(JsonView(true, "查询成功!", Customer));
  3680. }
  3681. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3682. }
  3683. catch (Exception ex)
  3684. {
  3685. return Ok(JsonView(false, "程序错误!"));
  3686. throw;
  3687. }
  3688. }
  3689. /// <summary>
  3690. /// 根据团号获取客户信息
  3691. /// </summary>
  3692. /// <param name="dto"></param>
  3693. /// <returns></returns>
  3694. [HttpPost]
  3695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3696. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3697. {
  3698. var jw = JsonView(false);
  3699. if (dto.DIID < 1)
  3700. {
  3701. jw.Msg += "请输入正确的diid";
  3702. return Ok(jw);
  3703. }
  3704. var arr = getSimplClientList(dto.DIID);
  3705. jw = JsonView(true, "获取成功!", arr);
  3706. return Ok(jw);
  3707. }
  3708. private List<SimplClientInfo> getSimplClientList(int diId)
  3709. {
  3710. 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);
  3711. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3712. foreach (var item in arr)
  3713. {
  3714. EncryptionProcessor.DecryptProperties(item);
  3715. }
  3716. return arr;
  3717. }
  3718. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3719. {
  3720. string result = origin;
  3721. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3722. {
  3723. string[] temparr = origin.Split(',');
  3724. string fistrStr = temparr[0];
  3725. int count = temparr.Count();
  3726. int tempId;
  3727. bool success = int.TryParse(fistrStr, out tempId);
  3728. if (success)
  3729. {
  3730. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3731. if (tempInfo != null)
  3732. {
  3733. if (count > 1)
  3734. {
  3735. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3736. }
  3737. else
  3738. {
  3739. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3740. }
  3741. }
  3742. }
  3743. }
  3744. return result;
  3745. }
  3746. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3747. {
  3748. string result = origin;
  3749. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3750. {
  3751. string[] temparr = origin.Split(',');
  3752. result = "";
  3753. foreach (var item in temparr)
  3754. {
  3755. int tempId;
  3756. bool success = int.TryParse(item, out tempId);
  3757. if (success)
  3758. {
  3759. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3760. if (tempInfo != null)
  3761. {
  3762. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3763. }
  3764. }
  3765. }
  3766. }
  3767. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3768. return result;
  3769. }
  3770. /// <summary>
  3771. /// 机票费用录入,删除
  3772. /// </summary>
  3773. /// <param name="dto"></param>
  3774. /// <returns></returns>
  3775. [HttpPost]
  3776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3777. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3778. {
  3779. try
  3780. {
  3781. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3782. if (res)
  3783. {
  3784. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3785. {
  3786. IsDel = 1,
  3787. DeleteUserId = dto.DeleteUserId,
  3788. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3789. }).ExecuteCommandAsync();
  3790. return Ok(JsonView(true, "删除成功!"));
  3791. }
  3792. return Ok(JsonView(false, "删除失败!"));
  3793. }
  3794. catch (Exception ex)
  3795. {
  3796. return Ok(JsonView(false, "程序错误!"));
  3797. throw;
  3798. }
  3799. }
  3800. /// <summary>
  3801. /// 导出机票录入报表
  3802. /// </summary>
  3803. /// <param name="dto"></param>
  3804. /// <returns></returns>
  3805. [HttpPost]
  3806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3807. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3808. {
  3809. try
  3810. {
  3811. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3812. if (groupData.Code != 0)
  3813. {
  3814. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3815. }
  3816. else
  3817. {
  3818. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3819. if (AirTicketReservations.Count != 0)
  3820. {
  3821. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3822. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3823. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3824. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3825. WorkbookDesigner designer = new WorkbookDesigner();
  3826. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3827. decimal countCost = 0;
  3828. foreach (var item in AirTicketReservations)
  3829. {
  3830. #region 处理客人姓名
  3831. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3832. item.ClientName = clientNames;
  3833. #endregion
  3834. if (item.BankType == "其他")
  3835. {
  3836. item.BankNo = "--";
  3837. }
  3838. else
  3839. {
  3840. if (!string.IsNullOrEmpty(item.BankType))
  3841. {
  3842. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3843. }
  3844. }
  3845. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3846. item.Price = System.Decimal.Round(item.Price, 2);
  3847. countCost += Convert.ToDecimal(item.Price);
  3848. }
  3849. designer.SetDataSource("Export", AirTicketReservations);
  3850. designer.SetDataSource("ExportDiCode", diCode);
  3851. designer.SetDataSource("ExportDiName", diName);
  3852. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3853. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3854. designer.Process();
  3855. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3856. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3857. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3858. return Ok(JsonView(true, "成功", url = rst));
  3859. }
  3860. else
  3861. {
  3862. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3863. }
  3864. }
  3865. }
  3866. catch (Exception ex)
  3867. {
  3868. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3869. throw;
  3870. }
  3871. }
  3872. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3873. /// <summary>
  3874. /// 行程单导出
  3875. /// </summary>
  3876. /// <param name="dto"></param>
  3877. /// <returns></returns>
  3878. [HttpPost]
  3879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3880. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3881. {
  3882. try
  3883. {
  3884. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3885. if (groupData.Code != 0)
  3886. {
  3887. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3888. }
  3889. else
  3890. {
  3891. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3892. if (dto.Language == "CN")
  3893. {
  3894. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3895. DocumentBuilder builder = new DocumentBuilder(doc);
  3896. int tableIndex = 0;//表格索引
  3897. //得到文档中的第一个表格
  3898. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3899. foreach (var item in _AirTicketReservations)
  3900. {
  3901. #region 处理固定数据
  3902. string[] FlightsCode = item.FlightsCode.Split('/');
  3903. if (FlightsCode.Length != 0)
  3904. {
  3905. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3906. if (_AirCompany != null)
  3907. {
  3908. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3909. }
  3910. else
  3911. {
  3912. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3913. }
  3914. }
  3915. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3916. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3917. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3918. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3919. string name = "";
  3920. foreach (string clientName in nameArray)
  3921. {
  3922. if (!name.Contains(clientName))
  3923. {
  3924. name += clientName + ",";
  3925. }
  3926. }
  3927. if (!string.IsNullOrWhiteSpace(name))
  3928. {
  3929. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3930. }
  3931. else
  3932. {
  3933. table.Range.Bookmarks["ClientName"].Text = "--";
  3934. }
  3935. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3936. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3937. table.Range.Bookmarks["JointTicket"].Text = "--";
  3938. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3939. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3940. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3941. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3942. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3943. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3944. #endregion
  3945. #region 循环数据处理
  3946. List<AirInfo> airs = new List<AirInfo>();
  3947. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3948. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3949. for (int i = 0; i < FlightsCode.Length; i++)
  3950. {
  3951. AirInfo air = new AirInfo();
  3952. string[] tempstr = DayArray[i]
  3953. .Replace("\r\n", string.Empty)
  3954. .Replace("\\r\\n", string.Empty)
  3955. .TrimStart().TrimEnd()
  3956. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3957. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3958. string starCity = "";
  3959. if (star_Three != null)
  3960. {
  3961. starCity = star_Three.AirPort;
  3962. }
  3963. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3964. string EndCity = "";
  3965. if (End_Three != null)
  3966. {
  3967. EndCity = End_Three.AirPort;
  3968. }
  3969. air.Destination = starCity + "/" + EndCity;
  3970. air.Flight = FlightsCode[i];
  3971. air.SeatingClass = item.CTypeName;
  3972. string dateTime = tempstr[2];
  3973. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3974. air.FlightDate = DateTemp;
  3975. air.DepartureTime = tempstr[5];
  3976. air.LandingTime = tempstr[6];
  3977. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3978. air.TicketStatus = "--";
  3979. air.Luggage = "--";
  3980. air.DepartureTerminal = "--";
  3981. air.LandingTerminal = "--";
  3982. airs.Add(air);
  3983. }
  3984. int row = 13;
  3985. for (int i = 0; i < airs.Count; i++)
  3986. {
  3987. if (airs.Count > 2)
  3988. {
  3989. for (int j = 0; j < airs.Count - 2; j++)
  3990. {
  3991. var CopyRow = table.Rows[12].Clone(true);
  3992. table.Rows.Add(CopyRow);
  3993. }
  3994. }
  3995. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3996. int index = 0;
  3997. foreach (PropertyInfo property in properties)
  3998. {
  3999. string value = property.GetValue(airs[i]).ToString();
  4000. Cell ishcel0 = table.Rows[row].Cells[index];
  4001. Paragraph p = new Paragraph(doc);
  4002. string s = value;
  4003. p.AppendChild(new Run(doc, s));
  4004. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4005. ishcel0.AppendChild(p);
  4006. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4007. index++;
  4008. }
  4009. row++;
  4010. }
  4011. #endregion
  4012. Paragraph lastParagraph = new Paragraph(doc);
  4013. //第一个表格末尾加段落
  4014. table.ParentNode.InsertAfter(lastParagraph, table);
  4015. //复制第一个表格
  4016. Table cloneTable = (Table)table.Clone(true);
  4017. //在文档末尾段落后面加入复制的表格
  4018. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4019. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4020. {
  4021. int rownewsIndex = 13;
  4022. for (int i = 0; i < 2; i++)
  4023. {
  4024. var CopyRow = table.Rows[12].Clone(true);
  4025. table.Rows.RemoveAt(13);
  4026. table.Rows.Add(CopyRow);
  4027. rownewsIndex++;
  4028. }
  4029. }
  4030. else
  4031. {
  4032. table.Rows.RemoveAt(12);
  4033. }
  4034. cloneTable.Rows.RemoveAt(12);
  4035. }
  4036. if (_AirTicketReservations.Count != 0)
  4037. {
  4038. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4039. if (FlightsCode.Length != 0)
  4040. {
  4041. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4042. if (_AirCompany != null)
  4043. {
  4044. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4045. }
  4046. else
  4047. {
  4048. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4049. }
  4050. }
  4051. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4052. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4053. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4054. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4055. string name = "";
  4056. foreach (string clientName in nameArray)
  4057. {
  4058. if (!name.Contains(clientName))
  4059. {
  4060. name += clientName + ",";
  4061. }
  4062. }
  4063. if (!string.IsNullOrWhiteSpace(name))
  4064. {
  4065. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4066. }
  4067. else
  4068. {
  4069. table.Range.Bookmarks["ClientName"].Text = "--";
  4070. }
  4071. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4072. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4073. table.Range.Bookmarks["JointTicket"].Text = "--";
  4074. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4075. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4076. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4077. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4078. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4079. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4080. }
  4081. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4082. //保存合并后的文档
  4083. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4084. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4085. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4086. return Ok(JsonView(true, "成功!", rst));
  4087. }
  4088. else
  4089. {
  4090. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4091. DocumentBuilder builder = new DocumentBuilder(doc);
  4092. int tableIndex = 0;//表格索引
  4093. //得到文档中的第一个表格
  4094. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4095. List<string> texts = new List<string>();
  4096. foreach (var item in _AirTicketReservations)
  4097. {
  4098. string[] FlightsCode = item.FlightsCode.Split('/');
  4099. if (FlightsCode.Length != 0)
  4100. {
  4101. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4102. if (_AirCompany != null)
  4103. {
  4104. if (!transDic.ContainsKey(_AirCompany.CnName))
  4105. {
  4106. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4107. }
  4108. }
  4109. else
  4110. {
  4111. if (!transDic.ContainsKey("--"))
  4112. {
  4113. transDic.Add("--", "--");
  4114. }
  4115. }
  4116. }
  4117. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4118. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4119. string name = "";
  4120. foreach (string clientName in nameArray)
  4121. {
  4122. name += clientName + ",";
  4123. }
  4124. if (!texts.Contains(name))
  4125. {
  4126. texts.Add(name);
  4127. }
  4128. List<AirInfo> airs = new List<AirInfo>();
  4129. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4130. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4131. for (int i = 0; i < FlightsCode.Length; i++)
  4132. {
  4133. AirInfo air = new AirInfo();
  4134. string[] tempstr = DayArray[i]
  4135. .Replace("\r\n", string.Empty)
  4136. .Replace("\\r\\n", string.Empty)
  4137. .TrimStart().TrimEnd()
  4138. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4139. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4140. if (star_Three != null)
  4141. {
  4142. if (!transDic.ContainsKey(star_Three.AirPort))
  4143. {
  4144. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4145. }
  4146. }
  4147. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4148. if (End_Three != null)
  4149. {
  4150. if (!transDic.ContainsKey(End_Three.AirPort))
  4151. {
  4152. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4153. }
  4154. }
  4155. if (!texts.Contains(item.CTypeName))
  4156. {
  4157. texts.Add(item.CTypeName);
  4158. }
  4159. }
  4160. }
  4161. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4162. if (transData.Count > 0)
  4163. {
  4164. foreach (TranslateResult item in transData)
  4165. {
  4166. if (!transDic.ContainsKey(item.Query))
  4167. {
  4168. transDic.Add(item.Query, item.Translation);
  4169. }
  4170. }
  4171. }
  4172. foreach (var item in _AirTicketReservations)
  4173. {
  4174. #region 处理固定数据
  4175. string[] FlightsCode = item.FlightsCode.Split('/');
  4176. if (FlightsCode.Length != 0)
  4177. {
  4178. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4179. if (_AirCompany != null)
  4180. {
  4181. string str = "--";
  4182. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4183. if (!string.IsNullOrEmpty(translateResult))
  4184. {
  4185. str = translateResult;
  4186. str = _airTicketResRep.Processing(str);
  4187. }
  4188. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4189. }
  4190. else
  4191. {
  4192. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4193. }
  4194. }
  4195. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4196. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4197. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4198. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4199. string names = "";
  4200. foreach (string clientName in nameArray)
  4201. {
  4202. names += clientName + ",";
  4203. }
  4204. if (!string.IsNullOrWhiteSpace(names))
  4205. {
  4206. string str = "--";
  4207. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4208. if (!string.IsNullOrEmpty(translateResult))
  4209. {
  4210. str = translateResult;
  4211. str = _airTicketResRep.Processing(str);
  4212. }
  4213. table.Range.Bookmarks["ClientName"].Text = str;
  4214. }
  4215. else
  4216. {
  4217. table.Range.Bookmarks["ClientName"].Text = "--";
  4218. }
  4219. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4220. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4221. table.Range.Bookmarks["JointTicket"].Text = "--";
  4222. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4223. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4224. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4225. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4226. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4227. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4228. #endregion
  4229. #region 循环数据处理
  4230. List<AirInfo> airs = new List<AirInfo>();
  4231. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4232. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4233. for (int i = 0; i < FlightsCode.Length; i++)
  4234. {
  4235. AirInfo air = new AirInfo();
  4236. string[] tempstr = DayArray[i]
  4237. .Replace("\r\n", string.Empty)
  4238. .Replace("\\r\\n", string.Empty)
  4239. .TrimStart().TrimEnd()
  4240. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4241. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4242. string starCity = "";
  4243. if (star_Three != null)
  4244. {
  4245. string str2 = "--";
  4246. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4247. if (!string.IsNullOrEmpty(translateResult2))
  4248. {
  4249. str2 = translateResult2;
  4250. str2 = _airTicketResRep.Processing(str2);
  4251. }
  4252. starCity = str2;
  4253. }
  4254. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4255. string EndCity = "";
  4256. if (End_Three != null)
  4257. {
  4258. string str1 = "--";
  4259. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4260. if (!string.IsNullOrEmpty(translateResult1))
  4261. {
  4262. str1 = translateResult1;
  4263. str1 = _airTicketResRep.Processing(str1);
  4264. }
  4265. EndCity = str1;
  4266. }
  4267. air.Destination = starCity + "/" + EndCity;
  4268. air.Flight = FlightsCode[i];
  4269. string str = "--";
  4270. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4271. if (!string.IsNullOrEmpty(translateResult))
  4272. {
  4273. str = translateResult;
  4274. str = _airTicketResRep.Processing(str);
  4275. }
  4276. air.SeatingClass = str;
  4277. string dateTime = tempstr[2];
  4278. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4279. air.FlightDate = DateTemp;
  4280. air.DepartureTime = tempstr[5];
  4281. air.LandingTime = tempstr[6];
  4282. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4283. air.TicketStatus = "--";
  4284. air.Luggage = "--";
  4285. air.DepartureTerminal = "--";
  4286. air.LandingTerminal = "--";
  4287. airs.Add(air);
  4288. }
  4289. int row = 13;
  4290. for (int i = 0; i < airs.Count; i++)
  4291. {
  4292. if (airs.Count > 2)
  4293. {
  4294. for (int j = 0; j < airs.Count - 2; j++)
  4295. {
  4296. var CopyRow = table.Rows[12].Clone(true);
  4297. table.Rows.Add(CopyRow);
  4298. }
  4299. }
  4300. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4301. int index = 0;
  4302. foreach (PropertyInfo property in properties)
  4303. {
  4304. string value = property.GetValue(airs[i]).ToString();
  4305. Cell ishcel0 = table.Rows[row].Cells[index];
  4306. Paragraph p = new Paragraph(doc);
  4307. string s = value;
  4308. p.AppendChild(new Run(doc, s));
  4309. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4310. ishcel0.AppendChild(p);
  4311. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4312. //ishcel0.CellFormat.VerticalAlignment=
  4313. index++;
  4314. }
  4315. row++;
  4316. }
  4317. #endregion
  4318. Paragraph lastParagraph = new Paragraph(doc);
  4319. //第一个表格末尾加段落
  4320. table.ParentNode.InsertAfter(lastParagraph, table);
  4321. //复制第一个表格
  4322. Table cloneTable = (Table)table.Clone(true);
  4323. //在文档末尾段落后面加入复制的表格
  4324. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4325. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4326. {
  4327. int rownewsIndex = 13;
  4328. for (int i = 0; i < 2; i++)
  4329. {
  4330. var CopyRow = table.Rows[12].Clone(true);
  4331. table.Rows.RemoveAt(13);
  4332. table.Rows.Add(CopyRow);
  4333. rownewsIndex++;
  4334. }
  4335. }
  4336. else
  4337. {
  4338. table.Rows.RemoveAt(12);
  4339. }
  4340. cloneTable.Rows.RemoveAt(12);
  4341. }
  4342. if (_AirTicketReservations.Count != 0)
  4343. {
  4344. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4345. if (FlightsCode.Length != 0)
  4346. {
  4347. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4348. if (_AirCompany != null)
  4349. {
  4350. string str = "--";
  4351. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4352. if (!string.IsNullOrEmpty(translateResult))
  4353. {
  4354. str = translateResult;
  4355. str = _airTicketResRep.Processing(str);
  4356. }
  4357. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4358. }
  4359. else
  4360. {
  4361. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4362. }
  4363. }
  4364. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4365. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4366. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4367. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4368. string names = "";
  4369. foreach (string clientName in nameArray)
  4370. {
  4371. names += clientName + ",";
  4372. }
  4373. if (!string.IsNullOrWhiteSpace(names))
  4374. {
  4375. string str = "--";
  4376. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4377. if (!string.IsNullOrEmpty(translateResult))
  4378. {
  4379. str = translateResult;
  4380. str = _airTicketResRep.Processing(str);
  4381. }
  4382. table.Range.Bookmarks["ClientName"].Text = str;
  4383. }
  4384. else
  4385. {
  4386. table.Range.Bookmarks["ClientName"].Text = "--";
  4387. }
  4388. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4389. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4390. table.Range.Bookmarks["JointTicket"].Text = "--";
  4391. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4392. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4393. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4394. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4395. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4396. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4397. }
  4398. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4399. //保存合并后的文档
  4400. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4401. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4402. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4403. return Ok(JsonView(true, "成功!", rst));
  4404. }
  4405. }
  4406. }
  4407. catch (Exception ex)
  4408. {
  4409. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4410. throw;
  4411. }
  4412. }
  4413. #endregion
  4414. #region 团组增减款项 --> 其他款项
  4415. /// <summary>
  4416. /// 团组增减款项下拉框绑定
  4417. /// </summary>
  4418. /// <param name="dto"></param>
  4419. /// <returns></returns>
  4420. [HttpPost]
  4421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4422. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4423. {
  4424. #region 参数验证
  4425. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4426. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4427. #endregion
  4428. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4429. }
  4430. /// <summary>
  4431. /// 根据团组Id查询团组增减款项
  4432. /// </summary>
  4433. /// <param name="dto"></param>
  4434. /// <returns></returns>
  4435. [HttpPost]
  4436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4437. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4438. {
  4439. #region 参数验证
  4440. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4441. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4442. #endregion
  4443. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4444. }
  4445. /// <summary>
  4446. /// 团组增减款项操作(Status:1.新增,2.修改)
  4447. /// </summary>
  4448. /// <param name="dto"></param>
  4449. /// <returns></returns>
  4450. [HttpPost]
  4451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4452. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4453. {
  4454. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4455. if (groupData.Code != 200)
  4456. {
  4457. return Ok(JsonView(false, groupData.Msg));
  4458. }
  4459. #region 应用推送
  4460. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4461. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4462. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4463. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4464. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4465. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4466. //自动审核
  4467. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4468. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4469. //2024-10-21 新增LZ UID
  4470. var userIds = new List<int>() { 21 };
  4471. string title = $"系统通知";
  4472. string content = "";
  4473. var diId = dto.DiId;
  4474. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4475. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4476. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4477. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4478. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4479. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4480. #endregion
  4481. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4482. }
  4483. /// <summary>
  4484. /// 团组增减款项操作 删除
  4485. /// </summary>
  4486. /// <param name="dto"></param>
  4487. /// <returns></returns>
  4488. [HttpPost]
  4489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4490. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4491. {
  4492. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4493. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4494. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4495. if (res.Code == 0)
  4496. {
  4497. return Ok(JsonView(true, "删除成功!"));
  4498. }
  4499. return Ok(JsonView(false, "删除失败!"));
  4500. }
  4501. /// <summary>
  4502. /// 根据团组增减款项Id查询
  4503. /// </summary>
  4504. /// <param name="dto"></param>
  4505. /// <returns></returns>
  4506. [HttpPost]
  4507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4508. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4509. {
  4510. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4511. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4512. }
  4513. /// <summary>
  4514. /// 查询供应商名称
  4515. /// </summary>
  4516. /// <param name="dto"></param>
  4517. /// <returns></returns>
  4518. [HttpPost]
  4519. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4520. {
  4521. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4522. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4523. ?? new List<Grp_DecreasePayments>();
  4524. dbResult = dbResult.Distinct(new
  4525. ProductComparer()).ToList();
  4526. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4527. {
  4528. x.Id,
  4529. x.SupplierAddress,
  4530. x.SupplierArea,
  4531. x.SupplierContact,
  4532. x.SupplierContactNumber,
  4533. x.SupplierEmail,
  4534. x.SupplierName,
  4535. x.SupplierSocialAccount,
  4536. x.SupplierTypeId,
  4537. }).ToList());
  4538. return Ok(jw);
  4539. }
  4540. /// <summary>
  4541. /// 团组增减款项 OTA匹配
  4542. /// </summary>
  4543. /// <param name="file"></param>
  4544. /// <returns></returns>
  4545. [HttpPost]
  4546. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4547. {
  4548. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4549. string fileName = file.FileName;
  4550. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4551. {
  4552. return Ok(JsonView(false, "请上传Excel文件!"));
  4553. }
  4554. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4555. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4556. if (!Directory.Exists(path))
  4557. {
  4558. Directory.CreateDirectory(path);
  4559. }
  4560. var filePath = @$"{path}/{fileName}";
  4561. //保存文件
  4562. using (FileStream fs = System.IO.File.Create(filePath))
  4563. {
  4564. file.CopyTo(fs);
  4565. fs.Flush();
  4566. }
  4567. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4568. //读取ExcelFile
  4569. DataTable dt = ConvertExcelToDataTable(filePath);
  4570. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4571. dt.TableName = "TB";
  4572. //修改table列名
  4573. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4574. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4575. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4576. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4577. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4578. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4579. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4580. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4581. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4582. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4583. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4584. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4585. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4586. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4587. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4588. var otaOrderNos = new List<string>();
  4589. foreach (DataRow item in dt.Rows)
  4590. {
  4591. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4592. }
  4593. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4594. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4595. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4596. .Select((dp, di) => new
  4597. {
  4598. dp.PriceName,
  4599. dp.OTAOrderNo,
  4600. dp.FeeTotal,
  4601. di.TeamName,
  4602. })
  4603. .ToListAsync();
  4604. foreach (DataRow item in dt.Rows)
  4605. {
  4606. var otaOrderNo = item["OTAOrderNo"].ToString();
  4607. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4608. if (oaData == null) continue;
  4609. item["GroupName"] = oaData.TeamName;
  4610. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4611. }
  4612. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4613. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4614. List<DataTable> datas = new List<DataTable>();
  4615. datas.Add(dt);
  4616. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4617. return Ok(JsonView(true, "操作成功", new { url = url }));
  4618. }
  4619. #region
  4620. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4621. {
  4622. // 创建Workbook对象
  4623. Workbook workbook = new Workbook(excelFilePath);
  4624. // 获取第一个工作表
  4625. Worksheet worksheet = workbook.Worksheets[0];
  4626. // 将工作表转换为DataTable
  4627. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4628. return dataTable;
  4629. }
  4630. #endregion
  4631. #endregion
  4632. #region 文件上传、删除
  4633. /// <summary>
  4634. /// region 文件上传 可以带参数
  4635. /// </summary>
  4636. /// <param name="file"></param>
  4637. /// <returns></returns>
  4638. [HttpPost]
  4639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4640. public async Task<IActionResult> UploadProject(IFormFile file)
  4641. {
  4642. //var TypeName = Request.Headers["TypeName"].ToString();
  4643. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4644. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4645. ////文件名称
  4646. //string projectFileName = file.FileName;
  4647. ////上传的文件的路径
  4648. //string filePath = $"{fileDir}/{projectFileName}";
  4649. //if (TypeName == "A")//A代表团组增减款项
  4650. //{
  4651. // filePath = fileDir + $@"\团组增减款项相关文件";
  4652. // if (!Directory.Exists(filePath))
  4653. // {
  4654. // Directory.CreateDirectory(filePath);
  4655. // }
  4656. // //上传的文件的路径
  4657. // filePath += $@"\{projectFileName}";
  4658. //}
  4659. //else if (TypeName == "B")//B代表商邀相关文件
  4660. //{
  4661. // //上传的文件的路径
  4662. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4663. // if (!Directory.Exists(filePath))
  4664. // {
  4665. // Directory.CreateDirectory(filePath);
  4666. // }
  4667. // //上传的文件的路径
  4668. // filePath = $@"\{projectFileName}";
  4669. //}
  4670. //try
  4671. //{
  4672. // using (FileStream fs = System.IO.File.Create(filePath))
  4673. // {
  4674. // file.CopyTo(fs);
  4675. // fs.Flush();
  4676. // }
  4677. //}
  4678. //catch (Exception ex)
  4679. //{
  4680. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4681. //}
  4682. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4683. try
  4684. {
  4685. var TypeName = Request.Headers["TypeName"].ToString();
  4686. if (file != null)
  4687. {
  4688. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4689. //文件名称
  4690. string projectFileName = file.FileName;
  4691. //上传的文件的路径
  4692. string filePath = $"{fileDir}/{projectFileName}";
  4693. if (TypeName == "A")//A代表团组增减款项
  4694. {
  4695. if (!Directory.Exists(fileDir))
  4696. {
  4697. Directory.CreateDirectory(fileDir);
  4698. }
  4699. //上传的文件的路径
  4700. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4701. }
  4702. else if (TypeName == "B")//B代表商邀相关文件
  4703. {
  4704. if (!Directory.Exists(fileDir))
  4705. {
  4706. Directory.CreateDirectory(fileDir);
  4707. }
  4708. //上传的文件的路径
  4709. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4710. }
  4711. using (FileStream fs = System.IO.File.Create(filePath))
  4712. {
  4713. file.CopyTo(fs);
  4714. fs.Flush();
  4715. }
  4716. return Ok(JsonView(true, "上传成功!", projectFileName));
  4717. }
  4718. else
  4719. {
  4720. return Ok(JsonView(false, "上传失败!"));
  4721. }
  4722. }
  4723. catch (Exception ex)
  4724. {
  4725. return Ok(JsonView(false, "程序错误!"));
  4726. }
  4727. }
  4728. /// <summary>
  4729. /// 删除指定文件
  4730. /// </summary>
  4731. /// <param name="dto"></param>
  4732. /// <returns></returns>
  4733. [HttpPost]
  4734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4735. public async Task<IActionResult> DelFile(DelFileDto dto)
  4736. {
  4737. try
  4738. {
  4739. var TypeName = Request.Headers["TypeName"].ToString();
  4740. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4741. string filePath = "";
  4742. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4743. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4744. int id = 0;
  4745. if (TypeName == "A")
  4746. {
  4747. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4748. // 删除该文件
  4749. System.IO.File.Delete(filePath);
  4750. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4751. .Where(a => a.Id == dto.Id)
  4752. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4753. .ExecuteCommandAsync();
  4754. }
  4755. else if (TypeName == "B")
  4756. {
  4757. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4758. // 删除该文件
  4759. System.IO.File.Delete(filePath);
  4760. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4761. if (info != null)
  4762. {
  4763. string[] files = new string[] { };
  4764. if (!string.IsNullOrEmpty(info.Attachment))
  4765. {
  4766. try
  4767. {
  4768. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4769. }
  4770. catch (Exception)
  4771. {
  4772. files = new List<string>() { info.Attachment }.ToArray();
  4773. }
  4774. }
  4775. if (files.Length > 0)
  4776. {
  4777. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4778. string filePath2 = string.Empty;
  4779. if (files1.Length > 0)
  4780. {
  4781. filePath2 = JsonConvert.SerializeObject(files1);
  4782. }
  4783. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4784. .Where(a => a.Id == dto.Id)
  4785. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4786. .ExecuteCommandAsync();
  4787. }
  4788. }
  4789. }
  4790. if (id != 0)
  4791. {
  4792. return Ok(JsonView(true, "成功!"));
  4793. }
  4794. else
  4795. {
  4796. return Ok(JsonView(false, "失败!"));
  4797. }
  4798. }
  4799. catch (Exception ex)
  4800. {
  4801. return Ok(JsonView(false, "程序错误!"));
  4802. throw;
  4803. }
  4804. }
  4805. /// <summary>
  4806. /// 文件上传多个文件 可以带参数
  4807. /// </summary>
  4808. /// <param name="files"></param>
  4809. /// <returns></returns>
  4810. [HttpPost]
  4811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4812. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4813. {
  4814. try
  4815. {
  4816. var TypeName = Request.Headers["TypeName"].ToString();
  4817. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4818. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4819. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4820. var filePahts = new List<string>();
  4821. foreach (var file in files)
  4822. {
  4823. //文件名称
  4824. string projectFileName = file.FileName;
  4825. //上传的文件的路径
  4826. string filePath = $"{fileDir}/{projectFileName}";
  4827. if (TypeName == "A")//A代表团组增减款项
  4828. {
  4829. if (!Directory.Exists(fileDir))
  4830. {
  4831. Directory.CreateDirectory(fileDir);
  4832. }
  4833. //上传的文件的路径
  4834. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4835. }
  4836. else if (TypeName == "B")//B代表商邀相关文件
  4837. {
  4838. if (!Directory.Exists(fileDir))
  4839. {
  4840. Directory.CreateDirectory(fileDir);
  4841. }
  4842. //上传的文件的路径
  4843. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4844. }
  4845. using (FileStream fs = System.IO.File.Create(filePath))
  4846. {
  4847. file.CopyTo(fs);
  4848. fs.Flush();
  4849. }
  4850. filePahts.Add(projectFileName);
  4851. }
  4852. return Ok(JsonView(true, "上传成功!", filePahts));
  4853. }
  4854. catch (Exception ex)
  4855. {
  4856. return Ok(JsonView(false, "程序错误!"));
  4857. }
  4858. }
  4859. #endregion
  4860. #region 商邀费用录入
  4861. /// <summary>
  4862. /// 根据团组Id查询商邀费用列表
  4863. /// </summary>
  4864. /// <param name="dto"></param>
  4865. /// <returns></returns>
  4866. [HttpPost]
  4867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4868. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4869. {
  4870. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4871. if (groupData.Code != 0)
  4872. {
  4873. return Ok(JsonView(false, groupData.Msg));
  4874. }
  4875. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4876. }
  4877. /// <summary>
  4878. /// 商邀费用列表
  4879. /// 下载文件
  4880. /// </summary>
  4881. /// <param name="id"></param>
  4882. /// <returns></returns>
  4883. [HttpGet("{id}")]
  4884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4885. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4886. {
  4887. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4888. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4889. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4890. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4891. var filePaths = new List<string>();
  4892. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4893. try
  4894. {
  4895. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4896. }
  4897. catch (Exception ex)
  4898. {
  4899. filePaths.Add(info.Attachment);
  4900. }
  4901. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4902. for (int i = 0; i < filePaths.Count; i++)
  4903. {
  4904. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4905. }
  4906. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4907. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4908. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4909. {
  4910. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4911. {
  4912. foreach (string filePath in filePaths)
  4913. {
  4914. if (System.IO.File.Exists(filePath))
  4915. {
  4916. // 获取文件名
  4917. string fileName = Path.GetFileName(filePath);
  4918. // 将文件添加到ZIP归档中
  4919. zipArchive.CreateEntryFromFile(filePath, fileName);
  4920. }
  4921. }
  4922. }
  4923. }
  4924. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4925. }
  4926. /// <summary>
  4927. /// 商邀费用 Info Page 基础数据源
  4928. /// </summary>
  4929. /// <returns></returns>
  4930. [HttpPost]
  4931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4932. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4933. {
  4934. try
  4935. {
  4936. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4937. if (groupData.Code != 0)
  4938. {
  4939. return Ok(JsonView(false, groupData.Msg));
  4940. }
  4941. return Ok(JsonView(true, "操作成功", groupData.Data));
  4942. }
  4943. catch (Exception ex)
  4944. {
  4945. return Ok(JsonView(false, ex.Message));
  4946. throw;
  4947. }
  4948. }
  4949. /// <summary>
  4950. /// 根据商邀费用ID查询C表和商邀费用数据
  4951. /// </summary>
  4952. /// <param name="dto"></param>
  4953. /// <returns></returns>
  4954. [HttpPost]
  4955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4956. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4957. {
  4958. try
  4959. {
  4960. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4961. if (groupData.Code != 0)
  4962. {
  4963. return Ok(JsonView(false, groupData.Msg));
  4964. }
  4965. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4966. }
  4967. catch (Exception ex)
  4968. {
  4969. return Ok(JsonView(false, ex.Message));
  4970. throw;
  4971. }
  4972. }
  4973. /// <summary>
  4974. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4975. /// </summary>
  4976. /// <param name="dto"></param>
  4977. /// <returns></returns>
  4978. [HttpPost]
  4979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4980. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4981. {
  4982. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4983. if (groupData.Code != 0)
  4984. {
  4985. return Ok(JsonView(false, groupData.Msg));
  4986. }
  4987. #region 应用推送
  4988. try
  4989. {
  4990. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4991. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4992. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4993. //2024-10-21 新增LZ UID
  4994. var userIds = new List<int>() { 21 };
  4995. string title = $"系统通知";
  4996. string content = "";
  4997. var diId = dto.DiId;
  4998. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4999. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5000. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5001. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5002. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5003. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5004. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5005. }
  5006. catch (Exception ex)
  5007. {
  5008. }
  5009. #endregion
  5010. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5011. }
  5012. /// <summary>
  5013. /// 商邀删除
  5014. /// </summary>
  5015. /// <param name="dto"></param>
  5016. /// <returns></returns>
  5017. [HttpPost]
  5018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5019. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5020. {
  5021. try
  5022. {
  5023. _sqlSugar.BeginTran();
  5024. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5025. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5026. {
  5027. IsDel = 1,
  5028. DeleteUserId = dto.DeleteUserId,
  5029. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5030. })
  5031. .Where(it => it.Id == dto.Id)
  5032. .ExecuteCommand();
  5033. if (res1 > 0)
  5034. {
  5035. int _diId = 0;
  5036. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5037. if (_ioaInfo != null)
  5038. {
  5039. _diId = _ioaInfo.DiId;
  5040. }
  5041. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5042. .SetColumns(a => new Grp_CreditCardPayment()
  5043. {
  5044. IsDel = 1,
  5045. DeleteUserId = dto.DeleteUserId,
  5046. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5047. })
  5048. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5049. .ExecuteCommand();
  5050. if (res2 > 0)
  5051. {
  5052. _sqlSugar.CommitTran();
  5053. return Ok(JsonView(true, "删除成功!"));
  5054. }
  5055. }
  5056. _sqlSugar.RollbackTran();
  5057. return Ok(JsonView(false, "删除失败"));
  5058. }
  5059. catch (Exception ex)
  5060. {
  5061. _sqlSugar.RollbackTran();
  5062. return Ok(JsonView(false, ex.Message));
  5063. }
  5064. }
  5065. #endregion
  5066. #region 票据上传
  5067. /// <summary>
  5068. /// 团组模块文件上传
  5069. /// </summary>
  5070. /// <param name="dto"></param>
  5071. /// <returns></returns>
  5072. [HttpPost]
  5073. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5074. {
  5075. var jw = JsonView(false);
  5076. long M = 1024 * 1024;
  5077. if (dto.Files == null || dto.Files.Count == 0)
  5078. {
  5079. jw.Msg = "无文件信息!";
  5080. return Ok(jw);
  5081. }
  5082. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5083. {
  5084. jw.Msg = "文件大小超过20M!";
  5085. return Ok(jw);
  5086. }
  5087. //var nameSp = dto.File.FileName.Split(".");
  5088. //if (nameSp.Length < 2)
  5089. //{
  5090. // jw.Msg = "拓展名称有误!";
  5091. // return Ok(jw);
  5092. //}
  5093. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5094. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5095. //{
  5096. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5097. // return Ok(jw);
  5098. //}
  5099. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5100. if (Ctable == null)
  5101. {
  5102. jw.Msg = "Ctable指向有误!";
  5103. return Ok(jw);
  5104. }
  5105. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5106. if (groupInfo == null)
  5107. {
  5108. jw.Msg = "团组信息不存在!";
  5109. return Ok(jw);
  5110. }
  5111. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5112. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5113. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5114. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5115. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5116. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5117. try
  5118. {
  5119. if (!Directory.Exists(fileBase))
  5120. {
  5121. Directory.CreateDirectory(fileBase);
  5122. }
  5123. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5124. foreach (var fileStream in dto.Files)
  5125. {
  5126. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5127. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5128. {
  5129. Cid = dto.Cid,
  5130. CreateTime = DateTime.Now,
  5131. CreateUserId = dto.Userid,
  5132. Ctable = dto.Ctable,
  5133. Diid = dto.Diid,
  5134. IsDel = 0,
  5135. FilePath = saveFilePath,
  5136. FileName = fileStream.FileName
  5137. };
  5138. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5139. {
  5140. fileStream.CopyTo(fs);
  5141. fs.Flush();
  5142. }
  5143. saveArr.Add(file);
  5144. }
  5145. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5146. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5147. jw = JsonView(true, "保存成功!", new
  5148. {
  5149. count = addResult,
  5150. filesName = saveArr.Select(x => x.FileName)
  5151. });
  5152. }
  5153. catch (Exception ex)
  5154. {
  5155. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5156. {
  5157. count = 0,
  5158. filesName = new string[0],
  5159. });
  5160. }
  5161. return Ok(jw);
  5162. }
  5163. /// <summary>
  5164. /// 查询各模块已保存文件
  5165. /// </summary>
  5166. /// <param name="dto"></param>
  5167. /// <returns></returns>
  5168. [HttpPost]
  5169. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5170. {
  5171. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5172. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5173. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5174. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5175. {
  5176. expression = Expressionable.Create<Grp_GroupModelFile>()
  5177. .And(x => visaIds.Contains(x.CreateUserId));
  5178. }
  5179. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5180. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5181. .Where(expression.ToExpression())
  5182. .ToList();
  5183. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5184. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5185. {
  5186. x.FileName,
  5187. x.Id,
  5188. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5189. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5190. })));
  5191. }
  5192. /// <summary>
  5193. /// 下载该团组下的所有文件
  5194. /// </summary>
  5195. /// <param name="dto"></param>
  5196. /// <returns></returns>
  5197. [HttpPost]
  5198. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5199. {
  5200. var jw = JsonView(false);
  5201. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5202. if (groupInfo == null)
  5203. {
  5204. jw.Msg = "团组信息不存在!";
  5205. return Ok(jw);
  5206. }
  5207. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5208. var isModule = Convert.ToBoolean(dto.isModule);
  5209. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5210. IOOperatorHelper io = new IOOperatorHelper();
  5211. if (isModule)
  5212. {
  5213. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5214. foreach (var moduleArr in moduleGroup)
  5215. {
  5216. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5217. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5218. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5219. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5220. foreach (var item in moduleArr)
  5221. {
  5222. if (System.IO.File.Exists(item.FilePath))
  5223. {
  5224. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5225. {
  5226. byte[] bytes = new byte[fileStream.Length];
  5227. fileStream.Read(bytes, 0, bytes.Length);
  5228. fileStream.Close();
  5229. Stream stream = new MemoryStream(bytes);
  5230. chiZips.Add(item.FileName, stream);
  5231. }
  5232. }
  5233. }
  5234. if (chiZips.Count > 0)
  5235. {
  5236. var byts = io.ConvertZipStream(chiZips);
  5237. Stream stream = new MemoryStream(byts);
  5238. Zips.Add(key.Name + "_.zip", stream);
  5239. }
  5240. }
  5241. }
  5242. else
  5243. {
  5244. foreach (var item in dbQuery)
  5245. {
  5246. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5247. {
  5248. byte[] bytes = new byte[fileStream.Length];
  5249. fileStream.Read(bytes, 0, bytes.Length);
  5250. fileStream.Close();
  5251. Stream stream = new MemoryStream(bytes);
  5252. while (Zips.Keys.Contains(item.FileName))
  5253. {
  5254. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5255. }
  5256. Zips.Add(item.FileName, stream);
  5257. }
  5258. }
  5259. }
  5260. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5261. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5262. if (Zips.Count > 0)
  5263. {
  5264. var byts = io.ConvertZipStream(Zips);
  5265. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5266. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5267. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5268. }
  5269. else
  5270. {
  5271. jw.Msg = "暂无生成文件!";
  5272. }
  5273. return Ok(jw);
  5274. }
  5275. /// <summary>
  5276. /// 下载该团组下此模块的所有文件
  5277. /// </summary>
  5278. /// <param name="dto"></param>
  5279. /// <returns></returns>
  5280. [HttpPost]
  5281. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5282. {
  5283. var jw = JsonView(false);
  5284. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5285. if (groupInfo == null)
  5286. {
  5287. jw.Msg = "团组信息不存在!";
  5288. return Ok(jw);
  5289. }
  5290. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5291. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5292. && x.IsDel == 0);
  5293. if (key == null)
  5294. {
  5295. jw.Msg = "Ctable指向错误!";
  5296. return Ok(jw);
  5297. }
  5298. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5299. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5300. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5301. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5302. IOOperatorHelper io = new IOOperatorHelper();
  5303. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5304. foreach (var item in dbQuery)
  5305. {
  5306. if (System.IO.File.Exists(item.FilePath))
  5307. {
  5308. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5309. {
  5310. byte[] bytes = new byte[fileStream.Length];
  5311. fileStream.Read(bytes, 0, bytes.Length);
  5312. fileStream.Close();
  5313. Stream stream = new MemoryStream(bytes);
  5314. while (Zips.Keys.Contains(item.FileName))
  5315. {
  5316. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5317. }
  5318. Zips.Add(item.FileName, stream);
  5319. }
  5320. }
  5321. }
  5322. if (Zips.Count > 0)
  5323. {
  5324. var byts = io.ConvertZipStream(Zips);
  5325. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5326. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5327. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5328. }
  5329. else
  5330. {
  5331. jw.Msg = "暂无生成文件!";
  5332. }
  5333. return Ok(jw);
  5334. }
  5335. /// <summary>
  5336. /// 删除该团组下的指定文件
  5337. /// </summary>
  5338. /// <param name="dto"></param>
  5339. /// <returns></returns>
  5340. [HttpPost]
  5341. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5342. {
  5343. var jw = JsonView(false);
  5344. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5345. if (sing == null)
  5346. {
  5347. jw.Msg = "暂无";
  5348. return Ok(jw);
  5349. }
  5350. if (System.IO.File.Exists(sing.FilePath))
  5351. {
  5352. try
  5353. {
  5354. System.IO.File.Delete(sing.FilePath);
  5355. }
  5356. catch (Exception ex)
  5357. {
  5358. jw.Msg = "删除失败!" + ex.Message;
  5359. return Ok(jw);
  5360. }
  5361. }
  5362. sing.IsDel = 1;
  5363. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5364. sing.DeleteUserId = dto.UserId;
  5365. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5366. jw = JsonView(true, "删除成功!");
  5367. return Ok(jw);
  5368. }
  5369. #endregion
  5370. #region 共享文件上传
  5371. /// <summary>
  5372. /// 共享文件数据初始化
  5373. /// </summary>
  5374. /// <returns></returns>
  5375. [HttpGet]
  5376. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  5377. {
  5378. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  5379. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5380. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5381. .Select(x => x.Id)
  5382. .ToList()
  5383. .Contains(userid);
  5384. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5385. .Where(x => x.STid == 111 && x.IsDel == 0)
  5386. .Select(x => new
  5387. {
  5388. x.Name,
  5389. x.Id,
  5390. }).ToList();
  5391. if (isMarketingDepartment)
  5392. {
  5393. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5394. }
  5395. if (portType == 1)
  5396. {
  5397. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5398. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5399. .Where(x => x.IsDel == 0)
  5400. .OrderByDescending(x=> x.VisitDate )
  5401. .Select(x => new
  5402. {
  5403. x.TeamName,
  5404. x.Id,
  5405. x.CityId,
  5406. })
  5407. .ToList()
  5408. .Select(x=>
  5409. {
  5410. var provinceId = x.CityId;
  5411. var isDefualtVal = true;
  5412. if (provinceId > 0)
  5413. {
  5414. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5415. if (parentId != null)
  5416. {
  5417. isDefualtVal = false;
  5418. provinceId = (int)parentId;
  5419. }
  5420. }
  5421. if (isDefualtVal)
  5422. {
  5423. provinceId = 122; //默认四川
  5424. }
  5425. return new
  5426. {
  5427. x.TeamName,
  5428. x.Id,
  5429. provinceId,
  5430. };
  5431. })
  5432. .ToList();
  5433. return Ok(JsonView(true, "SUCCESS!", new
  5434. {
  5435. dropDownType,
  5436. dropDownGroupList,
  5437. isMarketingDepartment
  5438. }));
  5439. }
  5440. else if (portType == 2 || portType == 3)
  5441. {
  5442. return Ok(JsonView(true, "SUCCESS!", new
  5443. {
  5444. dropDownType,
  5445. isMarketingDepartment
  5446. }));
  5447. }
  5448. else
  5449. {
  5450. return Ok(JsonView(false, "portType有误!"));
  5451. }
  5452. }
  5453. /// <summary>
  5454. /// 共享文件上传
  5455. /// </summary>
  5456. /// <param name="dto"></param>
  5457. /// <returns></returns>
  5458. [HttpPost]
  5459. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5460. {
  5461. var isGroup = new List<int> { 1412 };
  5462. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5463. {
  5464. return Ok(JsonView(false, "该文件需要关联团组!"));
  5465. }
  5466. if (dto.Files == null || dto.Files.Count == 0)
  5467. {
  5468. return Ok(JsonView(false, "无文件信息!"));
  5469. }
  5470. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5471. {
  5472. return Ok(JsonView(false, "文件大小超过20M!"));
  5473. }
  5474. if (dto.Userid < 1)
  5475. {
  5476. return Ok(JsonView(false, "请传入有效的Userid!"));
  5477. }
  5478. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5479. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5480. .Select((u, j) => new
  5481. {
  5482. u.CnName,
  5483. UserId = u.Id,
  5484. j.JobName,
  5485. })
  5486. .First();
  5487. if (jobInfo == null)
  5488. {
  5489. return Ok(JsonView(false, "请传入有效的Userid!"));
  5490. }
  5491. List<string> commonFileExtensions = new List<string>
  5492. {
  5493. // 文本文件
  5494. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5495. // 图片文件
  5496. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5497. // 视频文件
  5498. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5499. // 音频文件
  5500. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5501. // 压缩文件
  5502. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5503. // 数据文件
  5504. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5505. };
  5506. try
  5507. {
  5508. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5509. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5510. commonFileExtensions.AddRange(settingExtend);
  5511. }
  5512. catch (Exception)
  5513. { }
  5514. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5515. if (setdata == null)
  5516. {
  5517. return Ok(JsonView(false, "请传入有效的FileType!"));
  5518. }
  5519. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5520. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5521. if (!Directory.Exists(winPath))
  5522. {
  5523. Directory.CreateDirectory(winPath);
  5524. }
  5525. foreach (var item in dto.Files)
  5526. {
  5527. var houzui = Path.GetExtension(item.FileName);
  5528. if (!commonFileExtensions.Contains(houzui))
  5529. {
  5530. return Ok(JsonView(false, "未知后缀名称!"));
  5531. }
  5532. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5533. var saveFilePath = winPath + fileName;
  5534. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5535. {
  5536. item.CopyTo(fs);
  5537. fs.Flush();
  5538. }
  5539. var fileDetail = new Grp_GroupShareFile()
  5540. {
  5541. CreateUserId = dto.Userid,
  5542. CreateTime = DateTime.Now,
  5543. UploadJob = jobInfo.JobName,
  5544. FileName = fileName,
  5545. FileType = dto.FileType,
  5546. Diid = dto.Diid,
  5547. FilePath = winPath + fileName,
  5548. };
  5549. insertList.Add(fileDetail);
  5550. }
  5551. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5552. return Ok(JsonView(true, "保存成功!"));
  5553. }
  5554. /// <summary>
  5555. /// 查询共享文件列表
  5556. /// </summary>
  5557. /// <param name="dto"></param>
  5558. /// <returns></returns>
  5559. [HttpPost]
  5560. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5561. {
  5562. var isGroup = new List<int> { 1412 };
  5563. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5564. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5565. .And(x => x.Diid == dto.Diid)
  5566. .And(x => x.FileType == dto.FileType)
  5567. .And(x => x.IsDel == 0)
  5568. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5569. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5570. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5571. int totalCount = 0;
  5572. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5573. .Where(queryExpression.ToExpression())
  5574. .OrderBy(x => x.UploadJob)
  5575. .Select(x => new
  5576. {
  5577. x.Id,
  5578. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5579. x.FileName,
  5580. x.FileType,
  5581. x.CreateTime,
  5582. })
  5583. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5584. return Ok(JsonView(true, "SUCCESS!", new
  5585. {
  5586. FileList = dbQuery,
  5587. dto.PageSize,
  5588. dto.PageIndex,
  5589. totalCount
  5590. }));
  5591. }
  5592. /// <summary>
  5593. /// 删除共享文件模块下的指定文件
  5594. /// </summary>
  5595. /// <param name="dto"></param>
  5596. /// <returns></returns>
  5597. [HttpPost]
  5598. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5599. {
  5600. var jw = JsonView(false);
  5601. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5602. if (sing == null)
  5603. {
  5604. jw.Msg = "暂无文件信息!";
  5605. return Ok(jw);
  5606. }
  5607. if (sing.CreateUserId != dto.UserId)
  5608. {
  5609. jw.Msg = "只能删除自己上传的文件!";
  5610. return Ok(jw);
  5611. }
  5612. if (System.IO.File.Exists(sing.FilePath))
  5613. {
  5614. try
  5615. {
  5616. System.IO.File.Delete(sing.FilePath);
  5617. }
  5618. catch (Exception ex)
  5619. {
  5620. jw.Msg = "删除失败!" + ex.Message;
  5621. return Ok(jw);
  5622. }
  5623. }
  5624. sing.IsDel = 1;
  5625. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5626. sing.DeleteUserId = dto.UserId;
  5627. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5628. jw = JsonView(true, "删除成功!");
  5629. return Ok(jw);
  5630. }
  5631. #endregion
  5632. #region 团组英文资料
  5633. /// <summary>
  5634. /// 查询团组英文所有资料
  5635. /// </summary>
  5636. /// <param name="dto"></param>
  5637. /// <returns></returns>
  5638. [HttpPost]
  5639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5640. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5641. {
  5642. try
  5643. {
  5644. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5645. if (groupData.Code != 0)
  5646. {
  5647. return Ok(JsonView(false, groupData.Msg));
  5648. }
  5649. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5650. }
  5651. catch (Exception ex)
  5652. {
  5653. return Ok(JsonView(false, "程序错误!"));
  5654. throw;
  5655. }
  5656. }
  5657. /// <summary>
  5658. /// 团组英文资料操作(Status:1.新增,2.修改)
  5659. /// </summary>
  5660. /// <param name="dto"></param>
  5661. /// <returns></returns>
  5662. [HttpPost]
  5663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5664. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5665. {
  5666. try
  5667. {
  5668. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5669. if (groupData.Code != 0)
  5670. {
  5671. return Ok(JsonView(false, groupData.Msg));
  5672. }
  5673. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5674. }
  5675. catch (Exception ex)
  5676. {
  5677. return Ok(JsonView(false, "程序错误!"));
  5678. throw;
  5679. }
  5680. }
  5681. /// <summary>
  5682. /// 团组英文资料Id查询数据
  5683. /// </summary>
  5684. /// <param name="dto"></param>
  5685. /// <returns></returns>
  5686. [HttpPost]
  5687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5688. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5689. {
  5690. try
  5691. {
  5692. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5693. if (_DelegationEnData != null)
  5694. {
  5695. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5696. }
  5697. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5698. }
  5699. catch (Exception ex)
  5700. {
  5701. return Ok(JsonView(false, "程序错误!"));
  5702. throw;
  5703. }
  5704. }
  5705. /// <summary>
  5706. /// 团组英文资料删除
  5707. /// </summary>
  5708. /// <param name="dto"></param>
  5709. /// <returns></returns>
  5710. [HttpPost]
  5711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5712. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5713. {
  5714. try
  5715. {
  5716. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5717. if (!res)
  5718. {
  5719. return Ok(JsonView(false, "删除失败"));
  5720. }
  5721. return Ok(JsonView(true, "删除成功!"));
  5722. }
  5723. catch (Exception ex)
  5724. {
  5725. return Ok(JsonView(false, "程序错误!"));
  5726. throw;
  5727. }
  5728. }
  5729. #endregion
  5730. #region 导出邀请函
  5731. /// <summary>
  5732. /// 导出邀请函页面初始化
  5733. /// </summary>
  5734. /// <param name="dto"></param>
  5735. /// <returns></returns>
  5736. [HttpPost]
  5737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5738. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5739. {
  5740. try
  5741. {
  5742. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5743. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5744. if (dto.DiId == 0)
  5745. {
  5746. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5747. }
  5748. else
  5749. {
  5750. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5751. }
  5752. return Ok(JsonView(true, "查询成功!", new
  5753. {
  5754. deleClient = crm_Deles,
  5755. delegations = grp_Delegations
  5756. }));
  5757. }
  5758. catch (Exception ex)
  5759. {
  5760. return Ok(JsonView(false, "程序错误!"));
  5761. throw;
  5762. }
  5763. }
  5764. /// <summary>
  5765. /// 导出邀请函
  5766. /// </summary>
  5767. /// <param name="dto"></param>
  5768. /// <returns></returns>
  5769. [HttpPost]
  5770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5771. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5772. {
  5773. #region 参数验证
  5774. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5775. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5776. #endregion
  5777. try
  5778. {
  5779. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5780. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5781. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5782. From Grp_TourClientList tcl
  5783. Left Join
  5784. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5785. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5786. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5787. From Crm_DeleClient dc
  5788. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5789. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5790. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5791. Where dc.IsDel = 0) temp
  5792. On temp.DcId =tcl.ClientId
  5793. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5794. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5795. List<string> texts = new List<string>();
  5796. if (datas.Count != 0)
  5797. {
  5798. foreach (TourClientListDetailsView item in datas)
  5799. {
  5800. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5801. {
  5802. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5803. }
  5804. else
  5805. {
  5806. string name = item.LastName + item.FirstName;
  5807. texts.Add(name);
  5808. }
  5809. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5810. {
  5811. if (!transDic.ContainsKey(item.Job))
  5812. {
  5813. texts.Add(item.Job);
  5814. }
  5815. }
  5816. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5817. {
  5818. texts.Add(item.CompanyFullName);
  5819. }
  5820. }
  5821. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5822. if (transData.Count > 0)
  5823. {
  5824. foreach (TranslateResult item in transData)
  5825. {
  5826. if (!transDic.ContainsKey(item.Query))
  5827. {
  5828. transDic.Add(item.Query, item.Translation);
  5829. }
  5830. }
  5831. }
  5832. List<GuestList> list = new List<GuestList>();
  5833. foreach (TourClientListDetailsView dele in datas)
  5834. {
  5835. GuestList guestList = new GuestList();
  5836. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5837. {
  5838. guestList.Name = dele.Pinyin;
  5839. }
  5840. else
  5841. {
  5842. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5843. guestList.Name = Name;
  5844. }
  5845. if (dele.Sex == 0)
  5846. {
  5847. guestList.Sex = "Male";
  5848. }
  5849. else if (dele.Sex == 1)
  5850. {
  5851. guestList.Sex = "Female";
  5852. }
  5853. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5854. if (!string.IsNullOrEmpty(dele.Job))
  5855. {
  5856. guestList.Job = dele.Job;
  5857. }
  5858. list.Add(guestList);
  5859. }
  5860. //载入模板
  5861. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5862. DocumentBuilder builder = new DocumentBuilder(doc);
  5863. //获取word里所有表格
  5864. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5865. //获取所填表格的序数
  5866. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5867. var rowStart = tableOne.Rows[0]; //获取第1行
  5868. //循环赋值
  5869. for (int i = 0; i < list.Count; i++)
  5870. {
  5871. builder.MoveToCell(0, i + 1, 0, 0);
  5872. builder.Write(list[i].Name.ToString());
  5873. builder.MoveToCell(0, i + 1, 1, 0);
  5874. builder.Write(list[i].Sex.ToString());
  5875. builder.MoveToCell(0, i + 1, 2, 0);
  5876. builder.Write(list[i].DOB.ToString());
  5877. builder.MoveToCell(0, i + 1, 3, 0);
  5878. builder.Write(list[i].Job.ToString());
  5879. }
  5880. //删除多余行
  5881. while (tableOne.Rows.Count > list.Count + 1)
  5882. {
  5883. tableOne.Rows.RemoveAt(list.Count + 1);
  5884. }
  5885. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5886. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5887. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5888. doc.Save(filePath);
  5889. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5890. return Ok(JsonView(true, "操作成功!", Url));
  5891. }
  5892. else
  5893. {
  5894. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5895. }
  5896. }
  5897. catch (Exception ex)
  5898. {
  5899. return Ok(JsonView(false, ex.Message));
  5900. throw;
  5901. }
  5902. }
  5903. #endregion
  5904. #region 团组经理模块 出入境费用
  5905. /// <summary>
  5906. /// 团组模块 - 出入境费用 - 省份基础数据源
  5907. /// </summary>
  5908. /// <returns></returns>
  5909. [HttpGet]
  5910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5911. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5912. {
  5913. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5914. }
  5915. /// <summary>
  5916. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5917. /// </summary>
  5918. /// <returns></returns>
  5919. [HttpPost]
  5920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5921. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5922. {
  5923. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5924. var groupNamFirst = groupNameData.FirstOrDefault();
  5925. //SetDataInfoView
  5926. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5927. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5928. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5929. //验证城市归属并给默认值
  5930. int provinceId = 122;
  5931. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5932. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5933. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5934. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5935. return Ok(JsonView(true, "查询成功!", new
  5936. {
  5937. GroupNameData = groupNameData,
  5938. CurrencyData = _CurrencyData,
  5939. WordTypeData = wordTypeData,
  5940. ExcelTypeData = excelTypeData,
  5941. CurrencyInit = _currencyInfos,
  5942. ViewPermissionData = viewPermissionData
  5943. }));
  5944. }
  5945. /// <summary>
  5946. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5947. /// </summary>
  5948. /// <returns></returns>
  5949. [HttpGet("{provinceId}")]
  5950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5951. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5952. {
  5953. //验证城市归属并给默认值
  5954. if (provinceId < 1) provinceId = 122;
  5955. /*
  5956. * 122 四川
  5957. * 108 贵州
  5958. * 103 重庆
  5959. * 132 云南
  5960. */
  5961. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5962. return Ok(JsonView(true, "查询成功!", new
  5963. {
  5964. WordTypeData = wordTypeData,
  5965. ExcelTypeData = excelTypeData,
  5966. }));
  5967. }
  5968. /// <summary>
  5969. /// 团组模块 - 出入境费用
  5970. /// 实时汇率 tips
  5971. /// 签证费用 tips
  5972. /// 机票费用 tips
  5973. /// </summary>
  5974. /// <returns></returns>
  5975. [HttpPost]
  5976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5977. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5978. {
  5979. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5980. //默认币种显示
  5981. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5982. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5983. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  5984. return Ok(JsonView(true, "查询成功!", new
  5985. {
  5986. //GroupNameData = groupNameData.Data,
  5987. visaData = visaData.Data,
  5988. airData = airData,
  5989. reteInfos = reteInfos
  5990. }));
  5991. }
  5992. /// <summary>
  5993. /// 团组模块 - 出入境费用 - Info
  5994. /// </summary>
  5995. /// <returns></returns>
  5996. [HttpPost]
  5997. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5999. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6000. {
  6001. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6002. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6003. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6004. }
  6005. /// <summary>
  6006. /// 团组模块 - 出入境费用 - 设置view权限
  6007. /// </summary>
  6008. /// <returns></returns>
  6009. [HttpPost]
  6010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6011. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6012. {
  6013. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6014. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6015. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6016. var permissions = new List<Grp_EnterExitCostPermission>();
  6017. foreach (var userId in dto.UserIds)
  6018. {
  6019. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6020. }
  6021. if (permissions.Any())
  6022. {
  6023. _sqlSugar.BeginTran();
  6024. try
  6025. {
  6026. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6027. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6028. if (result < 1)
  6029. {
  6030. _sqlSugar.RollbackTran();
  6031. return Ok(JsonView(false));
  6032. }
  6033. }
  6034. catch (Exception ex)
  6035. {
  6036. _sqlSugar.RollbackTran();
  6037. return Ok(JsonView(false, ex.Message));
  6038. }
  6039. _sqlSugar.CommitTran();
  6040. return Ok(JsonView(true));
  6041. }
  6042. return Ok(JsonView(false));
  6043. }
  6044. /// <summary>
  6045. /// 团组模块 - 出入境费用 - Add And Update
  6046. /// </summary>
  6047. /// <returns></returns>
  6048. [HttpPost]
  6049. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6051. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6052. {
  6053. try
  6054. {
  6055. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6056. if (dto.DayOtherPriceData.Any())
  6057. {
  6058. var inserList = dto.DayOtherPriceData
  6059. .Where(x => x.Id == 0)
  6060. .Select(x => new Grp_DayOtherPrice
  6061. {
  6062. Cost = x.Cost,
  6063. Id = x.Id,
  6064. CreateTime = DateTime.Now,
  6065. CreateUserId = dto.UserId,
  6066. Currency = x.Currency,
  6067. Diid = x.DiId,
  6068. Index = x.Index,
  6069. IsDel = 0,
  6070. SetDataId = x.SetDataId,
  6071. SubTotal = x.SubTotal,
  6072. Remark = x.Remark
  6073. })
  6074. .ToList();
  6075. var updateList = dto.DayOtherPriceData
  6076. .Where(x => x.Id != 0)
  6077. .Select(x => new Grp_DayOtherPrice
  6078. {
  6079. Cost = x.Cost,
  6080. Id = x.Id,
  6081. CreateTime = DateTime.Now,
  6082. CreateUserId = dto.UserId,
  6083. Currency = x.Currency,
  6084. Diid = x.DiId,
  6085. Index = x.Index,
  6086. IsDel = 0,
  6087. SetDataId = x.SetDataId,
  6088. SubTotal = x.SubTotal,
  6089. Remark = x.Remark
  6090. })
  6091. .ToList();
  6092. //添加
  6093. _sqlSugar.BeginTran();
  6094. if (inserList.Any())
  6095. {
  6096. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6097. }
  6098. if (updateList.Any())
  6099. {
  6100. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6101. }
  6102. _sqlSugar.CommitTran();
  6103. }
  6104. if (data.Code != 0)
  6105. {
  6106. return Ok(JsonView(false, data.Msg));
  6107. }
  6108. //生成默认文件pdf并且通知人员
  6109. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6110. {
  6111. DiId = dto.DiId,
  6112. ExportType = 1,
  6113. SubTypeId = 1005
  6114. }, "pdf");
  6115. //发送通知
  6116. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6117. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6118. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6119. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6120. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6121. //汇率信息记录
  6122. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6123. return Ok(JsonView(true, data.Msg, data.Data));
  6124. }
  6125. catch (Exception ex)
  6126. {
  6127. return Ok(JsonView(false, ex.Message));
  6128. }
  6129. }
  6130. /// <summary>
  6131. /// 团组模块 - 出入境费用 - Confirm 费用
  6132. /// </summary>
  6133. /// <returns></returns>
  6134. [HttpPost]
  6135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6136. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6137. {
  6138. //TODO:测试完毕需把对应的用户ID更改
  6139. //1、数据表添加字段
  6140. //2、更改字段接口()
  6141. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6142. //3、确认成功 给财务发送消息
  6143. if (_view.Code == 200)
  6144. {
  6145. if (dto.Type == 1)
  6146. {
  6147. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6148. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6149. }
  6150. }
  6151. return Ok(_view);
  6152. }
  6153. /// <summary>
  6154. /// 团组模块 - 出入境费用 - File download
  6155. /// </summary>
  6156. /// <param name="dto"></param>
  6157. /// <returns></returns>
  6158. [HttpPost]
  6159. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6161. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6162. {
  6163. try
  6164. {
  6165. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6166. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6167. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6168. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6169. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6170. 3 团组成员名单 1 团组成员名单", ""));
  6171. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6172. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6173. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6174. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6175. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6176. //数据源
  6177. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6178. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6179. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6180. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6181. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6182. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6183. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6184. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6185. .Select((x, a, b) => new
  6186. {
  6187. x.Index,
  6188. itemName = a.Name,
  6189. CurrencyStr = b.Name,
  6190. x.Cost,
  6191. x.SubTotal,
  6192. x.Remark
  6193. })
  6194. .OrderBy((x) => x.Index)
  6195. .ToList(); //其他款项费用
  6196. var peiceItemCurrencys = new List<string>();
  6197. if (_DayAndCosts.Any())
  6198. {
  6199. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6200. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6201. }
  6202. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6203. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6204. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6205. {
  6206. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6207. }
  6208. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6209. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6210. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6211. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6212. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6213. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6214. .Select((tcl, dc, cc) => new ClientInfo
  6215. {
  6216. LastName = dc.LastName,
  6217. FirstName = dc.FirstName,
  6218. Sex = dc.Sex,
  6219. Birthday = dc.BirthDay,
  6220. Company = cc.CompanyFullName,
  6221. Job = dc.Job
  6222. })
  6223. .ToList();
  6224. foreach (var item in DeleClientList)
  6225. {
  6226. EncryptionProcessor.DecryptProperties(item);
  6227. }
  6228. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6229. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6230. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6231. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6232. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6233. if (dto.ExportType == 1) //明细表
  6234. {
  6235. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6236. {
  6237. //获取模板
  6238. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6239. //载入模板
  6240. Document doc = new Document(tempPath);
  6241. DocumentBuilder builder = new DocumentBuilder(doc);
  6242. //利用键值对存放数据
  6243. Dictionary<string, string> dic = new Dictionary<string, string>();
  6244. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6245. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6246. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6247. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6248. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6249. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6250. //境内费用(其他费用)
  6251. if (_EnterExitCosts.ChoiceOne == 1)
  6252. {
  6253. string row1_1 = "";
  6254. if (_EnterExitCosts.Visa > 0)
  6255. {
  6256. //insidePayTotal += _EnterExitCosts.Visa;
  6257. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6258. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6259. //{
  6260. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6261. //}
  6262. }
  6263. string row1_2 = "";
  6264. if (_EnterExitCosts.YiMiao > 0)
  6265. {
  6266. //insidePayTotal += _EnterExitCosts.YiMiao;
  6267. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6268. }
  6269. if (_EnterExitCosts.HeSuan > 0)
  6270. {
  6271. //insidePayTotal += _EnterExitCosts.HeSuan;
  6272. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6273. }
  6274. if (_EnterExitCosts.Service > 0)
  6275. {
  6276. //insidePayTotal += _EnterExitCosts.Service;
  6277. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6278. }
  6279. string row1_3 = "";
  6280. if (_EnterExitCosts.Safe > 0)
  6281. {
  6282. //insidePayTotal += _EnterExitCosts.Safe;
  6283. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6284. }
  6285. if (_EnterExitCosts.Ticket > 0)
  6286. {
  6287. //insidePayTotal += _EnterExitCosts.Ticket;
  6288. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6289. }
  6290. string row1 = "";
  6291. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6292. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6293. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6294. row1 += $"备注:{_EnterExitCosts.Remark}";
  6295. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6296. dic.Add("Row1Str", row1);
  6297. }
  6298. string airTotalStr = string.Empty,
  6299. airPriceStr = string.Empty;
  6300. //经济舱
  6301. if (_EnterExitCosts.SumJJC == 1)
  6302. {
  6303. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6304. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6305. }
  6306. //公务舱
  6307. if (_EnterExitCosts.SumGWC == 1)
  6308. {
  6309. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6310. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6311. }
  6312. //头等舱
  6313. if (_EnterExitCosts.SumTDC == 1)
  6314. {
  6315. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6316. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6317. }
  6318. //汇率描述
  6319. string rateStr = "";
  6320. if (peiceItemCurrencyInfos.Any())
  6321. {
  6322. rateStr = "\r\n汇率描述:";
  6323. foreach (var item in peiceItemCurrencyInfos)
  6324. {
  6325. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6326. }
  6327. }
  6328. string twoItemRemark = "备注:";
  6329. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6330. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6331. dic.Add("AirTotalStr", airTotalStr);
  6332. dic.Add("AirPriceStr", airPriceStr);
  6333. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6334. dic.Add("TwoItemRemark", twoItemRemark);
  6335. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6336. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6337. int table1Row = 0,
  6338. table2Row = 0,
  6339. table3Row = 0,
  6340. table4Row = 0,
  6341. table5Row = 0;
  6342. //住宿费
  6343. if (_EnterExitCosts.ChoiceThree == 1)
  6344. {
  6345. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6346. table1Row = dac1.Count;
  6347. #region 填充word表格内容
  6348. for (int i = 0; i < dac1.Count; i++)
  6349. {
  6350. Grp_DayAndCost dac = dac1[i];
  6351. if (dac == null) continue;
  6352. builder.MoveToCell(0, i, 0, 0);
  6353. builder.Write("第" + dac.Days.ToString() + "晚:");
  6354. builder.MoveToCell(0, i, 1, 0);
  6355. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6356. //builder.Write(dac.Place == null ? "" : dac.Place);
  6357. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6358. builder.MoveToCell(0, i, 2, 0);
  6359. builder.Write("费用标准:");
  6360. string curr = "";
  6361. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6362. if (currData != null)
  6363. {
  6364. curr = currData.Name;
  6365. }
  6366. builder.MoveToCell(0, i, 3, 0);
  6367. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6368. builder.MoveToCell(0, i, 4, 0);
  6369. builder.Write("费用小计:");
  6370. builder.MoveToCell(0, i, 5, 0);
  6371. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6372. }
  6373. #endregion
  6374. }
  6375. else dic.Add("SubZS", "0.00");
  6376. //删除多余行
  6377. while (table1.Rows.Count > table1Row)
  6378. {
  6379. table1.Rows.RemoveAt(table1Row);
  6380. }
  6381. //伙食费
  6382. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6383. if (_EnterExitCosts.ChoiceFour == 1)
  6384. {
  6385. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6386. table2Row = dac2.Count;
  6387. #region 填充word表格内容
  6388. for (int i = 0; i < dac2.Count; i++)
  6389. {
  6390. Grp_DayAndCost dac = dac2[i];
  6391. if (dac == null) continue;
  6392. builder.MoveToCell(1, i, 0, 0);
  6393. builder.Write("第" + dac.Days.ToString() + "天:");
  6394. builder.MoveToCell(1, i, 1, 0);
  6395. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6396. builder.MoveToCell(1, i, 2, 0);
  6397. builder.Write("费用标准:");
  6398. string curr = "";
  6399. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6400. if (currData != null)
  6401. {
  6402. curr = currData.Name;
  6403. }
  6404. builder.MoveToCell(1, i, 3, 0);
  6405. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6406. builder.MoveToCell(1, i, 4, 0);
  6407. builder.Write("费用小计:");
  6408. builder.MoveToCell(1, i, 5, 0);
  6409. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6410. }
  6411. #endregion
  6412. }
  6413. else dic.Add("SubHS", "0.00");
  6414. //删除多余行
  6415. while (table2.Rows.Count > table2Row)
  6416. {
  6417. table2.Rows.RemoveAt(table2Row);
  6418. }
  6419. //公杂费
  6420. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6421. if (_EnterExitCosts.ChoiceFive == 1)
  6422. {
  6423. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6424. table3Row = dac3.Count;
  6425. #region 填充word表格内容
  6426. for (int i = 0; i < dac3.Count; i++)
  6427. {
  6428. Grp_DayAndCost dac = dac3[i];
  6429. if (dac == null) continue;
  6430. builder.MoveToCell(2, i, 0, 0);
  6431. builder.Write("第" + dac.Days.ToString() + "天:");
  6432. builder.MoveToCell(2, i, 1, 0);
  6433. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6434. builder.MoveToCell(2, i, 2, 0);
  6435. builder.Write("费用标准:");
  6436. string curr = "";
  6437. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6438. if (currData != null)
  6439. {
  6440. curr = currData.Name;
  6441. }
  6442. builder.MoveToCell(2, i, 3, 0);
  6443. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6444. builder.MoveToCell(2, i, 4, 0);
  6445. builder.Write("费用小计:");
  6446. builder.MoveToCell(2, i, 5, 0);
  6447. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6448. }
  6449. //删除多余行
  6450. while (table3.Rows.Count > table3Row)
  6451. {
  6452. table3.Rows.RemoveAt(table3Row);
  6453. }
  6454. #endregion
  6455. }
  6456. else dic.Add("SubGZF", "0.00");
  6457. //删除多余行
  6458. while (table3.Rows.Count > table3Row)
  6459. {
  6460. table3.Rows.RemoveAt(table3Row);
  6461. }
  6462. //培训费
  6463. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6464. if (_EnterExitCosts.ChoiceSix == 1)
  6465. {
  6466. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6467. dic.Add("SubPX", pxStr);
  6468. table4Row = dac4.Count;
  6469. #region 填充word表格内容
  6470. for (int i = 0; i < dac4.Count; i++)
  6471. {
  6472. Grp_DayAndCost dac = dac4[i];
  6473. if (dac == null) continue;
  6474. builder.MoveToCell(3, i, 0, 0);
  6475. builder.Write("第" + dac.Days.ToString() + "天:");
  6476. builder.MoveToCell(3, i, 1, 0);
  6477. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6478. builder.MoveToCell(3, i, 2, 0);
  6479. builder.Write("费用标准:");
  6480. string curr = "";
  6481. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6482. if (currData != null)
  6483. {
  6484. curr = currData.Name;
  6485. }
  6486. builder.MoveToCell(3, i, 3, 0);
  6487. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6488. builder.MoveToCell(3, i, 4, 0);
  6489. builder.Write("费用小计:");
  6490. builder.MoveToCell(3, i, 5, 0);
  6491. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6492. }
  6493. #endregion
  6494. }
  6495. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6496. //删除多余行
  6497. while (table4.Rows.Count > table4Row)
  6498. {
  6499. table4.Rows.RemoveAt(table4Row);
  6500. }
  6501. //其他费用
  6502. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6503. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6504. {
  6505. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6506. dic.Add("titleQi", qtStr);
  6507. table5Row = dac5.Count;
  6508. #region 填充word表格内容
  6509. for (int i = 0; i < dac5.Count; i++)
  6510. {
  6511. var dac = dac5[i];
  6512. if (dac == null) continue;
  6513. builder.MoveToCell(4, i, 0, 0);
  6514. builder.Write("第" + dac.Index.ToString() + "项:");
  6515. builder.MoveToCell(4, i, 1, 0);
  6516. builder.Write(dac.itemName);
  6517. builder.MoveToCell(4, i, 2, 0);
  6518. builder.Write("费用标准:");
  6519. builder.MoveToCell(4, i, 3, 0);
  6520. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6521. builder.MoveToCell(4, i, 4, 0);
  6522. builder.Write("费用小计:");
  6523. builder.MoveToCell(4, i, 5, 0);
  6524. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6525. builder.MoveToCell(4, i, 6, 0);
  6526. builder.Write("备注:");
  6527. builder.MoveToCell(4, i, 7, 0);
  6528. builder.Write(dac.Remark);
  6529. }
  6530. #endregion
  6531. }
  6532. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6533. //删除多余行
  6534. while (table5.Rows.Count > table5Row)
  6535. {
  6536. table5.Rows.RemoveAt(table5Row);
  6537. }
  6538. //加上其他费用
  6539. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6540. decimal subJJC = 0.00M,
  6541. subGWC = 0.00M,
  6542. subTDC = 0.00M;
  6543. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6544. string totalLabel = string.Format("全部费用总计:");
  6545. //经济舱
  6546. if (_EnterExitCosts.SumJJC == 1)
  6547. {
  6548. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6549. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6550. }
  6551. //公务舱
  6552. if (_EnterExitCosts.SumGWC == 1)
  6553. {
  6554. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6555. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6556. }
  6557. //头等舱
  6558. if (_EnterExitCosts.SumTDC == 1)
  6559. {
  6560. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6561. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6562. }
  6563. //TotalLabel
  6564. dic.Add("TotalLabel", totalLabel);
  6565. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6566. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6567. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6568. #region 填充word模板书签内容
  6569. foreach (var key in dic.Keys)
  6570. {
  6571. Bookmark bookmark = doc.Range.Bookmarks[key];
  6572. if (bookmark != null)
  6573. {
  6574. builder.MoveToBookmark(key);
  6575. builder.Write(dic[key]);
  6576. }
  6577. }
  6578. #endregion
  6579. #region 设置页眉
  6580. string userLabel = string.Empty;
  6581. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6582. if (currUserInfo != null)
  6583. {
  6584. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6585. if (userInfo != null)
  6586. {
  6587. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6588. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6589. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6590. }
  6591. }
  6592. //设置页脚
  6593. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6594. #endregion
  6595. //文件名
  6596. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6597. AsposeHelper.removewatermark_v2180();
  6598. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6599. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6600. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6601. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6602. }
  6603. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6604. {
  6605. //获取模板
  6606. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6607. //载入模板
  6608. Document doc = new Document(tempPath);
  6609. DocumentBuilder builder = new DocumentBuilder(doc);
  6610. Dictionary<string, string> dic = new Dictionary<string, string>();
  6611. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6612. {
  6613. List<string> list = new List<string>();
  6614. try
  6615. {
  6616. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6617. foreach (var item in spilitArr)
  6618. {
  6619. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6620. var depCode = spDotandEmpty[2].Substring(0, 3);
  6621. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6622. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6623. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6624. list.Add(depName);
  6625. list.Add(arrName);
  6626. }
  6627. list = list.Distinct().ToList();
  6628. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6629. }
  6630. catch (Exception)
  6631. {
  6632. dic.Add("ReturnCode", "行程录入不正确!");
  6633. }
  6634. }
  6635. else
  6636. {
  6637. dic.Add("ReturnCode", "未录入行程!");
  6638. }
  6639. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6640. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6641. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6642. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6643. {
  6644. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6645. dic.Add("Day", sp.Days.ToString());
  6646. }
  6647. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6648. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6649. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6650. //dic.Add("Names", Names);
  6651. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6652. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6653. decimal dac1totalPrice = 0.00M;
  6654. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6655. foreach (var dac in dac1)
  6656. {
  6657. if (dac.SubTotal == 0.00M)
  6658. {
  6659. continue;
  6660. }
  6661. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6662. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6663. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6664. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6665. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6666. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6667. builder.Write(currency);//币种
  6668. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6669. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6670. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6671. builder.Write("");//人数
  6672. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6673. builder.Write("");//天数
  6674. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6675. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6676. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6677. decimal rate = 0.00M;
  6678. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6679. builder.Write(rate.ToString("#0.0000"));//汇率
  6680. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6681. decimal rbmPrice = dac.SubTotal;
  6682. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6683. accommodationStartIndex++;
  6684. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6685. }
  6686. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6687. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6688. {
  6689. table1.Rows.RemoveAt(i - 1);
  6690. foodandotherStartIndex--;
  6691. }
  6692. if (dac2.Count == dac3.Count)//国家 币种 金额
  6693. {
  6694. for (int i = 0; i < dac2.Count; i++)
  6695. {
  6696. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6697. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6698. }
  6699. }
  6700. decimal dac2totalPrice = 0.00M;
  6701. foreach (var dac in dac2)
  6702. {
  6703. if (dac.SubTotal == 0)
  6704. {
  6705. continue;
  6706. }
  6707. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6708. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6709. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6710. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6711. builder.Write(currency);//币种
  6712. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6713. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6714. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6715. builder.Write("");//人数
  6716. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6717. builder.Write("");//天数
  6718. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6719. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6720. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6721. decimal rate = 0.00M;
  6722. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6723. builder.Write(rate.ToString("#0.0000"));//汇率
  6724. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6725. decimal rbmPrice = dac.SubTotal;
  6726. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6727. foodandotherStartIndex++;
  6728. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6729. }
  6730. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6731. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6732. {
  6733. table1.Rows.RemoveAt(i - 1);
  6734. }
  6735. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6736. string otherFeeStr = "";
  6737. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6738. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6739. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6740. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6741. foreach (var otherInfo in dac5)
  6742. {
  6743. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6744. }
  6745. #endregion
  6746. if (otherFeeStr.Length > 0)
  6747. {
  6748. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6749. otherFeeStr = $"({otherFeeStr})";
  6750. dic.Add("OtherFeeStr", otherFeeStr);
  6751. }
  6752. //总计
  6753. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6754. //国际旅费
  6755. string outsideAir = string.Empty;
  6756. string allPriceAir = string.Empty;
  6757. if (_EnterExitCosts.SumJJC == 1)
  6758. {
  6759. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6760. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6761. }
  6762. if (_EnterExitCosts.SumGWC == 1)
  6763. {
  6764. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6765. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6766. }
  6767. if (_EnterExitCosts.SumTDC == 1)
  6768. {
  6769. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6770. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6771. }
  6772. dic.Add("InTravelPrice", $"({outsideAir})");
  6773. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6774. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6775. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6776. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6777. foreach (var key in dic.Keys)
  6778. {
  6779. builder.MoveToBookmark(key);
  6780. builder.Write(dic[key]);
  6781. }
  6782. //模板文件名
  6783. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6784. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6785. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6786. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6787. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6788. }
  6789. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6790. {
  6791. //获取模板
  6792. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6793. //载入模板
  6794. WorkbookDesigner designer = new WorkbookDesigner();
  6795. designer.Workbook = new Workbook(tempPath);
  6796. Dictionary<string, string> dic = new Dictionary<string, string>();
  6797. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6798. {
  6799. List<string> list = new List<string>();
  6800. try
  6801. {
  6802. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6803. foreach (var item in spilitArr)
  6804. {
  6805. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6806. var depCode = spDotandEmpty[2].Substring(0, 3);
  6807. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6808. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6809. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6810. list.Add(depName);
  6811. list.Add(arrName);
  6812. }
  6813. list = list.Distinct().ToList();
  6814. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6815. }
  6816. catch (Exception)
  6817. {
  6818. dic.Add("ReturnCode", "行程录入不正确!");
  6819. }
  6820. }
  6821. else
  6822. {
  6823. dic.Add("ReturnCode", "未录入行程!");
  6824. }
  6825. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6826. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6827. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6828. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6829. {
  6830. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6831. dic.Add("Day", sp.Days.ToString());
  6832. }
  6833. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6834. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6835. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6836. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6837. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6838. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6839. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6840. designer.SetDataSource("Name", Names);
  6841. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6842. designer.SetDataSource("Day", dic["Day"] + "天");
  6843. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6844. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6845. int startIndex = 10;
  6846. const int startIndexcopy = 10;
  6847. if (dac2.Count == dac3.Count)//国家 币种 金额
  6848. {
  6849. for (int i = 0; i < dac2.Count; i++)
  6850. {
  6851. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6852. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6853. }
  6854. }
  6855. DataTable dtdac1 = new DataTable();
  6856. List<string> place = new List<string>();
  6857. dtdac1.Columns.AddRange(new DataColumn[] {
  6858. new DataColumn(){ ColumnName = "city"},
  6859. new DataColumn(){ ColumnName = "curr"},
  6860. new DataColumn(){ ColumnName = "criterion"},
  6861. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6862. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6863. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6864. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6865. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6866. });
  6867. DataTable dtdac2 = new DataTable();
  6868. dtdac2.Columns.AddRange(new DataColumn[] {
  6869. new DataColumn(){ ColumnName = "city"},
  6870. new DataColumn(){ ColumnName = "curr"},
  6871. new DataColumn(){ ColumnName = "criterion"},
  6872. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6873. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6874. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6875. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6876. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6877. });
  6878. dtdac1.TableName = "tb1";
  6879. dtdac2.TableName = "tb2";
  6880. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6881. foreach (var item in dac1)
  6882. {
  6883. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6884. if (place.Contains(item.Place))
  6885. {
  6886. continue;
  6887. }
  6888. DataRow row = dtdac1.NewRow();
  6889. row["city"] = item.Place;
  6890. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6891. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6892. row["curr"] = currency;
  6893. row["rate"] = rate.ToString("#0.0000");
  6894. row["criterion"] = item.Cost.ToString("#0.00");
  6895. row["number"] = 1;
  6896. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6897. //row["costRMB"] = rbmPrice;
  6898. dtdac1.Rows.Add(row);
  6899. place.Add(item.Place);
  6900. }
  6901. place = new List<string>();
  6902. foreach (var item in dac2)
  6903. {
  6904. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6905. if (place.Contains(item.Place))
  6906. {
  6907. continue;
  6908. }
  6909. DataRow row = dtdac2.NewRow();
  6910. row["city"] = item.Place;
  6911. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6912. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6913. row["curr"] = currency;
  6914. row["rate"] = rate.ToString("#0.0000");
  6915. row["criterion"] = item.Cost.ToString("#0.00");
  6916. row["number"] = 1;
  6917. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6918. //row["cost"] = item.SubTotal;
  6919. //row["costRMB"] = rbmPrice;
  6920. dtdac2.Rows.Add(row);
  6921. place.Add(item.Place);
  6922. //dac2totalPrice += rbmPrice;
  6923. }
  6924. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6925. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6926. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6927. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6928. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6929. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6930. string cell4Str1 = string.Empty;
  6931. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6932. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6933. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6934. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6935. string cellStr = $" 5.其他费用(";
  6936. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6937. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6938. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6939. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6940. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6941. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6942. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6943. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6944. foreach (var otherInfo in dac5)
  6945. {
  6946. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6947. }
  6948. #endregion
  6949. if (cellStr.Length > 8)
  6950. {
  6951. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6952. }
  6953. cellStr += ")";
  6954. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6955. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6956. decimal pxFee = dac4.Sum(it => it.Cost);
  6957. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6958. string celllastStr1 = "";
  6959. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6960. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6961. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6962. celllastStr1 += $",国际旅费 元";
  6963. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6964. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6965. designer.SetDataSource("cell4Str", cell4Str);
  6966. designer.SetDataSource("cellStr", cellStr);
  6967. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6968. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6969. designer.SetDataSource("celllastStr", celllastStr);
  6970. Workbook wb = designer.Workbook;
  6971. var sheet = wb.Worksheets[0];
  6972. //绑定datatable数据集
  6973. designer.SetDataSource(dtdac1);
  6974. designer.SetDataSource(dtdac2);
  6975. designer.Process();
  6976. var rowStart = dtdac1.Rows.Count;
  6977. while (rowStart > 0)
  6978. {
  6979. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6980. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6981. startIndex++;
  6982. rowStart--;
  6983. }
  6984. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6985. startIndex += 1; //总计行
  6986. rowStart = dtdac2.Rows.Count;
  6987. while (rowStart > 0)
  6988. {
  6989. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6990. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6991. startIndex++;
  6992. rowStart--;
  6993. }
  6994. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6995. wb.CalculateFormula(true);
  6996. //模板文件名
  6997. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6998. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6999. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7000. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7001. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7002. }
  7003. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7004. {
  7005. //获取模板
  7006. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7007. //载入模板
  7008. Document doc = new Document(tempPath);
  7009. DocumentBuilder builder = new DocumentBuilder(doc);
  7010. Dictionary<string, string> dic = new Dictionary<string, string>();
  7011. dic.Add("GroupName", _DelegationInfo.TeamName);
  7012. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7013. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7014. string missionLeaderJob = "";//负责人job
  7015. //int groupNumber = 0; //团人数
  7016. if (DeleClientList.Count > 0)
  7017. {
  7018. missionLeader = DeleClientList[0]?.Name ?? "";
  7019. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7020. }
  7021. dic.Add("MissionLeader", missionLeader); //团负责人
  7022. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7023. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7024. #region MyRegion
  7025. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7026. //{
  7027. // List<string> list = new List<string>();
  7028. // try
  7029. // {
  7030. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7031. // foreach (var item in spilitArr)
  7032. // {
  7033. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7034. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7035. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7036. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7037. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7038. // list.Add(depName);
  7039. // list.Add(arrName);
  7040. // }
  7041. // list = list.Distinct().ToList();
  7042. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7043. // }
  7044. // catch (Exception)
  7045. // {
  7046. // dic.Add("ReturnCode", "行程录入不正确!");
  7047. // }
  7048. //}
  7049. //else
  7050. //{
  7051. // dic.Add("ReturnCode", "未录入行程!");
  7052. //}
  7053. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7054. dic.Add("ReturnCode", string.Join("、", countrys));
  7055. #endregion
  7056. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7057. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7058. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7059. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7060. //{
  7061. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7062. // dic.Add("Day", sp.Days.ToString());
  7063. //}
  7064. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7065. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7066. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7067. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7068. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7069. //培训人员名单
  7070. int cultivateRowIndex = 7;
  7071. foreach (var item in DeleClientList)
  7072. {
  7073. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7074. builder.Write(item.Name);
  7075. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7076. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7077. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7078. string birthDay = "";
  7079. if (item.Birthday != null)
  7080. {
  7081. DateTime dt = Convert.ToDateTime(item.Birthday);
  7082. birthDay = $"{dt.Year}.{dt.Month}";
  7083. }
  7084. builder.Write(birthDay);
  7085. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7086. builder.Write(item.Company);
  7087. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7088. builder.Write(item.Job);
  7089. cultivateRowIndex++;
  7090. }
  7091. //删除多余行
  7092. //cultivateRowIndex -= 2;
  7093. int delRows = 10 + 7 - cultivateRowIndex;
  7094. if (delRows > 0)
  7095. {
  7096. for (int i = 0; i < delRows; i++)
  7097. {
  7098. table1.Rows.RemoveAt(cultivateRowIndex);
  7099. //cultivateRowIndex++;
  7100. }
  7101. }
  7102. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7103. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7104. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7105. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7106. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7107. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7108. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7109. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7110. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7111. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7112. //其他费用
  7113. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7114. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7115. //其他费用合计
  7116. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7117. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7118. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7119. //公务舱合计
  7120. //国际旅费
  7121. //string outsideJJ = "";
  7122. //string allPriceJJ = "";
  7123. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7124. {
  7125. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7126. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7127. }
  7128. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7129. {
  7130. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7131. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7132. }
  7133. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7134. {
  7135. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7136. dic.Add("AirFeeTotal", airFeeTotalStr);
  7137. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7138. dic.Add("FeeTotal", feeTotalStr);
  7139. }
  7140. foreach (var key in dic.Keys)
  7141. {
  7142. builder.MoveToBookmark(key);
  7143. builder.Write(dic[key]);
  7144. }
  7145. //模板文件名
  7146. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7147. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7148. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7149. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7150. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7151. }
  7152. }
  7153. else if (dto.ExportType == 2) //表格
  7154. {
  7155. //利用键值对存放数据
  7156. Dictionary<string, string> dic = new Dictionary<string, string>();
  7157. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7158. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7159. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7160. dic.Add("Day", sp.Days.ToString());
  7161. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7162. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7163. {
  7164. //获取模板
  7165. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7166. //载入模板
  7167. Document doc = new Document(tempPath);
  7168. DocumentBuilder builder = new DocumentBuilder(doc);
  7169. dic.Add("TeamName", _DelegationInfo.TeamName);
  7170. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7171. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7172. string missionLeaderName = "",
  7173. missionLeaderJob = "";
  7174. if (DeleClientList.Count > 0)
  7175. {
  7176. missionLeaderName = DeleClientList[0].Name;
  7177. missionLeaderJob = DeleClientList[0].Job;
  7178. }
  7179. dic.Add("MissionLeaderName", missionLeaderName);
  7180. dic.Add("MissionLeaderJob", missionLeaderJob);
  7181. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7182. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7183. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7184. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7185. int rowCount = 10;//总人数行
  7186. int startRowIndex = 7; //起始行
  7187. for (int i = 0; i < DeleClientList.Count; i++)
  7188. {
  7189. builder.MoveToCell(0, startRowIndex, 0, 0);
  7190. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7191. builder.MoveToCell(0, startRowIndex, 1, 0);
  7192. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7193. builder.Write(sex);//性别
  7194. builder.MoveToCell(0, startRowIndex, 2, 0);
  7195. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7196. builder.MoveToCell(0, startRowIndex, 3, 0);
  7197. builder.Write(DeleClientList[i].Company);//工作单位
  7198. builder.MoveToCell(0, startRowIndex, 4, 0);
  7199. builder.Write(DeleClientList[i].Job);//职务及级别
  7200. builder.MoveToCell(0, startRowIndex, 5, 0);
  7201. builder.Write("");//人员属性
  7202. builder.MoveToCell(0, startRowIndex, 6, 0);
  7203. builder.Write("");//上次出国时间
  7204. startRowIndex++;
  7205. }
  7206. int nullRow = rowCount - DeleClientList.Count;//空行
  7207. for (int i = 0; i < nullRow; i++)
  7208. {
  7209. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7210. }
  7211. foreach (var key in dic.Keys)
  7212. {
  7213. builder.MoveToBookmark(key);
  7214. builder.Write(dic[key]);
  7215. }
  7216. //模板文件名
  7217. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7218. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7219. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7220. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7221. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7222. }
  7223. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7224. {
  7225. //获取模板
  7226. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7227. //载入模板
  7228. Document doc = new Document(tempPath);
  7229. DocumentBuilder builder = new DocumentBuilder(doc);
  7230. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7231. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7232. dic.Add("Names", Names);
  7233. int accommodationRows = 12;
  7234. //int foodandotherRows = 12;
  7235. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7236. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7237. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7238. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7239. int accommodationStartIndex = 6;
  7240. decimal dac1totalPrice = 0.00M;
  7241. foreach (var dac in dac1)
  7242. {
  7243. if (dac.SubTotal == 0)
  7244. {
  7245. continue;
  7246. }
  7247. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7248. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7249. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7250. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7251. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7252. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7253. builder.Write(currency);//币种
  7254. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7255. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7256. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7257. builder.Write("");//人数
  7258. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7259. builder.Write("");//天数
  7260. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7261. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7262. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7263. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7264. builder.Write(rate.ToString("#0.0000"));//汇率
  7265. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7266. decimal rbmPrice = rate * dac.SubTotal;
  7267. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7268. accommodationStartIndex++;
  7269. dac1totalPrice += rbmPrice;
  7270. }
  7271. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7272. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7273. builder.Write("小计");
  7274. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7275. builder.Write(dac1totalPrice.ToString("#0.00"));
  7276. accommodationStartIndex++;
  7277. int nullRow = accommodationRows - dac1.Count;
  7278. //删除空行
  7279. //if (nullRow > 0)
  7280. //{
  7281. // int rowIndex = accommodationStartIndex;
  7282. // for (int i = 0; i < nullRow; i++)
  7283. // {
  7284. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7285. // row.Remove();
  7286. // rowIndex++;
  7287. // }
  7288. //}
  7289. if (dac2.Count == dac3.Count)//国家 币种 金额
  7290. {
  7291. for (int i = 0; i < dac2.Count; i++)
  7292. {
  7293. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7294. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7295. }
  7296. }
  7297. int foodandotherStartIndex = 19;//
  7298. decimal dac2totalPrice = 0.00M;
  7299. foreach (var dac in dac2)
  7300. {
  7301. if (dac.SubTotal == 0)
  7302. {
  7303. continue;
  7304. }
  7305. //foodandotherStartIndex = 12;
  7306. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7307. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7308. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7309. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7310. builder.Write(currency);//币种
  7311. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7312. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7313. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7314. builder.Write("");//人数
  7315. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7316. builder.Write("");//天数
  7317. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7318. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7319. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7320. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7321. builder.Write(rate.ToString("#0.0000"));//汇率
  7322. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7323. decimal rbmPrice = rate * dac.SubTotal;
  7324. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7325. foodandotherStartIndex++;
  7326. dac2totalPrice += rbmPrice;
  7327. }
  7328. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7329. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7330. //删除空行
  7331. //if (dac2.Count < foodandotherRows)
  7332. //{
  7333. // while (table2.Rows.Count > dac2.Count)
  7334. // {
  7335. // table2.Rows.RemoveAt(dac2.Count);
  7336. // }
  7337. //}
  7338. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7339. string otherFeeStr = "";
  7340. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7341. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7342. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7343. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7344. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7345. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7346. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7347. foreach (var otherInfo in dac5)
  7348. {
  7349. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7350. }
  7351. #endregion
  7352. if (otherFeeStr.Length > 0)
  7353. {
  7354. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7355. otherFeeStr = $"({otherFeeStr})";
  7356. dic.Add("OtherFeeStr", otherFeeStr);
  7357. }
  7358. foreach (var key in dic.Keys)
  7359. {
  7360. builder.MoveToBookmark(key);
  7361. builder.Write(dic[key]);
  7362. }
  7363. //模板文件名
  7364. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7365. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7366. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7367. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7368. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7369. }
  7370. }
  7371. else if (dto.ExportType == 3)
  7372. {
  7373. if (dto.SubTypeId == 1) //团组成员名单
  7374. {
  7375. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7376. //获取模板
  7377. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7378. //载入模板
  7379. Document doc = new Document(tempPath);
  7380. DocumentBuilder builder = new DocumentBuilder(doc);
  7381. //获取word里所有表格
  7382. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7383. //获取所填表格的序数
  7384. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7385. var rowStart = tableOne.Rows[0]; //获取第1行
  7386. //循环赋值
  7387. for (int i = 0; i < DeleClientList.Count; i++)
  7388. {
  7389. builder.MoveToCell(0, i + 1, 0, 0);
  7390. builder.Write(DeleClientList[i].Name);
  7391. builder.MoveToCell(0, i + 1, 1, 0);
  7392. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7393. builder.Write(sex);
  7394. builder.MoveToCell(0, i + 1, 2, 0);
  7395. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7396. builder.MoveToCell(0, i + 1, 3, 0);
  7397. builder.Write(DeleClientList[i].Company);
  7398. builder.MoveToCell(0, i + 1, 4, 0);
  7399. builder.Write(DeleClientList[i].Job);
  7400. }
  7401. //删除多余行
  7402. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7403. {
  7404. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7405. }
  7406. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7407. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7408. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7409. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7410. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7411. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7412. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7413. }
  7414. }
  7415. return Ok(JsonView(400, "操作失败!", ""));
  7416. }
  7417. catch (Exception ex)
  7418. {
  7419. return Ok(JsonView(400, ex.Message, ""));
  7420. }
  7421. }
  7422. /// <summary>
  7423. /// 获取三公费用标准city
  7424. /// </summary>
  7425. /// <param name="placeData"></param>
  7426. /// <param name="nationalTravelFeeId"></param>
  7427. /// <returns></returns>
  7428. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7429. {
  7430. string _city = string.Empty;
  7431. if (placeData.Count < 1) return _city;
  7432. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7433. if (data == null) return _city;
  7434. string country = data.Country;
  7435. string city = data.City;
  7436. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7437. else _city = city;
  7438. return _city;
  7439. }
  7440. ///// <summary>
  7441. ///// 团组模块 - 出入境费用 - 明细表导出
  7442. ///// </summary>
  7443. ///// <returns></returns>
  7444. //[HttpPost]
  7445. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7446. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7447. //{
  7448. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7449. // if (data.Code != 0)
  7450. // {
  7451. // return Ok(JsonView(false, data.Msg));
  7452. // }
  7453. // return Ok(JsonView(true, data.Msg, data.Data));
  7454. //}
  7455. /// <summary>
  7456. /// 团组模块 - 出入境费用 - 一键清空
  7457. /// </summary>
  7458. /// <returns></returns>
  7459. [HttpPost]
  7460. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7462. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7463. {
  7464. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7465. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7466. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7467. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7468. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7469. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7470. .SetColumns(x => new Grp_DayOtherPrice
  7471. {
  7472. IsDel = 1,
  7473. DeleteUserId = dto.UserId,
  7474. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7475. })
  7476. .ExecuteCommandAsync();
  7477. if (_view.Code == 0)
  7478. {
  7479. return Ok(JsonView(true, "操作成功"));
  7480. }
  7481. return Ok(JsonView(false, "操作失败"));
  7482. }
  7483. /// <summary>
  7484. /// 团组模块 - 出入境费用 - 子项删除
  7485. /// </summary>
  7486. /// <returns></returns>
  7487. [HttpPost]
  7488. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7490. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7491. {
  7492. try
  7493. {
  7494. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7495. if (data.Code != 0)
  7496. {
  7497. return Ok(JsonView(false, data.Msg));
  7498. }
  7499. return Ok(JsonView(true, "操作成功!", data.Data));
  7500. }
  7501. catch (Exception ex)
  7502. {
  7503. return Ok(JsonView(false, ex.Message));
  7504. }
  7505. }
  7506. /// <summary>
  7507. /// 删除三公其他费用
  7508. /// </summary>
  7509. /// <param name="dto"></param>
  7510. /// <returns></returns>
  7511. [HttpPost]
  7512. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7513. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7514. {
  7515. var jw = JsonView(false, "删除失败!");
  7516. var data = new Grp_DayOtherPrice()
  7517. {
  7518. Id = dto.Id,
  7519. IsDel = 1,
  7520. DeleteUserId = dto.DeleteUserId,
  7521. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7522. };
  7523. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7524. if (del > 0)
  7525. {
  7526. jw.Code = 200;
  7527. jw.Msg = "删除成功!";
  7528. }
  7529. return Ok(jw);
  7530. }
  7531. /// <summary>
  7532. /// 团组模块 - 出入境国家费用标准 List
  7533. /// </summary>
  7534. /// <returns></returns>
  7535. [HttpPost]
  7536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7537. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7538. {
  7539. int provinceId = dto.ProvinceId;
  7540. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7541. var nftData = await _sqlSugar
  7542. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7543. JoinType.Left, ntf.Currency == sd1.Id,
  7544. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7545. JoinType.Left, ntf.ProvinceId == c.Id
  7546. ))
  7547. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7548. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7549. {
  7550. Id = ntf.Id,
  7551. ProvinceId = ntf.ProvinceId,
  7552. ProvinceName = c.Name_CN,
  7553. Continent = ntf.Continent,
  7554. Country = ntf.Country,
  7555. City = ntf.City,
  7556. Currency = ntf.Currency,
  7557. CurrencyCode = sd1.Name,
  7558. CurrencyName = sd1.Remark,
  7559. RoomCost = ntf.RoomCost,
  7560. FoodCost = ntf.FoodCost,
  7561. PublicCost = ntf.PublicCost,
  7562. LastUpdateUserId = ntf.LastUpdateUserId,
  7563. LastUpdateUserName = u.CnName,
  7564. LastUpdateTime = ntf.LastUpdateTime
  7565. })
  7566. .ToListAsync();
  7567. return Ok(JsonView(true, "查询成功!", nftData));
  7568. }
  7569. /// <summary>
  7570. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7571. /// </summary>
  7572. /// <returns></returns>
  7573. [HttpPost]
  7574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7575. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7576. {
  7577. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7578. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7579. List<string> countryData = new List<string>();
  7580. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7581. countryData = countryData.Distinct().ToList();
  7582. List<dynamic> dataSource = new List<dynamic>();
  7583. foreach (var item in countryData)
  7584. {
  7585. var cityData1 = new List<string>();
  7586. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7587. var countryData2 = new
  7588. {
  7589. CountryName = item,
  7590. CityData = cityData1
  7591. };
  7592. if (!dataSource.Contains(countryData2))
  7593. {
  7594. dataSource.Add(countryData2);
  7595. }
  7596. }
  7597. return Ok(JsonView(true, "查询成功!", dataSource));
  7598. }
  7599. /// <summary>
  7600. /// 团组模块 - 出入境国家费用标准 Page List
  7601. /// </summary>
  7602. /// <returns></returns>
  7603. [HttpPost]
  7604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7605. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7606. {
  7607. int portId = dto.PortType,
  7608. pageIndex = dto.PageIndex,
  7609. pageSize = dto.PageSize;
  7610. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7611. if (pageIndex == 0) pageIndex = 1;
  7612. if (pageSize == 0) pageSize = 10;
  7613. RefAsync<int> total = 0;
  7614. var nationalTravelFeeData = await _sqlSugar
  7615. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7616. JoinType.Left, ntf.Currency == sd1.Id,
  7617. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7618. JoinType.Left, ntf.ProvinceId == sd2.Id
  7619. ))
  7620. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7621. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7622. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7623. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7624. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7625. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7626. {
  7627. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7628. Id = ntf.Id,
  7629. ProvinceId = ntf.ProvinceId,
  7630. ProvinceName = sd2.Name_CN,
  7631. Continent = ntf.Continent,
  7632. Country = ntf.Country,
  7633. City = ntf.City,
  7634. Currency = ntf.Currency,
  7635. CurrencyCode = sd1.Name,
  7636. CurrencyName = sd1.Remark,
  7637. RoomCost = ntf.RoomCost,
  7638. FoodCost = ntf.FoodCost,
  7639. PublicCost = ntf.PublicCost,
  7640. LastUpdateUserId = ntf.LastUpdateUserId,
  7641. LastUpdateUserName = u.CnName,
  7642. LastUpdateTime = ntf.LastUpdateTime,
  7643. Remark = ntf.Remark
  7644. })
  7645. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7646. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7647. }
  7648. /// <summary>
  7649. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7650. /// </summary>
  7651. /// <returns></returns>
  7652. [HttpPost]
  7653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7654. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7655. {
  7656. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7657. int portId = dto.PortType;
  7658. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7659. string whereSql = string.Empty;
  7660. if (!string.IsNullOrEmpty(dto.Country))
  7661. {
  7662. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7663. }
  7664. if (!string.IsNullOrEmpty(dto.City))
  7665. {
  7666. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7667. }
  7668. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7669. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7670. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7671. From Grp_NationalTravelFee gntf
  7672. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7673. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7674. Where gntf.Isdel = 0 {0} ", whereSql);
  7675. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7676. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7677. }
  7678. /// <summary>
  7679. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7680. /// </summary>
  7681. /// <returns></returns>
  7682. [HttpPost]
  7683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7684. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7685. {
  7686. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7687. }
  7688. /// <summary>
  7689. /// 团组模块 - 出入境国家费用标准 - Del
  7690. /// </summary>
  7691. /// <returns></returns>
  7692. [HttpPost]
  7693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7694. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7695. {
  7696. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7697. {
  7698. Id = dto.Id,
  7699. DeleteUserId = dto.DeleteUserId,
  7700. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7701. IsDel = 1
  7702. };
  7703. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7704. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7705. .WhereColumns(it => new { it.Id })
  7706. .ExecuteCommandAsync();
  7707. if (delStatus <= 0)
  7708. {
  7709. return Ok(JsonView(false, "删除失败!"));
  7710. }
  7711. return Ok(JsonView(true, "操作成功!"));
  7712. }
  7713. /// <summary>
  7714. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7715. /// 注:Get 请求Headers 加 Token
  7716. /// </summary>
  7717. /// <param name="groupId"></param>
  7718. /// <returns></returns>
  7719. [HttpGet("{groupId}")]
  7720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7721. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7722. {
  7723. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7724. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7725. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7726. data.ForEach(x =>
  7727. {
  7728. x.CreateUserId = _currUserInfo.UserId;
  7729. });
  7730. if (data.Any())
  7731. {
  7732. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7733. if (add > 0)
  7734. {
  7735. return Ok(JsonView(true, "操作成功!"));
  7736. }
  7737. }
  7738. return Ok(JsonView(false, "未操作!"));
  7739. }
  7740. #endregion
  7741. #region 团组经理模块 出入境费用-草稿
  7742. /// <summary>
  7743. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7744. /// </summary>
  7745. /// <returns></returns>
  7746. [HttpGet]
  7747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7748. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7749. {
  7750. var provData = await _groupRepository.ProvinceBasicSource();
  7751. return Ok(JsonView(true, "查询成功!", provData));
  7752. }
  7753. /// <summary>
  7754. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7755. /// </summary>
  7756. /// <returns></returns>
  7757. [HttpGet("{provinceId}")]
  7758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7759. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7760. {
  7761. //验证城市归属并给默认值
  7762. if (provinceId < 1) provinceId = 122;
  7763. /*
  7764. * 122 四川
  7765. * 108 贵州
  7766. * 103 重庆
  7767. * 132 云南
  7768. */
  7769. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7770. return Ok(JsonView(true, "查询成功!", new
  7771. {
  7772. WordTypeData = wordTypeData,
  7773. ExcelTypeData = excelTypeData,
  7774. }));
  7775. }
  7776. /// <summary>
  7777. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7778. /// </summary>
  7779. /// <returns></returns>
  7780. [HttpPost]
  7781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7782. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7783. {
  7784. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7785. .Where(x => x.IsDel == 0)
  7786. .OrderByDescending(x => x.CreateTime)
  7787. .Select(x => new { x.Id, x.DraftName })
  7788. .ToListAsync();
  7789. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7790. //SetDataInfoView
  7791. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7792. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7793. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7794. int provinceId = dto.ProvinceId;
  7795. if (provinceId < 1) provinceId = 122;
  7796. /*
  7797. * 122 四川
  7798. * 108 贵州
  7799. * 103 重庆
  7800. * 132 云南
  7801. */
  7802. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7803. //默认币种显示
  7804. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7805. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7806. return Ok(JsonView(true, "查询成功!", new
  7807. {
  7808. DraftNameDatas = draftNameDatas,
  7809. CurrencyData = _CurrencyData,
  7810. WordTypeData = wordTypeData,
  7811. ExcelTypeData = excelTypeData,
  7812. CurrencyInit = _currencyInfos,
  7813. ViewPermissionData = viewPermissionData
  7814. }));
  7815. }
  7816. /// <summary>
  7817. /// 团组模块 - 出入境费用-草稿
  7818. /// 实时汇率 tips
  7819. /// 机票费用 tips
  7820. /// </summary>
  7821. /// <returns></returns>
  7822. [HttpPost]
  7823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7824. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7825. {
  7826. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7827. return Ok(JsonView(true, "查询成功!", new
  7828. {
  7829. //GroupNameData = groupNameData.Data,
  7830. //visaData = visaData.Data,
  7831. //airData = airData.Data,
  7832. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7833. }));
  7834. }
  7835. /// <summary>
  7836. /// 团组模块 - 出入境费用-草稿
  7837. /// 签证费用 tips
  7838. /// </summary>
  7839. /// <returns></returns>
  7840. [HttpPost]
  7841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7842. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7843. {
  7844. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7845. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7846. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7847. .Select(x => x.NationalTravelFeeId)
  7848. .Distinct()
  7849. .ToListAsync();
  7850. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7851. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7852. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7853. .Select(x => x.Country)
  7854. .Distinct()
  7855. .ToArrayAsync();
  7856. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7857. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7858. return Ok(JsonView(true, "查询成功!", new
  7859. {
  7860. totalAmt = totalAmt,
  7861. remark = remark
  7862. }));
  7863. }
  7864. /// <summary>
  7865. /// 团组模块 - 出入境费用-草稿 - Info
  7866. /// </summary>
  7867. /// <returns></returns>
  7868. [HttpPost]
  7869. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7871. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7872. {
  7873. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7874. }
  7875. /// <summary>
  7876. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7877. /// </summary>
  7878. /// <returns></returns>
  7879. [HttpPost]
  7880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7881. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7882. {
  7883. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7884. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7885. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7886. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7887. foreach (var userId in dto.UserIds)
  7888. {
  7889. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7890. }
  7891. if (permissions.Any())
  7892. {
  7893. _sqlSugar.BeginTran();
  7894. try
  7895. {
  7896. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7897. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7898. if (result < 1)
  7899. {
  7900. _sqlSugar.RollbackTran();
  7901. return Ok(JsonView(false));
  7902. }
  7903. }
  7904. catch (Exception ex)
  7905. {
  7906. _sqlSugar.RollbackTran();
  7907. return Ok(JsonView(false, ex.Message));
  7908. }
  7909. _sqlSugar.CommitTran();
  7910. return Ok(JsonView(true));
  7911. }
  7912. return Ok(JsonView(false));
  7913. }
  7914. /// <summary>
  7915. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7916. /// </summary>
  7917. /// <returns></returns>
  7918. [HttpPost]
  7919. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7921. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7922. {
  7923. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7924. if (data.Code != 0)
  7925. {
  7926. return Ok(JsonView(false, data.Msg));
  7927. }
  7928. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7929. //汇率信息记录
  7930. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7931. return Ok(JsonView(true, data.Msg, data.Data));
  7932. }
  7933. /// <summary>
  7934. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7935. /// </summary>
  7936. /// <param name="dto"></param>
  7937. /// <returns></returns>
  7938. [HttpPost]
  7939. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7941. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7942. {
  7943. try
  7944. {
  7945. var id = dto.Id;
  7946. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7947. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7948. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7949. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7950. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7951. 3 团组成员名单 1 团组成员名单", ""));
  7952. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7953. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7954. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7955. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7956. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7957. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7958. //数据源
  7959. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7960. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7961. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7962. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7963. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7964. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7965. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7966. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7967. .Select((x, a, b) => new
  7968. {
  7969. x.Index,
  7970. itemName = a.Name,
  7971. CurrencyStr = b.Name,
  7972. x.Cost,
  7973. x.SubTotal,
  7974. x.Remark
  7975. })
  7976. .OrderBy((x) => x.Index)
  7977. .ToList(); //其他款项费用
  7978. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7979. var peiceItemCurrencys = new List<string>();
  7980. if (_DayAndCosts.Any())
  7981. {
  7982. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7983. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7984. }
  7985. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7986. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7987. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7988. {
  7989. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7990. }
  7991. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7992. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7993. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7994. if (dto.ExportType == 1) //明细表
  7995. {
  7996. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7997. {
  7998. //获取模板
  7999. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8000. //载入模板
  8001. Document doc = new Document(tempPath);
  8002. DocumentBuilder builder = new DocumentBuilder(doc);
  8003. //利用键值对存放数据
  8004. Dictionary<string, string> dic = new Dictionary<string, string>();
  8005. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8006. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8007. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8008. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8009. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8010. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8011. //境内费用(其他费用)
  8012. if (_EnterExitCosts.ChoiceOne == 1)
  8013. {
  8014. string row1_1 = "";
  8015. if (_EnterExitCosts.Visa > 0)
  8016. {
  8017. //insidePayTotal += _EnterExitCosts.Visa;
  8018. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8019. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8020. //{
  8021. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8022. //}
  8023. }
  8024. string row1_2 = "";
  8025. if (_EnterExitCosts.YiMiao > 0)
  8026. {
  8027. //insidePayTotal += _EnterExitCosts.YiMiao;
  8028. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8029. }
  8030. if (_EnterExitCosts.HeSuan > 0)
  8031. {
  8032. //insidePayTotal += _EnterExitCosts.HeSuan;
  8033. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8034. }
  8035. if (_EnterExitCosts.Service > 0)
  8036. {
  8037. //insidePayTotal += _EnterExitCosts.Service;
  8038. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8039. }
  8040. string row1_3 = "";
  8041. if (_EnterExitCosts.Safe > 0)
  8042. {
  8043. //insidePayTotal += _EnterExitCosts.Safe;
  8044. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8045. }
  8046. if (_EnterExitCosts.Ticket > 0)
  8047. {
  8048. //insidePayTotal += _EnterExitCosts.Ticket;
  8049. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8050. }
  8051. string row1 = "";
  8052. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8053. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8054. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8055. row1 += $"备注:{_EnterExitCosts.Remark}";
  8056. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8057. dic.Add("Row1Str", row1);
  8058. }
  8059. string airTotalStr = string.Empty,
  8060. airPriceStr = string.Empty;
  8061. //经济舱
  8062. if (_EnterExitCosts.SumJJC == 1)
  8063. {
  8064. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8065. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8066. }
  8067. //公务舱
  8068. if (_EnterExitCosts.SumGWC == 1)
  8069. {
  8070. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8071. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8072. }
  8073. //头等舱
  8074. if (_EnterExitCosts.SumTDC == 1)
  8075. {
  8076. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8077. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8078. }
  8079. //汇率描述
  8080. string rateStr = "";
  8081. if (peiceItemCurrencyInfos.Any())
  8082. {
  8083. rateStr = "\r\n汇率描述:";
  8084. foreach (var item in peiceItemCurrencyInfos)
  8085. {
  8086. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8087. }
  8088. }
  8089. string twoItemRemark = "备注:";
  8090. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8091. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8092. dic.Add("AirTotalStr", airTotalStr);
  8093. dic.Add("AirPriceStr", airPriceStr);
  8094. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8095. dic.Add("TwoItemRemark", twoItemRemark);
  8096. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8097. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8098. int table1Row = 0,
  8099. table2Row = 0,
  8100. table3Row = 0,
  8101. table4Row = 0,
  8102. table5Row = 0;
  8103. //住宿费
  8104. if (_EnterExitCosts.ChoiceThree == 1)
  8105. {
  8106. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8107. table1Row = dac1.Count;
  8108. #region 填充word表格内容
  8109. for (int i = 0; i < dac1.Count; i++)
  8110. {
  8111. var dac = dac1[i];
  8112. if (dac == null) continue;
  8113. builder.MoveToCell(0, i, 0, 0);
  8114. builder.Write("第" + dac.Days.ToString() + "晚:");
  8115. builder.MoveToCell(0, i, 1, 0);
  8116. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8117. //builder.Write(dac.Place == null ? "" : dac.Place);
  8118. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8119. builder.MoveToCell(0, i, 2, 0);
  8120. builder.Write("费用标准:");
  8121. string curr = "";
  8122. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8123. if (currData != null)
  8124. {
  8125. curr = currData.Name;
  8126. }
  8127. builder.MoveToCell(0, i, 3, 0);
  8128. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8129. builder.MoveToCell(0, i, 4, 0);
  8130. builder.Write("费用小计:");
  8131. builder.MoveToCell(0, i, 5, 0);
  8132. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8133. }
  8134. #endregion
  8135. }
  8136. else dic.Add("SubZS", "0.00");
  8137. //删除多余行
  8138. while (table1.Rows.Count > table1Row)
  8139. {
  8140. table1.Rows.RemoveAt(table1Row);
  8141. }
  8142. //伙食费
  8143. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8144. if (_EnterExitCosts.ChoiceFour == 1)
  8145. {
  8146. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8147. table2Row = dac2.Count;
  8148. #region 填充word表格内容
  8149. for (int i = 0; i < dac2.Count; i++)
  8150. {
  8151. var dac = dac2[i];
  8152. if (dac == null) continue;
  8153. builder.MoveToCell(1, i, 0, 0);
  8154. builder.Write("第" + dac.Days.ToString() + "天:");
  8155. builder.MoveToCell(1, i, 1, 0);
  8156. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8157. builder.MoveToCell(1, i, 2, 0);
  8158. builder.Write("费用标准:");
  8159. string curr = "";
  8160. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8161. if (currData != null)
  8162. {
  8163. curr = currData.Name;
  8164. }
  8165. builder.MoveToCell(1, i, 3, 0);
  8166. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8167. builder.MoveToCell(1, i, 4, 0);
  8168. builder.Write("费用小计:");
  8169. builder.MoveToCell(1, i, 5, 0);
  8170. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8171. }
  8172. #endregion
  8173. }
  8174. else dic.Add("SubHS", "0.00");
  8175. //删除多余行
  8176. while (table2.Rows.Count > table2Row)
  8177. {
  8178. table2.Rows.RemoveAt(table2Row);
  8179. }
  8180. //公杂费
  8181. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8182. if (_EnterExitCosts.ChoiceFive == 1)
  8183. {
  8184. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8185. table3Row = dac3.Count;
  8186. #region 填充word表格内容
  8187. for (int i = 0; i < dac3.Count; i++)
  8188. {
  8189. var dac = dac3[i];
  8190. if (dac == null) continue;
  8191. builder.MoveToCell(2, i, 0, 0);
  8192. builder.Write("第" + dac.Days.ToString() + "天:");
  8193. builder.MoveToCell(2, i, 1, 0);
  8194. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8195. builder.MoveToCell(2, i, 2, 0);
  8196. builder.Write("费用标准:");
  8197. string curr = "";
  8198. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8199. if (currData != null)
  8200. {
  8201. curr = currData.Name;
  8202. }
  8203. builder.MoveToCell(2, i, 3, 0);
  8204. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8205. builder.MoveToCell(2, i, 4, 0);
  8206. builder.Write("费用小计:");
  8207. builder.MoveToCell(2, i, 5, 0);
  8208. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8209. }
  8210. //删除多余行
  8211. while (table3.Rows.Count > table3Row)
  8212. {
  8213. table3.Rows.RemoveAt(table3Row);
  8214. }
  8215. #endregion
  8216. }
  8217. else dic.Add("SubGZF", "0.00");
  8218. //删除多余行
  8219. while (table3.Rows.Count > table3Row)
  8220. {
  8221. table3.Rows.RemoveAt(table3Row);
  8222. }
  8223. //培训费
  8224. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8225. if (_EnterExitCosts.ChoiceSix == 1)
  8226. {
  8227. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8228. dic.Add("SubPX", pxStr);
  8229. table4Row = dac4.Count;
  8230. #region 填充word表格内容
  8231. for (int i = 0; i < dac4.Count; i++)
  8232. {
  8233. var dac = dac4[i];
  8234. if (dac == null) continue;
  8235. builder.MoveToCell(3, i, 0, 0);
  8236. builder.Write("第" + dac.Days.ToString() + "天:");
  8237. builder.MoveToCell(3, i, 1, 0);
  8238. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8239. builder.MoveToCell(3, i, 2, 0);
  8240. builder.Write("费用标准:");
  8241. string curr = "";
  8242. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8243. if (currData != null)
  8244. {
  8245. curr = currData.Name;
  8246. }
  8247. builder.MoveToCell(3, i, 3, 0);
  8248. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8249. builder.MoveToCell(3, i, 4, 0);
  8250. builder.Write("费用小计:");
  8251. builder.MoveToCell(3, i, 5, 0);
  8252. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8253. }
  8254. #endregion
  8255. }
  8256. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8257. //删除多余行
  8258. while (table4.Rows.Count > table4Row)
  8259. {
  8260. table4.Rows.RemoveAt(table4Row);
  8261. }
  8262. //其他费用
  8263. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8264. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8265. {
  8266. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8267. dic.Add("titleQi", qtStr);
  8268. table5Row = dac5.Count;
  8269. #region 填充word表格内容
  8270. for (int i = 0; i < dac5.Count; i++)
  8271. {
  8272. var dac = dac5[i];
  8273. if (dac == null) continue;
  8274. builder.MoveToCell(4, i, 0, 0);
  8275. builder.Write("第" + dac.Index.ToString() + "项:");
  8276. builder.MoveToCell(4, i, 1, 0);
  8277. builder.Write(dac.itemName);
  8278. builder.MoveToCell(4, i, 2, 0);
  8279. builder.Write("费用标准:");
  8280. builder.MoveToCell(4, i, 3, 0);
  8281. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8282. builder.MoveToCell(4, i, 4, 0);
  8283. builder.Write("费用小计:");
  8284. builder.MoveToCell(4, i, 5, 0);
  8285. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8286. builder.MoveToCell(4, i, 6, 0);
  8287. builder.Write("备注:");
  8288. builder.MoveToCell(4, i, 7, 0);
  8289. builder.Write(dac.Remark);
  8290. }
  8291. #endregion
  8292. }
  8293. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8294. //删除多余行
  8295. while (table5.Rows.Count > table5Row)
  8296. {
  8297. table5.Rows.RemoveAt(table5Row);
  8298. }
  8299. //加上其他费用
  8300. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8301. decimal subJJC = 0.00M,
  8302. subGWC = 0.00M,
  8303. subTDC = 0.00M;
  8304. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8305. string totalLabel = string.Format("全部费用总计:");
  8306. //经济舱
  8307. if (_EnterExitCosts.SumJJC == 1)
  8308. {
  8309. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8310. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8311. }
  8312. //公务舱
  8313. if (_EnterExitCosts.SumGWC == 1)
  8314. {
  8315. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8316. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8317. }
  8318. //头等舱
  8319. if (_EnterExitCosts.SumTDC == 1)
  8320. {
  8321. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8322. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8323. }
  8324. //TotalLabel
  8325. dic.Add("TotalLabel", totalLabel);
  8326. #region 填充word模板书签内容
  8327. foreach (var key in dic.Keys)
  8328. {
  8329. Bookmark bookmark = doc.Range.Bookmarks[key];
  8330. if (bookmark != null)
  8331. {
  8332. builder.MoveToBookmark(key);
  8333. builder.Write(dic[key]);
  8334. }
  8335. }
  8336. #endregion
  8337. //文件名
  8338. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8339. strFileName = CommonFun.ValidFileName(strFileName);
  8340. AsposeHelper.removewatermark_v2180();
  8341. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8342. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8343. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8344. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8345. }
  8346. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8347. {
  8348. //获取模板
  8349. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8350. //载入模板
  8351. Document doc = new Document(tempPath);
  8352. DocumentBuilder builder = new DocumentBuilder(doc);
  8353. Dictionary<string, string> dic = new Dictionary<string, string>();
  8354. string returnCodeLabel = string.Empty;
  8355. if (nationalTravelFeeData.Any())
  8356. {
  8357. List<string> list = new List<string>();
  8358. foreach (var item in nationalTravelFeeData)
  8359. {
  8360. list.Add($"{item.Country}({item.City})");
  8361. }
  8362. list = list.Distinct().ToList();
  8363. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8364. }
  8365. var countryLabel = string.Empty;
  8366. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8367. if (countryData.Any())
  8368. {
  8369. countryLabel = string.Join("、", countryData);
  8370. }
  8371. dic.Add("ReturnCodeAir", returnCodeLabel);
  8372. dic.Add("VisitStartDate", "-");
  8373. dic.Add("VisitEndDate", "-");
  8374. dic.Add("Day", "-");
  8375. dic.Add("VisitCountry", countryLabel);
  8376. dic.Add("ClientUnit", "-");
  8377. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8378. //dic.Add("Names", Names);
  8379. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8380. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8381. decimal dac1totalPrice = 0.00M;
  8382. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8383. foreach (var dac in dac1)
  8384. {
  8385. if (dac.SubTotal == 0.00M)
  8386. {
  8387. continue;
  8388. }
  8389. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8390. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8391. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8392. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8393. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8394. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8395. builder.Write(currency);//币种
  8396. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8397. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8398. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8399. builder.Write("");//人数
  8400. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8401. builder.Write("");//天数
  8402. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8403. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8404. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8405. decimal rate = 0.00M;
  8406. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8407. builder.Write(rate.ToString("#0.0000"));//汇率
  8408. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8409. decimal rbmPrice = dac.SubTotal;
  8410. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8411. accommodationStartIndex++;
  8412. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8413. }
  8414. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8415. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8416. {
  8417. table1.Rows.RemoveAt(i - 1);
  8418. foodandotherStartIndex--;
  8419. }
  8420. if (dac2.Count == dac3.Count)//国家 币种 金额
  8421. {
  8422. for (int i = 0; i < dac2.Count; i++)
  8423. {
  8424. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8425. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8426. }
  8427. }
  8428. decimal dac2totalPrice = 0.00M;
  8429. foreach (var dac in dac2)
  8430. {
  8431. if (dac.SubTotal == 0)
  8432. {
  8433. continue;
  8434. }
  8435. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8436. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8437. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8438. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8439. builder.Write(currency);//币种
  8440. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8441. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8442. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8443. builder.Write("");//人数
  8444. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8445. builder.Write("");//天数
  8446. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8447. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8448. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8449. decimal rate = 0.00M;
  8450. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8451. builder.Write(rate.ToString("#0.0000"));//汇率
  8452. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8453. decimal rbmPrice = dac.SubTotal;
  8454. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8455. foodandotherStartIndex++;
  8456. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8457. }
  8458. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8459. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8460. {
  8461. table1.Rows.RemoveAt(i - 1);
  8462. }
  8463. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8464. string otherFeeStr = "";
  8465. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8466. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8467. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8468. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8469. foreach (var otherInfo in dac5)
  8470. {
  8471. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8472. }
  8473. #endregion
  8474. if (otherFeeStr.Length > 0)
  8475. {
  8476. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8477. otherFeeStr = $"({otherFeeStr})";
  8478. dic.Add("OtherFeeStr", otherFeeStr);
  8479. }
  8480. //总计
  8481. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8482. //国际旅费
  8483. string outsideAir = string.Empty;
  8484. string allPriceAir = string.Empty;
  8485. if (_EnterExitCosts.SumJJC == 1)
  8486. {
  8487. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8488. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8489. }
  8490. if (_EnterExitCosts.SumGWC == 1)
  8491. {
  8492. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8493. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8494. }
  8495. if (_EnterExitCosts.SumTDC == 1)
  8496. {
  8497. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8498. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8499. }
  8500. dic.Add("InTravelPrice", $"({outsideAir})");
  8501. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8502. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8503. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8504. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8505. foreach (var key in dic.Keys)
  8506. {
  8507. builder.MoveToBookmark(key);
  8508. builder.Write(dic[key]);
  8509. }
  8510. //模板文件名
  8511. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8512. strFileName = CommonFun.ValidFileName(strFileName);
  8513. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8514. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8515. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8516. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8517. }
  8518. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8519. {
  8520. //获取模板
  8521. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8522. //载入模板
  8523. WorkbookDesigner designer = new WorkbookDesigner();
  8524. designer.Workbook = new Workbook(tempPath);
  8525. Dictionary<string, string> dic = new Dictionary<string, string>();
  8526. string returnCodeLabel = string.Empty;
  8527. if (nationalTravelFeeData.Any())
  8528. {
  8529. List<string> list = new List<string>();
  8530. foreach (var item in nationalTravelFeeData)
  8531. {
  8532. list.Add($"{item.Country}({item.City})");
  8533. }
  8534. list = list.Distinct().ToList();
  8535. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8536. }
  8537. var countryLabel = string.Empty;
  8538. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8539. if (countryData.Any())
  8540. {
  8541. countryLabel = string.Join("、", countryData);
  8542. }
  8543. dic.Add("ReturnCodeAir", returnCodeLabel);
  8544. dic.Add("VisitStartDate", "-");
  8545. dic.Add("VisitEndDate", "-");
  8546. dic.Add("Day", "0");
  8547. dic.Add("VisitCountry", countryLabel);
  8548. dic.Add("ClientUnit", "-");
  8549. designer.SetDataSource("ClientUnit", "-");
  8550. designer.SetDataSource("VisitCountry", countryLabel);
  8551. designer.SetDataSource("Group", "-");
  8552. designer.SetDataSource("ClientUnitTitle", "-");
  8553. designer.SetDataSource("Name", "-");
  8554. designer.SetDataSource("VisitStartDate", "-");
  8555. designer.SetDataSource("Day", "0");
  8556. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8557. designer.SetDataSource("ReturnCodeAir", "-");
  8558. int startIndex = 10;
  8559. const int startIndexcopy = 10;
  8560. if (dac2.Count == dac3.Count)//国家 币种 金额
  8561. {
  8562. for (int i = 0; i < dac2.Count; i++)
  8563. {
  8564. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8565. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8566. }
  8567. }
  8568. DataTable dtdac1 = new DataTable();
  8569. List<string> place = new List<string>();
  8570. dtdac1.Columns.AddRange(new DataColumn[] {
  8571. new DataColumn(){ ColumnName = "city"},
  8572. new DataColumn(){ ColumnName = "curr"},
  8573. new DataColumn(){ ColumnName = "criterion"},
  8574. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8575. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8576. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8577. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8578. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8579. });
  8580. DataTable dtdac2 = new DataTable();
  8581. dtdac2.Columns.AddRange(new DataColumn[] {
  8582. new DataColumn(){ ColumnName = "city"},
  8583. new DataColumn(){ ColumnName = "curr"},
  8584. new DataColumn(){ ColumnName = "criterion"},
  8585. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8586. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8587. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8588. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8589. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8590. });
  8591. dtdac1.TableName = "tb1";
  8592. dtdac2.TableName = "tb2";
  8593. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8594. foreach (var item in dac1)
  8595. {
  8596. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8597. if (place.Contains(item.Place))
  8598. {
  8599. continue;
  8600. }
  8601. DataRow row = dtdac1.NewRow();
  8602. row["city"] = item.Place;
  8603. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8604. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8605. row["curr"] = currency;
  8606. row["rate"] = rate.ToString("#0.0000");
  8607. row["criterion"] = item.Cost.ToString("#0.00");
  8608. row["number"] = 1;
  8609. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8610. //row["costRMB"] = rbmPrice;
  8611. dtdac1.Rows.Add(row);
  8612. place.Add(item.Place);
  8613. }
  8614. place = new List<string>();
  8615. foreach (var item in dac2)
  8616. {
  8617. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8618. if (place.Contains(item.Place))
  8619. {
  8620. continue;
  8621. }
  8622. DataRow row = dtdac2.NewRow();
  8623. row["city"] = item.Place;
  8624. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8625. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8626. row["curr"] = currency;
  8627. row["rate"] = rate.ToString("#0.0000");
  8628. row["criterion"] = item.Cost.ToString("#0.00");
  8629. row["number"] = 1;
  8630. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8631. //row["cost"] = item.SubTotal;
  8632. //row["costRMB"] = rbmPrice;
  8633. dtdac2.Rows.Add(row);
  8634. place.Add(item.Place);
  8635. //dac2totalPrice += rbmPrice;
  8636. }
  8637. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8638. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8639. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8640. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8641. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8642. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8643. string cell4Str1 = string.Empty;
  8644. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8645. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8646. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8647. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8648. string cellStr = $" 5.其他费用(";
  8649. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8650. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8651. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8652. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8653. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8654. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8655. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8656. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8657. foreach (var otherInfo in dac5)
  8658. {
  8659. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8660. }
  8661. #endregion
  8662. if (cellStr.Length > 8)
  8663. {
  8664. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8665. }
  8666. cellStr += ")";
  8667. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8668. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8669. decimal pxFee = dac4.Sum(it => it.Cost);
  8670. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8671. string celllastStr1 = "";
  8672. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8673. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8674. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8675. celllastStr1 += $",国际旅费 元";
  8676. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8677. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8678. designer.SetDataSource("cell4Str", cell4Str);
  8679. designer.SetDataSource("cellStr", cellStr);
  8680. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8681. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8682. designer.SetDataSource("celllastStr", celllastStr);
  8683. Workbook wb = designer.Workbook;
  8684. var sheet = wb.Worksheets[0];
  8685. //绑定datatable数据集
  8686. designer.SetDataSource(dtdac1);
  8687. designer.SetDataSource(dtdac2);
  8688. designer.Process();
  8689. var rowStart = dtdac1.Rows.Count;
  8690. while (rowStart > 0)
  8691. {
  8692. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8693. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8694. startIndex++;
  8695. rowStart--;
  8696. }
  8697. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8698. startIndex += 1; //总计行
  8699. rowStart = dtdac2.Rows.Count;
  8700. while (rowStart > 0)
  8701. {
  8702. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8703. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8704. startIndex++;
  8705. rowStart--;
  8706. }
  8707. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8708. wb.CalculateFormula(true);
  8709. //模板文件名
  8710. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8711. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8712. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8713. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8714. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8715. }
  8716. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8717. {
  8718. //获取模板
  8719. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8720. //载入模板
  8721. Document doc = new Document(tempPath);
  8722. DocumentBuilder builder = new DocumentBuilder(doc);
  8723. Dictionary<string, string> dic = new Dictionary<string, string>();
  8724. dic.Add("GroupName", "-");
  8725. dic.Add("ClientUnit", "-");
  8726. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8727. //string missionLeaderJob = "";//负责人job
  8728. //int groupNumber = 0; //团人数
  8729. dic.Add("MissionLeader", "-"); //团负责人
  8730. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8731. dic.Add("GroupNumber", "0"); //团人数
  8732. dic.Add("Day", "0");
  8733. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8734. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8735. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8736. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8737. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8738. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8739. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8740. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8741. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8742. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8743. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8744. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8745. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8746. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8747. //其他费用
  8748. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8749. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8750. //其他费用合计
  8751. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8752. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8753. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8754. //公务舱合计
  8755. //国际旅费
  8756. //string outsideJJ = "";
  8757. //string allPriceJJ = "";
  8758. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8759. {
  8760. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8761. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8762. }
  8763. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8764. {
  8765. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8766. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8767. }
  8768. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8769. {
  8770. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8771. dic.Add("AirFeeTotal", airFeeTotalStr);
  8772. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8773. dic.Add("FeeTotal", feeTotalStr);
  8774. }
  8775. foreach (var key in dic.Keys)
  8776. {
  8777. builder.MoveToBookmark(key);
  8778. builder.Write(dic[key]);
  8779. }
  8780. //模板文件名
  8781. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8782. strFileName = CommonFun.ValidFileName(strFileName);
  8783. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8784. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8785. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8786. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8787. }
  8788. }
  8789. else if (dto.ExportType == 2) //表格
  8790. {
  8791. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8792. }
  8793. else if (dto.ExportType == 3)
  8794. {
  8795. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8796. }
  8797. return Ok(JsonView(400, "只可导出明细表!", ""));
  8798. }
  8799. catch (Exception ex)
  8800. {
  8801. return Ok(JsonView(400, ex.Message, ""));
  8802. }
  8803. }
  8804. /// <summary>
  8805. /// 获取三公费用标准city
  8806. /// </summary>
  8807. /// <param name="placeData"></param>
  8808. /// <param name="nationalTravelFeeId"></param>
  8809. /// <returns></returns>
  8810. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8811. {
  8812. string _city = string.Empty;
  8813. if (!placeData.Any()) return _city;
  8814. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8815. if (data == null) return _city;
  8816. string country = data.Country;
  8817. string city = data.City;
  8818. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8819. else _city = city;
  8820. return _city;
  8821. }
  8822. /// <summary>
  8823. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8824. /// </summary>
  8825. /// <returns></returns>
  8826. [HttpPost]
  8827. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8829. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8830. {
  8831. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8832. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8833. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8834. if (_view.Code == 0)
  8835. {
  8836. return Ok(JsonView(true, "操作成功"));
  8837. }
  8838. return Ok(JsonView(false, "操作失败"));
  8839. }
  8840. /// <summary>
  8841. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8842. /// </summary>
  8843. /// <returns></returns>
  8844. [HttpPost]
  8845. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8847. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8848. {
  8849. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8850. if (data.Code != 0)
  8851. {
  8852. return Ok(JsonView(false, data.Msg));
  8853. }
  8854. return Ok(JsonView(true, "操作成功!", data.Data));
  8855. }
  8856. /// <summary>
  8857. /// 三公其他费用草稿 删除
  8858. /// </summary>
  8859. /// <param name="dto"></param>
  8860. /// <returns></returns>
  8861. [HttpPost]
  8862. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8863. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8864. {
  8865. var jw = JsonView(false, "删除失败!");
  8866. var data = new Grp_DayOtherPriceDraft()
  8867. {
  8868. Id = dto.Id,
  8869. IsDel = 1,
  8870. DeleteUserId = dto.DeleteUserId,
  8871. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8872. };
  8873. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8874. if (del > 0)
  8875. {
  8876. jw.Code = 200;
  8877. jw.Msg = "删除成功!";
  8878. }
  8879. return Ok(jw);
  8880. }
  8881. /// <summary>
  8882. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8883. /// </summary>
  8884. /// <returns></returns>
  8885. [HttpPost]
  8886. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8887. {
  8888. var jw = JsonView(false);
  8889. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8890. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8891. jw.Code = StatusCodes.Status200OK;
  8892. jw.Msg = "操作成功!";
  8893. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8894. return Ok(jw);
  8895. }
  8896. /// <summary>
  8897. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8898. /// </summary>
  8899. /// <param name="dto"></param>
  8900. /// <returns></returns>
  8901. [HttpPost]
  8902. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8903. {
  8904. int userId = dto.UserId,
  8905. portId = dto.PortType,
  8906. groupId = dto.GroupId,
  8907. draftId = dto.DraftId;
  8908. _portTypeData.Add(1);
  8909. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8910. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8911. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8912. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8913. _sqlSugar.BeginTran();
  8914. try
  8915. {
  8916. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8917. if (draftDatas == null)
  8918. {
  8919. _sqlSugar.RollbackTran();
  8920. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8921. }
  8922. //验证可覆盖已有数据 两边创建人需为同一人;
  8923. int draftCreateUserId = draftDatas.CreateUserId,
  8924. formalCreateUserId = 0;
  8925. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8926. if (formalData != null)
  8927. {
  8928. formalCreateUserId = formalData.CreateUserId;
  8929. if (draftCreateUserId != formalCreateUserId)
  8930. {
  8931. _sqlSugar.RollbackTran();
  8932. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8933. }
  8934. }
  8935. //默认添加查看、编辑权限(创建人、自己)
  8936. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8937. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8938. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8939. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8940. newExterData.DiId = groupId;
  8941. newExterData.CreateUserId = userId;
  8942. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8943. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8944. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8945. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8946. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8947. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8948. //数据如果存在执行删除
  8949. if (enterExitCostInfo != null)
  8950. {
  8951. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8952. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8953. .Where(x => x.Id == enterExitCostInfo.Id)
  8954. .ExecuteCommand();
  8955. _sqlSugar.Updateable<Grp_DayAndCost>()
  8956. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8957. .Where(x => x.DiId == groupId)
  8958. .ExecuteCommand();
  8959. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8960. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8961. .Where(x => x.Diid == groupId)
  8962. .ExecuteCommand();
  8963. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8964. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8965. .Where(x => x.GroupId == groupId)
  8966. .ExecuteCommand();
  8967. }
  8968. //执行insert
  8969. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8970. if (insertId < 1)
  8971. {
  8972. _sqlSugar.RollbackTran();
  8973. return Ok(JsonView(false, "草稿数据导入失败!"));
  8974. }
  8975. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8976. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8977. #region 默认添加权限
  8978. #endregion
  8979. _sqlSugar.CommitTran();
  8980. //执行操作之后
  8981. //生成默认文件pdf并且通知人员
  8982. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8983. {
  8984. DiId = groupId,
  8985. ExportType = 1,
  8986. SubTypeId = 1005
  8987. }, "pdf");
  8988. //发送通知
  8989. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8990. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8991. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8992. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8993. //汇率信息记录
  8994. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8995. return Ok(JsonView(true));
  8996. }
  8997. catch (Exception ex)
  8998. {
  8999. _sqlSugar.RollbackTran();
  9000. return Ok(JsonView(false, ex.Message));
  9001. }
  9002. }
  9003. #endregion
  9004. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9005. /// <summary>
  9006. /// 获取币种基础数据(含逻辑处理)
  9007. /// </summary>
  9008. /// <returns></returns>
  9009. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9010. {
  9011. return await GeneralMethod.EnterExitCostInitRate();
  9012. }
  9013. /// <summary>
  9014. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9015. /// </summary>
  9016. /// <returns></returns>
  9017. [HttpPost]
  9018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9019. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9020. {
  9021. //验证城市归属并给默认值
  9022. int provinceId = dto.ProvinceId;
  9023. if (provinceId < 1) provinceId = 122;
  9024. var dataSource = await _sqlSugar
  9025. .Queryable<Sys_SetData>()
  9026. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9027. .ToListAsync();
  9028. var fileTypes = new List<EecSetDataInfoView>();
  9029. //三公费用-Word明细类型
  9030. var wordTypeData = dataSource
  9031. .Where(it => it.STid == 72)
  9032. .Select(x => new EecSetDataInfoView
  9033. {
  9034. ParentId = 1,
  9035. Id = x.Id,
  9036. Name = x.Name
  9037. })
  9038. .ToArray();
  9039. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9040. var excelTypeData = dataSource
  9041. .Where(it => it.STid == 73)
  9042. .Select(x => new EecSetDataInfoView
  9043. {
  9044. ParentId = 2,
  9045. Id = x.Id,
  9046. Name = x.Name
  9047. })
  9048. .ToArray();
  9049. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9050. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9051. fileTypes.Add(groupNameList);
  9052. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9053. //默认币种显示
  9054. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9055. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9056. return Ok(JsonView(true, "查询成功!", new
  9057. {
  9058. FileTypeData = fileTypes,
  9059. CurrencyInit = _currencyInfos,
  9060. viewPermissionData = viewPermissionData
  9061. }));
  9062. }
  9063. /// <summary>
  9064. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9065. /// </summary>
  9066. /// <returns></returns>
  9067. [HttpPost]
  9068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9069. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9070. {
  9071. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9072. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9073. RefAsync<int> total = 0;
  9074. int diId = 0;
  9075. var status = int.TryParse(dto.GroupName, out diId);
  9076. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9077. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9078. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9079. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9080. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9081. .OrderByDescending(x => x.VisitStartDate)
  9082. .Select(x => new EnterExitCostMobileGroupView()
  9083. {
  9084. Id = x.Id,
  9085. GroupName = x.TeamName,
  9086. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9087. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9088. ProvinceId = x.CityId
  9089. })
  9090. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9091. //处理省份Id
  9092. if (data.Any())
  9093. {
  9094. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9095. if (provCityDatas.Any())
  9096. {
  9097. foreach (var item in data)
  9098. {
  9099. var provinceId = item.ProvinceId;
  9100. var isDefualtVal = true;
  9101. if (provinceId > 0)
  9102. {
  9103. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9104. if (parentId != null)
  9105. {
  9106. isDefualtVal = false;
  9107. item.ProvinceId = (int)parentId;
  9108. }
  9109. }
  9110. if (isDefualtVal)
  9111. {
  9112. item.ProvinceId = 122; //默认四川
  9113. }
  9114. }
  9115. }
  9116. }
  9117. //处理是否显示
  9118. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9119. {
  9120. foreach (var item in data)
  9121. {
  9122. item.IsView = true;
  9123. }
  9124. }
  9125. return Ok(JsonView(true, "查询成功!", data, total));
  9126. }
  9127. /// <summary>
  9128. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9129. /// </summary>
  9130. /// <returns></returns>
  9131. [HttpPost]
  9132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9133. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9134. {
  9135. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9136. RefAsync<int> total = 0;
  9137. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9138. .Where(x => x.IsDel == 0 && x.STid == 66)
  9139. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9140. .Select(x => new
  9141. {
  9142. id = x.Id,
  9143. name = x.Name,
  9144. remark = x.Remark,
  9145. })
  9146. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9147. return Ok(JsonView(true, "查询成功!", data, total));
  9148. }
  9149. /// <summary>
  9150. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9151. /// </summary>
  9152. /// <returns></returns>
  9153. [HttpPost]
  9154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9155. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9156. {
  9157. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9158. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9159. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9160. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9161. var groupOtherRateData = groupRateData.TeamRates;
  9162. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9163. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9164. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9165. groupOtherRateData = groupOtherRateData
  9166. .Select(x => new TeamRateDescAddCurrencyIdView
  9167. {
  9168. CurrencyId = x.CurrencyId,
  9169. CurrencyName = x.CurrencyName,
  9170. CurrencyCode = x.CurrencyCode,
  9171. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9172. }).ToList();
  9173. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9174. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9175. }
  9176. /// <summary>
  9177. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9178. /// </summary>
  9179. /// <returns></returns>
  9180. [HttpPost]
  9181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9182. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9183. {
  9184. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9185. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9186. var tipsData = new List<int>() { 1, 2, 3 };
  9187. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9188. if (dto.TipsType == 1)
  9189. {
  9190. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9191. }
  9192. else if (dto.TipsType == 2)
  9193. {
  9194. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9195. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9196. }
  9197. else if (dto.TipsType == 3)
  9198. {
  9199. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9200. return Ok(JsonView(true, "查询成功!", airData));
  9201. }
  9202. return Ok(JsonView(false));
  9203. }
  9204. /// <summary>
  9205. /// 团组模块 - 出入境国家费用标准-移动端 List
  9206. /// </summary>
  9207. /// <returns></returns>
  9208. [HttpPost]
  9209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9210. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9211. {
  9212. Stopwatch sw = new Stopwatch();
  9213. sw.Start();
  9214. int provinceId = dto.ProvinceId;
  9215. if (provinceId < 1) provinceId = 122; // 默认四川
  9216. RefAsync<int> total = 0;
  9217. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9218. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9219. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9220. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9221. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9222. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9223. .Select((ntf, sd, u, sd1) => new
  9224. {
  9225. Id = ntf.Id,
  9226. Area = $"{ntf.Country}-{ntf.City}",
  9227. Currency = ntf.Currency,
  9228. CurrencyCode = sd.Name,
  9229. CurrencyName = sd.Remark,
  9230. RoomCost = ntf.RoomCost,
  9231. FoodCost = ntf.FoodCost,
  9232. PublicCost = ntf.PublicCost,
  9233. TrainCost = ntf.TrainCost,
  9234. LastUpdateUserId = ntf.LastUpdateUserId,
  9235. LastUpdateUserName = u.CnName,
  9236. LastUpdateTime = ntf.LastUpdateTime
  9237. })
  9238. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9239. sw.Stop();
  9240. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9241. }
  9242. /// <summary>
  9243. /// 团组模块 - 出入境费用-移动端 - Info
  9244. /// </summary>
  9245. /// <returns></returns>
  9246. [HttpPost]
  9247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9248. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9249. {
  9250. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9251. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9252. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9253. return Ok(data);
  9254. }
  9255. /// <summary>
  9256. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9257. /// </summary>
  9258. /// <returns></returns>
  9259. [HttpPost]
  9260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9261. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9262. {
  9263. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9264. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9265. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9266. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9267. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9268. mobileInfo.DiId = dto.DiId;
  9269. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9270. if (eecInfo == null) return Ok(mobileInfo);
  9271. //验证查看权限
  9272. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9273. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9274. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9275. mobileInfo.IsAssignPerm = isSet;
  9276. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9277. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9278. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9279. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9280. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9281. {
  9282. SubId = dac.Id,
  9283. DiId = dac.DiId,
  9284. Type = dac.Type,
  9285. Days = dac.Days,
  9286. NationalTravelFeeId = dac.NationalTravelFeeId,
  9287. Arae = $"{ntf.Country}-{ntf.City}",
  9288. Cost = dac.Cost,
  9289. Currency = dac.Currency,
  9290. CurrencyName = sd.Name,
  9291. SubTotal = dac.SubTotal,
  9292. })
  9293. .ToList();
  9294. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9295. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9296. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9297. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9298. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9299. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9300. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9301. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9302. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9303. //其他款项
  9304. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9305. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9306. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9307. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9308. .OrderBy((dop, sd1, sd2) => dop.Index)
  9309. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9310. {
  9311. SubId = dop.Id,
  9312. DiId = dop.Diid,
  9313. Index = dop.Index,
  9314. SetDataId = dop.SetDataId,
  9315. SetDataName = sd1.Name,
  9316. Cost = dop.Cost,
  9317. Currency = dop.Currency,
  9318. CurrencyName = sd2.Remark,
  9319. SubTotal = dop.SubTotal,
  9320. Remark = dop.Remark,
  9321. })
  9322. .ToArray();
  9323. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9324. return Ok(mobileInfo);
  9325. }
  9326. /// <summary>
  9327. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9328. /// </summary>
  9329. /// <returns></returns>
  9330. [HttpPost]
  9331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9332. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9333. {
  9334. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9335. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9336. //验证查看权限
  9337. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9338. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9339. var userIds = await _sqlSugar
  9340. .Queryable<Grp_EnterExitCostPermission>()
  9341. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9342. .Select(x => x.UserId)
  9343. .ToArrayAsync();
  9344. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9345. var perUsersView = new List<dynamic>();
  9346. foreach (var item in perUsers)
  9347. {
  9348. bool isView1 = false;
  9349. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9350. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9351. }
  9352. return Ok(JsonView(perUsersView));
  9353. }
  9354. /// <summary>
  9355. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9356. /// </summary>
  9357. /// <returns></returns>
  9358. [HttpPost]
  9359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9360. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9361. {
  9362. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9363. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9364. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9365. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9366. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9367. //验证查看权限
  9368. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9369. //if (!isView) return Ok(JsonView(false, msg));
  9370. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9371. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9372. var subType = dto.SubType;
  9373. if (subType == 1) //1:境内费用
  9374. {
  9375. var oneData = new ChoiceOneMobileSubInfoView()
  9376. {
  9377. Id = eecInfo.Id,
  9378. ChoiceOne = eecInfo.ChoiceOne,
  9379. ChoiceOneTotalCost = eecInfo.InsidePay,
  9380. Visa = eecInfo.Visa,
  9381. VisaRemark = eecInfo.VisaRemark,
  9382. YiMiao = eecInfo.YiMiao,
  9383. HeSuan = eecInfo.HeSuan,
  9384. Service = eecInfo.Service,
  9385. Ticket = eecInfo.Ticket,
  9386. Safe = eecInfo.Safe,
  9387. FirstItemRemark = eecInfo.FirstItemRemark
  9388. };
  9389. return Ok(JsonView(oneData));
  9390. }
  9391. else if (subType == 2) //2:国际旅费
  9392. {
  9393. var twoData = new ChoiceTwoMobileSubInfoView()
  9394. {
  9395. Id = eecInfo.Id,
  9396. ChoiceTwoJJ = eecInfo.SumJJC,
  9397. OutsideJJPay = eecInfo.OutsideJJPay,
  9398. ChoiceTwoGW = eecInfo.SumGWC,
  9399. OutsideGWPay = eecInfo.OutsideGWPay,
  9400. ChoiceTwoTD = eecInfo.SumTDC,
  9401. OutsideTDPay = eecInfo.OutsideTDPay,
  9402. AirJJ = eecInfo.AirJJ,
  9403. AirGW = eecInfo.AirGW,
  9404. AirTD = eecInfo.AirTD,
  9405. CityTranffic = eecInfo.CityTranffic,
  9406. TwoItemRemark = eecInfo.TwoItemRemark
  9407. };
  9408. return Ok(JsonView(twoData));
  9409. }
  9410. else if (subType == 3) //3:住宿费
  9411. {
  9412. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9413. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9414. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9415. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9416. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9417. {
  9418. SubId = dac.Id,
  9419. DiId = dac.DiId,
  9420. Type = dac.Type,
  9421. Days = dac.Days,
  9422. NationalTravelFeeId = dac.NationalTravelFeeId,
  9423. Arae = $"{ntf.Country}-{ntf.City}",
  9424. Cost = dac.Cost,
  9425. Currency = dac.Currency,
  9426. CurrencyName = sd.Name,
  9427. SubTotal = dac.SubTotal,
  9428. })
  9429. .ToArray();
  9430. var data = new ChoiceMobileSubInfo3To6View()
  9431. {
  9432. ParentId = eecInfo.Id,
  9433. Choice = eecInfo.ChoiceThree,
  9434. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9435. Details = dayAndCostDatas
  9436. };
  9437. return Ok(JsonView(data));
  9438. }
  9439. else if (subType == 4) //4:伙食费
  9440. {
  9441. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9442. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9443. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9444. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9445. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9446. {
  9447. SubId = dac.Id,
  9448. DiId = dac.DiId,
  9449. Type = dac.Type,
  9450. Days = dac.Days,
  9451. NationalTravelFeeId = dac.NationalTravelFeeId,
  9452. Arae = $"{ntf.Country}-{ntf.City}",
  9453. Cost = dac.Cost,
  9454. Currency = dac.Currency,
  9455. CurrencyName = sd.Name,
  9456. SubTotal = dac.SubTotal,
  9457. })
  9458. .ToArray();
  9459. var data = new ChoiceMobileSubInfo3To6View()
  9460. {
  9461. ParentId = eecInfo.Id,
  9462. Choice = eecInfo.ChoiceFour,
  9463. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9464. Details = dayAndCostDatas
  9465. };
  9466. return Ok(JsonView(data));
  9467. }
  9468. else if (subType == 5) //5:公杂费
  9469. {
  9470. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9471. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9472. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9473. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9474. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9475. {
  9476. SubId = dac.Id,
  9477. DiId = dac.DiId,
  9478. Type = dac.Type,
  9479. Days = dac.Days,
  9480. NationalTravelFeeId = dac.NationalTravelFeeId,
  9481. Arae = $"{ntf.Country}-{ntf.City}",
  9482. Cost = dac.Cost,
  9483. Currency = dac.Currency,
  9484. CurrencyName = sd.Name,
  9485. SubTotal = dac.SubTotal,
  9486. })
  9487. .ToArray();
  9488. var data = new ChoiceMobileSubInfo3To6View()
  9489. {
  9490. ParentId = eecInfo.Id,
  9491. Choice = eecInfo.ChoiceFive,
  9492. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9493. Details = dayAndCostDatas
  9494. };
  9495. return Ok(JsonView(data));
  9496. }
  9497. else if (subType == 6) //6:培训费
  9498. {
  9499. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9500. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9501. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9502. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9503. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9504. {
  9505. SubId = dac.Id,
  9506. DiId = dac.DiId,
  9507. Type = dac.Type,
  9508. Days = dac.Days,
  9509. NationalTravelFeeId = dac.NationalTravelFeeId,
  9510. Arae = $"{ntf.Country}-{ntf.City}",
  9511. Cost = dac.Cost,
  9512. Currency = dac.Currency,
  9513. CurrencyName = sd.Name,
  9514. SubTotal = dac.SubTotal,
  9515. })
  9516. .ToArray();
  9517. var data = new ChoiceMobileSubInfo3To6View()
  9518. {
  9519. ParentId = eecInfo.Id,
  9520. Choice = eecInfo.ChoiceSix,
  9521. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9522. Details = dayAndCostDatas
  9523. };
  9524. return Ok(JsonView(data));
  9525. }
  9526. else if (subType == 7) //7:其他
  9527. {
  9528. //其他款项
  9529. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9530. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9531. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9532. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9533. .OrderBy((dop, sd1, sd2) => dop.Index)
  9534. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9535. {
  9536. SubId = dop.Id,
  9537. DiId = dop.Diid,
  9538. Index = dop.Index,
  9539. SetDataId = dop.SetDataId,
  9540. SetDataName = sd1.Name,
  9541. Cost = dop.Cost,
  9542. Currency = dop.Currency,
  9543. CurrencyName = sd2.Name,
  9544. SubTotal = dop.SubTotal,
  9545. Remark = dop.Remark,
  9546. })
  9547. .ToArray();
  9548. var data = new ChoiceSevenMobileSubInfoView()
  9549. {
  9550. ParentId = eecInfo.Id,
  9551. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9552. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9553. Details = otherData
  9554. };
  9555. return Ok(JsonView(data));
  9556. }
  9557. return Ok(JsonView(false));
  9558. }
  9559. #region op
  9560. /// <summary>
  9561. /// 移动端更新费用消息通知
  9562. /// </summary>
  9563. /// <param name="diid"></param>
  9564. /// <param name="id"></param>
  9565. /// <param name="currUserId"></param>
  9566. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9567. {
  9568. try
  9569. {
  9570. ////生成默认文件pdf并且通知人员
  9571. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9572. //{
  9573. // DiId = diid,
  9574. // ExportType = 1,
  9575. // SubTypeId = 1005
  9576. //}, "pdf");
  9577. ////发送通知
  9578. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9579. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9580. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9581. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9582. ////汇率信息记录
  9583. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9584. }
  9585. catch (Exception ex)
  9586. {
  9587. //记录日志
  9588. throw;
  9589. }
  9590. }
  9591. /// <summary>
  9592. /// 验证出入境费用数据是否存在
  9593. /// 不存在添加
  9594. /// </summary>
  9595. /// <param name="diId"></param>
  9596. /// <param name="currUserId"></param>
  9597. /// <returns></returns>
  9598. /// <exception cref="CustomException"></exception>
  9599. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9600. {
  9601. var parentId = 0;
  9602. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9603. if (info != null)
  9604. {
  9605. parentId = info.Id;
  9606. }
  9607. else
  9608. {
  9609. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9610. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9611. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9612. parentId = addId;
  9613. }
  9614. return parentId;
  9615. }
  9616. /// <summary>
  9617. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9618. /// </summary>
  9619. /// <returns></returns>
  9620. [HttpPost]
  9621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9622. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9623. {
  9624. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9625. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9626. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9627. //验证编辑权限
  9628. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9629. //if (!isEdit) return Ok(JsonView(false, msg));
  9630. var permissions = new List<Grp_EnterExitCostPermission>();
  9631. foreach (var userId in dto.UserIds)
  9632. {
  9633. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9634. }
  9635. if (permissions.Any())
  9636. {
  9637. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9638. {
  9639. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9640. }
  9641. _sqlSugar.BeginTran();
  9642. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9643. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9644. if (result < 1)
  9645. {
  9646. _sqlSugar.RollbackTran();
  9647. return Ok(JsonView(false));
  9648. }
  9649. _sqlSugar.CommitTran();
  9650. return Ok(JsonView(true));
  9651. }
  9652. return Ok(JsonView(false));
  9653. }
  9654. /// <summary>
  9655. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9656. /// </summary>
  9657. /// <returns></returns>
  9658. [HttpPost]
  9659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9660. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9661. {
  9662. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9663. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9664. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9665. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9666. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9667. int id = dto.Id;
  9668. if (id <= 0) //add
  9669. {
  9670. //int provinceId = dto.ProvinceId;
  9671. int groupId = dto.DiId;
  9672. //if (provinceId < 1) provinceId = 122;
  9673. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9674. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9675. if (add < 1) return Ok(JsonView(false));
  9676. id = add;
  9677. }
  9678. else //update
  9679. {
  9680. ////验证编辑权限
  9681. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9682. //if (!isEdit) return Ok(JsonView(false, msg));
  9683. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9684. if (upd < 1) return Ok(JsonView(false));
  9685. }
  9686. #region 汇率变更时更改币种相关费用
  9687. var opDayCosts = new List<Grp_DayAndCost>();
  9688. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9689. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9690. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9691. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9692. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9693. .Select((dac, sd) => new
  9694. {
  9695. dac.Id,
  9696. dac.DiId,
  9697. CurrencyCode = sd.Name,
  9698. dac.Cost
  9699. })
  9700. .ToList();
  9701. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9702. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9703. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9704. .Select((dop, sd) => new
  9705. {
  9706. dop.Id,
  9707. dop.Diid,
  9708. CurrencyCode = sd.Name,
  9709. dop.Cost
  9710. })
  9711. .ToList();
  9712. if (dayCosts.Count > 0)
  9713. {
  9714. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9715. foreach (var dc in new_dayCosts)
  9716. {
  9717. var thisCurrency = dc.Key.ToUpper();
  9718. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9719. if (thisRate == 0.00M) continue;
  9720. foreach (var dcSub in dc)
  9721. {
  9722. opDayCosts.Add(new Grp_DayAndCost()
  9723. {
  9724. Id = dcSub.Id,
  9725. DiId = dcSub.DiId,
  9726. Cost = dcSub.Cost,
  9727. SubTotal = dcSub.Cost * thisRate,
  9728. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9729. });
  9730. }
  9731. }
  9732. if (opDayCosts.Count > 0)
  9733. {
  9734. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9735. }
  9736. }
  9737. if (dayOtherCosts.Count > 0)
  9738. {
  9739. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9740. foreach (var dc in new_dayOtherCosts)
  9741. {
  9742. var thisCurrency = dc.Key.ToUpper();
  9743. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9744. if (thisRate == 0.00M) continue;
  9745. foreach (var dcSub in dc)
  9746. {
  9747. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9748. {
  9749. Id = dcSub.Id,
  9750. Diid = dcSub.Diid,
  9751. Cost = dcSub.Cost,
  9752. SubTotal = dcSub.Cost * thisRate,
  9753. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9754. });
  9755. }
  9756. }
  9757. if (opDayOtherCosts.Count > 0)
  9758. {
  9759. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9760. }
  9761. }
  9762. #endregion
  9763. //消息通知
  9764. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9765. //汇率信息记录
  9766. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9767. return Ok(JsonView(new { parentId = id }));
  9768. }
  9769. /// <summary>
  9770. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9771. /// </summary>
  9772. /// <returns></returns>
  9773. [HttpPost]
  9774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9775. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9776. {
  9777. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9778. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9779. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9780. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9781. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9782. int id = dto.Id;
  9783. if (id <= 0) //add
  9784. {
  9785. checkboxInfo.CreateUserId = dto.CurrUserId;
  9786. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9787. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9788. if (add < 1) return Ok(JsonView(false));
  9789. }
  9790. else //update
  9791. {
  9792. ////验证编辑权限
  9793. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9794. //if (!isEdit) return Ok(JsonView(false, msg));
  9795. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9796. .UpdateColumns(x => new
  9797. {
  9798. x.ChoiceOne,
  9799. x.ChoiceTwo,
  9800. x.SumJJC,
  9801. x.SumGWC,
  9802. x.SumTDC,
  9803. x.ChoiceThree,
  9804. x.ChoiceFour,
  9805. x.ChoiceFive,
  9806. x.ChoiceSix,
  9807. x.OtherExpenses_Checked
  9808. })
  9809. .Where(x => x.Id == id)
  9810. .ExecuteCommandAsync();
  9811. if (upd < 1) return Ok(JsonView(false));
  9812. }
  9813. return Ok(JsonView(new { parentId = id }));
  9814. }
  9815. /// <summary>
  9816. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9817. /// </summary>
  9818. /// <returns></returns>
  9819. [HttpPost]
  9820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9821. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9822. {
  9823. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9824. // if (provinceId < 1) provinceId = 122;
  9825. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9827. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9828. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9829. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9830. var checkboxInfo = new Grp_EnterExitCost()
  9831. {
  9832. Id = id,
  9833. //ProvinceId = provinceId,
  9834. DiId = diId,
  9835. CreateUserId = currUserId
  9836. };
  9837. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9838. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9839. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9840. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9841. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9842. if (id <= 0) //add
  9843. {
  9844. checkboxInfo.CreateUserId = dto.CurrUserId;
  9845. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9846. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9847. if (add < 1) return Ok(JsonView(false));
  9848. }
  9849. else //update
  9850. {
  9851. ////验证编辑权限
  9852. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9853. //if (!isEdit) return Ok(JsonView(false, msg));
  9854. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9855. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9856. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9857. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9858. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9859. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9860. .Where(x => x.Id == id)
  9861. .ExecuteCommandAsync();
  9862. if (upd < 1) return Ok(JsonView(false));
  9863. }
  9864. return Ok(JsonView(new { parentId = id }));
  9865. }
  9866. /// <summary>
  9867. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9868. /// </summary>
  9869. /// <returns></returns>
  9870. [HttpPost]
  9871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9872. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9873. {
  9874. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9875. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9876. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9877. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9878. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9879. info.FirstItemRemark = dto.FirstItemRemark;
  9880. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9881. int id = dto.Id;
  9882. if (id <= 0) //add
  9883. {
  9884. info.CreateUserId = dto.CurrUserId;
  9885. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9886. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9887. if (add < 1) return Ok(JsonView(false));
  9888. id = add;
  9889. }
  9890. else //update
  9891. {
  9892. ////验证编辑权限
  9893. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9894. //if (!isEdit) return Ok(JsonView(false, msg));
  9895. var upd = await _sqlSugar.Updateable(info)
  9896. .UpdateColumns(x => new
  9897. {
  9898. x.ChoiceOne,
  9899. x.InsidePay,
  9900. x.VisaRemark,
  9901. x.Visa,
  9902. x.Service,
  9903. x.Safe,
  9904. x.Ticket,
  9905. x.HeSuan,
  9906. x.YiMiao,
  9907. x.FirstItemRemark
  9908. })
  9909. .Where(x => x.Id == id)
  9910. .ExecuteCommandAsync();
  9911. if (upd < 1) return Ok(JsonView(false));
  9912. }
  9913. //消息通知
  9914. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9915. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9916. }
  9917. /// <summary>
  9918. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9919. /// </summary>
  9920. /// <returns></returns>
  9921. [HttpPost]
  9922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9923. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9924. {
  9925. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9926. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9927. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9928. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9929. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9930. info.DiId = dto.DiId;
  9931. //info.ProvinceId = dto.ProvinceId;
  9932. info.OutsideJJPay = dto.OutsideJJPay;
  9933. info.OutsideGWPay = dto.OutsideGWPay;
  9934. info.OutsideTDPay = dto.OutsideTDPay;
  9935. info.AirJJ = dto.AirJJ;
  9936. info.AirGW = dto.AirGW;
  9937. info.AirTD = dto.AirTD;
  9938. info.CityTranffic = dto.CityTranffic;
  9939. info.TwoItemRemark = dto.TwoItemRemark;
  9940. info.SumJJC = dto.ChoiceTwoJJ;
  9941. info.SumGWC = dto.ChoiceTwoGW;
  9942. info.SumTDC = dto.ChoiceTwoTD;
  9943. int id = dto.Id;
  9944. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9945. if (id <= 0) //add
  9946. {
  9947. info.CreateUserId = dto.CurrUserId;
  9948. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9949. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9950. if (addId <= 0) return Ok(JsonView(false));
  9951. id = addId;
  9952. }
  9953. else //update
  9954. {
  9955. ////验证编辑权限
  9956. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9957. //if (!isEdit) return Ok(JsonView(false, msg));
  9958. var upd = await _sqlSugar.Updateable(info)
  9959. .UpdateColumns(x => new
  9960. {
  9961. x.SumJJC,
  9962. x.OutsideJJPay,
  9963. x.SumGWC,
  9964. x.OutsideGWPay,
  9965. x.SumTDC,
  9966. x.OutsideTDPay,
  9967. x.AirJJ,
  9968. x.AirGW,
  9969. x.AirTD,
  9970. x.CityTranffic,
  9971. x.TwoItemRemark
  9972. })
  9973. .Where(x => x.Id == id)
  9974. .ExecuteCommandAsync();
  9975. if (upd < 1) return Ok(JsonView(false));
  9976. }
  9977. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9978. gwcItemTotal = info.AirGW + info.CityTranffic;
  9979. tdcItemTotal = info.AirTD + info.CityTranffic;
  9980. //消息通知
  9981. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9982. return Ok(JsonView(new
  9983. {
  9984. parentId = id,
  9985. choiceTwoJJ = dto.ChoiceTwoJJ,
  9986. jjcItemTotal = jjcItemTotal,
  9987. choiceTwoGW = dto.ChoiceTwoGW,
  9988. gwcItemTotal = gwcItemTotal,
  9989. choiceTwoTD = dto.ChoiceTwoTD,
  9990. tdcItemTotal = tdcItemTotal
  9991. }));
  9992. }
  9993. /// <summary>
  9994. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9995. /// </summary>
  9996. /// <returns></returns>
  9997. [HttpPost]
  9998. [ApiExplorerSettings(IgnoreApi = true)]
  9999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10000. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10001. {
  10002. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10003. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10004. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10005. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10006. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10007. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10008. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10009. var infos = infos1.Select(x => new Grp_DayAndCost
  10010. {
  10011. Id = x.Id,
  10012. DiId = dto.DiId,
  10013. Type = dto.FeeType,
  10014. Days = x.Days,
  10015. NationalTravelFeeId = x.NationalTravelFeeId,
  10016. Cost = x.Cost,
  10017. Currency = x.Currency,
  10018. SubTotal = x.SubTotal,
  10019. CreateUserId = dto.CurrUserId
  10020. })
  10021. .ToList();
  10022. var adds = infos.Where(x => x.Id <= 0).ToList();
  10023. var upds = infos.Where(x => x.Id > 0).ToList();
  10024. if (adds.Count > 0)
  10025. {
  10026. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10027. if (add < 1) return Ok(JsonView(false));
  10028. }
  10029. if (upds.Count > 0)
  10030. {
  10031. var upd = await _sqlSugar.Updateable(adds)
  10032. .UpdateColumns(x => new
  10033. {
  10034. x.Days,
  10035. x.NationalTravelFeeId,
  10036. x.Cost,
  10037. x.Currency,
  10038. x.SubTotal
  10039. })
  10040. .WhereColumns(x => new { x.Id })
  10041. .ExecuteCommandAsync();
  10042. if (upd < 1) return Ok(JsonView(false));
  10043. }
  10044. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10045. //消息通知
  10046. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10047. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10048. return Ok(JsonView(new { itemTotal = itemTotal }));
  10049. }
  10050. /// <summary>
  10051. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10052. /// </summary>
  10053. /// <returns></returns>
  10054. [HttpPost]
  10055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10056. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10057. {
  10058. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10059. int subId = dto.SubId, feeType = dto.FeeType;
  10060. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10061. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10062. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10063. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10064. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10065. subInfo.Id = subId;
  10066. subInfo.DiId = dto.DiId;
  10067. if (feeType == 3) subInfo.Type = 1;
  10068. else if (feeType == 4) subInfo.Type = 2;
  10069. else if (feeType == 5) subInfo.Type = 3;
  10070. else if (feeType == 6) subInfo.Type = 4;
  10071. subInfo.CreateUserId = dto.CurrUserId;
  10072. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10073. if (parentId < 1) return Ok(JsonView(false));
  10074. //子表op
  10075. if (subId < 1)
  10076. {
  10077. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10078. if (subAdd < 1) return Ok(JsonView(false));
  10079. }
  10080. else
  10081. {
  10082. ////验证编辑权限
  10083. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10084. //if (!isEdit) return Ok(JsonView(false, msg));
  10085. var subUpd = await _sqlSugar.Updateable(subInfo)
  10086. .UpdateColumns(x => new
  10087. {
  10088. x.Days,
  10089. x.NationalTravelFeeId,
  10090. x.Cost,
  10091. x.Currency,
  10092. x.SubTotal
  10093. })
  10094. .WhereColumns(x => new { x.Id })
  10095. .ExecuteCommandAsync();
  10096. if (subUpd < 1) return Ok(JsonView(false));
  10097. }
  10098. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10099. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10100. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10101. }
  10102. /// <summary>
  10103. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10104. /// </summary>
  10105. /// <returns></returns>
  10106. [HttpPost]
  10107. [ApiExplorerSettings(IgnoreApi = true)]
  10108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10109. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10110. {
  10111. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10112. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10113. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10114. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10115. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10116. {
  10117. Id = x.Id,
  10118. Diid = dto.DiId,
  10119. SetDataId = x.SetDataId,
  10120. Index = x.Index,
  10121. Cost = x.Cost,
  10122. Currency = x.Currency,
  10123. SubTotal = x.SubTotal,
  10124. CreateUserId = dto.CurrUserId,
  10125. Remark = x.Remark
  10126. }).ToList();
  10127. var adds = infos.Where(x => x.Id <= 0).ToList();
  10128. var upds = infos.Where(x => x.Id > 0).ToList();
  10129. if (adds.Count > 0)
  10130. {
  10131. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10132. if (add < 1) return Ok(JsonView(false));
  10133. }
  10134. if (upds.Count > 0)
  10135. {
  10136. var upd = await _sqlSugar.Updateable(adds)
  10137. .UpdateColumns(x => new
  10138. {
  10139. x.Index,
  10140. x.SetDataId,
  10141. x.Cost,
  10142. x.Currency,
  10143. x.SubTotal,
  10144. x.Remark
  10145. })
  10146. .WhereColumns(x => new { x.Id })
  10147. .ExecuteCommandAsync();
  10148. if (upd < 1) return Ok(JsonView(false));
  10149. }
  10150. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10151. //消息通知
  10152. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10153. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10154. return Ok(JsonView(new { itemTotal = itemTotal }));
  10155. }
  10156. /// <summary>
  10157. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10158. /// </summary>
  10159. /// <returns></returns>
  10160. [HttpPost]
  10161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10162. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10163. {
  10164. int subId = dto.SubId;
  10165. int diId = dto.Diid;
  10166. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10167. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10168. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10169. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10170. subInfo.Id = subId;
  10171. subInfo.Diid = dto.Diid;
  10172. subInfo.CreateUserId = dto.CurrUserId;
  10173. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10174. if (parentId < 1) return Ok(JsonView(false));
  10175. #region 子表op
  10176. if (subId < 1)//add
  10177. {
  10178. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10179. if (subAdd < 1) return Ok(JsonView(false));
  10180. }
  10181. else //upd
  10182. {
  10183. ////验证编辑权限
  10184. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10185. //if (!isEdit) return Ok(JsonView(false, msg));
  10186. var subUpd = await _sqlSugar.Updateable(subInfo)
  10187. .UpdateColumns(x => new
  10188. {
  10189. x.Index,
  10190. x.SetDataId,
  10191. x.Cost,
  10192. x.Currency,
  10193. x.SubTotal,
  10194. x.Remark
  10195. })
  10196. .WhereColumns(x => new { x.Id })
  10197. .ExecuteCommandAsync();
  10198. if (subUpd < 1) return Ok(JsonView(false));
  10199. }
  10200. #endregion
  10201. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10202. //消息通知
  10203. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10204. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10205. }
  10206. /// <summary>
  10207. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10208. /// </summary>
  10209. /// <returns></returns>
  10210. [HttpPost]
  10211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10212. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10213. {
  10214. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10215. if (data.Code != 0)
  10216. {
  10217. return Ok(JsonView(false, data.Msg));
  10218. }
  10219. return Ok(JsonView(true, "操作成功!", data.Data));
  10220. }
  10221. /// <summary>
  10222. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10223. /// </summary>
  10224. /// <param name="dto"></param>
  10225. /// <returns></returns>
  10226. [HttpPost]
  10227. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10228. {
  10229. var data = new Grp_DayOtherPrice()
  10230. {
  10231. Id = dto.Id,
  10232. IsDel = 1,
  10233. DeleteUserId = dto.DeleteUserId,
  10234. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10235. };
  10236. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10237. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10238. return Ok(JsonView(false, "删除失败!"));
  10239. }
  10240. #endregion
  10241. #endregion
  10242. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10243. /// <summary>
  10244. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10245. /// </summary>
  10246. /// <returns></returns>
  10247. [HttpGet]
  10248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10249. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10250. {
  10251. var provData = await _groupRepository.ProvinceBasicSource();
  10252. return Ok(JsonView(true, "查询成功!", provData));
  10253. }
  10254. /// <summary>
  10255. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10256. /// </summary>
  10257. /// <returns></returns>
  10258. [HttpPost]
  10259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10260. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10261. {
  10262. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10263. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10264. RefAsync<int> total = 0;
  10265. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10266. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10267. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10268. .Select(x => new
  10269. {
  10270. Id = x.Id,
  10271. DraftName = x.DraftName,
  10272. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10273. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10274. .Any()
  10275. })
  10276. .OrderByDescending(x => x.Id)
  10277. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10278. return Ok(JsonView(true, "查询成功!", data, total));
  10279. }
  10280. /// <summary>
  10281. /// 出入境费用-草稿 移动端
  10282. /// 获取币种基础数据(含逻辑处理)
  10283. /// </summary>
  10284. /// <returns></returns>
  10285. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10286. {
  10287. return await GeneralMethod.EnterExitCostInitRate();
  10288. }
  10289. /// <summary>
  10290. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10291. /// </summary>
  10292. /// <returns></returns>
  10293. [HttpPost]
  10294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10295. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10296. {
  10297. //验证城市归属并给默认值
  10298. int provinceId = dto.ProvinceId;
  10299. if (provinceId < 1) provinceId = 122;
  10300. var dataSource = await _sqlSugar
  10301. .Queryable<Sys_SetData>()
  10302. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10303. .ToListAsync();
  10304. //三公费用-Word明细类型
  10305. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10306. .Select(x => new SetDataInfoView
  10307. {
  10308. Id = x.Id,
  10309. Name = x.Name,
  10310. Remark = x.Remark
  10311. })
  10312. .ToList();
  10313. //三公费用-Excel明细类型
  10314. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10315. .Select(x => new SetDataInfoView
  10316. {
  10317. Id = x.Id,
  10318. Name = x.Name,
  10319. Remark = x.Remark
  10320. })
  10321. .ToList();
  10322. //默认币种显示
  10323. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10324. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10325. return Ok(JsonView(true, "查询成功!", new
  10326. {
  10327. WordTypeData = wordTypeData,
  10328. ExcelTypeData = excelTypeData,
  10329. CurrencyInit = _currencyInfos,
  10330. viewPermissionData = viewPermissionData
  10331. }));
  10332. }
  10333. /// <summary>
  10334. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10335. /// </summary>
  10336. /// <returns></returns>
  10337. [HttpPost]
  10338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10339. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10340. {
  10341. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10342. RefAsync<int> total = 0;
  10343. int diId = 0;
  10344. var status = int.TryParse(dto.GroupName, out diId);
  10345. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10346. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10347. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10348. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10349. .OrderByDescending(x => x.VisitStartDate)
  10350. .Select(x => new
  10351. {
  10352. Id = x.Id,
  10353. GroupName = x.TeamName
  10354. })
  10355. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10356. return Ok(JsonView(true, "查询成功!", data, total));
  10357. }
  10358. /// <summary>
  10359. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10360. /// </summary>
  10361. /// <returns></returns>
  10362. [HttpPost]
  10363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10364. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10365. {
  10366. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10367. RefAsync<int> total = 0;
  10368. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10369. .Where(x => x.IsDel == 0 && x.STid == 66)
  10370. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10371. .Select(x => new
  10372. {
  10373. id = x.Id,
  10374. name = x.Name,
  10375. remark = x.Remark,
  10376. })
  10377. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10378. return Ok(JsonView(true, "查询成功!", data, total));
  10379. }
  10380. /// <summary>
  10381. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10382. /// </summary>
  10383. /// <returns></returns>
  10384. [HttpPost]
  10385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10386. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10387. {
  10388. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10389. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10390. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10391. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10392. var groupOtherRateData = groupRateData.TeamRates;
  10393. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10394. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10395. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10396. groupOtherRateData = groupOtherRateData
  10397. .Select(x => new TeamRateDescAddCurrencyIdView
  10398. {
  10399. CurrencyId = x.CurrencyId,
  10400. CurrencyName = x.CurrencyName,
  10401. CurrencyCode = x.CurrencyCode,
  10402. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10403. }).ToList();
  10404. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10405. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10406. }
  10407. /// <summary>
  10408. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10409. /// </summary>
  10410. /// <returns></returns>
  10411. [HttpPost]
  10412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10413. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10414. {
  10415. int portType = dto.PortType;
  10416. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10417. var tipsData = new List<int>() { 1, 2, 3 };
  10418. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10419. if (dto.TipsType == 1)
  10420. {
  10421. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10422. }
  10423. else if (dto.TipsType == 2)
  10424. {
  10425. if (portType == 2)
  10426. {
  10427. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10428. }
  10429. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10430. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10431. .Select(x => x.NationalTravelFeeId)
  10432. .Distinct()
  10433. .ToListAsync();
  10434. if (portType == 2)
  10435. {
  10436. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10437. }
  10438. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10439. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10440. .Select(x => x.Country)
  10441. .Distinct()
  10442. .ToArrayAsync();
  10443. if (portType == 2)
  10444. {
  10445. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10446. }
  10447. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10448. return Ok(JsonView(true, "查询成功!", new
  10449. {
  10450. totalAmt = totalAmt,
  10451. remark = remark
  10452. }));
  10453. }
  10454. else if (dto.TipsType == 3)
  10455. {
  10456. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10457. }
  10458. return Ok(JsonView(false));
  10459. }
  10460. /// <summary>
  10461. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10462. /// </summary>
  10463. /// <returns></returns>
  10464. [HttpPost]
  10465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10466. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10467. {
  10468. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10469. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10470. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10471. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10472. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10473. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10474. var info = new Grp_EnterExitCostDraft()
  10475. {
  10476. ProvinceId = dto.ProvinceId,
  10477. DraftName = dto.DraftName,
  10478. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10479. CreateUserId = dto.CurrUserId
  10480. };
  10481. _sqlSugar.BeginTran();
  10482. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10483. if (draftId < 1)
  10484. {
  10485. _sqlSugar.RollbackTran();
  10486. return Ok(JsonView(false, "草稿创建失败!"));
  10487. }
  10488. //添加默认权限
  10489. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10490. _sqlSugar.CommitTran();
  10491. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10492. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10493. mobileInfo.Id = draftId;
  10494. mobileInfo.DraftName = dto.DraftName;
  10495. mobileInfo.Currencys = rateInfos;
  10496. mobileInfo.IsAssignPerm = assignPerm;
  10497. return Ok(JsonView(mobileInfo));
  10498. }
  10499. /// <summary>
  10500. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10501. /// </summary>
  10502. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10503. /// <summary>
  10504. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10505. /// </summary>
  10506. /// <returns></returns>
  10507. [HttpPost]
  10508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10509. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10510. {
  10511. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10512. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10513. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10514. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10515. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10516. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10517. //验证查看编辑权限
  10518. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10519. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10520. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10521. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10522. mobileInfo.IsAssignPerm = assignPerm;
  10523. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10524. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10525. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10526. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10527. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10528. {
  10529. ParentId = dac.ParentId,
  10530. SubId = dac.Id,
  10531. Type = dac.Type,
  10532. Days = dac.Days,
  10533. NationalTravelFeeId = dac.NationalTravelFeeId,
  10534. Arae = $"{ntf.Country}-{ntf.City}",
  10535. Cost = dac.Cost,
  10536. Currency = dac.Currency,
  10537. CurrencyName = sd.Name,
  10538. SubTotal = dac.SubTotal,
  10539. })
  10540. .ToList();
  10541. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10542. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10543. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10544. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10545. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10546. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10547. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10548. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10549. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10550. //其他款项
  10551. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10552. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10553. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10554. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10555. .OrderBy((dop, sd1, sd2) => dop.Index)
  10556. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10557. {
  10558. ParentId = dop.ParentId,
  10559. SubId = dop.Id,
  10560. Index = dop.Index,
  10561. SetDataId = dop.SetDataId,
  10562. SetDataName = sd1.Name,
  10563. Cost = dop.Cost,
  10564. Currency = dop.Currency,
  10565. CurrencyName = sd2.Remark,
  10566. SubTotal = dop.SubTotal,
  10567. Remark = dop.Remark,
  10568. })
  10569. .ToArray();
  10570. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10571. return Ok(mobileInfo);
  10572. }
  10573. /// <summary>
  10574. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10575. /// </summary>
  10576. /// <returns></returns>
  10577. [HttpPost]
  10578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10579. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10580. {
  10581. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10582. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10583. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10584. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10585. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10586. //验证查看编辑权限
  10587. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10588. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10589. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10590. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10591. var subType = dto.SubType;
  10592. if (subType == 1) //1:境内费用
  10593. {
  10594. var oneData = new ChoiceOneMobileSubInfoView()
  10595. {
  10596. Id = eecInfo.Id,
  10597. ChoiceOne = eecInfo.ChoiceOne,
  10598. ChoiceOneTotalCost = eecInfo.InsidePay,
  10599. Visa = eecInfo.Visa,
  10600. VisaRemark = eecInfo.VisaRemark,
  10601. YiMiao = eecInfo.YiMiao,
  10602. HeSuan = eecInfo.HeSuan,
  10603. Service = eecInfo.Service,
  10604. Ticket = eecInfo.Ticket,
  10605. Safe = eecInfo.Safe,
  10606. FirstItemRemark = eecInfo.FirstItemRemark
  10607. };
  10608. return Ok(JsonView(oneData));
  10609. }
  10610. else if (subType == 2) //2:国际旅费
  10611. {
  10612. var twoData = new ChoiceTwoMobileSubInfoView()
  10613. {
  10614. Id = eecInfo.Id,
  10615. ChoiceTwoJJ = eecInfo.SumJJC,
  10616. OutsideJJPay = eecInfo.OutsideJJPay,
  10617. ChoiceTwoGW = eecInfo.SumGWC,
  10618. OutsideGWPay = eecInfo.OutsideGWPay,
  10619. ChoiceTwoTD = eecInfo.SumTDC,
  10620. OutsideTDPay = eecInfo.OutsideTDPay,
  10621. AirJJ = eecInfo.AirJJ,
  10622. AirGW = eecInfo.AirGW,
  10623. AirTD = eecInfo.AirTD,
  10624. CityTranffic = eecInfo.CityTranffic,
  10625. TwoItemRemark = eecInfo.TwoItemRemark
  10626. };
  10627. return Ok(JsonView(twoData));
  10628. }
  10629. else if (subType == 3) //3:住宿费
  10630. {
  10631. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10632. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10633. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10634. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10635. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10636. {
  10637. ParentId = dac.ParentId,
  10638. SubId = dac.Id,
  10639. Type = dac.Type,
  10640. Days = dac.Days,
  10641. NationalTravelFeeId = dac.NationalTravelFeeId,
  10642. Arae = $"{ntf.Country}-{ntf.City}",
  10643. Cost = dac.Cost,
  10644. Currency = dac.Currency,
  10645. CurrencyName = sd.Name,
  10646. SubTotal = dac.SubTotal,
  10647. })
  10648. .ToArray();
  10649. var data = new ChoiceDraftMobileSubInfo3To6View()
  10650. {
  10651. ParentId = eecInfo.Id,
  10652. Choice = eecInfo.ChoiceThree,
  10653. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10654. Details = dayAndCostDatas
  10655. };
  10656. return Ok(JsonView(data));
  10657. }
  10658. else if (subType == 4) //4:伙食费
  10659. {
  10660. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10661. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10662. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10663. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10664. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10665. {
  10666. ParentId = dac.ParentId,
  10667. SubId = dac.Id,
  10668. Type = dac.Type,
  10669. Days = dac.Days,
  10670. NationalTravelFeeId = dac.NationalTravelFeeId,
  10671. Arae = $"{ntf.Country}-{ntf.City}",
  10672. Cost = dac.Cost,
  10673. Currency = dac.Currency,
  10674. CurrencyName = sd.Name,
  10675. SubTotal = dac.SubTotal,
  10676. })
  10677. .ToArray();
  10678. var data = new ChoiceDraftMobileSubInfo3To6View()
  10679. {
  10680. ParentId = eecInfo.Id,
  10681. Choice = eecInfo.ChoiceFour,
  10682. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10683. Details = dayAndCostDatas
  10684. };
  10685. return Ok(JsonView(data));
  10686. }
  10687. else if (subType == 5) //5:公杂费
  10688. {
  10689. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10690. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10691. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10692. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10693. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10694. {
  10695. ParentId = dac.ParentId,
  10696. SubId = dac.Id,
  10697. Type = dac.Type,
  10698. Days = dac.Days,
  10699. NationalTravelFeeId = dac.NationalTravelFeeId,
  10700. Arae = $"{ntf.Country}-{ntf.City}",
  10701. Cost = dac.Cost,
  10702. Currency = dac.Currency,
  10703. CurrencyName = sd.Name,
  10704. SubTotal = dac.SubTotal,
  10705. })
  10706. .ToArray();
  10707. var data = new ChoiceDraftMobileSubInfo3To6View()
  10708. {
  10709. ParentId = eecInfo.Id,
  10710. Choice = eecInfo.ChoiceFive,
  10711. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10712. Details = dayAndCostDatas
  10713. };
  10714. return Ok(JsonView(data));
  10715. }
  10716. else if (subType == 6) //6:培训费
  10717. {
  10718. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10719. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10720. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10721. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10722. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10723. {
  10724. ParentId = dac.ParentId,
  10725. SubId = dac.Id,
  10726. Type = dac.Type,
  10727. Days = dac.Days,
  10728. NationalTravelFeeId = dac.NationalTravelFeeId,
  10729. Arae = $"{ntf.Country}-{ntf.City}",
  10730. Cost = dac.Cost,
  10731. Currency = dac.Currency,
  10732. CurrencyName = sd.Name,
  10733. SubTotal = dac.SubTotal,
  10734. })
  10735. .ToArray();
  10736. var data = new ChoiceDraftMobileSubInfo3To6View()
  10737. {
  10738. ParentId = eecInfo.Id,
  10739. Choice = eecInfo.ChoiceSix,
  10740. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10741. Details = dayAndCostDatas
  10742. };
  10743. return Ok(JsonView(data));
  10744. }
  10745. else if (subType == 7) //7:其他
  10746. {
  10747. //其他款项
  10748. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10749. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10750. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10751. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10752. .OrderBy((dop, sd1, sd2) => dop.Index)
  10753. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10754. {
  10755. ParentId = dop.ParentId,
  10756. SubId = dop.Id,
  10757. Index = dop.Index,
  10758. SetDataId = dop.SetDataId,
  10759. SetDataName = sd1.Name,
  10760. Cost = dop.Cost,
  10761. Currency = dop.Currency,
  10762. CurrencyName = sd2.Name,
  10763. SubTotal = dop.SubTotal,
  10764. Remark = dop.Remark,
  10765. })
  10766. .ToArray();
  10767. var data = new ChoiceSevenDraftMobileSubInfoView()
  10768. {
  10769. ParentId = eecInfo.Id,
  10770. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10771. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10772. Details = otherData
  10773. };
  10774. return Ok(JsonView(data));
  10775. }
  10776. return Ok(JsonView(false));
  10777. }
  10778. #region op
  10779. /// <summary>
  10780. /// 移动端更新费用消息通知
  10781. /// </summary>
  10782. /// <param name="draftId"></param>
  10783. /// <param name="id"></param>
  10784. /// <param name="currUserId"></param>
  10785. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10786. {
  10787. try
  10788. {
  10789. ////生成默认文件pdf并且通知人员
  10790. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10791. //{
  10792. // DiId = draftId,
  10793. // ExportType = 1,
  10794. // SubTypeId = 1005
  10795. //}, "pdf");
  10796. ////发送通知
  10797. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10798. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10799. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10800. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10801. ////汇率信息记录
  10802. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10803. }
  10804. catch (Exception ex)
  10805. {
  10806. //记录日志
  10807. throw;
  10808. }
  10809. }
  10810. /// <summary>
  10811. /// 验证出入境费用数据是否存在
  10812. /// 不存在添加
  10813. /// </summary>
  10814. /// <param name="draftId"></param>
  10815. /// <param name="currUserId"></param>
  10816. /// <returns></returns>
  10817. /// <exception cref="CustomException"></exception>
  10818. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10819. {
  10820. var parentId = 0;
  10821. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10822. if (info != null) parentId = info.Id;
  10823. else
  10824. {
  10825. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10826. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10827. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10828. parentId = addId;
  10829. }
  10830. return parentId;
  10831. }
  10832. /// <summary>
  10833. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10834. /// </summary>
  10835. /// <returns></returns>
  10836. [HttpPost]
  10837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10838. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10839. {
  10840. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10841. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10842. //验证查看权限
  10843. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10844. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10845. var userIds = await _sqlSugar
  10846. .Queryable<Grp_EnterExitCostDraftPermission>()
  10847. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10848. .Select(x => x.UserId)
  10849. .ToArrayAsync();
  10850. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10851. var perUsersView = new List<dynamic>();
  10852. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10853. var viewPermissionData = new List<PermissionViewUserview>();
  10854. if (feeBasePerm.Any())
  10855. {
  10856. foreach (var item in feeBasePerm)
  10857. {
  10858. if (item.Users.Any())
  10859. {
  10860. viewPermissionData.AddRange(item.Users);
  10861. }
  10862. }
  10863. }
  10864. foreach (var item in perUsers)
  10865. {
  10866. bool isView1 = false;
  10867. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10868. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10869. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10870. }
  10871. return Ok(JsonView(perUsersView));
  10872. }
  10873. /// <summary>
  10874. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10875. /// </summary>
  10876. /// <returns></returns>
  10877. [HttpPost]
  10878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10879. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10880. {
  10881. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10882. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10883. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10884. //验证查看编辑权限
  10885. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10886. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10887. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10888. foreach (var userId in dto.UserIds)
  10889. {
  10890. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10891. }
  10892. if (permissions.Any())
  10893. {
  10894. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10895. {
  10896. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10897. }
  10898. _sqlSugar.BeginTran();
  10899. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10900. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10901. if (result < 1)
  10902. {
  10903. _sqlSugar.RollbackTran();
  10904. return Ok(JsonView(false));
  10905. }
  10906. _sqlSugar.CommitTran();
  10907. return Ok(JsonView(true));
  10908. }
  10909. return Ok(JsonView(false));
  10910. }
  10911. /// <summary>
  10912. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10913. /// </summary>
  10914. /// <returns></returns>
  10915. [HttpPost]
  10916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10917. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10918. {
  10919. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10920. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10921. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10922. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10923. int id = dto.DraftId;
  10924. if (id <= 0) //add
  10925. {
  10926. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10927. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10928. if (add < 1) return Ok(JsonView(false));
  10929. id = add;
  10930. }
  10931. else //update
  10932. {
  10933. //验证查看编辑权限
  10934. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10935. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10936. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10937. if (upd < 1) return Ok(JsonView(false));
  10938. }
  10939. return Ok(JsonView(new { parentId = id }));
  10940. }
  10941. /// <summary>
  10942. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10943. /// </summary>
  10944. /// <returns></returns>
  10945. [HttpPost]
  10946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10947. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10948. {
  10949. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10950. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10951. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10952. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10953. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10954. int id = dto.DraftId;
  10955. if (id <= 0) //add
  10956. {
  10957. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10958. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10959. if (add < 1) return Ok(JsonView(false));
  10960. id = add;
  10961. }
  10962. else //update
  10963. {
  10964. //验证查看编辑权限
  10965. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10966. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10967. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10968. if (upd < 1) return Ok(JsonView(false));
  10969. }
  10970. #region 汇率变更时更改币种相关费用
  10971. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10972. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10973. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10974. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10975. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10976. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10977. .Select((dac, sd) => new
  10978. {
  10979. dac.Id,
  10980. dac.ParentId,
  10981. CurrencyCode = sd.Name,
  10982. dac.Cost
  10983. })
  10984. .ToList();
  10985. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10986. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10987. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10988. .Select((dop, sd) => new
  10989. {
  10990. dop.Id,
  10991. dop.ParentId,
  10992. CurrencyCode = sd.Name,
  10993. dop.Cost
  10994. })
  10995. .ToList();
  10996. if (dayCosts.Count > 0)
  10997. {
  10998. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10999. foreach (var dc in new_dayCosts)
  11000. {
  11001. var thisCurrency = dc.Key.ToUpper();
  11002. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11003. if (thisRate == 0.00M) continue;
  11004. foreach (var dcSub in dc)
  11005. {
  11006. opDayCosts.Add(new Grp_DayAndCostDraft()
  11007. {
  11008. Id = dcSub.Id,
  11009. ParentId = dcSub.ParentId,
  11010. Cost = dcSub.Cost,
  11011. SubTotal = dcSub.Cost * thisRate,
  11012. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11013. });
  11014. }
  11015. }
  11016. if (opDayCosts.Count > 0)
  11017. {
  11018. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11019. }
  11020. }
  11021. if (dayOtherCosts.Count > 0)
  11022. {
  11023. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11024. foreach (var dc in new_dayOtherCosts)
  11025. {
  11026. var thisCurrency = dc.Key.ToUpper();
  11027. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11028. if (thisRate == 0.00M) continue;
  11029. foreach (var dcSub in dc)
  11030. {
  11031. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11032. {
  11033. Id = dcSub.Id,
  11034. ParentId = dcSub.ParentId,
  11035. Cost = dcSub.Cost,
  11036. SubTotal = dcSub.Cost * thisRate,
  11037. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11038. });
  11039. }
  11040. }
  11041. if (opDayOtherCosts.Count > 0)
  11042. {
  11043. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11044. }
  11045. }
  11046. #endregion
  11047. ////消息通知
  11048. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11049. ////汇率信息记录
  11050. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11051. return Ok(JsonView(new { parentId = id }));
  11052. }
  11053. /// <summary>
  11054. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11055. /// </summary>
  11056. /// <returns></returns>
  11057. [HttpPost]
  11058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11059. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11060. {
  11061. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11062. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11063. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11064. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11065. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11066. int id = dto.DraftId;
  11067. if (id <= 0) //add
  11068. {
  11069. checkboxInfo.ProvinceId = dto.ProvinceId;
  11070. checkboxInfo.CreateUserId = dto.CurrUserId;
  11071. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11072. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11073. if (add < 1) return Ok(JsonView(false));
  11074. }
  11075. else //update
  11076. {
  11077. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11078. .UpdateColumns(x => new
  11079. {
  11080. x.ChoiceOne,
  11081. x.ChoiceTwo,
  11082. x.SumJJC,
  11083. x.SumGWC,
  11084. x.SumTDC,
  11085. x.ChoiceThree,
  11086. x.ChoiceFour,
  11087. x.ChoiceFive,
  11088. x.ChoiceSix,
  11089. x.OtherExpenses_Checked
  11090. })
  11091. .Where(x => x.Id == id)
  11092. .ExecuteCommandAsync();
  11093. if (upd < 1) return Ok(JsonView(false));
  11094. }
  11095. return Ok(JsonView(new { parentId = id }));
  11096. }
  11097. /// <summary>
  11098. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11099. /// </summary>
  11100. /// <returns></returns>
  11101. [HttpPost]
  11102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11103. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11104. {
  11105. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11106. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11107. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11108. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11109. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11110. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11111. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11112. var checkboxInfo = new Grp_EnterExitCostDraft()
  11113. {
  11114. Id = draftId,
  11115. ProvinceId = dto.ProvinceId,
  11116. CreateUserId = currUserId
  11117. };
  11118. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11119. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11120. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11121. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11122. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11123. if (draftId <= 0) //add
  11124. {
  11125. checkboxInfo.CreateUserId = dto.CurrUserId;
  11126. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11127. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11128. if (add < 1) return Ok(JsonView(false));
  11129. }
  11130. else //update
  11131. {
  11132. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11133. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11134. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11135. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11136. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11137. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11138. .Where(x => x.Id == draftId)
  11139. .ExecuteCommandAsync();
  11140. if (upd < 1) return Ok(JsonView(false));
  11141. }
  11142. return Ok(JsonView(new { parentId = draftId }));
  11143. }
  11144. /// <summary>
  11145. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11146. /// </summary>
  11147. /// <returns></returns>
  11148. [HttpPost]
  11149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11150. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11151. {
  11152. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11153. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11154. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11155. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11156. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11157. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11158. info.ProvinceId = dto.ProvinceId;
  11159. info.FirstItemRemark = dto.FirstItemRemark;
  11160. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11161. if (id <= 0) //add
  11162. {
  11163. info.CreateUserId = dto.CurrUserId;
  11164. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11165. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11166. if (add < 1) return Ok(JsonView(false));
  11167. id = add;
  11168. }
  11169. else //update
  11170. {
  11171. var upd = await _sqlSugar.Updateable(info)
  11172. .UpdateColumns(x => new
  11173. {
  11174. x.ChoiceOne,
  11175. x.InsidePay,
  11176. x.VisaRemark,
  11177. x.Visa,
  11178. x.Service,
  11179. x.Safe,
  11180. x.Ticket,
  11181. x.HeSuan,
  11182. x.YiMiao,
  11183. x.FirstItemRemark
  11184. })
  11185. .Where(x => x.Id == id)
  11186. .ExecuteCommandAsync();
  11187. if (upd < 1) return Ok(JsonView(false));
  11188. }
  11189. ////消息通知
  11190. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11191. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11192. }
  11193. /// <summary>
  11194. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11195. /// </summary>
  11196. /// <returns></returns>
  11197. [HttpPost]
  11198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11199. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11200. {
  11201. int id = dto.DraftId;
  11202. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11203. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11204. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11205. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11206. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11207. info.ProvinceId = dto.ProvinceId;
  11208. info.OutsideJJPay = dto.OutsideJJPay;
  11209. info.OutsideGWPay = dto.OutsideGWPay;
  11210. info.OutsideTDPay = dto.OutsideTDPay;
  11211. info.AirJJ = dto.AirJJ;
  11212. info.AirGW = dto.AirGW;
  11213. info.AirTD = dto.AirTD;
  11214. info.CityTranffic = dto.CityTranffic;
  11215. info.TwoItemRemark = dto.TwoItemRemark;
  11216. info.SumJJC = dto.ChoiceTwoJJ;
  11217. info.SumGWC = dto.ChoiceTwoGW;
  11218. info.SumTDC = dto.ChoiceTwoTD;
  11219. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11220. if (id <= 0) //add
  11221. {
  11222. info.CreateUserId = dto.CurrUserId;
  11223. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11224. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11225. if (addId <= 0) return Ok(JsonView(false));
  11226. id = addId;
  11227. }
  11228. else //update
  11229. {
  11230. var upd = await _sqlSugar.Updateable(info)
  11231. .UpdateColumns(x => new
  11232. {
  11233. x.SumJJC,
  11234. x.OutsideJJPay,
  11235. x.SumGWC,
  11236. x.OutsideGWPay,
  11237. x.SumTDC,
  11238. x.OutsideTDPay,
  11239. x.AirJJ,
  11240. x.AirGW,
  11241. x.AirTD,
  11242. x.CityTranffic,
  11243. x.TwoItemRemark
  11244. })
  11245. .Where(x => x.Id == id)
  11246. .ExecuteCommandAsync();
  11247. if (upd < 1) return Ok(JsonView(false));
  11248. }
  11249. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11250. gwcItemTotal = info.AirGW + info.CityTranffic;
  11251. tdcItemTotal = info.AirTD + info.CityTranffic;
  11252. ////消息通知
  11253. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11254. return Ok(JsonView(new
  11255. {
  11256. parentId = id,
  11257. choiceTwoJJ = dto.ChoiceTwoJJ,
  11258. jjcItemTotal = jjcItemTotal,
  11259. choiceTwoGW = dto.ChoiceTwoGW,
  11260. gwcItemTotal = gwcItemTotal,
  11261. choiceTwoTD = dto.ChoiceTwoTD,
  11262. tdcItemTotal = tdcItemTotal
  11263. }));
  11264. }
  11265. /// <summary>
  11266. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11267. /// </summary>
  11268. /// <returns></returns>
  11269. [HttpPost]
  11270. [ApiExplorerSettings(IgnoreApi = true)]
  11271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11272. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11273. {
  11274. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11275. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11276. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11277. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11278. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11279. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11280. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11281. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11282. {
  11283. Id = x.Id,
  11284. ParentId = dto.DraftId,
  11285. Type = dto.FeeType,
  11286. Days = x.Days,
  11287. NationalTravelFeeId = x.NationalTravelFeeId,
  11288. Cost = x.Cost,
  11289. Currency = x.Currency,
  11290. SubTotal = x.SubTotal,
  11291. CreateUserId = dto.CurrUserId
  11292. })
  11293. .ToList();
  11294. var adds = infos.Where(x => x.Id <= 0).ToList();
  11295. var upds = infos.Where(x => x.Id > 0).ToList();
  11296. if (adds.Count > 0)
  11297. {
  11298. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11299. if (add < 1) return Ok(JsonView(false));
  11300. }
  11301. if (upds.Count > 0)
  11302. {
  11303. var upd = await _sqlSugar.Updateable(adds)
  11304. .UpdateColumns(x => new
  11305. {
  11306. x.Days,
  11307. x.NationalTravelFeeId,
  11308. x.Cost,
  11309. x.Currency,
  11310. x.SubTotal
  11311. })
  11312. .WhereColumns(x => new { x.Id })
  11313. .ExecuteCommandAsync();
  11314. if (upd < 1) return Ok(JsonView(false));
  11315. }
  11316. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11317. ////消息通知
  11318. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11319. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11320. return Ok(JsonView(new { itemTotal = itemTotal }));
  11321. }
  11322. /// <summary>
  11323. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11324. /// </summary>
  11325. /// <returns></returns>
  11326. [HttpPost]
  11327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11328. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11329. {
  11330. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11331. int subId = dto.SubId, feeType = dto.FeeType;
  11332. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11333. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11334. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11335. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11336. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11337. subInfo.Id = subId;
  11338. subInfo.ParentId = dto.DraftId;
  11339. if (feeType == 3) subInfo.Type = 1;
  11340. else if (feeType == 4) subInfo.Type = 2;
  11341. else if (feeType == 5) subInfo.Type = 3;
  11342. else if (feeType == 6) subInfo.Type = 4;
  11343. subInfo.CreateUserId = dto.CurrUserId;
  11344. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11345. if (parentId < 1) return Ok(JsonView(false));
  11346. //子表op
  11347. if (subId < 1)
  11348. {
  11349. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11350. if (subAdd < 1) return Ok(JsonView(false));
  11351. }
  11352. else
  11353. {
  11354. var subUpd = await _sqlSugar.Updateable(subInfo)
  11355. .UpdateColumns(x => new
  11356. {
  11357. x.Days,
  11358. x.NationalTravelFeeId,
  11359. x.Cost,
  11360. x.Currency,
  11361. x.SubTotal
  11362. })
  11363. .WhereColumns(x => new { x.Id })
  11364. .ExecuteCommandAsync();
  11365. if (subUpd < 1) return Ok(JsonView(false));
  11366. }
  11367. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11368. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11369. }
  11370. /// <summary>
  11371. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11372. /// </summary>
  11373. /// <returns></returns>
  11374. [HttpPost]
  11375. [ApiExplorerSettings(IgnoreApi = true)]
  11376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11377. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11378. {
  11379. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11380. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11381. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11382. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11383. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11384. {
  11385. Id = x.Id,
  11386. ParentId = dto.DraftId,
  11387. SetDataId = x.SetDataId,
  11388. Index = x.Index,
  11389. Cost = x.Cost,
  11390. Currency = x.Currency,
  11391. SubTotal = x.SubTotal,
  11392. CreateUserId = dto.CurrUserId,
  11393. Remark = x.Remark
  11394. }).ToList();
  11395. var adds = infos.Where(x => x.Id <= 0).ToList();
  11396. var upds = infos.Where(x => x.Id > 0).ToList();
  11397. if (adds.Count > 0)
  11398. {
  11399. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11400. if (add < 1) return Ok(JsonView(false));
  11401. }
  11402. if (upds.Count > 0)
  11403. {
  11404. var upd = await _sqlSugar.Updateable(adds)
  11405. .UpdateColumns(x => new
  11406. {
  11407. x.Index,
  11408. x.SetDataId,
  11409. x.Cost,
  11410. x.Currency,
  11411. x.SubTotal,
  11412. x.Remark
  11413. })
  11414. .WhereColumns(x => new { x.Id })
  11415. .ExecuteCommandAsync();
  11416. if (upd < 1) return Ok(JsonView(false));
  11417. }
  11418. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11419. //消息通知
  11420. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11421. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11422. return Ok(JsonView(new { itemTotal = itemTotal }));
  11423. }
  11424. /// <summary>
  11425. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11426. /// </summary>
  11427. /// <returns></returns>
  11428. [HttpPost]
  11429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11430. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11431. {
  11432. int subId = dto.SubId, id = dto.DraftId;
  11433. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11434. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11435. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11436. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11437. subInfo.Id = subId;
  11438. subInfo.ParentId = id;
  11439. subInfo.CreateUserId = dto.CurrUserId;
  11440. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11441. if (parentId < 1) return Ok(JsonView(false));
  11442. #region 子表op
  11443. if (subId < 1)//add
  11444. {
  11445. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11446. if (subAdd < 1) return Ok(JsonView(false));
  11447. }
  11448. else //upd
  11449. {
  11450. var subUpd = await _sqlSugar.Updateable(subInfo)
  11451. .UpdateColumns(x => new
  11452. {
  11453. x.Index,
  11454. x.SetDataId,
  11455. x.Cost,
  11456. x.Currency,
  11457. x.SubTotal,
  11458. x.Remark
  11459. })
  11460. .WhereColumns(x => new { x.Id })
  11461. .ExecuteCommandAsync();
  11462. if (subUpd < 1) return Ok(JsonView(false));
  11463. }
  11464. #endregion
  11465. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11466. ////消息通知
  11467. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11468. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11469. }
  11470. /// <summary>
  11471. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11472. /// </summary>
  11473. /// <returns></returns>
  11474. [HttpPost]
  11475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11476. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11477. {
  11478. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11479. if (data.Code != 0)
  11480. {
  11481. return Ok(JsonView(false, data.Msg));
  11482. }
  11483. return Ok(JsonView(true, "操作成功!", data.Data));
  11484. }
  11485. /// <summary>
  11486. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11487. /// </summary>
  11488. /// <param name="dto"></param>
  11489. /// <returns></returns>
  11490. [HttpPost]
  11491. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11492. {
  11493. var data = new Grp_DayOtherPriceDraft()
  11494. {
  11495. Id = dto.Id,
  11496. IsDel = 1,
  11497. DeleteUserId = dto.DeleteUserId,
  11498. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11499. };
  11500. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11501. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11502. return Ok(JsonView(false, "删除失败!"));
  11503. }
  11504. #endregion
  11505. #endregion
  11506. #region 团组经理模块 出入境费用报价表
  11507. /// <summary>
  11508. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11509. /// </summary>
  11510. /// <returns></returns>
  11511. [HttpPost]
  11512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11513. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11514. {
  11515. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11516. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11517. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11518. initRates.Insert(0, cnyInfo);
  11519. liveRates.Insert(0, cnyInfo);
  11520. return Ok(JsonView(true, "查询成功!", new
  11521. {
  11522. InitRates = initRates,
  11523. LiveRates = liveRates
  11524. }));
  11525. }
  11526. /// <summary>
  11527. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11528. /// </summary>
  11529. /// <returns></returns>
  11530. [HttpPost]
  11531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11532. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11533. {
  11534. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11535. }
  11536. /// <summary>
  11537. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11538. /// </summary>
  11539. /// <returns></returns>
  11540. [HttpPost]
  11541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11542. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11543. {
  11544. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11545. }
  11546. /// <summary>
  11547. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11548. /// </summary>
  11549. /// <returns></returns>
  11550. [HttpPost]
  11551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11552. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11553. {
  11554. int groupId = dto.DiId,
  11555. currUserId = dto.CurrUserId;
  11556. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11557. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11558. //验证报价数据是否存在
  11559. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11560. if (isNull != null)
  11561. {
  11562. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11563. if (!info1.Rates.Any())
  11564. {
  11565. var rates = await GeneralMethod.EnterExitCostInitRate();
  11566. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11567. info1.Rates = rates.ToArray();
  11568. }
  11569. return Ok(JsonView(info1));
  11570. }
  11571. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11572. result.GroupId = groupId;
  11573. //处理报价名称
  11574. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11575. if (groupInfo != null)
  11576. {
  11577. var visitCountry = groupInfo.VisitCountry;
  11578. if (!string.IsNullOrEmpty(visitCountry))
  11579. {
  11580. string quoteName = string.Empty;
  11581. if (visitCountry.Contains("|"))
  11582. {
  11583. var countrys = visitCountry.Split("|");
  11584. quoteName = string.Join("、", countrys);
  11585. }
  11586. else quoteName = visitCountry;
  11587. quoteName += $"团组报价表";
  11588. result.Name = quoteName;
  11589. }
  11590. }
  11591. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11592. if (info.Code != StatusCodes.Status200OK)
  11593. {
  11594. if (!result.Rates.Any())
  11595. {
  11596. var rates = await GeneralMethod.EnterExitCostInitRate();
  11597. result.Rates = rates.ToArray();
  11598. }
  11599. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11600. }
  11601. var infoView = info.Data as EnterExitCostInfoView;
  11602. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11603. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11604. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11605. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11606. var eecRates = infoView.Currencys;
  11607. //默认添加人名币
  11608. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11609. {
  11610. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11611. }
  11612. //处理团组人数
  11613. int pplNum = 1;
  11614. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11615. var views = new List<QuoteSubItemInfo>();
  11616. #region 数据填充
  11617. var intTravelCosts = new List<QuoteSubItemInfo>();
  11618. #region 机票费用 1354
  11619. int intTravelIndex = 1;
  11620. if (infoView.SumJJC == 1)
  11621. {
  11622. intTravelCosts.Add(new QuoteSubItemInfo
  11623. {
  11624. ItemId = 1354,
  11625. Index = intTravelIndex,
  11626. FeeName = "经济舱",
  11627. UnitPrice = infoView.AirJJ,
  11628. Currency = "CNY",
  11629. Quantity = 1,
  11630. PplNum = 1,
  11631. TotalAmt = infoView.AirJJ,
  11632. Remark = "",
  11633. });
  11634. intTravelIndex++;
  11635. }
  11636. if (infoView.SumGWC == 1)
  11637. {
  11638. intTravelCosts.Add(new QuoteSubItemInfo
  11639. {
  11640. ItemId = 1354,
  11641. Index = intTravelIndex,
  11642. FeeName = "公务舱",
  11643. UnitPrice = infoView.AirGW,
  11644. Currency = "CNY",
  11645. Quantity = 1,
  11646. PplNum = 1,
  11647. TotalAmt = infoView.AirGW,
  11648. Remark = "",
  11649. });
  11650. intTravelIndex++;
  11651. }
  11652. if (infoView.SumTDC == 1)
  11653. {
  11654. intTravelCosts.Add(new QuoteSubItemInfo
  11655. {
  11656. ItemId = 1354,
  11657. Index = intTravelIndex,
  11658. FeeName = "头等舱",
  11659. UnitPrice = infoView.AirTD,
  11660. Currency = "CNY",
  11661. Quantity = 1,
  11662. PplNum = 1,
  11663. TotalAmt = infoView.AirTD,
  11664. Remark = "",
  11665. });
  11666. intTravelIndex++;
  11667. }
  11668. intTravelCosts.Add(new QuoteSubItemInfo
  11669. {
  11670. ItemId = 1354,
  11671. Index = intTravelIndex,
  11672. FeeName = "城市间交通费用",
  11673. UnitPrice = infoView.CityTranffic,
  11674. Currency = "CNY",
  11675. Quantity = 1,
  11676. PplNum = pplNum,
  11677. TotalAmt = infoView.CityTranffic * pplNum,
  11678. Remark = "",
  11679. });
  11680. views.AddRange(intTravelCosts);
  11681. #endregion
  11682. var accomCosts = new List<QuoteSubItemInfo>();
  11683. #region 住宿费 1355
  11684. if (infoView.QuarterageData.Any())
  11685. {
  11686. int accomIndex = 1;
  11687. int accomItemTypeId = 1355;
  11688. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11689. foreach (var item in groupData)
  11690. {
  11691. string feeName = string.Empty;
  11692. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11693. if (countryInfo != null)
  11694. {
  11695. feeName = countryInfo.Country;
  11696. var city = countryInfo.City;
  11697. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11698. {
  11699. feeName += $"-{city}";
  11700. }
  11701. }
  11702. var hotelInfo = item.FirstOrDefault();
  11703. if (hotelInfo == null) continue;
  11704. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11705. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11706. int quantity = item.ToList().Count;
  11707. accomCosts.Add(new QuoteSubItemInfo
  11708. {
  11709. ItemId = accomItemTypeId,
  11710. Index = accomIndex,
  11711. FeeName = feeName,
  11712. UnitPrice = hotelInfo.Cost,
  11713. Currency = thisCurrency,
  11714. Quantity = quantity,
  11715. PplNum = pplNum,
  11716. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11717. Remark = "",
  11718. });
  11719. accomIndex++;
  11720. }
  11721. views.AddRange(accomCosts);
  11722. }
  11723. #endregion
  11724. var mealCosts = new List<QuoteSubItemInfo>();
  11725. #region 餐饮费 1356
  11726. if (infoView.BoardWagesData.Any())
  11727. {
  11728. var mealIndex = 1;
  11729. int mealItemTypeId = 1356;
  11730. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11731. foreach (var item in groupData)
  11732. {
  11733. string feeName = string.Empty;
  11734. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11735. if (countryInfo != null)
  11736. {
  11737. feeName = countryInfo.Country;
  11738. var city = countryInfo.City;
  11739. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11740. {
  11741. feeName += $"-{city}";
  11742. }
  11743. }
  11744. var mealInfo = item.FirstOrDefault();
  11745. if (mealInfo == null) continue;
  11746. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11747. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11748. int quantity = item.ToList().Count;
  11749. mealCosts.Add(new QuoteSubItemInfo
  11750. {
  11751. ItemId = mealItemTypeId,
  11752. Index = mealIndex,
  11753. FeeName = feeName,
  11754. UnitPrice = mealInfo.Cost,
  11755. Currency = thisCurrency,
  11756. Quantity = quantity,
  11757. PplNum = pplNum,
  11758. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11759. Remark = "",
  11760. });
  11761. mealIndex++;
  11762. }
  11763. views.AddRange(mealCosts);
  11764. }
  11765. #endregion
  11766. var miscCosts = new List<QuoteSubItemInfo>();
  11767. #region 公杂费 1364
  11768. if (infoView.MiscellaneousFeeData.Any())
  11769. {
  11770. var miscIndex = 1;
  11771. int miscItemTypeId = 1364;
  11772. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11773. foreach (var item in groupData)
  11774. {
  11775. string feeName = string.Empty;
  11776. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11777. if (countryInfo != null)
  11778. {
  11779. feeName = countryInfo.Country;
  11780. var city = countryInfo.City;
  11781. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11782. {
  11783. feeName += $"-{city}";
  11784. }
  11785. }
  11786. var miscInfo = item.FirstOrDefault();
  11787. if (miscInfo == null) continue;
  11788. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11789. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11790. int quantity = item.ToList().Count;
  11791. miscCosts.Add(new QuoteSubItemInfo
  11792. {
  11793. ItemId = miscItemTypeId,
  11794. Index = miscIndex,
  11795. FeeName = feeName,
  11796. UnitPrice = miscInfo.Cost,
  11797. Currency = thisCurrency,
  11798. Quantity = quantity,
  11799. PplNum = pplNum,
  11800. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11801. Remark = "",
  11802. });
  11803. miscIndex++;
  11804. }
  11805. views.AddRange(miscCosts);
  11806. }
  11807. #endregion
  11808. #region 签证+保险 1362
  11809. int visaInsIndex = 1;
  11810. int visaInsItemTypeId = 1362;
  11811. if (infoView.Visa > 0)
  11812. {
  11813. views.Add(new QuoteSubItemInfo()
  11814. {
  11815. ItemId = visaInsItemTypeId,
  11816. Index = visaInsIndex,
  11817. FeeName = $"签证",
  11818. UnitPrice = infoView.Visa,
  11819. Currency = $"CNY",
  11820. Quantity = 1,
  11821. PplNum = pplNum,
  11822. TotalAmt = infoView.Visa * pplNum,
  11823. Remark = "",
  11824. });
  11825. visaInsIndex++;
  11826. }
  11827. if (infoView.Safe > 0)
  11828. {
  11829. views.Add(new QuoteSubItemInfo()
  11830. {
  11831. ItemId = visaInsItemTypeId,
  11832. Index = visaInsIndex,
  11833. FeeName = $"保险",
  11834. UnitPrice = infoView.Safe,
  11835. Currency = $"CNY",
  11836. Quantity = 1,
  11837. PplNum = pplNum,
  11838. TotalAmt = infoView.Safe * pplNum,
  11839. Remark = "",
  11840. });
  11841. }
  11842. #endregion
  11843. #region 服务费 1363
  11844. int serviceFeeIndex = 1;
  11845. int serviceFeeItemTypeId = 1363;
  11846. if (infoView.Service > 0)
  11847. {
  11848. views.Add(new QuoteSubItemInfo()
  11849. {
  11850. ItemId = serviceFeeItemTypeId,
  11851. Index = serviceFeeIndex,
  11852. FeeName = $"服务费",
  11853. UnitPrice = infoView.Service,
  11854. Currency = $"CNY",
  11855. Quantity = 1,
  11856. PplNum = pplNum,
  11857. TotalAmt = infoView.Service * pplNum,
  11858. Remark = "",
  11859. });
  11860. }
  11861. #endregion
  11862. #endregion
  11863. if (result.FeeItems.Any())
  11864. {
  11865. result.FeeItems.Select(x =>
  11866. {
  11867. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11868. if (feeInfos.Any()) x.Infos = feeInfos;
  11869. return x;
  11870. }
  11871. ).OrderBy(x => x.Index)
  11872. .ToList();
  11873. if (!result.Rates.Any())
  11874. {
  11875. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  11876. else
  11877. {
  11878. var rates = await GeneralMethod.EnterExitCostInitRate();
  11879. rates.Insert(0,new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11880. result.Rates = rates.ToArray();
  11881. }
  11882. }
  11883. }
  11884. return Ok(JsonView(result));
  11885. }
  11886. /// <summary>
  11887. /// 团组模块 - 出入境费用报价表 - Info
  11888. /// </summary>
  11889. /// <returns></returns>
  11890. [HttpPost]
  11891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11892. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11893. {
  11894. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11895. if (!info.Rates.Any())
  11896. {
  11897. var rates = await GeneralMethod.EnterExitCostInitRate();
  11898. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11899. info.Rates = rates.ToArray();
  11900. }
  11901. return Ok(JsonView(info));
  11902. }
  11903. /// <summary>
  11904. /// 团组模块 - 出入境费用报价表 - OP
  11905. /// </summary>
  11906. /// <returns></returns>
  11907. [HttpPost]
  11908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11909. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11910. {
  11911. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11912. }
  11913. /// <summary>
  11914. /// 团组模块 - 出入境费用报价表 - 删除 项
  11915. /// </summary>
  11916. /// <returns></returns>
  11917. [HttpPost]
  11918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11919. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11920. {
  11921. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11922. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11923. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11924. }
  11925. /// <summary>
  11926. /// 团组模块 - 出入境费用报价表 - 导出
  11927. /// </summary>
  11928. /// <returns></returns>
  11929. [HttpPost]
  11930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11931. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11932. {
  11933. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11934. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11935. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11936. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11937. var rates = info.Rates;
  11938. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11939. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11940. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11941. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11942. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11943. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11944. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  11945. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  11946. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  11947. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  11948. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  11949. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  11950. //获取模板
  11951. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11952. var designer = new WorkbookDesigner();
  11953. designer.Workbook = new Workbook(tempPath);
  11954. designer.SetDataSource("QuoteName", info.Name);
  11955. designer.SetDataSource("CompanyTitle", "公司名称");
  11956. designer.SetDataSource("CompanyLabel", "");
  11957. #region 国际旅费
  11958. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  11959. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  11960. {
  11961. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11962. StringBuilder label = new StringBuilder();
  11963. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11964. if (infos.Any())
  11965. {
  11966. label.Append(infos.Sum(x => x.PplNum));
  11967. label.Append("人全程机票:");
  11968. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11969. label.AppendLine("元");
  11970. }
  11971. foreach (var item in intTravelCosts.Infos)
  11972. {
  11973. label.Append(item.FeeName);
  11974. label.Append(":");
  11975. label.Append(item.UnitPrice.TruncDecimals(2));
  11976. label.Append("元/人*");
  11977. label.Append(item.PplNum);
  11978. label.AppendLine("人");
  11979. }
  11980. if (label.HasValue())
  11981. {
  11982. label.Append("\r\n以上小计:");
  11983. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11984. label.Append("元");
  11985. }
  11986. designer.SetDataSource("IntTravelLabel", label.ToString());
  11987. }
  11988. #endregion
  11989. #region 住宿费
  11990. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  11991. if (accomCosts!=null && accomCosts.Infos.Any())
  11992. {
  11993. string currencyName = string.Empty,
  11994. countryName = string.Empty;
  11995. decimal rate = 1.0000M;
  11996. StringBuilder label = new StringBuilder();
  11997. label.AppendLine("全程五星酒店,每人1间房");
  11998. foreach (var item in accomCosts.Infos)
  11999. {
  12000. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12001. string name = string.Empty, thisCountryName = string.Empty;
  12002. if (item.FeeName.Contains("-"))
  12003. {
  12004. var feeName = item.FeeName.Split('-');
  12005. thisCountryName = feeName[0];
  12006. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12007. name = feeName[1];
  12008. }
  12009. else name = item.FeeName;
  12010. string thisFeeName = string.Empty;
  12011. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12012. else thisFeeName = $"\r\n{name}:";
  12013. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12014. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12015. rate = rateInfo?.Rate ?? 1.0000M;
  12016. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12017. label.AppendLine(subLabel);
  12018. }
  12019. if (label.HasValue())
  12020. {
  12021. //以上小计:52440元(美金汇率:7.5 )
  12022. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12023. label.AppendLine(subLabel);
  12024. }
  12025. designer.SetDataSource("AccomLabel", label.ToString());
  12026. }
  12027. #endregion
  12028. #region 餐饮费
  12029. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12030. if (mealCosts != null && mealCosts.Infos.Any())
  12031. {
  12032. string currencyName = string.Empty;
  12033. decimal rate = 1.0000M;
  12034. StringBuilder label = new StringBuilder();
  12035. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12036. foreach (var item in mealCosts.Infos)
  12037. {
  12038. string name = string.Empty;
  12039. if (item.FeeName.Contains("-"))
  12040. {
  12041. var feeName = item.FeeName.Split('-');
  12042. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12043. }
  12044. else name = $"\r\n{item.FeeName}:";
  12045. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12046. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12047. rate = rateInfo?.Rate ?? 1.0000M;
  12048. label.Append(name);
  12049. label.Append(item.UnitPrice.TruncDecimals(2));
  12050. label.Append(currencyName);
  12051. label.Append("/天*");
  12052. label.Append(item.Quantity.ToString("#0"));
  12053. label.Append("*");
  12054. label.Append(item.PplNum);
  12055. label.Append("人\r\n");
  12056. }
  12057. if (label.HasValue())
  12058. {
  12059. label.Append("\r\n以上小计:");
  12060. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12061. label.Append("元\r\n(");
  12062. label.Append("汇率:");
  12063. label.Append(rate.TruncDecimals(4));
  12064. label.Append(")");
  12065. }
  12066. designer.SetDataSource("MealLabel", label.ToString());
  12067. }
  12068. #endregion
  12069. #region 车辆安排
  12070. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12071. if (vehArranges!=null&&vehArranges.Infos.Any())
  12072. {
  12073. string currencyName = string.Empty;
  12074. //decimal rate = 1.0000M;
  12075. StringBuilder label = new StringBuilder();
  12076. foreach (var item in vehArranges.Infos)
  12077. {
  12078. label.AppendLine();
  12079. label.AppendLine();
  12080. label.Append(item.FeeName);
  12081. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12082. }
  12083. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12084. }
  12085. #endregion
  12086. #region 邀请函发放对象
  12087. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12088. designer.SetDataSource("InviteToContent", "");
  12089. #endregion
  12090. #region 邀请函费
  12091. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12092. StringBuilder is_label = new StringBuilder();
  12093. if (inviteCosts != null&&inviteCosts.Infos.Any())
  12094. {
  12095. string currencyName = string.Empty;
  12096. decimal rate = 1.0000M;
  12097. foreach (var item in inviteCosts.Infos)
  12098. {
  12099. //乌兹别克斯坦:2000美金
  12100. currencyName = item.Currency;
  12101. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12102. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12103. is_label.AppendLine(label);
  12104. }
  12105. if (is_label.HasValue())
  12106. {
  12107. //以上小计:28500元(美金汇率:7.5)
  12108. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2),"元", currencyName, rate.TruncDecimals(4));
  12109. is_label.AppendLine(label);
  12110. }
  12111. }
  12112. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12113. #endregion
  12114. #region 邀请函发放时间
  12115. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12116. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12117. #endregion
  12118. #region 公务活动(含翻译)
  12119. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12120. StringBuilder oa_label = new StringBuilder();
  12121. if (officialActs != null && officialActs.Infos.Any())
  12122. {
  12123. string currencyName = string.Empty;
  12124. decimal rate = 1.0000M;
  12125. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12126. foreach (var item in officialActs.Infos)
  12127. {
  12128. //乌兹别克斯坦:1000美金/场
  12129. currencyName = item.Currency;
  12130. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12131. string label_remark = string.Empty;
  12132. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12133. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12134. }
  12135. label_content += "*总费用中未含超出公务活动价格";
  12136. //8场公务活动(以上小计:60000元)
  12137. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12138. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12139. oa_label.AppendLine(label_title);
  12140. oa_label.AppendLine(label_content);
  12141. }
  12142. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12143. #endregion
  12144. #region 签证+保险
  12145. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12146. StringBuilder vi_label = new StringBuilder();
  12147. if (visaIns != null && visaIns.Infos.Any())
  12148. {
  12149. foreach (var item in visaIns.Infos)
  12150. {
  12151. //签证:500元/人
  12152. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12153. vi_label.AppendLine(label);
  12154. }
  12155. if (vi_label.HasValue())
  12156. {
  12157. //以上小计:6000元
  12158. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12159. vi_label.AppendLine(label);
  12160. }
  12161. }
  12162. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12163. #endregion
  12164. #region 服务费
  12165. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12166. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12167. #endregion
  12168. #region 公杂费
  12169. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12170. StringBuilder pm_label = new StringBuilder();
  12171. if (pubMiscs != null && pubMiscs.Infos.Any())
  12172. {
  12173. string currencyName = string.Empty,
  12174. countryName = string.Empty;
  12175. decimal rate = 1.0000M;
  12176. foreach (var item in pubMiscs.Infos)
  12177. {
  12178. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12179. string name = string.Empty, thisCountryName = string.Empty;
  12180. if (item.FeeName.Contains("-"))
  12181. {
  12182. var feeName = item.FeeName.Split('-');
  12183. thisCountryName = feeName[0];
  12184. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12185. name = feeName[1];
  12186. }
  12187. else name = item.FeeName;
  12188. string thisFeeName = string.Empty;
  12189. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12190. else thisFeeName = $"\r\n{name}:";
  12191. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12192. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12193. rate = rateInfo?.Rate ?? 1.0000M;
  12194. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12195. pm_label.AppendLine(label);
  12196. }
  12197. if (pm_label.HasValue())
  12198. {
  12199. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12200. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12201. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12202. pm_label.AppendLine(string.Format("部分发放成员"));
  12203. }
  12204. }
  12205. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12206. #endregion
  12207. #region 税费
  12208. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12209. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12210. #endregion
  12211. #region 合计(单位:元)
  12212. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12213. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12214. #endregion
  12215. #region 汇率 Remark
  12216. var rate_label = new StringBuilder();
  12217. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12218. foreach (var item in rateGroups)
  12219. {
  12220. //美元汇率按\r\n1:7.5
  12221. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12222. rate_label.AppendLine(label);
  12223. }
  12224. designer.SetDataSource("RateLabel", rate_label.ToString());
  12225. #endregion
  12226. designer.Process();
  12227. //文件名
  12228. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12229. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12230. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12231. return Ok(JsonView(true, "成功", url));
  12232. }
  12233. #endregion
  12234. #region 签证费用录入
  12235. /// <summary>
  12236. /// 根据diid查询签证费用列表
  12237. /// </summary>
  12238. /// <param name="dto"></param>
  12239. /// <returns></returns>
  12240. [HttpPost]
  12241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12242. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12243. {
  12244. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12245. if (groupData.Code != 0)
  12246. {
  12247. return Ok(JsonView(false, groupData.Msg));
  12248. }
  12249. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12250. }
  12251. /// <summary>
  12252. /// 根据签证费用Id查询单条数据及c表数据
  12253. /// </summary>
  12254. /// <param name="dto"></param>
  12255. /// <returns></returns>
  12256. [HttpPost]
  12257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12258. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12259. {
  12260. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12261. if (groupData.Code != 0)
  12262. {
  12263. return Ok(JsonView(false, groupData.Msg));
  12264. }
  12265. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12266. }
  12267. /// <summary>
  12268. /// 签证费用删除
  12269. /// </summary>
  12270. /// <param name="dto"></param>
  12271. /// <returns></returns>
  12272. [HttpPost]
  12273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12274. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12275. {
  12276. _sqlSugar.BeginTran();
  12277. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12278. if (!res)
  12279. {
  12280. _sqlSugar.RollbackTran();
  12281. return Ok(JsonView(false, "删除失败"));
  12282. }
  12283. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12284. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12285. .SetColumns(a => new Grp_CreditCardPayment()
  12286. {
  12287. IsDel = 1,
  12288. DeleteUserId = dto.DeleteUserId,
  12289. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12290. })
  12291. .ExecuteCommand();
  12292. if (resSub < 1)
  12293. {
  12294. _sqlSugar.RollbackTran();
  12295. return Ok(JsonView(false, "删除失败"));
  12296. }
  12297. _sqlSugar.CommitTran();
  12298. return Ok(JsonView(true, "删除成功!"));
  12299. }
  12300. /// <summary>
  12301. /// 签证费用录入下拉框初始化
  12302. /// </summary>
  12303. /// <returns></returns>
  12304. [HttpPost]
  12305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12306. public async Task<IActionResult> VisaPriceAddSelect()
  12307. {
  12308. //支付方式
  12309. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12310. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12311. //币种
  12312. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12313. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12314. //乘客类型
  12315. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12316. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12317. //卡类型
  12318. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12319. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12320. //代办费类型
  12321. var agencyFeeTypeData = new List<dynamic>() {
  12322. new { id = 0 , Text = "未选择" },
  12323. new { id = 1 , Text = "小公务" },
  12324. new { id = 2 , Text = "大公务" },
  12325. };
  12326. //签证费用标准国家Data
  12327. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12328. var data = new
  12329. {
  12330. Payment = _Payment,
  12331. CurrencyList = _CurrencyList,
  12332. PassengerType = _PassengerType,
  12333. BankCard = _BankCard,
  12334. AgencyFeeType = agencyFeeTypeData,
  12335. CountryFeeData = visaCountryFeeData
  12336. };
  12337. return Ok(JsonView(true, "查询成功!", data));
  12338. }
  12339. /// <summary>
  12340. /// 签证费用录入操作(Status:1.新增,2.修改)
  12341. /// </summary>
  12342. /// <param name="dto"></param>
  12343. /// <returns></returns>
  12344. [HttpPost]
  12345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12346. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12347. {
  12348. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12349. if (groupData.Code != 0)
  12350. {
  12351. return Ok(JsonView(false, groupData.Msg));
  12352. }
  12353. #region 应用推送
  12354. try
  12355. {
  12356. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12357. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12358. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12359. //2024-10-21 新增LZ UID
  12360. var userIds = new List<int>() { 21 };
  12361. string title = $"系统通知";
  12362. string content = "";
  12363. var diId = dto.DiId;
  12364. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12365. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12366. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12367. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12368. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12369. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12370. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12371. }
  12372. catch (Exception ex)
  12373. {
  12374. }
  12375. #endregion
  12376. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12377. }
  12378. #endregion
  12379. #region 签证提成录入
  12380. /// <summary>
  12381. /// 签证提成录入
  12382. /// 基础数据
  12383. /// </summary>
  12384. /// <returns></returns>
  12385. [HttpGet]
  12386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12387. public async Task<IActionResult> VisaCommissionInit()
  12388. {
  12389. return Ok(await _visaCommissionRep.Init());
  12390. }
  12391. /// <summary>
  12392. /// 签证提成录入
  12393. /// Item
  12394. /// </summary>
  12395. /// <param name="_dto"></param>
  12396. /// <returns></returns>
  12397. [HttpPost]
  12398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12399. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12400. {
  12401. var validator = new VisaCommissionItemDtoValidator();
  12402. var validatorRes = await validator.ValidateAsync(_dto);
  12403. if (!validatorRes.IsValid)
  12404. {
  12405. StringBuilder sb = new StringBuilder();
  12406. foreach (var item in validatorRes.Errors)
  12407. {
  12408. sb.AppendLine(item.ErrorMessage);
  12409. }
  12410. return Ok(JsonView(false, sb.ToString()));
  12411. }
  12412. return Ok(await _visaCommissionRep.Item(_dto));
  12413. }
  12414. /// <summary>
  12415. /// 签证提成录入
  12416. /// Save
  12417. /// </summary>
  12418. /// <param name="_dto"></param>
  12419. /// <returns></returns>
  12420. [HttpPost]
  12421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12422. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12423. {
  12424. //参数验证
  12425. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12426. foreach (var item in _dto.Items)
  12427. {
  12428. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12429. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12430. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12431. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12432. }
  12433. return Ok(await _visaCommissionRep.Save(_dto));
  12434. }
  12435. /// <summary>
  12436. /// 签证提成录入
  12437. /// Create
  12438. /// </summary>
  12439. /// <param name="_dto"></param>
  12440. /// <returns></returns>
  12441. [HttpPost]
  12442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12443. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12444. {
  12445. var validator = new VisaCommissionCreateDtoValidator();
  12446. var validatorRes = await validator.ValidateAsync(_dto);
  12447. if (!validatorRes.IsValid)
  12448. {
  12449. StringBuilder sb = new StringBuilder();
  12450. foreach (var item in validatorRes.Errors)
  12451. {
  12452. sb.AppendLine(item.ErrorMessage);
  12453. }
  12454. return Ok(JsonView(false, sb.ToString()));
  12455. }
  12456. return Ok(await _visaCommissionRep.Create(_dto));
  12457. }
  12458. /// <summary>
  12459. /// 签证提成录入
  12460. /// Put(编辑)
  12461. /// </summary>
  12462. /// <param name="id"></param>
  12463. /// <param name="_dto"></param>
  12464. /// <returns></returns>
  12465. [HttpPut]
  12466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12467. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12468. {
  12469. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12470. var validator = new VisaCommissionCreateDtoValidator();
  12471. var validatorRes = await validator.ValidateAsync(_dto);
  12472. if (!validatorRes.IsValid)
  12473. {
  12474. StringBuilder sb = new StringBuilder();
  12475. foreach (var item in validatorRes.Errors)
  12476. {
  12477. sb.AppendLine(item.ErrorMessage);
  12478. }
  12479. return Ok(JsonView(false, sb.ToString()));
  12480. }
  12481. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12482. }
  12483. /// <summary>
  12484. /// 签证提成录入
  12485. /// Del
  12486. /// </summary>
  12487. /// <param name="id"></param>
  12488. /// <param name="currUserId"></param>
  12489. /// <returns></returns>
  12490. [HttpPost]
  12491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12492. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12493. {
  12494. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12495. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12496. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12497. }
  12498. #endregion
  12499. #region op费用录入
  12500. /// <summary>
  12501. /// 根据diid查询op费用列表
  12502. /// </summary>
  12503. /// <param name="dto"></param>
  12504. /// <returns></returns>
  12505. [HttpPost]
  12506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12507. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12508. {
  12509. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12510. if (groupData.Code != 0)
  12511. {
  12512. return Ok(JsonView(false, groupData.Msg));
  12513. }
  12514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12515. }
  12516. /// <summary>
  12517. /// 根据op费用Id查询单条数据及c表数据
  12518. /// </summary>
  12519. /// <param name="dto"></param>
  12520. /// <returns></returns>
  12521. [HttpPost]
  12522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12523. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12524. {
  12525. try
  12526. {
  12527. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12528. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12529. var data = new
  12530. {
  12531. CarTouristGuideGround = _groupData,
  12532. CreditCardPayment = _creditCardPayment
  12533. };
  12534. return Ok(JsonView(true, "查询成功!", data));
  12535. }
  12536. catch (Exception ex)
  12537. {
  12538. return Ok(JsonView(false, "程序错误!"));
  12539. }
  12540. }
  12541. /// <summary>
  12542. /// op费用删除
  12543. /// </summary>
  12544. /// <param name="dto"></param>
  12545. /// <returns></returns>
  12546. [HttpPost]
  12547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12548. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12549. {
  12550. try
  12551. {
  12552. _sqlSugar.BeginTran();
  12553. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12554. if (!res)
  12555. {
  12556. return Ok(JsonView(false, "删除失败"));
  12557. }
  12558. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12559. {
  12560. IsDel = 1,
  12561. DeleteUserId = dto.DeleteUserId,
  12562. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12563. }).ExecuteCommandAsync();
  12564. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12565. {
  12566. IsDel = 1,
  12567. DeleteUserId = dto.DeleteUserId,
  12568. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12569. }).ExecuteCommandAsync();
  12570. #region 删除超支相关数据
  12571. //删除导入的超支数据
  12572. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12573. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12574. {
  12575. IsDel = 1,
  12576. DeleteUserId = dto.DeleteUserId,
  12577. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12578. }).ExecuteCommand();
  12579. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12580. {
  12581. IsDel = 1,
  12582. DeleteUserId = dto.DeleteUserId,
  12583. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12584. }).ExecuteCommand();
  12585. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12586. {
  12587. IsDel = 1,
  12588. DeleteUserId = dto.DeleteUserId,
  12589. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12590. }).ExecuteCommand();
  12591. #endregion
  12592. _sqlSugar.CommitTran();
  12593. return Ok(JsonView(true, "删除成功!"));
  12594. }
  12595. catch (Exception ex)
  12596. {
  12597. _sqlSugar.RollbackTran();
  12598. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12599. }
  12600. }
  12601. /// <summary>
  12602. /// op费用录入操作(Status:1.新增,2.修改)
  12603. /// </summary>
  12604. /// <param name="dto"></param>
  12605. /// <returns></returns>
  12606. [HttpPost]
  12607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12608. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12609. {
  12610. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12611. if (groupData.Code != 0)
  12612. {
  12613. return Ok(JsonView(false, groupData.Msg));
  12614. }
  12615. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12616. }
  12617. /// <summary>
  12618. /// 填写费用详细页面初始化绑定
  12619. /// </summary>
  12620. /// <param name="dto"></param>
  12621. /// <returns></returns>
  12622. [HttpPost]
  12623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12624. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12625. {
  12626. try
  12627. {
  12628. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12629. if (groupData.Code != 0)
  12630. {
  12631. return Ok(JsonView(false, groupData.Msg));
  12632. }
  12633. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12634. }
  12635. catch (Exception ex)
  12636. {
  12637. return Ok(JsonView(false, ex.Message));
  12638. }
  12639. }
  12640. /// <summary>
  12641. /// 根据op费用Id查询详细数据
  12642. /// </summary>
  12643. /// <param name="dto"></param>
  12644. /// <returns></returns>
  12645. [HttpPost]
  12646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12647. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12648. {
  12649. try
  12650. {
  12651. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12652. if (groupData.Code != 0)
  12653. {
  12654. return Ok(JsonView(false, groupData.Msg));
  12655. }
  12656. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12657. }
  12658. catch (Exception ex)
  12659. {
  12660. return Ok(JsonView(false, ex.Message));
  12661. }
  12662. }
  12663. /// <summary>
  12664. /// OP费用录入填写详情
  12665. /// </summary>
  12666. /// <param name="dto"></param>
  12667. /// <returns></returns>
  12668. [HttpPost]
  12669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12670. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12671. {
  12672. try
  12673. {
  12674. #region 参数校验
  12675. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12676. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12677. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12678. #endregion
  12679. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12680. if (groupData.Code != 0)
  12681. {
  12682. return Ok(JsonView(false, groupData.Msg));
  12683. }
  12684. //自动审核
  12685. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12686. #region 应用推送
  12687. try
  12688. {
  12689. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12690. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12691. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12692. //2024-10-21 新增LZ UID
  12693. var userIds = new List<int>() { 21 };
  12694. string title = $"系统通知";
  12695. var diId = dto.DiId;
  12696. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12697. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12698. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12699. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12700. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12701. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12702. }
  12703. catch (Exception ex)
  12704. {
  12705. }
  12706. #endregion
  12707. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12708. }
  12709. catch (Exception ex)
  12710. {
  12711. return Ok(JsonView(false, ex.Message));
  12712. }
  12713. }
  12714. /// <summary>
  12715. /// 获取三公详细所有城市
  12716. /// </summary>
  12717. /// <returns></returns>
  12718. [HttpGet]
  12719. public IActionResult OpCarCityResult()
  12720. {
  12721. var jw = JsonView(false);
  12722. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12723. {
  12724. x.Id,
  12725. x.Country,
  12726. x.City,
  12727. }).ToList();
  12728. if (data.Count > 0)
  12729. {
  12730. jw = JsonView(true, "获取成功!", data);
  12731. }
  12732. else
  12733. {
  12734. jw.Msg = "城市数据为空!";
  12735. jw.Data = new string[0];
  12736. }
  12737. return Ok(jw);
  12738. }
  12739. /// <summary>
  12740. /// 导出地接费用明细
  12741. /// </summary>
  12742. /// <param name="dto"></param>
  12743. /// <returns></returns>
  12744. [HttpPost]
  12745. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12746. {
  12747. var jw = JsonView(false);
  12748. if (dto.Diid < 1)
  12749. {
  12750. jw.Msg = "请输入正确的diid!";
  12751. return Ok(jw);
  12752. }
  12753. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12754. if (group == null)
  12755. {
  12756. jw.Msg = "未找到团组信息!";
  12757. return Ok(jw);
  12758. }
  12759. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12760. if (localGuideArr.Count == 0)
  12761. {
  12762. jw.Msg = "该团组暂无地接信息!";
  12763. return Ok(jw);
  12764. }
  12765. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12766. var overspendSoure = new Dictionary<int, int>
  12767. {
  12768. { 91, 982 }, //车
  12769. { 92 , 1059} ,//导游
  12770. { 994 , 1073}, //翻译
  12771. { 988 , 1074 }, //早餐
  12772. { 93 , 1075 }, //午餐
  12773. { 989 , 1076 }, //晚餐
  12774. };
  12775. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12776. foreach (var groupArr in localGroup)
  12777. {
  12778. var keyValue = groupArr.Key;
  12779. if (int.TryParse(keyValue, out int cityid))
  12780. {
  12781. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12782. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12783. }
  12784. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12785. foreach (var item in groupArr)
  12786. {
  12787. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12788. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12789. new Grp_CarTouristGuideGroundReservationsContentExtend
  12790. {
  12791. Count = a.Count,
  12792. CreateTime = a.CreateTime,
  12793. CreateUserId = a.CreateUserId,
  12794. CTGGRId = a.CTGGRId,
  12795. Currency = a.Currency,
  12796. DatePrice = a.DatePrice,
  12797. DeleteTime = a.DeleteTime,
  12798. DeleteUserId = a.DeleteUserId,
  12799. DiId = a.DiId,
  12800. Id = a.Id,
  12801. IsDel = a.IsDel,
  12802. Price = a.Price,
  12803. PriceContent = a.PriceContent,
  12804. Remark = a.Remark,
  12805. SId = a.SId,
  12806. SidName = b.Name,
  12807. Units = a.Units,
  12808. }
  12809. ).ToList();
  12810. if (content.Count > 0)
  12811. {
  12812. contentArr.Add(content);
  12813. }
  12814. }
  12815. //open excel
  12816. //set excel
  12817. //save excel
  12818. try
  12819. {
  12820. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12821. IWorkbook workbook;
  12822. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12823. {
  12824. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12825. }
  12826. else
  12827. {
  12828. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12829. }
  12830. ISheet sheet = workbook.GetSheetAt(0);
  12831. var rowStartIndex = 2;
  12832. var clounmCount = 10;
  12833. var initStyleRow = sheet.GetRow(2);
  12834. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12835. //var overspendArrDetail =
  12836. var existsId = new List<CarCompare>();
  12837. var lastElem = arr.Last();
  12838. var thisSid = -1;
  12839. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12840. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12841. {
  12842. Name = "未知币种!",
  12843. Remark = "未知币种!",
  12844. };
  12845. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12846. Action cloneRowFn = () =>
  12847. {
  12848. rowStartIndex++;
  12849. var cloneRow = sheet.CreateRow(rowStartIndex);
  12850. // 复制样式
  12851. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12852. {
  12853. ICell sourceCell = initStyleRow.GetCell(i);
  12854. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12855. // 确保单元格存在样式
  12856. if (sourceCell.CellStyle != null)
  12857. {
  12858. targetCell.CellStyle = sourceCell.CellStyle;
  12859. }
  12860. }
  12861. };
  12862. var mergeRow = () =>
  12863. {
  12864. for (int i = 2; i < sheet.LastRowNum; i++)
  12865. {
  12866. var row = sheet.GetRow(i);
  12867. var cellFirst = row.GetCell(0);
  12868. var thisIndex = i + 1;
  12869. while (thisIndex < sheet.LastRowNum)
  12870. {
  12871. var nextRow = sheet.GetRow(thisIndex);
  12872. var nextCellFirst = nextRow.GetCell(0);
  12873. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12874. {
  12875. thisIndex++;
  12876. }
  12877. else
  12878. {
  12879. break;
  12880. }
  12881. }
  12882. thisIndex--;
  12883. if (thisIndex != i)
  12884. {
  12885. //合并row
  12886. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12887. i, // 起始行索引(0-based)
  12888. thisIndex, // 结束行索引(0-based)
  12889. 0, // 起始列索引(0-based)
  12890. 0 // 结束列索引(0-based)
  12891. );
  12892. sheet.AddMergedRegion(cellRangeAddress);
  12893. i = thisIndex;
  12894. }
  12895. }
  12896. };
  12897. var chaoshiNumber = 0;
  12898. var totalNumber = 0.00M;
  12899. string lastStr = "";
  12900. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12901. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12902. {
  12903. b.IsAuditGM,
  12904. x.Id,
  12905. x.Area,
  12906. b.PayPercentage,
  12907. b.PayMoney,
  12908. }).ToList();
  12909. string yesPayment = "", noPayment = "";
  12910. foreach (var item in queryCarArrByCityAndDiid)
  12911. {
  12912. if (item.IsAuditGM == 1)
  12913. {
  12914. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12915. }
  12916. else
  12917. {
  12918. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12919. }
  12920. }
  12921. lastStr = yesPayment + noPayment;
  12922. foreach (var item in arr)
  12923. {
  12924. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12925. {
  12926. if (thisSid != item.SId)
  12927. {
  12928. if (thisSid == -1)
  12929. {
  12930. thisSid = item.SId;
  12931. }
  12932. else
  12933. {
  12934. //合并小计行
  12935. //创建合并区域的实例
  12936. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12937. rowStartIndex, // 起始行索引(0-based)
  12938. rowStartIndex, // 结束行索引(0-based)
  12939. 0, // 起始列索引(0-based)
  12940. 3 // 结束列索引(0-based)
  12941. );
  12942. sheet.AddMergedRegion(cellRangeAddress);
  12943. var CellStyle = workbook.CreateCellStyle();
  12944. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12945. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12946. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12947. for (int i = 0; i <= clounmCount; i++)
  12948. {
  12949. if (i > 6)
  12950. {
  12951. var CellStyle1 = workbook.CreateCellStyle();
  12952. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12953. IFont Font = workbook.CreateFont(); // 创建字体
  12954. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12955. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12956. CellStyle1.SetFont(Font);
  12957. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12958. }
  12959. else
  12960. {
  12961. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12962. }
  12963. }
  12964. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12965. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12966. //超时合计
  12967. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12968. //超时数
  12969. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12970. //超时合计费用
  12971. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12972. thisSid = item.SId;
  12973. cloneRowFn();
  12974. chaoshiNumber = 0;
  12975. totalNumber = 0;
  12976. }
  12977. }
  12978. IRow row = sheet.GetRow(rowStartIndex);
  12979. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12980. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12981. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12982. if (isOpenOverspendSoure)
  12983. {
  12984. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12985. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12986. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12987. }
  12988. for (int i = 0; i <= clounmCount; i++)
  12989. {
  12990. var cell = row.GetCell(i);
  12991. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12992. if (cell == null)
  12993. {
  12994. cell = row.CreateCell(i);
  12995. }
  12996. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12997. fontRed.CloneStyleFrom(cell.CellStyle);
  12998. IFont Font = workbook.CreateFont(); // 创建字体
  12999. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13000. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13001. fontRed.SetFont(Font);
  13002. byte[] rgb = new byte[3] { 255, 242, 204 };
  13003. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13004. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13005. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13006. if (workbook is XSSFWorkbook)
  13007. {
  13008. BackgroundColor255_242_204.FillForegroundColor = 0;
  13009. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13010. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13011. }
  13012. else
  13013. {
  13014. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13015. }
  13016. if (i == 1 || i > 6)
  13017. {
  13018. if (i > 6)
  13019. {
  13020. fontRed.FillForegroundColor = 0;
  13021. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13022. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13023. }
  13024. cell.CellStyle = fontRed;
  13025. }
  13026. if (i > 2 && i < 7)
  13027. {
  13028. cell.CellStyle = BackgroundColor255_242_204;
  13029. }
  13030. cell.SetCellValue(setCellValue); //写入单元格
  13031. }
  13032. if (overspendSoure.ContainsKey(thisSid))
  13033. {
  13034. var overspendId = overspendSoure[thisSid];
  13035. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13036. }
  13037. cloneRowFn();
  13038. existsId.Add(new CarCompare
  13039. {
  13040. DataPrice = item.DatePrice.ObjToDate(),
  13041. Sid = item.SId
  13042. });
  13043. }
  13044. if (item.Equals(lastElem))
  13045. {
  13046. //合并小计行
  13047. //创建合并区域的实例
  13048. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13049. rowStartIndex, // 起始行索引(0-based)
  13050. rowStartIndex, // 结束行索引(0-based)
  13051. 0, // 起始列索引(0-based)
  13052. 3 // 结束列索引(0-based)
  13053. );
  13054. sheet.AddMergedRegion(cellRangeAddress);
  13055. var CellStyle = workbook.CreateCellStyle();
  13056. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13057. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13058. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13059. for (int i = 0; i <= clounmCount; i++)
  13060. {
  13061. if (i > 6)
  13062. {
  13063. var CellStyle1 = workbook.CreateCellStyle();
  13064. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13065. IFont Font = workbook.CreateFont(); // 创建字体
  13066. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13067. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13068. CellStyle1.SetFont(Font);
  13069. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13070. }
  13071. else
  13072. {
  13073. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13074. }
  13075. }
  13076. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13077. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13078. //超时合计
  13079. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13080. //超时数
  13081. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13082. //超时合计费用
  13083. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13084. cloneRowFn();
  13085. // 创建合并区域的实例
  13086. cellRangeAddress = new CellRangeAddress(
  13087. rowStartIndex, // 起始行索引(0-based)
  13088. rowStartIndex, // 结束行索引(0-based)
  13089. 0, // 起始列索引(0-based)
  13090. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13091. );
  13092. // 添加合并区域
  13093. sheet.AddMergedRegion(cellRangeAddress);
  13094. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13095. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13096. }
  13097. }
  13098. mergeRow();
  13099. // 保存修改后的Excel文件到新文件
  13100. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13101. // new FileStream(newFilePath, FileMode.CreateNew)
  13102. using (var stream = new MemoryStream())
  13103. {
  13104. workbook.Write(stream, true);
  13105. stream.Flush();
  13106. stream.Seek(0, SeekOrigin.Begin);
  13107. MemoryStream memoryStream = new MemoryStream();
  13108. stream.CopyTo(memoryStream);
  13109. memoryStream.Seek(0, SeekOrigin.Begin);
  13110. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13111. }
  13112. workbook.Close();
  13113. workbook.Dispose();
  13114. }
  13115. catch (Exception ex)
  13116. {
  13117. jw.Msg = "出现异常!" + ex.Message;
  13118. return Ok(jw);
  13119. }
  13120. }
  13121. if (Zips.Count > 0)
  13122. {
  13123. IOOperatorHelper io = new IOOperatorHelper();
  13124. var byts = io.ConvertZipStream(Zips);
  13125. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13126. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13127. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13128. }
  13129. else
  13130. {
  13131. jw.Msg = "暂无生成文件!";
  13132. }
  13133. return Ok(jw);
  13134. }
  13135. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13136. {
  13137. string outStr = string.Empty;
  13138. switch (i)
  13139. {
  13140. case 0:
  13141. outStr = arr[0].SidName;
  13142. break;
  13143. case 1:
  13144. outStr = arr[0].DataPriceStr;
  13145. break;
  13146. case 2:
  13147. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13148. break;
  13149. case 4:
  13150. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13151. break;
  13152. case 7:
  13153. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13154. {
  13155. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13156. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13157. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13158. }
  13159. break;
  13160. case 8:
  13161. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13162. {
  13163. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13164. }
  13165. break;
  13166. case 9:
  13167. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13168. {
  13169. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13170. }
  13171. break;
  13172. case 10:
  13173. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13174. {
  13175. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13176. }
  13177. break;
  13178. }
  13179. return outStr;
  13180. }
  13181. #region OP行程单
  13182. /// <summary>
  13183. /// OP行程单初始化
  13184. /// </summary>
  13185. /// <param name="dto"></param>
  13186. /// <returns></returns>
  13187. [HttpPost]
  13188. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13189. {
  13190. var jw = JsonView(false);
  13191. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13192. var group = groupList.First();
  13193. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13194. if (group == null)
  13195. {
  13196. jw.Msg = "暂无团组!";
  13197. return Ok(jw);
  13198. }
  13199. group = groupList.Find(x => x.Id == diid);
  13200. if (group == null)
  13201. {
  13202. jw.Msg = "请输入正确的团组ID!";
  13203. return Ok(jw);
  13204. }
  13205. string city = string.Empty;
  13206. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13207. if (blackCode.Count > 0)
  13208. {
  13209. var black = blackCode.First();
  13210. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13211. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13212. if (blackSp.Length > 0)
  13213. {
  13214. try
  13215. {
  13216. var cityArrCode = new List<string>(20);
  13217. foreach (var item in blackSp)
  13218. {
  13219. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13220. var IndexSelect = itemSp[2];
  13221. var cityArrCodeLength = cityArrCode.Count - 1;
  13222. var startCity = IndexSelect.Substring(0, 3);
  13223. if (cityArrCodeLength > 0)
  13224. {
  13225. var arrEndCity = cityArrCode[cityArrCodeLength];
  13226. if (arrEndCity != startCity)
  13227. {
  13228. cityArrCode.Add(startCity.ToUpper());
  13229. }
  13230. }
  13231. else
  13232. {
  13233. cityArrCode.Add(startCity.ToUpper());
  13234. }
  13235. var endCity = IndexSelect.Substring(3, 3);
  13236. cityArrCode.Add(endCity.ToUpper());
  13237. }
  13238. var cityThree = string.Empty;
  13239. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13240. cityThree = cityThree.TrimEnd(',');
  13241. if (string.IsNullOrWhiteSpace(cityThree))
  13242. {
  13243. throw new
  13244. Exception("error");
  13245. }
  13246. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13247. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13248. foreach (var item in cityArrCode)
  13249. {
  13250. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13251. if (find != null)
  13252. {
  13253. city += find.City + "/";
  13254. }
  13255. else
  13256. {
  13257. city += item + "三字码未收入/";
  13258. }
  13259. }
  13260. city = city.TrimEnd('/');
  13261. }
  13262. catch (Exception e)
  13263. {
  13264. city = "黑屏代码格式不正确!";
  13265. }
  13266. }
  13267. }
  13268. else
  13269. {
  13270. city = "未录入黑屏代码";
  13271. }
  13272. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13273. {
  13274. Date = x.Date,
  13275. Days = x.Days,
  13276. Diffgroup = x.Diffgroup,
  13277. Diid = x.Diid,
  13278. Traffic_First = x.Traffic_First,
  13279. Traffic_Second = x.Traffic_Second,
  13280. Trip = x.Trip,
  13281. WeekDay = x.WeekDay,
  13282. Id = x.Id
  13283. }).ToList();
  13284. jw.Data = new
  13285. {
  13286. groupList = groupList.Select(x => new
  13287. {
  13288. x.Id,
  13289. x.TeamName,
  13290. x.TourCode
  13291. }).ToList(),
  13292. groupInfo = new
  13293. {
  13294. group.VisitDays,
  13295. group.TourCode,
  13296. group.VisitPNumber,
  13297. group.TeamName,
  13298. city
  13299. },
  13300. OpTravelList
  13301. };
  13302. jw.Code = 200;
  13303. jw.Msg = "操作成功!";
  13304. return Ok(jw);
  13305. }
  13306. /// <summary>
  13307. /// 删除团组行程单
  13308. /// </summary>
  13309. /// <returns></returns>
  13310. [HttpPost]
  13311. public IActionResult DelTravel(DelOpTravelDto dto)
  13312. {
  13313. var jw = JsonView(false);
  13314. if (dto.UserId <= 0 || dto.Diid <= 0)
  13315. {
  13316. jw.Msg = "请输入正确的参数!";
  13317. return Ok(jw);
  13318. }
  13319. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13320. .SetColumns(x => new Grp_TravelList
  13321. {
  13322. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13323. DeleteUserId = dto.UserId,
  13324. IsDel = 1,
  13325. }).ExecuteCommand();
  13326. jw = JsonView(true);
  13327. return Ok(jw);
  13328. }
  13329. /// <summary>
  13330. /// 行程单保存
  13331. /// </summary>
  13332. /// <returns></returns>
  13333. [HttpPost]
  13334. public IActionResult TravelSave(TravelSaveDto dto)
  13335. {
  13336. var jw = JsonView(false);
  13337. if (dto.Arr.Count > 0)
  13338. {
  13339. try
  13340. {
  13341. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13342. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13343. .ToList();
  13344. _sqlSugar.BeginTran();
  13345. foreach (var item in dto.Arr)
  13346. {
  13347. if (item.Id == 0)
  13348. {
  13349. throw new Exception("请传入正确的Id");
  13350. }
  13351. //比较上一次的差异
  13352. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13353. if (findTravel != null)
  13354. {
  13355. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13356. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13357. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13358. }
  13359. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13360. .SetColumns(x => new Grp_TravelList
  13361. {
  13362. Trip = item.Trip
  13363. }).ExecuteCommand();
  13364. }
  13365. _sqlSugar.CommitTran();
  13366. jw = JsonView(true);
  13367. }
  13368. catch (Exception ex)
  13369. {
  13370. _sqlSugar.RollbackTran();
  13371. jw.Msg = "程序异常!" + ex.Message;
  13372. }
  13373. }
  13374. else
  13375. {
  13376. jw.Msg = "请传入正确的参数!";
  13377. }
  13378. return Ok(jw);
  13379. }
  13380. private string CheckStr(string original, string changed)
  13381. {
  13382. // 创建diff_match_patch对象
  13383. var dmp = new diff_match_patch();
  13384. // 计算差异
  13385. List<Diff> diffs = dmp.diff_main(original, changed);
  13386. // 清理和合并差异
  13387. dmp.diff_cleanupSemantic(diffs);
  13388. // 使用StringBuilder构建最终的字符串
  13389. StringBuilder finalString = new StringBuilder();
  13390. // 输出差异结果,并构建变动后的字符串
  13391. foreach (Diff diff in diffs)
  13392. {
  13393. switch (diff.operation)
  13394. {
  13395. case Operation.EQUAL:
  13396. // 相等的部分,直接添加到最终字符串
  13397. finalString.Append(diff.text);
  13398. break;
  13399. case Operation.INSERT:
  13400. // 插入的部分,添加标记并添加到最终字符串
  13401. finalString.Append("[++]" + diff.text + "[++]");
  13402. break;
  13403. case Operation.DELETE:
  13404. // 删除的部分,不添加到最终字符串
  13405. //finalString.Append("[++]" + diff.text + "[++]");
  13406. break;
  13407. }
  13408. }
  13409. // 输出变动后的字符串
  13410. return finalString.ToString();
  13411. }
  13412. private class tagContent
  13413. {
  13414. public DateTime Date { get; set; }
  13415. public string StartTag { get; set; }
  13416. public string EndTag { get; set; }
  13417. public string Content { get; set; }
  13418. public static int tagLength { get { return 3; } }
  13419. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13420. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13421. public bool IsFinally { get; set; }
  13422. }
  13423. private List<string> ExtractContentBetweenTags(string input, string tag)
  13424. {
  13425. List<string> results = new List<string>();
  13426. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13427. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13428. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13429. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13430. string[] strValueArr = new string[1];
  13431. foreach (System.Text.RegularExpressions.Match match in matches)
  13432. {
  13433. var strValue = match.Groups[1].Value;
  13434. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13435. }
  13436. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13437. return results;
  13438. }
  13439. /// <summary>
  13440. /// 导出行程单
  13441. /// </summary>
  13442. /// <param name="dto"></param>
  13443. /// <returns></returns>
  13444. [HttpPost]
  13445. public IActionResult ExportTravel(ExportTravelDto dto)
  13446. {
  13447. var jw = JsonView(false);
  13448. jw.Data = "";
  13449. int diid = 0;
  13450. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13451. if (Find == null)
  13452. {
  13453. jw.Msg = "请选择正确的团组!";
  13454. return Ok(jw);
  13455. }
  13456. else
  13457. {
  13458. diid = Find.Id;
  13459. }
  13460. //数据源
  13461. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13462. DataTable dtBlack = null;
  13463. try
  13464. {
  13465. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13466. }
  13467. catch (Exception)
  13468. {
  13469. jw.Msg = "机票黑屏代码有误!";
  13470. return Ok(jw);
  13471. }
  13472. string CityStr = string.Empty;
  13473. if (dtBlack.Rows.Count == 0)
  13474. {
  13475. jw.Msg = "机票黑屏代码有误!";
  13476. return Ok(jw);
  13477. }
  13478. else
  13479. {
  13480. foreach (DataRow row in dtBlack.Rows)
  13481. {
  13482. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13483. {
  13484. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13485. return Ok(jw);
  13486. }
  13487. }
  13488. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13489. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13490. }
  13491. // 指定的文字
  13492. var targetTextDic = new Dictionary<string, List<string>>();
  13493. //创建数据源Table
  13494. DataTable dtSource = new DataTable();
  13495. dtSource.Columns.Add("Days", typeof(string));
  13496. dtSource.Columns.Add("Date", typeof(string));
  13497. dtSource.Columns.Add("Week", typeof(string));
  13498. dtSource.Columns.Add("Traffic", typeof(string));
  13499. dtSource.Columns.Add("Trip", typeof(string));
  13500. //获取数据,放到datatable
  13501. foreach (var item in _travelList)
  13502. {
  13503. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13504. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13505. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13506. .Replace("[++]", string.Empty);
  13507. DataRow dr = dtSource.NewRow();
  13508. dr["Days"] = item.Days;
  13509. dr["Date"] = item.Date;
  13510. dr["Week"] = item.WeekDay;
  13511. dr["Traffic"] = item.Traffic_First
  13512. + "\r\n"
  13513. + item.Traffic_Second;
  13514. dr["Trip"] = item.Trip;
  13515. dtSource.Rows.Add(dr);
  13516. }
  13517. Dictionary<string, string> dic = new Dictionary<string, string>();
  13518. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13519. dic.Add("City", CityStr);
  13520. dic.Add("Days", Find.VisitDays.ToString());
  13521. dic.Add("DeleCode", Find.TourCode);
  13522. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13523. //模板路径
  13524. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13525. //载入模板
  13526. Document doc = null;
  13527. DocumentBuilder builder = null;
  13528. try
  13529. {
  13530. //载入模板
  13531. doc = new Document(tempPath);
  13532. builder = new DocumentBuilder(doc);
  13533. }
  13534. catch (Exception)
  13535. {
  13536. jw.Msg = "模板位置不存在!";
  13537. return Ok(jw);
  13538. }
  13539. foreach (var key in dic.Keys)
  13540. {
  13541. Bookmark bookmark = doc.Range.Bookmarks[key];
  13542. if (bookmark != null)
  13543. {
  13544. builder.MoveToBookmark(key);
  13545. builder.Write(dic[key]);
  13546. }
  13547. }
  13548. //获取word里所有表格
  13549. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13550. //获取所填表格的序数
  13551. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13552. try
  13553. {
  13554. //循环赋值
  13555. for (int i = 0; i < dtSource.Rows.Count; i++)
  13556. {
  13557. builder.MoveToCell(0, i + 1, 0, 0);
  13558. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13559. builder.MoveToCell(0, i + 1, 1, 0);
  13560. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13561. builder.MoveToCell(0, i + 1, 2, 0);
  13562. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13563. var trip = dtSource.Rows[i]["Trip"].ToString();
  13564. builder.MoveToCell(0, i + 1, 3, 0);
  13565. builder.Write(trip);
  13566. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13567. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13568. // 获取特定索引的段落
  13569. Paragraph paragraph = (Paragraph)paragraphs[0];
  13570. Run run = paragraph.Runs[0];
  13571. Aspose.Words.Font font = run.Font;
  13572. font.Name = "黑体";
  13573. //设置双休红色
  13574. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13575. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13576. paragraph = (Paragraph)paragraphs[1];
  13577. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13578. {
  13579. run = paragraph.Runs[0];
  13580. font = run.Font;
  13581. font.Color = Color.Red;
  13582. }
  13583. }
  13584. }
  13585. catch (Exception ex)
  13586. {
  13587. }
  13588. //删除多余行
  13589. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13590. {
  13591. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13592. }
  13593. var targetTextList = new List<string>();
  13594. // 遍历文档中的表格
  13595. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13596. {
  13597. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13598. {
  13599. var cellIndex = 0;
  13600. foreach (Cell cell in row.Cells)
  13601. {
  13602. if (cellIndex == 1 && row.Cells.Count == 4)
  13603. {
  13604. foreach (var target in targetTextDic.Keys)
  13605. {
  13606. if (cell.GetText().Contains(target))
  13607. {
  13608. targetTextList = targetTextDic[target];
  13609. break;
  13610. }
  13611. }
  13612. }
  13613. // 遍历单元格中的所有段落
  13614. foreach (Paragraph paragraph in cell.Paragraphs)
  13615. {
  13616. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13617. List<Run> runs = new List<Run>();
  13618. foreach (Run run in paragraph.Runs)
  13619. {
  13620. runs.Add(run);
  13621. }
  13622. foreach (Run run in runs)
  13623. {
  13624. foreach (var targetText in targetTextList)
  13625. {
  13626. // 检查文字是否包含指定文字
  13627. if (run.Text.Contains(targetText))
  13628. {
  13629. // 将包含的部分设置为红色
  13630. HighlightText(run, targetText, Color.Red);
  13631. }
  13632. }
  13633. }
  13634. }
  13635. cellIndex++;
  13636. }
  13637. }
  13638. }
  13639. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13640. if (!Directory.Exists(savePath))
  13641. {
  13642. try
  13643. {
  13644. Directory.CreateDirectory(savePath);
  13645. }
  13646. catch
  13647. {
  13648. }
  13649. }
  13650. string path = savePath + Find.TeamName + "出访日程";
  13651. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13652. try
  13653. {
  13654. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13655. string postfix = ".docx";
  13656. if (dto.IsPDF == 1)
  13657. {
  13658. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13659. postfix = ".pdf";
  13660. }
  13661. doc.Save(path + postfix, saveFormat);
  13662. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13663. }
  13664. catch (Exception)
  13665. {
  13666. jw = JsonView(false);
  13667. }
  13668. return Ok(jw);
  13669. }
  13670. /// <summary>
  13671. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13672. /// </summary>
  13673. /// <param name="num"></param>
  13674. /// <returns></returns>
  13675. string GetNum(string num)
  13676. {
  13677. string str = "";
  13678. switch (num)
  13679. {
  13680. case "1":
  13681. str = "一";
  13682. break;
  13683. case "2":
  13684. str = "二";
  13685. break;
  13686. case "3":
  13687. str = "三";
  13688. break;
  13689. case "4":
  13690. str = "四";
  13691. break;
  13692. case "5":
  13693. str = "五";
  13694. break;
  13695. case "6":
  13696. str = "六";
  13697. break;
  13698. case "7":
  13699. str = "七";
  13700. break;
  13701. case "8":
  13702. str = "八";
  13703. break;
  13704. case "9":
  13705. str = "九";
  13706. break;
  13707. case "10":
  13708. str = "十";
  13709. break;
  13710. case "11":
  13711. str = "十一";
  13712. break;
  13713. case "12":
  13714. str = "十二";
  13715. break;
  13716. case "一":
  13717. str = "1";
  13718. break;
  13719. case "二":
  13720. str = "2";
  13721. break;
  13722. case "三":
  13723. str = "3";
  13724. break;
  13725. case "四":
  13726. str = "4";
  13727. break;
  13728. case "五":
  13729. str = "5";
  13730. break;
  13731. case "六":
  13732. str = "6";
  13733. break;
  13734. case "七":
  13735. str = "7";
  13736. break;
  13737. case "八":
  13738. str = "8";
  13739. break;
  13740. case "九":
  13741. str = "9";
  13742. break;
  13743. case "十":
  13744. str = "10";
  13745. break;
  13746. case "十一":
  13747. str = "11";
  13748. break;
  13749. case "十二":
  13750. str = "12";
  13751. break;
  13752. }
  13753. return str;
  13754. }
  13755. // 高亮包含指定文字的部分
  13756. void HighlightText(Run run, string targetText, Color color)
  13757. {
  13758. string text = run.Text;
  13759. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13760. if (startIndex >= 0)
  13761. {
  13762. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13763. // 前部分
  13764. if (startIndex > 0)
  13765. {
  13766. Run beforeRun = (Run)run.Clone(true);
  13767. beforeRun.Text = text.Substring(0, startIndex);
  13768. parentParagraph.InsertBefore(beforeRun, run);
  13769. }
  13770. // 匹配部分
  13771. Run matchRun = (Run)run.Clone(true);
  13772. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13773. matchRun.Font.Color = color;
  13774. parentParagraph.InsertBefore(matchRun, run);
  13775. // 后部分
  13776. if (startIndex + targetText.Length < text.Length)
  13777. {
  13778. Run afterRun = (Run)run.Clone(true);
  13779. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13780. parentParagraph.InsertBefore(afterRun, run);
  13781. }
  13782. // 删除原始Run
  13783. run.Remove();
  13784. }
  13785. }
  13786. #endregion
  13787. #endregion
  13788. #region 团组成本
  13789. /// <summary>
  13790. /// 团组成本数据初始化
  13791. /// </summary>
  13792. /// <param name="dto"></param>
  13793. /// <returns></returns>
  13794. [HttpPost]
  13795. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13796. {
  13797. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13798. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13799. WHEN COUNT(*) >= 0 THEN 'True'
  13800. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13801. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13802. ").ToList(); //团组列表
  13803. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13804. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13805. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13806. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13807. if (groupinfoValue != null)
  13808. {
  13809. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13810. var spArr = new string[1] { countryArr };
  13811. if (countryArr.Contains("|"))
  13812. {
  13813. spArr = countryArr.Split("|");
  13814. }
  13815. else if (countryArr.Contains("、"))
  13816. {
  13817. spArr = countryArr.Split("、");
  13818. }
  13819. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13820. {
  13821. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13822. if (dbQueryCountry != null)
  13823. {
  13824. visaCountryInfoArr.Add(dbQueryCountry);
  13825. }
  13826. }
  13827. }
  13828. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13829. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13830. #region 屏蔽黑屏代码生成
  13831. //var create = _GroupCostRepository.
  13832. // CreateGroupCostByBlackCode(dto.Diid);
  13833. //if (groupCost.Count == 0 && create.Code == 0)
  13834. //{
  13835. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13836. //}
  13837. #endregion
  13838. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13839. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13840. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13841. groupCostMap = groupCostMap.Select(x =>
  13842. {
  13843. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13844. {
  13845. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13846. }
  13847. return x;
  13848. }).ToList();
  13849. //GroupCostParameter.Add(new
  13850. // Grp_GroupCostParameter());
  13851. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13852. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13853. return Ok(JsonView(new
  13854. {
  13855. groupList,
  13856. groupInfo,
  13857. groupChecks,
  13858. groupCost = groupCostMap,
  13859. hotelNumber,
  13860. GroupCostParameter = GroupCostParameterMap,
  13861. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13862. {
  13863. x.VisaCountry,
  13864. x.VisaPrice,
  13865. x.Id,
  13866. }).ToList(),
  13867. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13868. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  13869. hotelIsTrue = hotelIsTrue,
  13870. }));
  13871. }
  13872. /// <summary>
  13873. /// 团组成本信息保存
  13874. /// </summary>
  13875. /// <param name="dto"></param>
  13876. /// <returns></returns>
  13877. [HttpPost]
  13878. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13879. {
  13880. if (dto.Diid <= 0 || dto.Userid <= 0)
  13881. {
  13882. return Ok(JsonView(false));
  13883. }
  13884. JsonView jw = null;
  13885. bool isTrue = false;
  13886. #region 复制团组成本
  13887. //if (dto.Diid == 2581)
  13888. //{
  13889. // dto.Diid = 2599;
  13890. // dto.CheckBoxs.ForEach(x =>
  13891. // {
  13892. // x.Diid = 2599;
  13893. // });
  13894. // dto.GroupCosts.ForEach(x =>
  13895. // {
  13896. // x.Diid = 2599;
  13897. // });
  13898. // dto.CostTypeHotelNumbers.ForEach(x =>
  13899. // {
  13900. // x.Diid = 2599;
  13901. // });
  13902. // dto.GroupCostParameters.ForEach(x =>
  13903. // {
  13904. // x.DiId = 2599;
  13905. // });
  13906. //}
  13907. #endregion
  13908. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13909. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13910. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13911. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13912. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13913. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13914. try
  13915. {
  13916. _sqlSugar.BeginTran();
  13917. isTrue = await _GroupCostRepository.
  13918. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13919. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13920. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13921. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13922. _sqlSugar.CommitTran();
  13923. jw = JsonView(true, "保存成功!", isTrue);
  13924. }
  13925. catch (Exception)
  13926. {
  13927. _sqlSugar.RollbackTran();
  13928. jw = JsonView(false);
  13929. }
  13930. return Ok(jw);
  13931. }
  13932. /// <summary>
  13933. /// 司兼导数据
  13934. /// </summary>
  13935. /// <param name="dto"></param>
  13936. /// <returns></returns>
  13937. [HttpPost]
  13938. public IActionResult GetCarGuides(CarGuidesDto dto)
  13939. {
  13940. JsonView jw = null;
  13941. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13942. jw = JsonView(true, "获取成功!", Data);
  13943. return Ok(jw);
  13944. }
  13945. /// <summary>
  13946. /// 导游数据
  13947. /// </summary>
  13948. /// <param name="dto"></param>
  13949. /// <returns></returns>
  13950. [HttpPost]
  13951. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  13952. {
  13953. JsonView jw = null;
  13954. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  13955. // 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
  13956. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  13957. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  13958. jw = JsonView(true, "获取成功!", Data);
  13959. return Ok(jw);
  13960. }
  13961. /// <summary>
  13962. /// 成本车数据
  13963. /// </summary>
  13964. /// <param name="dto"></param>
  13965. /// <returns></returns>
  13966. [HttpPost]
  13967. public IActionResult GetCarInfo(CarGuidesDto dto)
  13968. {
  13969. JsonView jw = null;
  13970. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  13971. jw = JsonView(true, "获取成功!", Data);
  13972. return Ok(jw);
  13973. }
  13974. /// <summary>
  13975. /// 景点数据
  13976. /// </summary>
  13977. /// <param name="dto"></param>
  13978. /// <returns></returns>
  13979. [HttpPost]
  13980. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  13981. {
  13982. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  13983. return Ok(JsonView(true, "获取成功!", Data));
  13984. }
  13985. /// <summary>
  13986. /// 成本通知
  13987. /// </summary>
  13988. /// <param name="dto"></param>
  13989. /// <returns></returns>
  13990. [HttpPost]
  13991. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  13992. {
  13993. if (dto.Diid < 0)
  13994. {
  13995. return Ok(JsonView(false));
  13996. }
  13997. JsonView jw = null;
  13998. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  13999. if (GroupCostParameter != null)
  14000. {
  14001. int IsShare = 0;
  14002. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14003. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14004. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14005. string msg = string.Empty;
  14006. if (isTrue)
  14007. {
  14008. if (IsShare == 0)
  14009. {
  14010. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14011. }
  14012. else
  14013. {
  14014. #region 企微通知对应岗位用户
  14015. try
  14016. {
  14017. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14018. }
  14019. catch (Exception ex)
  14020. {
  14021. }
  14022. #endregion
  14023. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14024. }
  14025. jw = JsonView(isTrue, msg, new { IsShare });
  14026. }
  14027. else
  14028. {
  14029. msg = "修改失败!";
  14030. jw = JsonView(isTrue, msg);
  14031. }
  14032. }
  14033. else
  14034. {
  14035. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14036. }
  14037. return Ok(jw);
  14038. }
  14039. /// <summary>
  14040. /// 导出报价单
  14041. /// </summary>
  14042. /// <param name="dto"></param>
  14043. /// <returns></returns>
  14044. [HttpPost]
  14045. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14046. {
  14047. if (dto.Diid == 0)
  14048. {
  14049. return Ok(JsonView(false, "请传递团组id"));
  14050. }
  14051. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14052. if (deleInfo.Code != 0)
  14053. {
  14054. return Ok(JsonView(false, "团组信息查询失败!"));
  14055. }
  14056. var di = deleInfo.Data as DelegationInfoWebView;
  14057. if (di != null)
  14058. {
  14059. di.TeamName = di.TeamName.Replace("|", "、");
  14060. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14061. //文件名
  14062. string strFileName = di.TeamName + "-收款账单.doc";
  14063. //获取模板
  14064. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14065. //载入模板
  14066. Document doc = new Document(tmppath);
  14067. decimal TotalPrice = 0.00M;
  14068. string itemStr = string.Empty;
  14069. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14070. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14071. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14072. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14073. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14074. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14075. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14076. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14077. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14078. foreach (var cost in groupCostType)
  14079. {
  14080. var List = cost.ToList();
  14081. if (cost.Key == "A")
  14082. {
  14083. foreach (var ListItem in List)
  14084. {
  14085. if (ListItem.number > 0)
  14086. {
  14087. if (ListItem.code.Contains("TBR"))
  14088. {
  14089. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14090. }
  14091. else
  14092. {
  14093. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14094. }
  14095. TotalPrice += (ListItem.number * ListItem.price);
  14096. }
  14097. }
  14098. }
  14099. else
  14100. {
  14101. itemStr = itemStr.Insert(0, "A段\r\n");
  14102. itemStr += "B段\r\n";
  14103. foreach (var ListItem in List)
  14104. {
  14105. if (ListItem.number > 0)
  14106. {
  14107. if (ListItem.code.Contains("TBR"))
  14108. {
  14109. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14110. }
  14111. else
  14112. {
  14113. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14114. }
  14115. TotalPrice += (ListItem.number * ListItem.price);
  14116. }
  14117. }
  14118. }
  14119. }
  14120. #region 替换Word模板书签内容
  14121. Dictionary<string, string> marks = new Dictionary<string, string>();
  14122. marks.Add("To", di.ClientUnit);//付款方
  14123. marks.Add("ToTel", di.TellPhone);//付款方电话
  14124. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14125. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14126. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14127. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14128. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14129. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14130. marks.Add("PayItemContent", itemStr);//详细信息
  14131. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14132. #endregion
  14133. ////注
  14134. //if (doc.Range.Bookmarks["Attention"] != null)
  14135. //{
  14136. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14137. // mark.Text = frList[0].Attention;
  14138. //}
  14139. foreach (var item in marks.Keys)
  14140. {
  14141. if (doc.Range.Bookmarks[item] != null)
  14142. {
  14143. Bookmark mark = doc.Range.Bookmarks[item];
  14144. mark.Text = marks[item];
  14145. }
  14146. }
  14147. byte[] bytes = null;
  14148. using (MemoryStream stream = new MemoryStream())
  14149. {
  14150. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14151. bytes = stream.ToArray();
  14152. }
  14153. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14154. return Ok(JsonView(true, "", new
  14155. {
  14156. Data = bytes,
  14157. strFileName,
  14158. }));
  14159. }
  14160. else
  14161. {
  14162. return Ok(JsonView(false, "团组信息不存在!"));
  14163. }
  14164. }
  14165. /// <summary>
  14166. /// 导出团组成本
  14167. /// </summary>
  14168. /// <param name="dto"></param>
  14169. /// <returns></returns>
  14170. [HttpPost]
  14171. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14172. {
  14173. var jw = JsonView(false);
  14174. if (dto.Diid == 0)
  14175. {
  14176. return Ok(JsonView(false, "请传递团组id"));
  14177. }
  14178. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14179. if (deleInfo.Code != 0)
  14180. {
  14181. return Ok(JsonView(false, "团组信息查询失败!"));
  14182. }
  14183. var di = deleInfo.Data as DelegationInfoWebView;
  14184. if (di == null)
  14185. {
  14186. return Ok(JsonView(false, "团组信息查询失败!"));
  14187. }
  14188. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14189. WorkbookDesigner designer = new WorkbookDesigner();
  14190. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14191. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14192. for (int i = 0; i < List_GC.Count; i++)
  14193. {
  14194. GroupCost_Excel gc = new GroupCost_Excel();
  14195. gc.Id = List_GC[i].Id;
  14196. gc.Diid = List_GC[i].Diid.ToString();
  14197. gc.DAY = List_GC[i].DAY;
  14198. string week = "";
  14199. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14200. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14201. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14202. gc.ITIN = List_GC[i].ITIN;
  14203. gc.CarType = List_GC[i].CarType;
  14204. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14205. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14206. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14207. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14208. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14209. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14210. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14211. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14212. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14213. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14214. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14215. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14216. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14217. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14218. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14219. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14220. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14221. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14222. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14223. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14224. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14225. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14226. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14227. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14228. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14229. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14230. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14231. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14232. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14233. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14234. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14235. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14236. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14237. List_GC1.Add(gc);
  14238. }
  14239. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14240. dt.TableName = "TB";
  14241. //报表标题等不用dt的值
  14242. designer.SetDataSource("TeamName", dto.title.TeamName);
  14243. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14244. designer.SetDataSource("Tax", dto.title.Tax);
  14245. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14246. designer.SetDataSource("Currency", dto.title.Currency);
  14247. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14248. designer.SetDataSource("Rate", dto.title.Rate);
  14249. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14250. var Aparams = hotels.Find(x => x.Type == "Default");
  14251. if (Aparams == null)
  14252. {
  14253. return Ok(jw);
  14254. }
  14255. //酒店数量
  14256. var txtSGRNumber = Aparams.SGR.ToString();
  14257. var txtTBRNumber = Aparams.TBR.ToString();
  14258. var txtJSESNumber = Aparams.JSES.ToString();
  14259. var txtSUITENumbe = Aparams.SUITE.ToString();
  14260. if (dto.costType == "B")
  14261. {
  14262. Aparams = hotels.Find(x => x.Type == "A");
  14263. var Bparams = hotels.Find(x => x.Type == "B");
  14264. if (Aparams == null || Bparams == null)
  14265. {
  14266. return Ok(jw);
  14267. }
  14268. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14269. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14270. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14271. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14272. }
  14273. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14274. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14275. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14276. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14277. var ws = designer.Workbook.Worksheets[0];
  14278. int Row = List_GC.Count;
  14279. int startIndex = 11;
  14280. int HideRows = 0;
  14281. List<int> hideRowsList = new List<int>();
  14282. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14283. #region A段left数据
  14284. var left = dto.leftInfo.Find(x => x.Type == "A");
  14285. if (left == null)
  14286. {
  14287. return Ok(jw);
  14288. }
  14289. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14290. if (leftBindData != null)
  14291. {
  14292. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14293. designer.SetDataSource("VisaRS", leftBindData.rs);
  14294. designer.SetDataSource("VisaXS", leftBindData.xs);
  14295. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14296. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14297. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14298. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14299. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14300. }
  14301. else
  14302. {
  14303. hideRowsList.Add(Row + startIndex + HideRows);
  14304. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14305. }
  14306. HideRows += 2;
  14307. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14308. if (leftBindData != null)
  14309. {
  14310. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14311. designer.SetDataSource("BXRS", leftBindData.rs);
  14312. designer.SetDataSource("BXXS", leftBindData.xs);
  14313. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14314. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14315. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14316. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14317. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14318. }
  14319. else
  14320. {
  14321. hideRowsList.Add(Row + startIndex + HideRows);
  14322. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14323. }
  14324. HideRows += 2;
  14325. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14326. if (leftBindData != null)
  14327. {
  14328. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14329. designer.SetDataSource("HSRS", leftBindData.rs);
  14330. designer.SetDataSource("HSXS", leftBindData.xs);
  14331. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14332. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14333. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14334. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14335. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14336. }
  14337. else
  14338. {
  14339. hideRowsList.Add(Row + startIndex + HideRows);
  14340. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14341. }
  14342. HideRows += 2;
  14343. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14344. if (leftBindData != null)
  14345. {
  14346. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14347. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14348. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14349. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14350. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14351. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14352. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14353. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14354. }
  14355. else
  14356. {
  14357. hideRowsList.Add(Row + startIndex + HideRows);
  14358. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14359. }
  14360. HideRows += 2;
  14361. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14362. if (leftBindData != null)
  14363. {
  14364. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14365. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14366. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14367. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14368. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14369. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14370. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14371. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14372. }
  14373. else
  14374. {
  14375. hideRowsList.Add(Row + startIndex + HideRows);
  14376. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14377. }
  14378. HideRows += 2;
  14379. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14380. if (leftBindData != null)
  14381. {
  14382. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14383. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14384. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14385. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14386. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14387. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14388. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14389. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14390. }
  14391. else
  14392. {
  14393. hideRowsList.Add(Row + startIndex + HideRows);
  14394. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14395. }
  14396. HideRows += 2;
  14397. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14398. if (leftBindData != null)
  14399. {
  14400. ////TBR
  14401. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14402. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14403. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14404. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14405. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14406. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14407. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14408. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14409. }
  14410. else
  14411. {
  14412. hideRowsList.Add(Row + startIndex + HideRows);
  14413. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14414. }
  14415. HideRows += 2;
  14416. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14417. if (leftBindData != null)
  14418. {
  14419. ////SGR
  14420. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14421. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14422. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14423. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14424. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14425. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14426. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14427. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14428. }
  14429. else
  14430. {
  14431. hideRowsList.Add(Row + startIndex + HideRows);
  14432. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14433. }
  14434. HideRows += 2;
  14435. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14436. if (leftBindData != null)
  14437. {
  14438. ////JS/ES
  14439. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14440. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14441. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14442. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14443. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14444. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14445. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14446. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14447. }
  14448. else
  14449. {
  14450. hideRowsList.Add(Row + startIndex + HideRows);
  14451. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14452. }
  14453. HideRows += 2;
  14454. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14455. if (leftBindData != null)
  14456. {
  14457. ////SUITE
  14458. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14459. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14460. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14461. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14462. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14463. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14464. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14465. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14466. }
  14467. else
  14468. {
  14469. hideRowsList.Add(Row + startIndex + HideRows);
  14470. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14471. }
  14472. HideRows += 2;
  14473. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14474. if (leftBindData != null)
  14475. {
  14476. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14477. designer.SetDataSource("DJRS", leftBindData.rs);
  14478. designer.SetDataSource("DJXS", leftBindData.xs);
  14479. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14480. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14481. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14482. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14483. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14484. }
  14485. else
  14486. {
  14487. hideRowsList.Add(Row + startIndex + HideRows);
  14488. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14489. }
  14490. HideRows += 2;
  14491. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14492. if (leftBindData != null)
  14493. {
  14494. designer.SetDataSource("HCPCB", leftBindData.cb);
  14495. designer.SetDataSource("HCPRS", leftBindData.rs);
  14496. designer.SetDataSource("HCPXS", leftBindData.xs);
  14497. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14498. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14499. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14500. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14501. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14502. }
  14503. else
  14504. {
  14505. hideRowsList.Add(Row + startIndex + HideRows);
  14506. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14507. }
  14508. HideRows += 2;
  14509. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14510. if (leftBindData != null)
  14511. {
  14512. designer.SetDataSource("CPCB", leftBindData.cb);
  14513. designer.SetDataSource("CPRS", leftBindData.rs);
  14514. designer.SetDataSource("CPXS", leftBindData.xs);
  14515. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14516. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14517. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14518. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14519. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14520. }
  14521. else
  14522. {
  14523. hideRowsList.Add(Row + startIndex + HideRows);
  14524. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14525. }
  14526. HideRows += 2;
  14527. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14528. if (leftBindData != null)
  14529. {
  14530. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14531. designer.SetDataSource("GWRS", leftBindData.rs);
  14532. designer.SetDataSource("GWXS", leftBindData.xs);
  14533. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14534. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14535. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14536. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14537. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14538. }
  14539. else
  14540. {
  14541. hideRowsList.Add(Row + startIndex + HideRows);
  14542. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14543. }
  14544. HideRows += 2;
  14545. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14546. if (leftBindData != null)
  14547. {
  14548. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14549. designer.SetDataSource("LYJRS", leftBindData.rs);
  14550. designer.SetDataSource("LYJXS", leftBindData.xs);
  14551. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14552. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14553. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14554. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14555. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14556. }
  14557. else
  14558. {
  14559. hideRowsList.Add(Row + startIndex + HideRows);
  14560. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14561. }
  14562. #endregion
  14563. #region A段Right信息
  14564. var right = dto.rightInfo.Find(x => x.Type == "A");
  14565. if (right == null)
  14566. {
  14567. return Ok(jw);
  14568. }
  14569. HideRows += 4;
  14570. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14571. if (rightBindData != null)
  14572. {
  14573. //经济舱 + 双人间 TBR
  14574. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14575. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14576. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14577. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14578. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14579. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14580. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14581. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14582. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14583. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14584. }
  14585. else
  14586. {
  14587. hideRowsList.Add(Row + startIndex + HideRows);
  14588. }
  14589. HideRows += 2;
  14590. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14591. if (rightBindData != null)
  14592. {
  14593. //经济舱 + 单人间 SGR
  14594. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14595. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14596. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14597. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14598. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14599. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14600. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14601. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14602. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14603. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14604. }
  14605. else
  14606. {
  14607. hideRowsList.Add(Row + startIndex + HideRows);
  14608. }
  14609. HideRows += 2;
  14610. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14611. if (rightBindData != null)
  14612. {
  14613. //公务舱 + 单人间 SGR
  14614. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14615. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14616. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14617. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14618. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14619. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14620. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14621. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14622. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14623. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14624. }
  14625. else
  14626. {
  14627. hideRowsList.Add(Row + startIndex + HideRows);
  14628. }
  14629. HideRows += 2;
  14630. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14631. if (rightBindData != null)
  14632. {
  14633. //公务舱 + 小套房 JSES
  14634. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14635. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14636. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14637. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14638. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14639. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14640. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14641. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14642. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14643. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14644. }
  14645. else
  14646. {
  14647. hideRowsList.Add(Row + startIndex + HideRows);
  14648. }
  14649. HideRows += 2;
  14650. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14651. if (rightBindData != null)
  14652. {
  14653. //公务舱 + 小套房 JSES
  14654. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14655. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14656. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14657. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14658. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14659. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14660. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14661. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14662. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14663. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14664. }
  14665. else
  14666. {
  14667. hideRowsList.Add(Row + startIndex + HideRows);
  14668. }
  14669. HideRows += 2;
  14670. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14671. if (rightBindData != null)
  14672. {
  14673. //经济舱 + 大套房
  14674. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14675. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14676. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14677. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14678. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14679. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14680. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14681. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14682. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14683. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14684. }
  14685. else
  14686. {
  14687. hideRowsList.Add(Row + startIndex + HideRows);
  14688. }
  14689. HideRows += 2;
  14690. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14691. if (rightBindData != null)
  14692. {
  14693. //头等舱 + 小套房 JSES
  14694. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14695. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14696. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14697. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14698. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14699. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14700. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14701. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14702. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14703. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14704. }
  14705. else
  14706. {
  14707. hideRowsList.Add(Row + startIndex + HideRows);
  14708. }
  14709. HideRows += 2;
  14710. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14711. if (rightBindData != null)
  14712. {
  14713. //头等舱 + 大套房
  14714. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14715. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14716. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14717. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14718. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14719. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14720. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14721. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14722. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14723. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14724. }
  14725. else
  14726. {
  14727. hideRowsList.Add(Row + startIndex + HideRows);
  14728. }
  14729. #endregion
  14730. #region B段标题清空
  14731. designer.SetDataSource("CostBDRCB", "");
  14732. designer.SetDataSource("CostBRS", "");
  14733. designer.SetDataSource("CostBXS", "");
  14734. designer.SetDataSource("CostBZCB", "");
  14735. designer.SetDataSource("CostBDRBJ", "");
  14736. designer.SetDataSource("CostBZBJ", "");
  14737. designer.SetDataSource("CostBDRLR", "");
  14738. designer.SetDataSource("CostBZLR", "");
  14739. designer.SetDataSource("CostBDRCBOM", "");
  14740. designer.SetDataSource("CostBRSOM", "");
  14741. designer.SetDataSource("CostBZCBOM", "");
  14742. designer.SetDataSource("CostBDRBJOM", "");
  14743. designer.SetDataSource("CostBZBJOM", "");
  14744. designer.SetDataSource("CostBDRLROM", "");
  14745. designer.SetDataSource("CostBZLROM", "");
  14746. #endregion
  14747. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14748. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14749. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14750. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14751. designer.SetDataSource("DJName", "地接(CNY)");
  14752. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14753. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14754. designer.SetDataSource("GWName", "公务(CNY)");
  14755. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14756. designer.SetDataSource("LYJName", "零用金(CNY)");
  14757. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14758. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14759. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14760. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14761. designer.SetDataSource("BXName", "保险(CNY)");
  14762. designer.SetDataSource("VisaName", "签证(CNY)");
  14763. #region B段基本数据
  14764. if (dto.costType == "B")
  14765. {
  14766. left = dto.leftInfo.Find(x => x.Type == "B");
  14767. if (left == null)
  14768. {
  14769. return Ok(jw);
  14770. }
  14771. #region B段left数据
  14772. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14773. if (leftBindData != null)
  14774. {
  14775. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14776. designer.SetDataSource("BHSRS", leftBindData.rs);
  14777. designer.SetDataSource("BHSXS", leftBindData.xs);
  14778. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14779. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14780. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14781. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14782. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14783. }
  14784. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14785. if (leftBindData != null)
  14786. {
  14787. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14788. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14789. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14790. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14791. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14792. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14793. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14794. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14795. }
  14796. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14797. if (leftBindData != null)
  14798. {
  14799. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14800. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14801. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14802. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14803. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14804. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14805. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14806. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14807. }
  14808. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14809. if (leftBindData != null)
  14810. {
  14811. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14812. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14813. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14814. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14815. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14816. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14817. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14818. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14819. }
  14820. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14821. if (leftBindData != null)
  14822. {
  14823. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14824. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14825. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14826. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14827. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14828. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14829. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14830. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14831. }
  14832. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14833. if (leftBindData != null)
  14834. {
  14835. designer.SetDataSource("BCPCB", leftBindData.cb);
  14836. designer.SetDataSource("BCPRS", leftBindData.rs);
  14837. designer.SetDataSource("BCPXS", leftBindData.xs);
  14838. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14839. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14840. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14841. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14842. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14843. }
  14844. //TBR
  14845. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14846. if (leftBindData != null)
  14847. {
  14848. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14849. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14850. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14851. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14852. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14853. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14854. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14855. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14856. }
  14857. //SGR
  14858. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14859. if (leftBindData != null)
  14860. {
  14861. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  14862. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  14863. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  14864. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14865. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14866. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14867. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14868. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14869. }
  14870. //JS/ES
  14871. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14872. if (leftBindData != null)
  14873. {
  14874. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  14875. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14876. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14877. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14878. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14879. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14880. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14881. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14882. }
  14883. //SUITE
  14884. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14885. if (leftBindData != null)
  14886. {
  14887. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14888. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14889. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14890. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14891. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14892. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14893. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14894. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14895. }
  14896. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14897. if (leftBindData != null)
  14898. {
  14899. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14900. designer.SetDataSource("BDJRS", leftBindData.rs);
  14901. designer.SetDataSource("BDJXS", leftBindData.xs);
  14902. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14903. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14904. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14905. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14906. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14907. }
  14908. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14909. if (leftBindData != null)
  14910. {
  14911. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14912. designer.SetDataSource("BGWRS", leftBindData.rs);
  14913. designer.SetDataSource("BGWXS", leftBindData.xs);
  14914. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14915. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14916. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14917. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14918. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14919. }
  14920. #region 优化方案
  14921. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14922. //excelBind.Add("零用金", new {
  14923. //cb="",
  14924. //rs="",
  14925. //xs ="",
  14926. //zcb = "",
  14927. //});
  14928. #endregion
  14929. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14930. if (leftBindData != null)
  14931. {
  14932. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14933. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14934. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14935. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14936. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14937. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14938. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14939. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14940. }
  14941. #endregion
  14942. #region B段Right信息
  14943. right = dto.rightInfo.Find(x => x.Type == "B");
  14944. if (right == null)
  14945. {
  14946. return Ok(jw);
  14947. }
  14948. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14949. if (rightBindData != null)
  14950. {
  14951. //经济舱 + 双人间 TBR
  14952. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  14953. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  14954. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14955. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  14956. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14957. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14958. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14959. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14960. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14961. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14962. }
  14963. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14964. if (rightBindData != null)
  14965. {
  14966. //经济舱 + 单人间 SGR
  14967. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  14968. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  14969. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14970. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  14971. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14972. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14973. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14974. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14975. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14976. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14977. }
  14978. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14979. if (rightBindData != null)
  14980. {
  14981. //公务舱 + 单人间 SGR
  14982. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  14983. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  14984. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14985. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  14986. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14987. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14988. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14989. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14990. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14991. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14992. }
  14993. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14994. if (rightBindData != null)
  14995. {
  14996. //公务舱 + 小套房 JSES
  14997. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  14998. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  14999. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15000. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15001. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15002. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15003. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15004. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15005. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15006. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15007. }
  15008. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15009. if (rightBindData != null)
  15010. {
  15011. //公务舱 + 小套房 JSES
  15012. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15013. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15014. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15015. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15016. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15017. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15018. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15019. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15020. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15021. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15022. }
  15023. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15024. if (rightBindData != null)
  15025. {
  15026. //经济舱 + 大套房
  15027. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15028. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15029. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15030. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15031. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15032. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15033. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15034. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15035. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15036. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15037. }
  15038. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15039. if (rightBindData != null)
  15040. {
  15041. //头等舱 + 小套房 JSES
  15042. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15043. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15044. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15045. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15046. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15047. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15048. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15049. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15050. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15051. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15052. }
  15053. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15054. if (rightBindData != null)
  15055. {
  15056. //头等舱 + 大套房
  15057. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15058. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15059. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15060. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15061. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15062. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15063. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15064. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15065. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15066. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15067. }
  15068. #endregion
  15069. #region 标题
  15070. designer.SetDataSource("CostBDRCB", "单人成本");
  15071. designer.SetDataSource("CostBRS", "人数");
  15072. designer.SetDataSource("CostBXS", "系数");
  15073. designer.SetDataSource("CostBZCB", "总成本");
  15074. designer.SetDataSource("CostBDRBJ", "单人报价");
  15075. designer.SetDataSource("CostBZBJ", "总报价");
  15076. designer.SetDataSource("CostBDRLR", "单人利润");
  15077. designer.SetDataSource("CostBZLR", "总利润");
  15078. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15079. designer.SetDataSource("CostBRSOM", "人数");
  15080. designer.SetDataSource("CostBZCBOM", "总成本");
  15081. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15082. designer.SetDataSource("CostBZBJOM", "总报价");
  15083. designer.SetDataSource("CostBDRLROM", "单人利润");
  15084. designer.SetDataSource("CostBZLROM", "总利润");
  15085. #endregion
  15086. }
  15087. #endregion
  15088. designer.SetDataSource("TzZCB2", TzZCB2);
  15089. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15090. designer.SetDataSource("TzZLR2", TzZLR2);
  15091. string[] dataSourceKeys = new string[]
  15092. {
  15093. "VF",
  15094. "TGS",
  15095. "TGOF",
  15096. "TGM",
  15097. "TGA",
  15098. "TGTF",
  15099. "TGEF",
  15100. "CFM",
  15101. "CFOF",
  15102. "B",
  15103. "L",
  15104. "D",
  15105. "TBR",
  15106. "SGR",
  15107. "JSES",
  15108. "Suite",
  15109. "TV",
  15110. "1L",
  15111. "IF",
  15112. "EF",
  15113. "BRF",
  15114. "TE",
  15115. "TGT",
  15116. "DRVT",
  15117. "PC",
  15118. "TLF",
  15119. "ECT"
  15120. };
  15121. foreach (var item in dataSourceKeys)
  15122. {
  15123. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15124. if (find != null)
  15125. {
  15126. designer.SetDataSource(item, find.text);
  15127. }
  15128. else
  15129. {
  15130. designer.SetDataSource(item, 0);
  15131. }
  15132. }
  15133. designer.SetDataSource(dt);
  15134. //根据数据源处理生成报表内容
  15135. designer.Process();
  15136. designer.Workbook.Worksheets[0].Name = "清单";
  15137. Worksheet sheet = designer.Workbook.Worksheets[0];
  15138. foreach (var Rowindex in hideRowsList)
  15139. {
  15140. ws.Cells.HideRows(Rowindex, 2);
  15141. }
  15142. byte[] bytes = null;
  15143. string strFileName = di.TeamName + "-团组-成本.xls";
  15144. using (MemoryStream stream = new MemoryStream())
  15145. {
  15146. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15147. bytes = stream.ToArray();
  15148. }
  15149. return Ok(JsonView(true, "", new
  15150. {
  15151. Data = bytes,
  15152. strFileName,
  15153. }));
  15154. }
  15155. /// <summary>
  15156. /// 导出客户报表
  15157. /// </summary>
  15158. /// <returns></returns>
  15159. [HttpPost]
  15160. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15161. {
  15162. var jw = JsonView(false);
  15163. if (dto.Diid == 0)
  15164. {
  15165. return Ok(JsonView(false, "请传递团组id"));
  15166. }
  15167. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15168. if (deleInfo.Code != 0)
  15169. {
  15170. return Ok(JsonView(false, "团组信息查询失败!"));
  15171. }
  15172. var di = deleInfo.Data as DelegationInfoWebView;
  15173. if (di == null)
  15174. {
  15175. return Ok(JsonView(false, "团组信息查询失败!"));
  15176. }
  15177. //文件名
  15178. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15179. //获取模板
  15180. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15181. //载入模板
  15182. Document doc = new Document(tmppath);
  15183. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15184. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15185. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15186. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15187. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15188. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15189. if (AParameter == null)
  15190. {
  15191. return Ok(JsonView(false, "系数不存在!"));
  15192. }
  15193. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15194. , TzAirDesc, TzZCost;
  15195. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15196. = TzAirDesc = TzZCost = string.Empty;
  15197. TzNumber = AParameter.CostTypenumber.ToString();
  15198. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15199. CarGuides1 = dto.CarGuides1;
  15200. Meal = dto.Meal;
  15201. SubsidizedMeals = dto.SubsidizedMeals;
  15202. NightRepair = dto.NightRepair;
  15203. AttractionsTickets = dto.AttractionsTickets;
  15204. MiscellaneousFees = dto.MiscellaneousFees;
  15205. ATip = dto.ATip;
  15206. TzHotelDesc = "";
  15207. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15208. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15209. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15210. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15211. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15212. TzAirDesc = "";
  15213. TzZCost = dto.TzZCost;
  15214. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15215. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15216. var index = 1;
  15217. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15218. foreach (var item in TzHotelDescArr)
  15219. {
  15220. if (AinfoArr != null)
  15221. {
  15222. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15223. if (Ainfo != null)
  15224. {
  15225. if (int.Parse(Ainfo.rs) <= 0)
  15226. {
  15227. continue;
  15228. }
  15229. var hotelText = string.Empty;
  15230. switch (item)
  15231. {
  15232. case "SGR":
  15233. hotelText = "单人间";
  15234. break;
  15235. case "JSES":
  15236. hotelText = "小套房";
  15237. break;
  15238. case "SUITE":
  15239. hotelText = "套房";
  15240. break;
  15241. case "TBR":
  15242. hotelText = "双人间";
  15243. break;
  15244. }
  15245. if (item != "TBR")
  15246. {
  15247. 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";
  15248. }
  15249. else
  15250. {
  15251. 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";
  15252. }
  15253. index++;
  15254. }
  15255. }
  15256. }
  15257. index = 1;
  15258. foreach (var item in TzAirDescArr)
  15259. {
  15260. if (AinfoArr != null)
  15261. {
  15262. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15263. if (Ainfo != null)
  15264. {
  15265. if (int.Parse(Ainfo.rs) <= 0)
  15266. {
  15267. continue;
  15268. }
  15269. 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";
  15270. index++;
  15271. }
  15272. }
  15273. }
  15274. if (dto.costType == "B")
  15275. {
  15276. if (BParameter == null)
  15277. {
  15278. return Ok(JsonView(false, "B段系数不存在!"));
  15279. }
  15280. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15281. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15282. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15283. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15284. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15285. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15286. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15287. foreach (var item in TzHotelDescArr)
  15288. {
  15289. if (AinfoArr != null)
  15290. {
  15291. TzHotelDesc += "B段信息 \r\n";
  15292. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15293. if (Ainfo != null)
  15294. {
  15295. if (int.Parse(Ainfo.rs) <= 0)
  15296. {
  15297. continue;
  15298. }
  15299. var hotelText = string.Empty;
  15300. switch (item)
  15301. {
  15302. case "SGR":
  15303. hotelText = "单人间";
  15304. break;
  15305. case "JSES":
  15306. hotelText = "小套房";
  15307. break;
  15308. case "SUITE":
  15309. hotelText = "套房";
  15310. break;
  15311. case "TBR":
  15312. hotelText = "双人间";
  15313. break;
  15314. }
  15315. if (item != "TBR")
  15316. {
  15317. 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";
  15318. }
  15319. else
  15320. {
  15321. 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";
  15322. }
  15323. index++;
  15324. }
  15325. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15326. }
  15327. }
  15328. index = 1;
  15329. foreach (var item in TzAirDescArr)
  15330. {
  15331. if (AinfoArr != null)
  15332. {
  15333. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15334. if (Ainfo != null)
  15335. {
  15336. if (int.Parse(Ainfo.rs) <= 0)
  15337. {
  15338. continue;
  15339. }
  15340. 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";
  15341. index++;
  15342. }
  15343. }
  15344. }
  15345. }
  15346. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15347. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15348. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15349. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15350. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15351. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15352. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15353. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15354. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15355. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15356. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15357. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15358. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15359. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15360. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15361. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15362. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15363. DickeyValue.Add("TzZCost", TzZCost);
  15364. foreach (var key in DickeyValue.Keys)
  15365. {
  15366. if (doc.Range.Bookmarks[key] != null)
  15367. {
  15368. Bookmark mark = doc.Range.Bookmarks[key];
  15369. mark.Text = DickeyValue[key];
  15370. }
  15371. }
  15372. byte[] bytes = null;
  15373. string strFileName = di.TeamName + "-客户报价.doc";
  15374. using (MemoryStream stream = new MemoryStream())
  15375. {
  15376. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15377. bytes = stream.ToArray();
  15378. }
  15379. return Ok(JsonView(true, "", new
  15380. {
  15381. Data = bytes,
  15382. strFileName,
  15383. }));
  15384. }
  15385. /// <summary>
  15386. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15387. /// </summary>
  15388. /// <param name="dto"></param>
  15389. /// <returns></returns>
  15390. [HttpPost]
  15391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15392. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15393. {
  15394. try
  15395. {
  15396. #region 参数验证
  15397. if (dto.DiId < 0)
  15398. {
  15399. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15400. }
  15401. List<int> cTableIds = new List<int>() {
  15402. 76 ,//酒店预订
  15403. 77 ,//行程
  15404. 79 ,//车/导游地接
  15405. 80 ,//签证
  15406. 81 ,//邀请/公务活
  15407. 82 ,//团组客户保险
  15408. 85 ,//机票预订
  15409. 98 ,//其他款项
  15410. 285 ,//收款退还
  15411. 751 ,//酒店早餐
  15412. 1015 // 超支费用
  15413. };
  15414. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15415. {
  15416. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15417. }
  15418. #endregion
  15419. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15420. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15421. if (_GroupCostParameters.Count <= 0)
  15422. {
  15423. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15424. }
  15425. if (_GroupCostParameters[0].IsShare == 0)
  15426. {
  15427. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15428. }
  15429. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15430. //处理date为空问题
  15431. if (_GroupCosts.Count > 0)
  15432. {
  15433. for (int i = 0; i < _GroupCosts.Count; i++)
  15434. {
  15435. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15436. {
  15437. if (i > 0)
  15438. {
  15439. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15440. }
  15441. }
  15442. }
  15443. }
  15444. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15445. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15446. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15447. string currCode = "";
  15448. #region currCode 验证
  15449. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15450. if (isInt)
  15451. {
  15452. var currData = currDatas.Find(it => it.Id == intCurrency);
  15453. if (currData != null)
  15454. {
  15455. currCode = currData.Name;
  15456. }
  15457. }
  15458. else
  15459. {
  15460. currCode = _GroupCostParameters[0].Currency.Trim();
  15461. }
  15462. #endregion
  15463. //op,酒店单段模式存储
  15464. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15465. {
  15466. CurrencyCode = currCode,
  15467. Rate = _GroupCostParameters[0].Rate,
  15468. CostType = _GroupCostParameters[0].CostType,
  15469. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15470. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15471. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15472. };
  15473. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15474. if (_GroupCostParameters.Count == 2)
  15475. {
  15476. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15477. }
  15478. foreach (var item in _GroupCostParameters)
  15479. {
  15480. decimal _rate = 1;
  15481. decimal _rate1 = item.Rate;
  15482. decimal _scale = 1;
  15483. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15484. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15485. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15486. //if (userInfo != null)
  15487. //{
  15488. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15489. // {
  15490. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15491. // {
  15492. // _scale = 1.00M;
  15493. // }
  15494. // }
  15495. //}
  15496. #endregion
  15497. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15498. {
  15499. CurrencyCode = currCode,
  15500. Rate = _rate1,
  15501. CostType = item.CostType,
  15502. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15503. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15504. CostTypeNumber = item.CostTypenumber
  15505. };
  15506. if (_GroupCostParameters.Count > 1)
  15507. {
  15508. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15509. }
  15510. else
  15511. {
  15512. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15513. }
  15514. if (dto.CTable == 79)//
  15515. {
  15516. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15517. modulePromptInfo.TotalCost = item.DJCB;
  15518. }
  15519. List<string> costTypes = new List<string>() { "A", "B" };
  15520. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15521. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15522. if (_GroupCostsDuplicates.Count() == 1)
  15523. {
  15524. _GroupCostsTypeData = _GroupCosts;
  15525. }
  15526. else
  15527. {
  15528. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15529. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15530. }
  15531. /*
  15532. * 76 酒店预订
  15533. * 77 行程
  15534. * 79 车/导游地接
  15535. * 80 签证
  15536. * 81 邀请/公务活动
  15537. * 82 团组客户保险
  15538. * 85 机票预订
  15539. * 98 其他款项
  15540. * 285 收款退还
  15541. * 751 酒店早餐
  15542. * 1015 超支费用
  15543. */
  15544. switch (dto.CTable)
  15545. {
  15546. case 76: // 酒店预订
  15547. _ModuleSubPromptInfo.AddRange(
  15548. _GroupCostsTypeData.Select(it => new
  15549. {
  15550. it.DAY,
  15551. it.Date,
  15552. it.ACCON,
  15553. it.ITIN,
  15554. it.SGR,
  15555. it.TBR,
  15556. it.JS_ES,
  15557. it.Suite
  15558. })
  15559. );
  15560. break;
  15561. case 79: // 车/导游地接
  15562. _ModuleSubPromptInfo.AddRange(
  15563. _GroupCostsTypeData.Select(it => new
  15564. {
  15565. Date = it.Date, //日期
  15566. CarFee = it.CarCost * _rate * _scale, //车费用
  15567. CarType = it.CarType, //车型
  15568. DriverFee = it.CFS * _rate * _scale, //司机工资
  15569. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15570. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15571. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15572. GuideFee = it.TGS * _rate * _scale, //导游费用
  15573. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15574. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15575. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15576. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15577. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15578. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15579. Breakfast = it.B * _rate * _scale, //早餐费
  15580. Lunch = it.L * _rate * _scale, //午餐费
  15581. Dinner = it.D * _rate * _scale, //晚餐费
  15582. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15583. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15584. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15585. TicketFee = it.EF * _rate * _scale, //门票费
  15586. TicketRemark = it.EFR, //门票费描述
  15587. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15588. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15589. SpentCash = it.PC * _rate * _scale, //零用金
  15590. LeadersFee = it.TLF * _rate * _scale, //领队费
  15591. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15592. })
  15593. );
  15594. break;
  15595. case 85: // 机票
  15596. List<dynamic> datas = new List<dynamic>();
  15597. datas.Add(
  15598. new
  15599. {
  15600. AirType = "经济舱",
  15601. AirNum = item.JJCRS,
  15602. AirDRCB = item.JJCCB,
  15603. AirZCB = (item.JJCRS * item.JJCCB)
  15604. }
  15605. );
  15606. datas.Add(
  15607. new
  15608. {
  15609. AirType = "公务舱",
  15610. AirNum = item.GWCRS,
  15611. AirDRCB = item.GWCCB,
  15612. AirZCB = (item.GWCRS * item.GWCCB)
  15613. }
  15614. );
  15615. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15616. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15617. modulePromptInfo.Data = new
  15618. {
  15619. airFeeData = datas,
  15620. airInitData = initDatas
  15621. };
  15622. _ModulePromptInfos.Add(modulePromptInfo);
  15623. break;
  15624. default:
  15625. break;
  15626. }
  15627. }
  15628. if (dto.CTable != 85)
  15629. {
  15630. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15631. _ModulePromptInfos.Add(_ModulePromptInfo);
  15632. }
  15633. _view.ModulePromptInfos = _ModulePromptInfos;
  15634. return Ok(JsonView(true, "操作成功!", _view));
  15635. }
  15636. catch (Exception ex)
  15637. {
  15638. return Ok(JsonView(false, ex.Message));
  15639. }
  15640. }
  15641. /// <summary>
  15642. /// 根据黑屏代码重新生成行程
  15643. /// </summary>
  15644. /// <param name="dto"></param>
  15645. /// <returns></returns>
  15646. [HttpPost]
  15647. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15648. {
  15649. var jw = JsonView(false,"Error");
  15650. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15651. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15652. .Select(x=> new
  15653. {
  15654. x.Id,
  15655. x.Title
  15656. })
  15657. .ToList();
  15658. if (Create.Any())
  15659. {
  15660. jw.Msg = "获取成功!";
  15661. jw.Code = 200;
  15662. jw.Data = new
  15663. {
  15664. BlackCodeListSelect = Create,
  15665. blackCodeIsTrue = true
  15666. };
  15667. }
  15668. else
  15669. {
  15670. jw.Code = 400;
  15671. jw.Data = new
  15672. {
  15673. BlackCodeListSelect = Create,
  15674. blackCodeIsTrue = false,
  15675. };
  15676. }
  15677. return Ok(jw);
  15678. }
  15679. /// <summary>
  15680. /// 根据黑屏代码Id重新生成行程
  15681. /// </summary>
  15682. /// <param name="dto"></param>
  15683. /// <returns></returns>
  15684. [HttpPost]
  15685. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15686. {
  15687. var jw = JsonView(false, "Error");
  15688. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15689. if (result.Code == 0)
  15690. {
  15691. jw.Msg = "获取成功!";
  15692. jw.Code = 200;
  15693. jw.Data = new
  15694. {
  15695. groupCost = result.Data,
  15696. blackCodeIsTrue = true
  15697. };
  15698. }
  15699. else
  15700. {
  15701. jw.Code = 400;
  15702. jw.Data = new
  15703. {
  15704. groupCost = result.Data,
  15705. blackCodeIsTrue = false,
  15706. };
  15707. }
  15708. return Ok(jw);
  15709. }
  15710. /// <summary>
  15711. /// 成本获取OP历史车费用
  15712. /// </summary>
  15713. /// <param name="dto"></param>
  15714. /// <returns></returns>
  15715. [HttpPost]
  15716. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15717. {
  15718. var jw = JsonView(false);
  15719. try
  15720. {
  15721. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15722. //获取现有所有车的数据
  15723. if (!dto.Param.IsNullOrWhiteSpace())
  15724. {
  15725. string sql = $@"
  15726. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15727. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15728. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15729. 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
  15730. AND gctggr.ServiceEndTime is not NULL
  15731. ORDER by gctggrc.id DESC
  15732. ";
  15733. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15734. var numeberResult = await Task.Run(() =>
  15735. {
  15736. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15737. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15738. return numberArr;
  15739. });
  15740. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15741. foreach (var item in numeberResult)
  15742. {
  15743. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15744. {
  15745. Country = "数据异常!",
  15746. City = string.Empty,
  15747. };
  15748. item.Area = find.Country + " " + find.City;
  15749. }
  15750. dbResult.AddRange(numeberResult);
  15751. if (dto.Param.Contains("、"))
  15752. {
  15753. var sp = dto.Param.Split("、");
  15754. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15755. .Where(x =>
  15756. {
  15757. return System.Array.Exists(sp, e =>
  15758. {
  15759. bool where = false;
  15760. if (x.Area != null)
  15761. {
  15762. where = x.Area.Contains(e);
  15763. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15764. {
  15765. return false;
  15766. }
  15767. }
  15768. if (x.PriceName != null && !where)
  15769. {
  15770. where = x.PriceName.Contains(e);
  15771. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15772. {
  15773. return false;
  15774. }
  15775. }
  15776. return where;
  15777. });
  15778. }).ToList();
  15779. }
  15780. else
  15781. {
  15782. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15783. .Where(x =>
  15784. {
  15785. bool where = false;
  15786. if (x.Area != null)
  15787. {
  15788. where = x.Area.Contains(dto.Param);
  15789. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15790. {
  15791. return false;
  15792. }
  15793. }
  15794. if (x.PriceName != null && !where)
  15795. {
  15796. where = x.PriceName.Contains(dto.Param);
  15797. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15798. {
  15799. return false;
  15800. }
  15801. }
  15802. return where;
  15803. }
  15804. )
  15805. .ToList();
  15806. }
  15807. }
  15808. var view = dbResult.Select(x =>
  15809. {
  15810. decimal dp = 0.00M;
  15811. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15812. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15813. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15814. {
  15815. if (startB && endB)
  15816. {
  15817. var timesp = endD.Subtract(startD);
  15818. if ((timesp.Days + 1) != 0)
  15819. {
  15820. dp = x.Price / (timesp.Days + 1);
  15821. }
  15822. }
  15823. }
  15824. else
  15825. {
  15826. dp = x.Price;
  15827. }
  15828. return new
  15829. {
  15830. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15831. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15832. x.Area,
  15833. x.id,
  15834. price = x.Price.ToString("F2"),
  15835. x.PriceName,
  15836. x.PriceContent,
  15837. x.TeamName,
  15838. x.DatePrice,
  15839. dayPrice = dp.ToString("F2"),
  15840. };
  15841. }).OrderByDescending(x => x.id).ToList();
  15842. jw = JsonView(true, "获取成功!", view);
  15843. }
  15844. catch (Exception e)
  15845. {
  15846. jw = JsonView(false, e.Message);
  15847. }
  15848. return Ok(jw);
  15849. }
  15850. [HttpPost]
  15851. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15852. {
  15853. var jw = JsonView(true);
  15854. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15855. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15856. {
  15857. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15858. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15859. WHEN COUNT(*) >= 0 THEN 'True'
  15860. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15861. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15862. ")
  15863. .ToList();
  15864. }
  15865. else
  15866. {
  15867. string likeKey = string.Empty;
  15868. foreach (var item in dto.Keyword)
  15869. {
  15870. likeKey += "%" + item;
  15871. }
  15872. likeKey += "%";
  15873. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15874. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15875. WHEN COUNT(*) >= 0 THEN 'True'
  15876. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15877. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15878. ")
  15879. .ToList();
  15880. }
  15881. if (matches.Any())
  15882. {
  15883. jw.Data = matches;
  15884. }
  15885. else
  15886. {
  15887. jw.Code = 201;
  15888. jw.Msg = "empty list";
  15889. jw.Data = new List<string>(1);
  15890. }
  15891. return Ok(jw);
  15892. }
  15893. /// <summary>
  15894. /// 报价Word下载
  15895. /// </summary>
  15896. /// <param name="dto"></param>
  15897. /// <returns></returns>
  15898. [HttpPost]
  15899. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  15900. {
  15901. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  15902. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  15903. if (di == null)
  15904. {
  15905. return Ok(JsonView(false, "团组不存在!"));
  15906. }
  15907. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15908. if (mainPrice == null || mainPrice.IsShare == 0)
  15909. {
  15910. return Ok(JsonView(false, "团组成本不存在!"));
  15911. }
  15912. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  15913. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  15914. if (costTypeHotelNumbers == null)
  15915. {
  15916. return Ok(JsonView(false, "团组成本不存在!"));
  15917. }
  15918. //文件名
  15919. string strFileName = di.TeamName + "-收款账单.doc";
  15920. //获取模板
  15921. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15922. //载入模板
  15923. Document doc = new Document(tmppath);
  15924. decimal allPrice = 0.00M;
  15925. string itemStr = string.Empty;
  15926. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15927. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  15928. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  15929. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  15930. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  15931. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  15932. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  15933. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  15934. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  15935. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  15936. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  15937. {
  15938. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  15939. ("BXRS", "BXCB", "BXXS", "bx"),
  15940. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  15941. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  15942. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  15943. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  15944. ("CPRS", "CPCB", "CPXS", "cp") ,
  15945. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  15946. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  15947. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  15948. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  15949. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  15950. ("DJRS", "DJCB", "DJXS", "dj") ,
  15951. ("GWRS", "GWCB", "GWXS", "gw") ,
  15952. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  15953. };
  15954. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  15955. var rightSum = 0.00M;
  15956. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  15957. {
  15958. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  15959. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  15960. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  15961. if (prefix == "tbr")
  15962. {
  15963. rsValue *= 2;
  15964. cbValue /= 2;
  15965. }
  15966. if (OtherCostPropertyBJ.Contains(prefix))
  15967. {
  15968. rightSum += cbValue * xsValue;
  15969. }
  15970. }
  15971. var hotelRooms = new Dictionary<string, int>
  15972. {
  15973. { "SGR", costTypeHotelNumbers.SGR },
  15974. { "TBR", costTypeHotelNumbers.TBR },
  15975. { "JSES", costTypeHotelNumbers.JSES },
  15976. { "SUITE", costTypeHotelNumbers.SUITE }
  15977. };
  15978. var flights = new Dictionary<string, int>
  15979. {
  15980. { "经济舱", mainPrice.JJCRS },
  15981. { "公务舱", mainPrice.GWCRS },
  15982. { "头等舱", mainPrice.TDCRS }
  15983. };
  15984. var flightRoomMatchingRules = new Dictionary<string, string[]>
  15985. {
  15986. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  15987. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  15988. { "头等舱", new[] { "SUITE", "JSES" } }
  15989. };
  15990. var result = new Dictionary<string, int>();
  15991. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  15992. foreach (var flight in flights.Keys)
  15993. {
  15994. // 获取当前舱位的匹配规则
  15995. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  15996. {
  15997. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  15998. }
  15999. }
  16000. #region right计算
  16001. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16002. {
  16003. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16004. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16005. airHotelPriceList.Add(new
  16006. AirHotelPrice
  16007. {
  16008. Name = "经济舱TBR",
  16009. Price = rightSum + air + hotel,
  16010. Count = result["经济舱TBR"] * 2
  16011. });
  16012. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16013. }
  16014. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16015. {
  16016. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16017. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16018. airHotelPriceList.Add(new
  16019. AirHotelPrice
  16020. {
  16021. Name = "经济舱SGR",
  16022. Price = rightSum + air + hotel,
  16023. Count = result["经济舱SGR"]
  16024. });
  16025. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16026. }
  16027. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16028. {
  16029. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16030. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16031. airHotelPriceList.Add(new
  16032. AirHotelPrice
  16033. {
  16034. Name = "公务舱SGR",
  16035. Price = rightSum + air + hotel,
  16036. Count = result["公务舱SGR"]
  16037. });
  16038. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16039. }
  16040. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16041. {
  16042. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16043. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16044. airHotelPriceList.Add(new
  16045. AirHotelPrice
  16046. {
  16047. Name = "公务舱JSES",
  16048. Price = rightSum + air + hotel,
  16049. Count = result["公务舱JSES"]
  16050. });
  16051. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16052. }
  16053. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16054. {
  16055. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16056. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16057. airHotelPriceList.Add(new
  16058. AirHotelPrice
  16059. {
  16060. Name = "公务舱SUITE",
  16061. Price = rightSum + air + hotel,
  16062. Count = result["公务舱SUITE"]
  16063. });
  16064. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16065. }
  16066. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16067. {
  16068. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16069. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16070. airHotelPriceList.Add(new
  16071. AirHotelPrice
  16072. {
  16073. Name = "经济舱SUITE",
  16074. Price = rightSum + air + hotel,
  16075. Count = result["经济舱SUITE"]
  16076. });
  16077. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16078. }
  16079. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16080. {
  16081. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16082. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16083. airHotelPriceList.Add(new
  16084. AirHotelPrice
  16085. {
  16086. Name = "头等舱JSES",
  16087. Price = rightSum + air + hotel,
  16088. Count = result["头等舱JSES"]
  16089. });
  16090. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16091. }
  16092. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16093. {
  16094. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16095. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16096. airHotelPriceList.Add(new
  16097. AirHotelPrice
  16098. {
  16099. Name = "头等舱SUITE",
  16100. Price = rightSum + air + hotel,
  16101. Count = result["头等舱SUITE"]
  16102. });
  16103. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16104. }
  16105. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16106. {
  16107. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16108. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16109. airHotelPriceList.Add(new
  16110. AirHotelPrice
  16111. {
  16112. Name = "经济舱JSES",
  16113. Price = rightSum + air + hotel,
  16114. Count = result["经济舱JSES"]
  16115. });
  16116. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16117. }
  16118. #endregion
  16119. foreach (var item in airSouer.Keys)
  16120. {
  16121. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16122. if (find != null && find.Count > 0)
  16123. {
  16124. if (item.Contains("TBR"))
  16125. {
  16126. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16127. }
  16128. else
  16129. {
  16130. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16131. }
  16132. }
  16133. }
  16134. #region 替换Word模板书签内容
  16135. Dictionary<string, string> marks = new Dictionary<string, string>();
  16136. marks.Add("To", di.ClientUnit);//付款方
  16137. marks.Add("ToTel", di.TellPhone);//付款方电话
  16138. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16139. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16140. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16141. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16142. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16143. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16144. marks.Add("PayItemContent", itemStr);//详细信息
  16145. marks.Add("Total", allPrice.ToString("F2"));//合计
  16146. #endregion
  16147. foreach (var item in marks.Keys)
  16148. {
  16149. if (doc.Range.Bookmarks[item] != null)
  16150. {
  16151. Bookmark mark = doc.Range.Bookmarks[item];
  16152. mark.Text = marks[item];
  16153. }
  16154. }
  16155. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16156. doc.Save(savePaht);
  16157. var jw = new JsonView();
  16158. jw.Msg = "生成成功!";
  16159. jw.Code = 200;
  16160. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16161. return Ok(jw);
  16162. }
  16163. /// <summary>
  16164. /// 详细报价费用Excel下载
  16165. /// </summary>
  16166. /// <param name="dto"></param>
  16167. /// <returns></returns>
  16168. [HttpPost]
  16169. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16170. {
  16171. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16172. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16173. if (di == null)
  16174. {
  16175. return Ok(JsonView(false, "团组不存在!"));
  16176. }
  16177. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16178. if (mainPrice == null || mainPrice.IsShare == 0)
  16179. {
  16180. return Ok(JsonView(false, "团组成本不存在!"));
  16181. }
  16182. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16183. .FirstAsync(x=>x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16184. if (costTypeHotelNumbers == null)
  16185. {
  16186. return Ok(JsonView(false, "团组成本不存在!"));
  16187. }
  16188. WorkbookDesigner designer = new WorkbookDesigner();
  16189. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16190. List<int> hideRowsList = new List<int>();
  16191. int conterStartIndex = 3;
  16192. int rowIndex = conterStartIndex;
  16193. designer.SetDataSource("GroupName", di.TeamName);
  16194. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16195. {
  16196. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16197. ("BXRS", "BXCB", "BXXS", "bx"),
  16198. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16199. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16200. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16201. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16202. ("CPRS", "CPCB", "CPXS", "cp") ,
  16203. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16204. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16205. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16206. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16207. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16208. ("DJRS", "DJCB", "DJXS", "dj") ,
  16209. ("GWRS", "GWCB", "GWXS", "gw") ,
  16210. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16211. };
  16212. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16213. var rightSum = 0.00M;
  16214. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16215. {
  16216. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16217. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16218. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16219. if (prefix == "tbr")
  16220. {
  16221. rsValue *= 2;
  16222. cbValue /= 2;
  16223. }
  16224. if (OtherCostPropertyBJ.Contains(prefix))
  16225. {
  16226. rightSum += cbValue * xsValue;
  16227. }
  16228. if (rsValue == 0)
  16229. {
  16230. hideRowsList.Add(rowIndex);
  16231. }
  16232. else
  16233. {
  16234. designer.SetDataSource($"{prefix}rs", rsValue);
  16235. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16236. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16237. }
  16238. rowIndex += 2;
  16239. }
  16240. var hotelRooms = new Dictionary<string, int>
  16241. {
  16242. { "SGR", costTypeHotelNumbers.SGR },
  16243. { "TBR", costTypeHotelNumbers.TBR },
  16244. { "JSES", costTypeHotelNumbers.JSES },
  16245. { "SUITE", costTypeHotelNumbers.SUITE }
  16246. };
  16247. var flights = new Dictionary<string, int>
  16248. {
  16249. { "经济舱", mainPrice.JJCRS },
  16250. { "公务舱", mainPrice.GWCRS },
  16251. { "头等舱", mainPrice.TDCRS }
  16252. };
  16253. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16254. {
  16255. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16256. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16257. { "头等舱", new[] { "SUITE", "JSES" } }
  16258. };
  16259. var result = new Dictionary<string, int>();
  16260. foreach (var flight in flights.Keys)
  16261. {
  16262. // 获取当前舱位的匹配规则
  16263. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16264. {
  16265. MatchRooms(ref hotelRooms,ref flights, roomTypes, flight,ref result);
  16266. }
  16267. }
  16268. var allPrice = 0.00M;
  16269. #region right计算
  16270. int airRowIndex = 35;
  16271. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16272. {
  16273. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16274. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16275. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16276. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16277. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16278. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16279. }
  16280. else
  16281. {
  16282. hideRowsList.Add(airRowIndex);
  16283. }
  16284. airRowIndex += 2;
  16285. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16286. {
  16287. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16288. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16289. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16290. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16291. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16292. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16293. }
  16294. else
  16295. {
  16296. hideRowsList.Add(airRowIndex);
  16297. }
  16298. airRowIndex += 2;
  16299. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16300. {
  16301. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16302. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16303. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16304. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16305. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16306. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16307. }
  16308. else
  16309. {
  16310. hideRowsList.Add(airRowIndex);
  16311. }
  16312. airRowIndex += 2;
  16313. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16314. {
  16315. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16316. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16317. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16318. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16319. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16320. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16321. }
  16322. else
  16323. {
  16324. hideRowsList.Add(airRowIndex);
  16325. }
  16326. airRowIndex += 2;
  16327. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16328. {
  16329. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16330. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16331. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16332. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16333. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16334. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16335. }
  16336. else
  16337. {
  16338. hideRowsList.Add(airRowIndex);
  16339. }
  16340. airRowIndex += 2;
  16341. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16342. {
  16343. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16344. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16345. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16346. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16347. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16348. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16349. }
  16350. else
  16351. {
  16352. hideRowsList.Add(airRowIndex);
  16353. }
  16354. airRowIndex += 2;
  16355. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16356. {
  16357. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16358. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16359. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16360. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16361. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16362. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16363. }
  16364. else
  16365. {
  16366. hideRowsList.Add(airRowIndex);
  16367. }
  16368. airRowIndex += 2;
  16369. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16370. {
  16371. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16372. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16373. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16374. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16375. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16376. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16377. }
  16378. else
  16379. {
  16380. hideRowsList.Add(airRowIndex);
  16381. }
  16382. airRowIndex += 2;
  16383. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16384. {
  16385. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16386. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16387. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16388. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16389. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16390. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16391. }
  16392. else
  16393. {
  16394. hideRowsList.Add(airRowIndex);
  16395. }
  16396. #endregion
  16397. designer.SetDataSource("AllPrice","总金额:" + allPrice.ToString("#0.00"));
  16398. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName +"_详细报批费用.xls";
  16399. var ws = designer.Workbook.Worksheets[0];
  16400. foreach (var Rowindex in hideRowsList)
  16401. {
  16402. ws.Cells.HideRows(Rowindex, 2);
  16403. }
  16404. designer.Process();
  16405. designer.Workbook.Save(savePaht);
  16406. return Ok(JsonView(true, "生成成功!", new
  16407. {
  16408. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16409. }));
  16410. }
  16411. private void MatchRooms(ref Dictionary<string, int> hotelRooms,ref Dictionary<string, int> flights, string[] roomTypes, string flightType,ref Dictionary<string, int> result)
  16412. {
  16413. foreach (var roomType in roomTypes)
  16414. {
  16415. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16416. {
  16417. hotelRooms[roomType]--;
  16418. flights[flightType]--;
  16419. if (roomType == "TBR")
  16420. {
  16421. flights[flightType]--; // 双人间在减少1
  16422. }
  16423. string key = flightType + roomType;
  16424. if (result.Keys.Contains(key))
  16425. {
  16426. result[key]++;
  16427. }
  16428. else
  16429. {
  16430. result.Add(key, 1);
  16431. }
  16432. }
  16433. }
  16434. }
  16435. private class AirHotelPrice
  16436. {
  16437. public string Name { get; set; }
  16438. public decimal Price { get; set; }
  16439. public int Count { get; set; }
  16440. }
  16441. #endregion
  16442. #region 酒店预订 新 雷怡 2023-12-28 17:45
  16443. /// <summary>
  16444. /// 酒店预订
  16445. /// 酒店费用列表 根据团组Id查询
  16446. /// </summary>
  16447. /// <param name="_dto"></param>
  16448. /// <returns></returns>
  16449. [HttpPost]
  16450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16451. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16452. {
  16453. #region 参数验证
  16454. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16455. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16456. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16457. #region 团组操作权限验证 76 酒店预定模块
  16458. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16459. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16460. #endregion
  16461. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16462. #region 页面操作权限验证
  16463. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16464. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16465. #endregion
  16466. #endregion
  16467. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16468. }
  16469. /// <summary>
  16470. /// 酒店预订
  16471. /// 基础数据
  16472. /// </summary>
  16473. /// <param name="_dto"></param>
  16474. /// <returns></returns>
  16475. [HttpPost]
  16476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16477. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16478. {
  16479. #region 参数验证
  16480. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16481. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16482. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16483. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16484. #region 页面操作权限验证
  16485. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16486. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16487. #endregion
  16488. #region 团组操作权限验证 76 酒店预定模块
  16489. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16490. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16491. #endregion
  16492. #endregion
  16493. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16494. }
  16495. /// <summary>
  16496. /// 酒店预订
  16497. /// 创建 入住卷号码
  16498. /// </summary>
  16499. /// <param name="_dto"></param>
  16500. /// <returns></returns>
  16501. [HttpPost]
  16502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16503. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16504. {
  16505. #region 参数验证
  16506. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16507. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16508. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16509. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16510. #region 页面操作权限验证
  16511. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16512. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16513. #endregion
  16514. #region 团组操作权限验证 76 酒店预定模块
  16515. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16516. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16517. #endregion
  16518. #endregion
  16519. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16520. if (data.Code != 0)
  16521. {
  16522. return Ok(JsonView(false, data.Msg));
  16523. }
  16524. return Ok(JsonView(true, data.Msg, data.Data));
  16525. }
  16526. /// <summary>
  16527. /// 酒店预订
  16528. /// 详情
  16529. /// </summary>
  16530. /// <param name="_dto"></param>
  16531. /// <returns></returns>
  16532. [HttpPost]
  16533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16534. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16535. {
  16536. #region 参数验证
  16537. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16538. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16539. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16540. #region 团组操作权限验证 76 酒店预定模块
  16541. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16542. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16543. #endregion
  16544. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16545. #region 页面操作权限验证
  16546. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16547. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16548. #endregion
  16549. #endregion
  16550. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16551. }
  16552. /// <summary>
  16553. /// 酒店预订
  16554. /// Add Or Edit
  16555. /// </summary>
  16556. /// <param name="_dto"></param>
  16557. /// <returns></returns>
  16558. [HttpPost]
  16559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16560. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16561. {
  16562. #region 参数验证
  16563. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16564. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16565. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16566. #region 团组操作权限验证 76 酒店预定模块
  16567. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16568. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16569. #endregion
  16570. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16571. #region 页面操作权限验证
  16572. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16573. if (_dto.Id == 0) // Add
  16574. {
  16575. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16576. }
  16577. else if (_dto.Id > 1) // Edit
  16578. {
  16579. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16580. }
  16581. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16582. #endregion
  16583. #endregion
  16584. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16585. if (_view.Code != 200)
  16586. {
  16587. return Ok(_view);
  16588. }
  16589. #region 成本无酒店价格数据进入超支
  16590. _sqlSugar.BeginTran();
  16591. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16592. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16593. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16594. for (int i = 0; i < groupCost.Count; i++)
  16595. {
  16596. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16597. {
  16598. groupCost[i].Date = groupCost[i - 1].Date;
  16599. }
  16600. }
  16601. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16602. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16603. List<Fin_GroupExtraCostDto_OP>();
  16604. if (start_Bool && end_Bool)
  16605. {
  16606. while (start_Time < end_Time)
  16607. {
  16608. foreach (var item in groupCost_Grp)
  16609. {
  16610. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16611. {
  16612. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16613. {
  16614. extraCostList.Add(new
  16615. Fin_GroupExtraCostDto_OP
  16616. {
  16617. Area = _dto.AreaId,
  16618. coefficient = 1.5M,
  16619. createUser = _dto.UserId,
  16620. currency = _dto.CardPriceCurrency,
  16621. diId = _dto.DiId,
  16622. ManagerConfirm = 0,
  16623. SupervisorConfirm = 0,
  16624. SYsupervisorConfirm = 0,
  16625. editType = 1,
  16626. PortType = 1,
  16627. price = _dto.CardPrice,
  16628. PriceCount = 1,
  16629. priceType = 1027,
  16630. priceDetailType = 1044,
  16631. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16632. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16633. });
  16634. }
  16635. }
  16636. }
  16637. start_Time = start_Time.AddDays(1);
  16638. }
  16639. }
  16640. if (extraCostList.Any())
  16641. {
  16642. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16643. }
  16644. _sqlSugar.CommitTran();
  16645. #endregion
  16646. #region 应用推送
  16647. try
  16648. {
  16649. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16650. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16651. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16652. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16653. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16654. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16655. var diId = _dto.DiId;
  16656. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16657. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16658. #region 操作记录
  16659. var opInfo = new Crm_TableOperationRecord()
  16660. {
  16661. TableName = "Grp_HotelReservations",
  16662. PortType = _dto.PortType,
  16663. DataId = hotelId,
  16664. CreateUserId = _dto.UserId
  16665. };
  16666. //var opStatus = OperationEnum.NoOperation;
  16667. if (_dto.Id < 1) //添加操作
  16668. {
  16669. opInfo.OperationItem = OperationEnum.Add;
  16670. }
  16671. else if (_dto.Id > 0)
  16672. {
  16673. opInfo.OperationItem = OperationEnum.Edit;
  16674. }
  16675. string opRemark = string.Empty;
  16676. if (ccpInfo != null)
  16677. {
  16678. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16679. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16680. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16681. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16682. }
  16683. opInfo.Remark = opRemark;
  16684. await _tableorRep.AddAsync(opInfo);
  16685. #endregion
  16686. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16687. //2024-10-21 新增LZ UID
  16688. var userIds = new List<int>() { 21 };
  16689. string title = $"费用审核";
  16690. string content = "";
  16691. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16692. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16693. try
  16694. {
  16695. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  16696. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  16697. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  16698. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  16699. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  16700. }
  16701. catch (Exception ex)
  16702. {
  16703. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  16704. }
  16705. }
  16706. catch (Exception ex)
  16707. {
  16708. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  16709. }
  16710. try
  16711. {
  16712. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16713. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16714. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16715. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16716. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16717. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16718. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16719. //自动审核
  16720. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  16721. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  16722. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  16723. //2024-10-21 新增LZ UID
  16724. var userIds = new List<int>() { 21 };
  16725. string title = $"系统通知";
  16726. var diId = _dto.DiId;
  16727. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16728. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16729. string content = "";
  16730. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16731. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16732. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16733. }
  16734. catch (Exception ex)
  16735. {
  16736. }
  16737. #endregion
  16738. return Ok(_view);
  16739. }
  16740. /// <summary>
  16741. /// 酒店自动审核测试
  16742. /// Add Or Edit
  16743. /// </summary>
  16744. /// <param name="diid"></param>
  16745. /// <param name="dataId"></param>
  16746. /// <returns></returns>
  16747. [HttpPost]
  16748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16749. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  16750. {
  16751. #region 应用推送
  16752. try
  16753. {
  16754. //自动审核
  16755. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  16756. }
  16757. catch (Exception ex)
  16758. {
  16759. return Ok(JsonView(false, "操作失败"));
  16760. }
  16761. #endregion
  16762. return Ok(JsonView(false, "操作成功"));
  16763. }
  16764. /// <summary>
  16765. /// 酒店预订
  16766. /// Del
  16767. /// </summary>
  16768. /// <param name="_dto"></param>
  16769. /// <returns></returns>
  16770. [HttpPost]
  16771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16772. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  16773. {
  16774. #region 参数验证
  16775. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16776. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16777. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16778. #region 团组操作权限验证 76 酒店预定模块
  16779. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16780. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16781. #endregion
  16782. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16783. #region 页面操作权限验证
  16784. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16785. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16786. #endregion
  16787. #endregion
  16788. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  16789. #region 操作记录
  16790. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  16791. {
  16792. TableName = "Grp_HotelReservations",
  16793. PortType = _dto.PortType,
  16794. OperationItem = OperationEnum.Del,
  16795. DataId = _dto.Id,
  16796. CreateUserId = _dto.UserId
  16797. });
  16798. #endregion
  16799. return Ok(data);
  16800. }
  16801. /// <summary>
  16802. /// 酒店预订
  16803. /// 生成VOUCHER
  16804. /// 2024.05.06 之前版本
  16805. /// </summary>
  16806. /// <param name="_dto"></param>
  16807. /// <returns></returns>
  16808. [HttpPost]
  16809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16810. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  16811. {
  16812. try
  16813. {
  16814. #region 参数验证
  16815. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16816. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16817. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16818. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  16819. #region 团组操作权限验证 76 酒店预定模块
  16820. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16821. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16822. #endregion
  16823. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16824. #region 页面操作权限验证
  16825. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16826. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16827. #endregion
  16828. #endregion
  16829. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  16830. //判断数据是否完整
  16831. if (hr != null)
  16832. {
  16833. if (!string.IsNullOrEmpty(hr.DetermineNo))
  16834. {
  16835. string strFileName = "HotelStatement/";
  16836. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16837. if (dele != null)
  16838. strFileName += dele.TourCode;
  16839. //载入模板
  16840. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  16841. Document doc = new Document(sss);
  16842. DocumentBuilder builder = new DocumentBuilder(doc);
  16843. #region 替换Word模板书签内容
  16844. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  16845. //入住卷预定号码
  16846. if (doc.Range.Bookmarks["VNO"] != null)
  16847. {
  16848. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16849. mark.Text = hr.CheckNumber;
  16850. }
  16851. //酒店时间
  16852. if (doc.Range.Bookmarks["Date"] != null)
  16853. {
  16854. Bookmark mark = doc.Range.Bookmarks["Date"];
  16855. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16856. }
  16857. //团号
  16858. if (doc.Range.Bookmarks["TNo"] != null)
  16859. {
  16860. Bookmark mark = doc.Range.Bookmarks["TNo"];
  16861. mark.Text = dele.TourCode;
  16862. }
  16863. //预定号码
  16864. if (doc.Range.Bookmarks["BookingId"] != null)
  16865. {
  16866. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  16867. mark.Text = hr.ReservationsNo;
  16868. }
  16869. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  16870. {
  16871. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  16872. mark.Text = hr.DetermineNo;
  16873. }
  16874. //酒店城市
  16875. if (doc.Range.Bookmarks["City"] != null)
  16876. {
  16877. Bookmark mark = doc.Range.Bookmarks["City"];
  16878. mark.Text = hr.City;
  16879. }
  16880. //酒店名称
  16881. if (doc.Range.Bookmarks["HName"] != null)
  16882. {
  16883. Bookmark mark = doc.Range.Bookmarks["HName"];
  16884. mark.Text = hr.HotelName;
  16885. }
  16886. //酒店地址
  16887. if (doc.Range.Bookmarks["Address"] != null)
  16888. {
  16889. Bookmark mark = doc.Range.Bookmarks["Address"];
  16890. mark.Text = hr.HotelAddress;
  16891. }
  16892. //酒店电话
  16893. if (doc.Range.Bookmarks["Tel"] != null)
  16894. {
  16895. Bookmark mark = doc.Range.Bookmarks["Tel"];
  16896. mark.Text = hr.HotelTel;
  16897. }
  16898. //酒店传真
  16899. if (doc.Range.Bookmarks["Fax"] != null)
  16900. {
  16901. Bookmark mark = doc.Range.Bookmarks["Fax"];
  16902. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  16903. {
  16904. mark.Text = hr.HotelFax;
  16905. }
  16906. }
  16907. //入住时间
  16908. if (doc.Range.Bookmarks["CIn"] != null)
  16909. {
  16910. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16911. Bookmark mark = doc.Range.Bookmarks["CIn"];
  16912. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  16913. }
  16914. //退房时间
  16915. if (doc.Range.Bookmarks["COut"] != null)
  16916. {
  16917. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16918. Bookmark mark = doc.Range.Bookmarks["COut"];
  16919. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16920. }
  16921. //客户名称
  16922. if (doc.Range.Bookmarks["GName"] != null)
  16923. {
  16924. string guestName = "";
  16925. string[] clients = new string[] { };
  16926. if (hr.GuestName.Contains(","))
  16927. {
  16928. clients = hr.GuestName.Split(",");
  16929. }
  16930. else
  16931. {
  16932. clients = new string[] { hr.GuestName };
  16933. }
  16934. List<int> clientIds_int = new List<int>();
  16935. if (clients.Length > 0)
  16936. {
  16937. foreach (var item in clients)
  16938. {
  16939. if (item.IsNumeric())
  16940. {
  16941. clientIds_int.Add(int.Parse(item));
  16942. }
  16943. }
  16944. }
  16945. if (clientIds_int.Count > 0)
  16946. {
  16947. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  16948. foreach (var client in _clientDatas)
  16949. {
  16950. //男
  16951. if (client.Sex == 0) guestName += $"Mr.";
  16952. //女
  16953. else if (client.Sex == 1) guestName += $"Ms.";
  16954. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  16955. {
  16956. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  16957. }
  16958. //guestName += $"{client.Pinyin},";
  16959. }
  16960. if (guestName.Length > 0)
  16961. {
  16962. guestName = guestName.Substring(0, guestName.Length - 1);
  16963. }
  16964. }
  16965. else
  16966. {
  16967. guestName = hr.GuestName;
  16968. }
  16969. Bookmark mark = doc.Range.Bookmarks["GName"];
  16970. mark.Text = guestName;
  16971. }
  16972. //房间介绍
  16973. if (doc.Range.Bookmarks["ROOM"] != null)
  16974. {
  16975. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  16976. mark.Text = hr.RoomExplanation;
  16977. }
  16978. //报价描述
  16979. if (doc.Range.Bookmarks["NOTE"] != null)
  16980. {
  16981. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  16982. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  16983. if (ss != null)
  16984. mark.Text = ss.Name;
  16985. }
  16986. //入住时间
  16987. if (doc.Range.Bookmarks["CheckIn"] != null)
  16988. {
  16989. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16990. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  16991. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16992. }
  16993. //退房时间
  16994. if (doc.Range.Bookmarks["CheckOut"] != null)
  16995. {
  16996. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16997. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  16998. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16999. }
  17000. //日期
  17001. if (doc.Range.Bookmarks["DT"] != null)
  17002. {
  17003. Bookmark mark = doc.Range.Bookmarks["DT"];
  17004. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17005. }
  17006. //名称
  17007. if (doc.Range.Bookmarks["VName"] != null)
  17008. {
  17009. Bookmark mark = doc.Range.Bookmarks["VName"];
  17010. mark.Text = hr.HotelName;
  17011. }
  17012. //号码
  17013. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17014. {
  17015. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17016. mark.Text = hr.CheckNumber;
  17017. }
  17018. #endregion
  17019. strFileName += "VOUCHER.doc";
  17020. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17021. doc.Save(fileDir);
  17022. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17023. return Ok(JsonView(true, "操作成功!", Url));
  17024. }
  17025. else
  17026. {
  17027. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17028. }
  17029. }
  17030. else
  17031. {
  17032. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17033. }
  17034. }
  17035. catch (Exception ex)
  17036. {
  17037. return Ok(JsonView(false, ex.Message));
  17038. }
  17039. }
  17040. /// <summary>
  17041. /// 酒店预订
  17042. /// 生成VOUCHER
  17043. /// 2024.05.06 之后版本
  17044. /// </summary>
  17045. /// <param name="_dto"></param>
  17046. /// <returns></returns>
  17047. [HttpPost]
  17048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17049. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17050. {
  17051. #region 参数验证
  17052. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17053. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17054. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17055. #region 团组操作权限验证 76 酒店预定模块
  17056. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17057. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17058. #endregion
  17059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17060. #region 页面操作权限验证
  17061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17062. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17063. #endregion
  17064. #endregion
  17065. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17066. //判断数据是否完整
  17067. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17068. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17069. string strFileName = "HotelStatement/";
  17070. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17071. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17072. #region 数据处理
  17073. List<int> guestIds = new List<int>();
  17074. //int index = 0;
  17075. foreach (var item in hrDtas)
  17076. {
  17077. if (item.GuestName.Contains(","))
  17078. {
  17079. string[] guestIdArr = item.GuestName.Split(',');
  17080. foreach (var guestIdStr in guestIdArr)
  17081. {
  17082. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17083. if (guestBool)
  17084. {
  17085. guestIds.Add(guestId);
  17086. }
  17087. }
  17088. }
  17089. else guestNames += item.GuestName;
  17090. var voucherInfo = new HotelVoucherInfoView()
  17091. {
  17092. HotelName = item.HotelName,
  17093. CheckInDate = item.CheckInDate,
  17094. CheckOutDate = item.CheckOutDate,
  17095. ConfirmationNumber = item.DetermineNo.Trim(),
  17096. RoomType = item.RoomExplanation
  17097. };
  17098. vouchers.Add(voucherInfo);
  17099. }
  17100. if (guestIds.Count > 0)
  17101. {
  17102. guestIds = guestIds.Distinct().ToList();
  17103. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17104. if (guestDatas.Count > 0)
  17105. {
  17106. guestNames = "";
  17107. foreach (var guest in guestDatas)
  17108. {
  17109. string guestName = "";
  17110. if (guest.Sex == 0) guestName += @"MR.";
  17111. else if (guest.Sex == 1) guestName += @"MS.";
  17112. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17113. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17114. guestNames += @$"{guestName.Trim()}、";
  17115. }
  17116. if (guestNames.Length > 0)
  17117. {
  17118. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17119. }
  17120. }
  17121. }
  17122. #endregion
  17123. //载入模板
  17124. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17125. Document doc = new Document(sss);
  17126. DocumentBuilder builder = new DocumentBuilder(doc);
  17127. if (doc.Range.Bookmarks["GuestName"] != null)
  17128. {
  17129. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17130. mark.Text = guestNames;
  17131. }
  17132. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17133. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17134. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17135. for (int i = 1; i <= vouchers.Count; i++)
  17136. {
  17137. HotelVoucherInfoView hviv = vouchers[i - 1];
  17138. builder.MoveToCell(0, i, 0, 0);
  17139. builder.Write(hviv.HotelName);
  17140. builder.MoveToCell(0, i, 1, 0);
  17141. builder.Write(hviv.CheckInDate);
  17142. builder.MoveToCell(0, i, 2, 0);
  17143. builder.Write(hviv.CheckOutDate);
  17144. builder.MoveToCell(0, i, 3, 0);
  17145. builder.Write(hviv.RoomType);
  17146. builder.MoveToCell(0, i, 4, 0);
  17147. builder.Write(hviv.ConfirmationNumber);
  17148. }
  17149. //删除多余行
  17150. int currRowIndex = vouchers.Count + 1;
  17151. int delRows = 21 - currRowIndex;
  17152. if (delRows > 0)
  17153. {
  17154. for (int i = 0; i < delRows; i++)
  17155. {
  17156. table.Rows.RemoveAt(currRowIndex);
  17157. //cultivateRowIndex++;
  17158. }
  17159. }
  17160. strFileName += "VOUCHER.docx";
  17161. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17162. doc.Save(fileDir);
  17163. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17164. return Ok(JsonView(true, "操作成功!", Url));
  17165. }
  17166. /// <summary>
  17167. /// 酒店预订
  17168. /// 生成VOUCHER 批量生成
  17169. /// New
  17170. /// </summary>
  17171. /// <param name="_dto"></param>
  17172. /// <returns></returns>
  17173. [HttpPost]
  17174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17175. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17176. {
  17177. #region 参数验证
  17178. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17179. if (_dto.PageId < 1) _dto.PageId = 28;
  17180. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17181. #region 团组操作权限验证 76 酒店预定模块
  17182. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17183. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17184. #endregion
  17185. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17186. #region 页面操作权限验证
  17187. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17188. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17189. #endregion
  17190. #endregion
  17191. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17192. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17193. .OrderBy(x => x.CheckInDate)
  17194. .ToListAsync();
  17195. //判断数据是否完整
  17196. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17197. string strFileName = "HotelStatement/";
  17198. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17199. if (dele != null)
  17200. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17201. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17202. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17203. .Where(it => it.IsDel == 0)
  17204. .ToListAsync();
  17205. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17206. for (int i = 0; i < hrDtas.Count; i++)
  17207. {
  17208. string guestNames = string.Empty;
  17209. List<int> guestIds = new List<int>();
  17210. var item = hrDtas[i];
  17211. //处理客户姓名
  17212. if (item.GuestName.Contains(","))
  17213. {
  17214. string[] guestIdArr = item.GuestName.Split(',');
  17215. foreach (var guestIdStr in guestIdArr)
  17216. if (int.TryParse(guestIdStr, out int guestId))
  17217. guestIds.Add(guestId);
  17218. }
  17219. else
  17220. {
  17221. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17222. if (guestIdBool)
  17223. {
  17224. guestIds.Add(guestId);
  17225. }
  17226. //NaN
  17227. if (item.GuestName.Contains("NaN"))
  17228. {
  17229. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17230. }
  17231. }
  17232. if (guestIds.Count > 0)
  17233. {
  17234. guestIds = guestIds.Distinct().ToList();
  17235. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17236. if (guestDatas1.Count > 0)
  17237. {
  17238. guestNames = "";
  17239. foreach (var guest in guestDatas1)
  17240. {
  17241. string guestName = "";
  17242. if (guest.Sex == 0) guestName += @"MR.";
  17243. else if (guest.Sex == 1) guestName += @"MS.";
  17244. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17245. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17246. guestNames += @$"{guestName.Trim()}、";
  17247. }
  17248. if (guestNames.Length > 0)
  17249. {
  17250. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17251. }
  17252. }
  17253. }
  17254. //if (!string.IsNullOrEmpty(guestNames))
  17255. //{
  17256. hrDtas[i].GuestName = guestNames;
  17257. //}
  17258. }
  17259. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17260. Document doc = new Document();
  17261. DocumentBuilder builder = new DocumentBuilder(doc);
  17262. try
  17263. {
  17264. builder.MoveToDocumentStart();
  17265. foreach (var item in hrDtas)
  17266. {
  17267. //标题
  17268. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17269. builder.ParagraphFormat.LineSpacing = 1;
  17270. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17271. builder.ParagraphFormat.Style.Font.Size = 9;
  17272. builder.ParagraphFormat.Style.Font.Bold = true;
  17273. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17274. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17275. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17276. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17277. builder.ParagraphFormat.LineSpacing = 1;
  17278. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17279. builder.ParagraphFormat.Style.Font.Size = 9;
  17280. builder.ParagraphFormat.Style.Font.Bold = true;
  17281. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17282. builder.StartTable();
  17283. // 设置边框颜色
  17284. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17285. //设置边框样式
  17286. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17287. //表格
  17288. #region 第一行
  17289. builder.InsertCell();
  17290. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17291. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17292. //builder.CellFormat.AllowAutoFit = false;
  17293. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17294. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17295. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17296. builder.CellFormat.WrapText = true; //自动换行
  17297. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17298. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17299. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17300. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17301. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17302. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17303. builder.Write("TOUR NO:");
  17304. builder.InsertCell();
  17305. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17306. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17307. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17308. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17309. builder.ParagraphFormat.Style.Font.Bold = false;
  17310. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17311. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17312. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17313. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17314. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17315. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17316. builder.Write($"{dele?.TourCode ?? "-"}");
  17317. builder.InsertCell();
  17318. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17319. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17320. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17321. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17322. builder.ParagraphFormat.Style.Font.Bold = false;
  17323. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17324. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17325. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17326. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17327. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17328. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17329. builder.Write($"CITY:");
  17330. builder.InsertCell();
  17331. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17332. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17333. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17334. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17335. builder.ParagraphFormat.Style.Font.Bold = false;
  17336. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17337. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17338. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17339. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17340. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17341. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17342. builder.Write($"{item.City}");
  17343. builder.EndRow();
  17344. #endregion
  17345. #region 第二行
  17346. builder.InsertCell();
  17347. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17348. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17349. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17350. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17351. builder.ParagraphFormat.Style.Font.Bold = false;
  17352. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17353. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17354. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17355. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17356. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17357. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17358. builder.Write("CONFIRMATION NO:");
  17359. builder.InsertCell();
  17360. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17361. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17362. builder.ParagraphFormat.Style.Font.Size = 8;
  17363. builder.ParagraphFormat.Style.Font.Bold = false;
  17364. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17365. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17366. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17367. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17368. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17369. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17370. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17371. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17372. builder.Write($"{item.DetermineNo}");
  17373. builder.InsertCell();
  17374. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17375. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17376. builder.InsertCell();
  17377. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17378. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17379. builder.EndRow();
  17380. #endregion
  17381. #region 第三行
  17382. builder.InsertCell();
  17383. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17384. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17385. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17386. builder.ParagraphFormat.Style.Font.Bold = false;
  17387. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17388. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17389. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17390. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17391. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17392. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17393. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17394. builder.Write($"HOTEL NAME:");
  17395. builder.InsertCell();
  17396. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17397. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17398. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17399. builder.ParagraphFormat.Style.Font.Bold = false;
  17400. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17401. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17402. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17403. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17404. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17405. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17406. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17407. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17408. builder.Write($"{item.HotelName}");
  17409. builder.InsertCell();
  17410. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17411. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17412. builder.InsertCell();
  17413. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17414. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17415. builder.EndRow();
  17416. #endregion
  17417. #region 第四行
  17418. builder.InsertCell();
  17419. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17420. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17421. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17422. builder.ParagraphFormat.Style.Font.Bold = false;
  17423. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17424. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17425. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17426. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17427. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17428. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17429. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17430. builder.Write($"HOTEL ADDRESS:");
  17431. builder.InsertCell();
  17432. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17433. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17434. builder.ParagraphFormat.Style.Font.Size = 8;
  17435. builder.ParagraphFormat.Style.Font.Bold = false;
  17436. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17437. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17438. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17439. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17440. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17441. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17442. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17443. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17444. builder.Write($"{item.HotelAddress}");
  17445. builder.InsertCell();
  17446. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17447. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17448. builder.InsertCell();
  17449. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17450. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17451. builder.EndRow();
  17452. #endregion
  17453. #region 第五行
  17454. builder.InsertCell();
  17455. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17456. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17457. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17458. builder.ParagraphFormat.Style.Font.Bold = false;
  17459. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17460. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17461. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17462. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17463. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17464. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17465. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17466. builder.Write("TEL:");
  17467. builder.InsertCell();
  17468. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17469. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17470. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17471. builder.ParagraphFormat.Style.Font.Bold = false;
  17472. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17473. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17474. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17475. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17476. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17477. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17478. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17479. builder.Write($"{item.HotelTel}");
  17480. builder.InsertCell();
  17481. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17482. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17483. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17484. builder.ParagraphFormat.Style.Font.Bold = false;
  17485. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17486. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17487. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17488. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17489. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17490. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17491. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17492. builder.Write($"FAX:");
  17493. builder.InsertCell();
  17494. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17495. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17496. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17497. builder.ParagraphFormat.Style.Font.Bold = false;
  17498. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17499. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17500. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17501. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17502. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17503. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17504. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17505. builder.Write($"{item.HotelFax}");
  17506. builder.EndRow();
  17507. #endregion
  17508. #region 第六行
  17509. builder.InsertCell();
  17510. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17511. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17512. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17513. builder.ParagraphFormat.Style.Font.Bold = false;
  17514. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17515. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17516. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17517. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17518. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17519. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17520. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17521. builder.Write("CHECK IN:");
  17522. builder.InsertCell();
  17523. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17524. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17525. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17526. builder.ParagraphFormat.Style.Font.Bold = false;
  17527. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17528. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17529. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17530. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17531. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17532. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17533. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17534. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17535. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17536. builder.Write($"{checkInStr}");
  17537. builder.InsertCell();
  17538. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17539. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17540. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17541. builder.ParagraphFormat.Style.Font.Bold = false;
  17542. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17543. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17544. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17545. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17546. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17547. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17548. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17549. builder.Write($"CHECK OUT:");
  17550. builder.InsertCell();
  17551. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17552. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17553. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17554. builder.ParagraphFormat.Style.Font.Bold = false;
  17555. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17556. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17557. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17558. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17559. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17560. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17561. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17562. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17563. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17564. builder.Write($"{checkOutStr}");
  17565. builder.EndRow();
  17566. #endregion
  17567. #region 第七行
  17568. builder.InsertCell();
  17569. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17570. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17571. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17572. builder.ParagraphFormat.Style.Font.Bold = false;
  17573. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17574. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17575. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17576. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17577. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17578. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17579. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17580. builder.Write($"GUEST NAME:");
  17581. builder.InsertCell();
  17582. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17583. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17584. builder.ParagraphFormat.Style.Font.Size = 8;
  17585. builder.ParagraphFormat.Style.Font.Bold = false;
  17586. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17587. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17588. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17589. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17590. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17591. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17592. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17593. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17594. builder.Write($"{item.GuestName.Trim()}");
  17595. builder.InsertCell();
  17596. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17597. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17598. builder.InsertCell();
  17599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17600. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17601. builder.EndRow();
  17602. #endregion
  17603. #region 第八行
  17604. builder.InsertCell();
  17605. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17606. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17607. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17608. builder.ParagraphFormat.Style.Font.Bold = false;
  17609. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17610. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17611. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17612. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17613. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17614. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17615. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17616. builder.Write($"ROOM TYPE:");
  17617. builder.InsertCell();
  17618. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17619. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17620. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17621. builder.ParagraphFormat.Style.Font.Bold = false;
  17622. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17623. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17624. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17625. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17626. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17627. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17628. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17629. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17630. builder.Write($"{item.RoomExplanation}");
  17631. builder.InsertCell();
  17632. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17633. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17634. builder.InsertCell();
  17635. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17636. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17637. builder.EndRow();
  17638. #endregion
  17639. #region 第九行
  17640. builder.InsertCell();
  17641. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17642. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17643. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17644. builder.ParagraphFormat.Style.Font.Bold = false;
  17645. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17646. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17647. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17648. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17649. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17650. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17651. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17652. builder.Write($"NOTE:");
  17653. builder.InsertCell();
  17654. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17655. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17656. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17657. builder.ParagraphFormat.Style.Font.Bold = false;
  17658. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17659. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17660. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17661. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17662. 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.");
  17663. builder.InsertCell();
  17664. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17665. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17666. builder.InsertCell();
  17667. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17668. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17669. builder.EndRow();
  17670. #endregion
  17671. builder.EndTable();
  17672. //换行
  17673. builder.Writeln("");
  17674. builder.Writeln("");
  17675. }
  17676. #region 获取文档中的所有表格 设置文字自适应
  17677. // 获取文档中的所有表格。
  17678. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17679. {
  17680. // 遍历表格中的所有行。
  17681. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17682. {
  17683. foreach (Cell cell in row.Cells)
  17684. {
  17685. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17686. cellFormat.Width = 0;
  17687. }
  17688. }
  17689. }
  17690. #endregion
  17691. #region 设置页眉
  17692. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  17693. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  17694. if (System.IO.File.Exists(voucherHeaderPath))
  17695. {
  17696. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  17697. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  17698. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  17699. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  17700. // 调整图片位置
  17701. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  17702. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  17703. shape.Top = 50; // 将图片距离页眉上边缘的距离
  17704. shape.Left = 0; // 将图片距离页面左边缘的距离
  17705. shape.Width = 81; // 设置图片宽度
  17706. shape.Height = 36; // 设置图片高度
  17707. }
  17708. //靠右
  17709. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17710. //// 设置页脚上下边距
  17711. //builder.PageSetup.HeaderDistance = 42;
  17712. // 添加页眉线
  17713. Aspose.Words.Border borderHeader = null;
  17714. try
  17715. {
  17716. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  17717. }
  17718. catch (Exception e)
  17719. {
  17720. // TODO Auto-generated catch block
  17721. //e.printStackTrace();
  17722. }
  17723. borderHeader.Shadow = true;
  17724. borderHeader.DistanceFromText = 2;
  17725. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  17726. #endregion
  17727. }
  17728. catch (Exception ex)
  17729. {
  17730. }
  17731. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17732. doc.Save(fileDir);
  17733. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17734. return Ok(JsonView(true, "操作成功!", Url));
  17735. }
  17736. /// <summary>
  17737. /// 酒店预订
  17738. /// 生成 预定成本 Excel
  17739. /// </summary>
  17740. /// <param name="_dto"></param>
  17741. /// <returns></returns>
  17742. [HttpPost]
  17743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17744. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  17745. {
  17746. #region 参数验证
  17747. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  17748. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  17749. if (!vadalitorRes.IsValid)
  17750. {
  17751. var errors = new StringBuilder();
  17752. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  17753. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  17754. }
  17755. #region 团组操作权限验证 76 酒店预定模块
  17756. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17757. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17758. #endregion
  17759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17760. #region 页面操作权限验证
  17761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17762. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17763. #endregion
  17764. #endregion
  17765. decimal _rate = 1.00M;
  17766. string _currency = string.Empty;
  17767. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  17768. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17769. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  17770. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17771. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  17772. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  17773. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  17774. if (_GroupCostParameter == null)
  17775. {
  17776. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  17777. bool isIntType = int.TryParse(_currency, out int currId);
  17778. if (isIntType)
  17779. {
  17780. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17781. }
  17782. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17783. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17784. if (currInfo == null)
  17785. {
  17786. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17787. }
  17788. else _rate = currInfo.Rate;
  17789. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  17790. {
  17791. _rate = _GroupCostParameter.Rate;
  17792. }
  17793. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17794. //string strFileName = "HotelStatement/";
  17795. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17796. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17797. var rateDatas = new List<dynamic>();
  17798. #region 数据处理
  17799. foreach (var item in hrDtas)
  17800. {
  17801. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17802. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17803. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17804. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17805. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17806. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  17807. {
  17808. continue;
  17809. }
  17810. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17811. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  17812. string singleRoomFeeStr = string.Empty,
  17813. doubleRoomFeeStr = string.Empty,
  17814. suiteRoomFeeStr = string.Empty,
  17815. otherRoomFeeStr = string.Empty,
  17816. payMoneyStr = string.Empty,
  17817. cardPriceStr = string.Empty;
  17818. if (roomCurr.Equals("CNY"))
  17819. {
  17820. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  17821. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17822. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17823. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17824. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17825. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  17826. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  17827. }
  17828. else
  17829. {
  17830. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17831. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17832. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17833. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17834. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17835. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17836. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17837. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17838. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17839. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17840. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  17841. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  17842. if (ccpPaymentCurrency.Equals("CNY"))
  17843. {
  17844. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  17845. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17846. }
  17847. else
  17848. {
  17849. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17850. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17851. }
  17852. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17853. if (hotelcardPriceCurrency.Equals("CNY"))
  17854. {
  17855. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17856. }
  17857. else
  17858. {
  17859. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  17860. }
  17861. }
  17862. string breakfastPriceStr = string.Empty,
  17863. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17864. governmentRentStr = string.Empty,
  17865. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17866. cityTaxStr = string.Empty,
  17867. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17868. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  17869. if (!string.IsNullOrEmpty(breakfastCurrency1))
  17870. {
  17871. if (breakfastCurrency1.Equals("CNY"))
  17872. {
  17873. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17874. }
  17875. else
  17876. {
  17877. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  17878. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  17879. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  17880. }
  17881. }
  17882. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17883. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  17884. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  17885. {
  17886. if (governmentRentCurrency.Equals("CNY"))
  17887. {
  17888. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17889. }
  17890. else
  17891. {
  17892. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  17893. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  17894. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  17895. }
  17896. }
  17897. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17898. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  17899. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  17900. {
  17901. if (cityTaxStrCurrency1.Equals("CNY"))
  17902. {
  17903. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17904. }
  17905. else
  17906. {
  17907. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  17908. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  17909. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  17910. }
  17911. }
  17912. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17913. int payDId = roomInfo?.PayDId ?? 0;
  17914. pcfds.Add(new HotelReservations_PCFD_View()
  17915. {
  17916. City = item.City,
  17917. HotelName = item.HotelName,
  17918. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17919. // SingleRoomCount = item.SingleRoomCount,
  17920. SingleRoomPrice = singleRoomFeeStr,
  17921. // DoubleRoomCount = item.DoubleRoomCount,
  17922. DoubleRoomPrice = doubleRoomFeeStr,
  17923. //SuiteRoomCount = item.SuiteRoomCount,
  17924. SuiteRoomPrice = suiteRoomFeeStr,
  17925. OtherRoomPrice = otherRoomFeeStr,
  17926. //OtherRoomCount = item.OtherRoomCount,
  17927. BreakfastPrice = breakfastPriceStr,
  17928. GovernmentRent = governmentRentStr,
  17929. CityTax = cityTaxStr,
  17930. RoomExplanation = item.RoomExplanation,
  17931. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17932. PayTime = roomInfo?.ConsumptionDate,
  17933. BankNo = roomInfo?.BankNo,
  17934. PayMoney = payMoneyStr,
  17935. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17936. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17937. CardPrice = cardPriceStr,
  17938. Remark = ccpInfo.Remark
  17939. });
  17940. }
  17941. #endregion
  17942. //载入模板
  17943. WorkbookDesigner designer = new WorkbookDesigner();
  17944. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17945. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17946. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17947. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17948. var rateDatas1 = rateDatas.Distinct();
  17949. var rateStr = string.Empty;
  17950. foreach (var item in rateDatas1)
  17951. {
  17952. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  17953. }
  17954. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  17955. designer.SetDataSource("Opertor", userInfo.CnName);
  17956. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17957. dt.TableName = "ViewMyHotelReservations";
  17958. designer.SetDataSource(dt);
  17959. designer.Process();
  17960. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17961. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17962. designer.Workbook.Save(serverPath);
  17963. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17964. #region 删除指定行
  17965. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17966. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17967. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17968. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17969. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17970. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17971. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17972. cssIndex = dt.Columns["CityTax"].Ordinal,
  17973. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17974. remarkIndex = dt.Columns["Remark"].Ordinal;
  17975. //删除指定列
  17976. foreach (DataRow item in dt.Rows)
  17977. {
  17978. string singleStr = item["SingleRoomPrice"].ToString();
  17979. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17980. if (containsDigitButNotZero1) singleDel = false;
  17981. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17982. string doubleStr = item["DoubleRoomPrice"].ToString();
  17983. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17984. if (containsDigitButNotZero2) doubleDel = false;
  17985. string suiteStr = item["SuiteRoomPrice"].ToString();
  17986. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17987. if (containsDigitButNotZero3) suiteDel = false;
  17988. string otherStr = item["OtherRoomPrice"].ToString();
  17989. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17990. if (containsDigitButNotZero4) otherDel = false;
  17991. string zcStr = item["BreakfastPrice"].ToString();
  17992. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17993. if (containsDigitButNotZero5) zcDel = false;
  17994. string dsStr = item["GovernmentRent"].ToString();
  17995. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17996. if (containsDigitButNotZero6) dsDel = false;
  17997. string cssStr = item["CityTax"].ToString();
  17998. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17999. if (containsDigitButNotZero7) cssDel = false;
  18000. string cpStr = item["ConsumptionPatterns"].ToString();
  18001. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18002. string remarkStr = item["Remark"].ToString();
  18003. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18004. }
  18005. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18006. DeleteColumn(serverPath, cpIndex, cpDel);
  18007. DeleteColumn(serverPath, dsIndex, dsDel);
  18008. DeleteColumn(serverPath, cssIndex, cssDel);
  18009. DeleteColumn(serverPath, zcIndex, zcDel);
  18010. DeleteColumn(serverPath, otherIndex, otherDel);
  18011. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18012. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18013. DeleteColumn(serverPath, singleIndex, singleDel);
  18014. #endregion
  18015. //只保留第一个表格
  18016. DeleteSheet(serverPath);
  18017. return Ok(JsonView(true, "操作成功", url = rst));
  18018. }
  18019. else
  18020. {
  18021. _currency = _GroupCostParameter.Currency;
  18022. bool isIntType = int.TryParse(_currency, out int currId);
  18023. if (isIntType)
  18024. {
  18025. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18026. }
  18027. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18028. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18029. if (currInfo == null)
  18030. {
  18031. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18032. }
  18033. if (!_currency.ToUpper().Equals("CNY"))
  18034. {
  18035. _rate = _GroupCostParameter.Rate;
  18036. }
  18037. _rate = currInfo.Rate;
  18038. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18039. //string strFileName = "HotelStatement/";
  18040. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18041. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18042. #region 数据处理
  18043. foreach (var item in hrDtas)
  18044. {
  18045. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18046. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18047. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18048. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18049. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18050. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18051. string singleRoomFeeStr = string.Empty,
  18052. doubleRoomFeeStr = string.Empty,
  18053. suiteRoomFeeStr = string.Empty,
  18054. otherRoomFeeStr = string.Empty,
  18055. payMoneyStr = string.Empty,
  18056. cardPriceStr = string.Empty;
  18057. if (roomCurr.Equals(_currency))
  18058. {
  18059. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18060. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18061. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18062. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18063. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18064. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18065. }
  18066. else
  18067. {
  18068. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18069. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18070. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18071. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18072. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18073. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18074. }
  18075. string breakfastPriceStr = string.Empty,
  18076. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18077. governmentRentStr = string.Empty,
  18078. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18079. cityTaxStrStr = string.Empty,
  18080. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18081. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18082. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18083. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18084. int payDId = roomInfo?.PayDId ?? 0;
  18085. pcfds.Add(new HotelReservations_PCFD_View()
  18086. {
  18087. City = item.City,
  18088. HotelName = item.HotelName,
  18089. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18090. // SingleRoomCount = item.SingleRoomCount,
  18091. SingleRoomPrice = singleRoomFeeStr,
  18092. // DoubleRoomCount = item.DoubleRoomCount,
  18093. DoubleRoomPrice = doubleRoomFeeStr,
  18094. //SuiteRoomCount = item.SuiteRoomCount,
  18095. SuiteRoomPrice = suiteRoomFeeStr,
  18096. OtherRoomPrice = otherRoomFeeStr,
  18097. //OtherRoomCount = item.OtherRoomCount,
  18098. BreakfastPrice = breakfastPriceStr,
  18099. GovernmentRent = governmentRentStr,
  18100. CityTax = cityTaxStrStr,
  18101. RoomExplanation = item.RoomExplanation,
  18102. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18103. PayTime = roomInfo?.ConsumptionDate,
  18104. BankNo = roomInfo?.BankNo,
  18105. PayMoney = payMoneyStr,
  18106. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18107. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18108. CardPrice = cardPriceStr,
  18109. Remark = ccpInfo.Remark
  18110. });
  18111. }
  18112. #endregion
  18113. //载入模板
  18114. WorkbookDesigner designer = new WorkbookDesigner();
  18115. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18116. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18117. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18118. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18119. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18120. designer.SetDataSource("Opertor", userInfo.CnName);
  18121. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18122. dt.TableName = "ViewMyHotelReservations";
  18123. designer.SetDataSource(dt);
  18124. designer.Process();
  18125. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18126. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18127. designer.Workbook.Save(serverPath);
  18128. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18129. #region 删除指定行
  18130. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18131. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18132. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18133. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18134. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18135. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18136. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18137. cssIndex = dt.Columns["CityTax"].Ordinal,
  18138. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18139. remarkIndex = dt.Columns["Remark"].Ordinal;
  18140. //删除指定列
  18141. foreach (DataRow item in dt.Rows)
  18142. {
  18143. string singleStr = item["SingleRoomPrice"].ToString();
  18144. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18145. if (containsDigitButNotZero1) singleDel = false;
  18146. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18147. string doubleStr = item["DoubleRoomPrice"].ToString();
  18148. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18149. if (containsDigitButNotZero2) doubleDel = false;
  18150. string suiteStr = item["SuiteRoomPrice"].ToString();
  18151. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18152. if (containsDigitButNotZero3) suiteDel = false;
  18153. string otherStr = item["OtherRoomPrice"].ToString();
  18154. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18155. if (containsDigitButNotZero4) otherDel = false;
  18156. string zcStr = item["BreakfastPrice"].ToString();
  18157. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18158. if (containsDigitButNotZero5) zcDel = false;
  18159. string dsStr = item["GovernmentRent"].ToString();
  18160. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18161. if (containsDigitButNotZero6) dsDel = false;
  18162. string cssStr = item["CityTax"].ToString();
  18163. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18164. if (containsDigitButNotZero7) cssDel = false;
  18165. string cpStr = item["ConsumptionPatterns"].ToString();
  18166. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18167. string remarkStr = item["Remark"].ToString();
  18168. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18169. }
  18170. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18171. DeleteColumn(serverPath, cpIndex, cpDel);
  18172. DeleteColumn(serverPath, dsIndex, dsDel);
  18173. DeleteColumn(serverPath, cssIndex, cssDel);
  18174. DeleteColumn(serverPath, zcIndex, zcDel);
  18175. DeleteColumn(serverPath, otherIndex, otherDel);
  18176. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18177. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18178. DeleteColumn(serverPath, singleIndex, singleDel);
  18179. #endregion
  18180. //只保留第一个表格
  18181. DeleteSheet(serverPath);
  18182. return Ok(JsonView(true, "操作成功", url = rst));
  18183. }
  18184. //return Ok(JsonView(false));
  18185. }
  18186. /// <summary>
  18187. /// 删除指定列
  18188. /// </summary>
  18189. /// <param name="file"></param>
  18190. /// <param name="columnIndex"></param>
  18191. /// <param name="isDel"></param>
  18192. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18193. {
  18194. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18195. //wb.Save(file);
  18196. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18197. if (sheet1 != null)
  18198. {
  18199. if (isDel)
  18200. {
  18201. Cells cells = sheet1.Cells;
  18202. cells.DeleteColumn(columnIndex);
  18203. }
  18204. }
  18205. wb.Save(file);
  18206. }
  18207. /// <summary>
  18208. /// 删除sheet
  18209. /// </summary>
  18210. /// <param name="file"></param>
  18211. /// <param name="sheetName"></param>
  18212. private void DeleteSheet(string file, string sheetName = "")
  18213. {
  18214. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18215. //wb.Save(file);
  18216. List<string> sheets = new List<string>();
  18217. foreach (var item in wb.Worksheets)
  18218. {
  18219. sheets.Add(item.Name);
  18220. }
  18221. if (sheets.Count > 0)
  18222. {
  18223. sheets.RemoveAt(0);//不删除第一个sheet
  18224. foreach (var item in sheets)
  18225. {
  18226. wb.Worksheets.RemoveAt(item);
  18227. }
  18228. }
  18229. wb.Save(file);
  18230. }
  18231. /// <summary>
  18232. /// 酒店预订
  18233. /// 确认单
  18234. /// </summary>
  18235. /// <param name="_dto"></param>
  18236. /// <returns></returns>
  18237. [HttpPost]
  18238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18239. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18240. {
  18241. try
  18242. {
  18243. #region 参数验证
  18244. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18245. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18246. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18247. #region 团组操作权限验证 76 酒店预定模块
  18248. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18249. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18250. #endregion
  18251. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18252. #region 页面操作权限验证
  18253. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18254. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18255. #endregion
  18256. #endregion
  18257. //团组信息
  18258. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18259. //酒店数据
  18260. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18261. if (listhoteldata.Count < 0)
  18262. {
  18263. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18264. }
  18265. //利datatable存储
  18266. DataTable dt = new DataTable();
  18267. dt.Columns.Add("CheckInDate", typeof(string));
  18268. dt.Columns.Add("City", typeof(string));
  18269. dt.Columns.Add("Hotel", typeof(string));
  18270. dt.Columns.Add("Room", typeof(string));
  18271. for (int i = 0; i < listhoteldata.Count; i++)
  18272. {
  18273. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18274. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18275. while (dayStart < dayEnd)
  18276. {
  18277. string temp = "";
  18278. DataRow row = dt.NewRow();
  18279. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18280. row["City"] = listhoteldata[i].City;
  18281. row["Hotel"] = listhoteldata[i].HotelName;
  18282. if (listhoteldata[i].SingleRoomCount > 0)
  18283. {
  18284. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18285. }
  18286. if (listhoteldata[i].DoubleRoomCount > 0)
  18287. {
  18288. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18289. }
  18290. if (listhoteldata[i].SuiteRoomCount > 0)
  18291. {
  18292. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18293. }
  18294. if (listhoteldata[i].OtherRoomCount > 0)
  18295. {
  18296. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18297. }
  18298. row["Room"] = temp;
  18299. dt.Rows.Add(row);
  18300. dayStart = dayStart.AddDays(1);
  18301. }
  18302. }
  18303. Dictionary<string, string> dic = new Dictionary<string, string>();
  18304. dic.Add("Dele", di.TeamName);
  18305. dic.Add("City", di.VisitCountry);
  18306. //模板路径
  18307. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18308. //载入模板
  18309. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18310. DocumentBuilder builder = new DocumentBuilder(doc);
  18311. foreach (var key in dic.Keys)
  18312. {
  18313. builder.MoveToBookmark(key);
  18314. builder.Write(dic[key]);
  18315. }
  18316. //获取word里所有表格
  18317. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18318. //获取所填表格的序数
  18319. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18320. var rowStart = tableOne.Rows[0]; //获取第1行
  18321. //循环赋值
  18322. for (int i = 0; i < dt.Rows.Count; i++)
  18323. {
  18324. builder.MoveToCell(0, i + 1, 0, 0);
  18325. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18326. builder.MoveToCell(0, i + 1, 1, 0);
  18327. builder.Write(dt.Rows[i]["City"].ToString());
  18328. builder.MoveToCell(0, i + 1, 2, 0);
  18329. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18330. builder.MoveToCell(0, i + 1, 3, 0);
  18331. builder.Write(dt.Rows[i]["Room"].ToString());
  18332. }
  18333. //删除多余行
  18334. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18335. {
  18336. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18337. }
  18338. string strFileName = di.TeamName + "酒店确认单.doc";
  18339. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18340. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18341. return Ok(JsonView(true, "成功", url));
  18342. }
  18343. catch (Exception ex)
  18344. {
  18345. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18346. }
  18347. }
  18348. #endregion
  18349. #region 团组状态
  18350. /// <summary>
  18351. /// 团组状态列表 Page
  18352. /// </summary>
  18353. /// <param name="dto">团组列表请求dto</param>
  18354. /// <returns></returns>
  18355. [HttpPost]
  18356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18357. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18358. {
  18359. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18360. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18361. {
  18362. string sqlWhere = string.Empty;
  18363. if (dto.IsSure == 0) //未完成
  18364. {
  18365. sqlWhere += string.Format(@" And IsSure = 0");
  18366. }
  18367. else if (dto.IsSure == 1) //已完成
  18368. {
  18369. sqlWhere += string.Format(@" And IsSure = 1");
  18370. }
  18371. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18372. {
  18373. string tj = dto.SearchCriteria;
  18374. 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}%')",
  18375. tj, tj, tj, tj, tj);
  18376. }
  18377. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18378. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18379. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18380. From (
  18381. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18382. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18383. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18384. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18385. From Grp_DelegationInfo gdi
  18386. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18387. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18388. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18389. Where gdi.IsDel = 0 {0}
  18390. ) temp ", sqlWhere);
  18391. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18392. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18393. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18394. }
  18395. else
  18396. {
  18397. return Ok(JsonView(false, "查询失败"));
  18398. }
  18399. }
  18400. /// <summary>
  18401. /// 团组状态
  18402. /// 设置操作完成
  18403. /// </summary>
  18404. /// <param name="dto">团组列表请求dto</param>
  18405. /// <returns></returns>
  18406. [HttpPost]
  18407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18408. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18409. {
  18410. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18411. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18412. {
  18413. Id = dto.Id,
  18414. IsSure = 1
  18415. };
  18416. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18417. .UpdateColumns(it => new { it.IsSure })
  18418. .WhereColumns(it => new { it.Id })
  18419. .ExecuteCommandAsync();
  18420. if (result > 0)
  18421. {
  18422. return Ok(JsonView(true, "操作完成!"));
  18423. }
  18424. return Ok(JsonView(false, "操作失败!"));
  18425. }
  18426. #endregion
  18427. #region 保险费用录入
  18428. /// <summary>
  18429. /// 根据团组Id查询保险费用列表
  18430. /// </summary>
  18431. /// <param name="dto"></param>
  18432. /// <returns></returns>
  18433. [HttpPost]
  18434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18435. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18436. {
  18437. Result groupData = await _customersRep.CustomersByDiId(dto);
  18438. if (groupData.Code != 0)
  18439. {
  18440. return Ok(JsonView(false, groupData.Msg));
  18441. }
  18442. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18443. }
  18444. /// <summary>
  18445. /// 根据保险费用Id查询保险费用详细
  18446. /// </summary>
  18447. /// <param name="dto"></param>
  18448. /// <returns></returns>
  18449. [HttpPost]
  18450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18451. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18452. {
  18453. try
  18454. {
  18455. Result groupData = await _customersRep.CustomersById(dto);
  18456. if (groupData.Code != 0)
  18457. {
  18458. return Ok(JsonView(false, groupData.Msg));
  18459. }
  18460. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18461. }
  18462. catch (Exception ex)
  18463. {
  18464. return Ok(JsonView(false, ex.Message));
  18465. }
  18466. }
  18467. /// <summary>
  18468. /// 保险费用录入页面初始化绑定
  18469. /// </summary>
  18470. /// <param name="dto"></param>
  18471. /// <returns></returns>
  18472. [HttpPost]
  18473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18474. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18475. {
  18476. try
  18477. {
  18478. Result groupData = await _customersRep.CustomersInitialize(dto);
  18479. if (groupData.Code != 0)
  18480. {
  18481. return Ok(JsonView(false, groupData.Msg));
  18482. }
  18483. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18484. }
  18485. catch (Exception ex)
  18486. {
  18487. return Ok(JsonView(false, ex.Message));
  18488. }
  18489. }
  18490. /// <summary>
  18491. /// 保险费用操作(Status:1.新增,2.修改)
  18492. /// </summary>
  18493. /// <param name="dto"></param>
  18494. /// <returns></returns>
  18495. [HttpPost]
  18496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18497. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18498. {
  18499. Result groupData = await _customersRep.OpCustomers(dto);
  18500. if (groupData.Code != 0)
  18501. {
  18502. return Ok(JsonView(false, groupData.Msg));
  18503. }
  18504. #region 应用推送
  18505. try
  18506. {
  18507. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18508. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18509. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18510. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18511. //自动审核
  18512. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18513. //2024-10-21 新增LZ UID
  18514. var userIds = new List<int>() { 21 };
  18515. string title = $"系统通知";
  18516. var diId = dto.DiId;
  18517. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18518. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18519. string content = "";
  18520. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18521. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18522. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18523. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18524. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18525. }
  18526. catch (Exception ex)
  18527. {
  18528. }
  18529. #endregion
  18530. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18531. }
  18532. /// <summary>
  18533. /// 保险文件上传
  18534. /// </summary>
  18535. /// <param name="file"></param>
  18536. /// <returns></returns>
  18537. [HttpPost]
  18538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18539. public async Task<IActionResult> UploadCus(IFormFile file)
  18540. {
  18541. try
  18542. {
  18543. if (file != null)
  18544. {
  18545. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18546. //文件名称
  18547. string projectFileName = file.FileName;
  18548. //上传的文件的路径
  18549. string filePath = "";
  18550. if (!Directory.Exists(fileDir))
  18551. {
  18552. Directory.CreateDirectory(fileDir);
  18553. }
  18554. //上传的文件的路径
  18555. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18556. using (FileStream fs = System.IO.File.Create(filePath))
  18557. {
  18558. file.CopyTo(fs);
  18559. fs.Flush();
  18560. }
  18561. return Ok(JsonView(true, "上传成功!", projectFileName));
  18562. }
  18563. else
  18564. {
  18565. return Ok(JsonView(false, "上传失败!"));
  18566. }
  18567. }
  18568. catch (Exception ex)
  18569. {
  18570. return Ok(JsonView(false, "程序错误!"));
  18571. throw;
  18572. }
  18573. }
  18574. /// <summary>
  18575. /// 保险删除指定文件
  18576. /// </summary>
  18577. /// <param name="dto"></param>
  18578. /// <returns></returns>
  18579. [HttpPost]
  18580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18581. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18582. {
  18583. try
  18584. {
  18585. string filePath = "";
  18586. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18587. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18588. //int id = 0;
  18589. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18590. // 删除该文件
  18591. try
  18592. {
  18593. System.IO.File.Delete(filePath);
  18594. 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()
  18595. {
  18596. Attachment = "",
  18597. }).ExecuteCommandAsync();
  18598. if (result != 0)
  18599. {
  18600. return Ok(JsonView(true, "成功!"));
  18601. }
  18602. else
  18603. {
  18604. return Ok(JsonView(false, "失败!"));
  18605. }
  18606. }
  18607. catch (Exception)
  18608. {
  18609. 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()
  18610. {
  18611. Attachment = "",
  18612. }).ExecuteCommandAsync();
  18613. if (result != 0)
  18614. {
  18615. return Ok(JsonView(true, "成功!"));
  18616. }
  18617. else
  18618. {
  18619. return Ok(JsonView(false, "失败!"));
  18620. }
  18621. }
  18622. }
  18623. catch (Exception ex)
  18624. {
  18625. return Ok(JsonView(false, "程序错误!"));
  18626. throw;
  18627. }
  18628. }
  18629. /// <summary>
  18630. /// 保险费用操作(删除)
  18631. /// </summary>
  18632. /// <param name="dto"></param>
  18633. /// <returns></returns>
  18634. [HttpPost]
  18635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18636. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18637. {
  18638. try
  18639. {
  18640. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18641. if (!res)
  18642. {
  18643. return Ok(JsonView(false, "删除失败"));
  18644. }
  18645. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18646. {
  18647. IsDel = 1,
  18648. DeleteUserId = dto.DeleteUserId,
  18649. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18650. }).ExecuteCommandAsync();
  18651. return Ok(JsonView(true, "删除成功!"));
  18652. }
  18653. catch (Exception ex)
  18654. {
  18655. return Ok(JsonView(false, "程序错误!"));
  18656. throw;
  18657. }
  18658. }
  18659. #endregion
  18660. #region 接团客户名单 PageId 104
  18661. /// <summary>
  18662. /// 接团客户名单
  18663. /// 迁移数据(慎用!)
  18664. /// </summary>
  18665. /// <returns></returns>
  18666. [HttpPost]
  18667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18668. public async Task<IActionResult> PostTourClientListChange()
  18669. {
  18670. try
  18671. {
  18672. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18673. //var groupClinetData1
  18674. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18675. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18676. int updateCount = 0;
  18677. if (oldOAClientList.Count > 0)
  18678. {
  18679. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18680. _sqlSugar.BeginTran();
  18681. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18682. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18683. foreach (var item in oldOAClientList)
  18684. {
  18685. int comId = 0;
  18686. string format = "yyyy-MM-dd HH:mm:ss";
  18687. string data11 = "1990-01-01 00:00";
  18688. var data1 = IsValidDate(item.OPdate, format);
  18689. if (data1) data11 = item.OPdate;
  18690. //客户公司验证
  18691. if (!string.IsNullOrEmpty(item.Company))
  18692. {
  18693. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  18694. if (clientComInfo == null) // add
  18695. {
  18696. var addInfo = new Crm_CustomerCompany()
  18697. {
  18698. CompanyAbbreviation = "",
  18699. CompanyFullName = item.Company,
  18700. Address = "",
  18701. PostCodes = "",
  18702. LastedOpUserId = item.OPer,
  18703. LastedOpDt = Convert.ToDateTime(data11),
  18704. CreateUserId = item.OPer,
  18705. CreateTime = Convert.ToDateTime(data11),
  18706. IsDel = 0
  18707. };
  18708. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  18709. if (comId1 > 0) comId = comId1;
  18710. }
  18711. else comId = clientComInfo.Id;
  18712. }
  18713. //客户人员验证
  18714. int clientId = 0;
  18715. string name = item.LastName + item.Name;
  18716. if (!string.IsNullOrEmpty(name))
  18717. {
  18718. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  18719. if (clientInfo == null)
  18720. {
  18721. DateTime? dateTime = null;
  18722. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  18723. if (isDt) dateTime = birthDayDt;
  18724. var addInfo1 = new Crm_DeleClient()
  18725. {
  18726. CrmCompanyId = comId,
  18727. DiId = -1,
  18728. LastName = item.LastName,
  18729. FirstName = item.Name,
  18730. OldName = "",
  18731. Pinyin = item.Pinyin,
  18732. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  18733. Marriage = 0,
  18734. Phone = item.Phone,
  18735. Job = item.Job,
  18736. BirthDay = dateTime
  18737. };
  18738. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  18739. if (clientId1 > 0) clientId = clientId1;
  18740. }
  18741. else clientId = clientInfo.Id;
  18742. }
  18743. if (clientId < 1)
  18744. {
  18745. continue;
  18746. }
  18747. int airType = 0;
  18748. if (item.AirType == "超经舱") airType = 459;
  18749. else if (item.AirType == "公务舱") airType = 458;
  18750. else if (item.AirType == "经济舱") airType = 460;
  18751. else if (item.AirType == "其他") airType = 565;
  18752. else if (item.AirType == "头等舱") airType = 457;
  18753. var _TourClientListEntity = new Grp_TourClientList()
  18754. {
  18755. DiId = item.Diid,
  18756. ClientId = clientId,
  18757. CreateUserId = item.OPer,
  18758. CreateTime = Convert.ToDateTime(data11),
  18759. Remark = item.Remark,
  18760. IsDel = item.Isdel,
  18761. ShippingSpaceTypeId = airType,
  18762. ShippingSpaceSpecialNeeds = item.AirRemark,
  18763. HotelSpecialNeeds = item.RoomType
  18764. };
  18765. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  18766. if (_TourClientList > 0)
  18767. {
  18768. updateCount++;
  18769. }
  18770. }
  18771. _sqlSugar.CommitTran();
  18772. }
  18773. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  18774. }
  18775. catch (Exception ex)
  18776. {
  18777. _sqlSugar.RollbackTran();
  18778. return Ok(JsonView(false, ex.Message));
  18779. }
  18780. //return Ok(JsonView(true));
  18781. }
  18782. private bool IsValidDate(string dateString, string format)
  18783. {
  18784. DateTime dateValue;
  18785. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  18786. return valid;
  18787. }
  18788. /// <summary>
  18789. /// 接团客户名单
  18790. /// 根据团组Id查询List
  18791. /// </summary>
  18792. /// <param name="_dto"></param>
  18793. /// <returns></returns>
  18794. [HttpPost]
  18795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18796. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  18797. {
  18798. #region 参数验证
  18799. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  18800. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  18801. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  18802. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18803. #region 页面操作权限验证
  18804. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18805. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18806. #endregion
  18807. #endregion
  18808. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  18809. if (viewData.Code != 0)
  18810. {
  18811. return Ok(JsonView(false, viewData.Msg));
  18812. }
  18813. return Ok(JsonView(viewData.Data));
  18814. }
  18815. /// <summary>
  18816. /// 接团客户名单
  18817. /// 基础数据 Init
  18818. /// </summary>
  18819. /// <param name="_dto"></param>
  18820. /// <returns></returns>
  18821. [HttpPost]
  18822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18823. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  18824. {
  18825. #region 参数验证
  18826. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18827. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18828. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18829. #region 页面操作权限验证
  18830. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18831. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18832. #endregion
  18833. #endregion
  18834. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  18835. }
  18836. /// <summary>
  18837. /// 接团客户名单
  18838. /// 根据 Id查询 Details
  18839. /// </summary>
  18840. /// <param name="_dto"></param>
  18841. /// <returns></returns>
  18842. [HttpPost]
  18843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18844. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  18845. {
  18846. #region 参数验证
  18847. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18848. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18849. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18850. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18851. #region 页面操作权限验证
  18852. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18853. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18854. #endregion
  18855. #endregion
  18856. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18857. if (viewData.Code != 0)
  18858. {
  18859. return Ok(JsonView(false, viewData.Msg));
  18860. }
  18861. return Ok(JsonView(viewData.Data));
  18862. }
  18863. /// <summary>
  18864. /// 接团客户名单
  18865. /// Add Or Edit
  18866. /// </summary>
  18867. /// <param name="_dto"></param>
  18868. /// <returns></returns>
  18869. [HttpPost]
  18870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18871. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  18872. {
  18873. #region 参数验证
  18874. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18875. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18876. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18877. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18878. #region 页面操作权限验证
  18879. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18880. if (_dto.Id == 0) //添加
  18881. {
  18882. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18883. }
  18884. else if (_dto.Id >= 0) //修改
  18885. {
  18886. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18887. }
  18888. #endregion
  18889. #endregion
  18890. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  18891. if (viewData.Code != 0)
  18892. {
  18893. return Ok(JsonView(false, viewData.Msg));
  18894. }
  18895. return Ok(JsonView(true));
  18896. }
  18897. /// <summary>
  18898. /// 接团客户名单
  18899. /// json字符串 AddMultiple(添加多个)
  18900. /// </summary>
  18901. /// <param name="_dto"></param>
  18902. /// <returns></returns>
  18903. [HttpPost]
  18904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18905. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  18906. {
  18907. #region 参数验证
  18908. string jsonLabel = _dto.JsonLabel;
  18909. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18910. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18911. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18912. #region 页面操作权限验证
  18913. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18914. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18915. #endregion
  18916. #endregion
  18917. var request = new TourClientListAddMultipleDto();
  18918. request.DiId = _dto.DiId;
  18919. request.UserId = _dto.UserId;
  18920. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  18921. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  18922. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  18923. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  18924. var infos = new List<TourClientListInfo>();
  18925. foreach (var data in datas)
  18926. {
  18927. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  18928. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  18929. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  18930. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  18931. {
  18932. continue;
  18933. }
  18934. infos.Add(new TourClientListInfo()
  18935. {
  18936. IsAccompany = 1,
  18937. LastName = lastName,
  18938. FirstName = firstName,
  18939. Pinyin = lastNameEn + @"/" + firstNameEn,
  18940. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  18941. CompanyFullName = data.CompanyFullName,
  18942. Job = data.Job
  18943. });
  18944. }
  18945. if (infos.Any())
  18946. {
  18947. var viewData = await _tourClientListRep._AddMultiple(request);
  18948. if (viewData.Code != 0)
  18949. {
  18950. return Ok(JsonView(false, viewData.Msg));
  18951. }
  18952. return Ok(JsonView(true));
  18953. }
  18954. return Ok(JsonView(false));
  18955. }
  18956. /// <summary>
  18957. /// 接团客户名单
  18958. /// AddMultiple(添加多个)
  18959. /// </summary>
  18960. /// <param name="_dto"></param>
  18961. /// <returns></returns>
  18962. [HttpPost]
  18963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18964. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  18965. {
  18966. #region 参数验证
  18967. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18968. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18969. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18970. #region 页面操作权限验证
  18971. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18972. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18973. #endregion
  18974. #endregion
  18975. var viewData = await _tourClientListRep._AddMultiple(_dto);
  18976. if (viewData.Code != 0)
  18977. {
  18978. return Ok(JsonView(false, viewData.Msg));
  18979. }
  18980. return Ok(JsonView(true));
  18981. }
  18982. /// <summary>
  18983. /// 接团客户名单
  18984. /// Del
  18985. /// </summary>
  18986. /// <param name="_dto"></param>
  18987. /// <returns></returns>
  18988. [HttpPost]
  18989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18990. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  18991. {
  18992. #region 参数验证
  18993. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18994. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18995. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18996. #region 页面操作权限验证
  18997. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18998. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18999. #endregion
  19000. #endregion
  19001. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19002. if (viewData.Code != 0)
  19003. {
  19004. return Ok(JsonView(false, viewData.Msg));
  19005. }
  19006. return Ok(JsonView(true));
  19007. }
  19008. /// <summary>
  19009. /// 接团客户名单
  19010. /// 文件下载 客户名单
  19011. /// </summary>
  19012. /// <param name="_dto"></param>
  19013. /// <returns></returns>
  19014. [HttpPost]
  19015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19016. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19017. {
  19018. #region 参数验证
  19019. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19020. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19021. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19022. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19023. #region 页面操作权限验证
  19024. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19025. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19026. #endregion
  19027. #endregion
  19028. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19029. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19030. From Grp_TourClientList tcl
  19031. Left Join
  19032. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19033. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19034. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19035. From Crm_DeleClient dc
  19036. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19037. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19038. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19039. Where dc.IsDel = 0) temp
  19040. On temp.DcId =tcl.ClientId
  19041. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19042. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19043. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19044. //载入模板
  19045. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19046. if (_dto.Language == 1)
  19047. {
  19048. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19049. }
  19050. //载入模板
  19051. var doc = new Document(tempPath);
  19052. DocumentBuilder builder = new DocumentBuilder(doc);
  19053. //获取word里所有表格
  19054. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19055. //获取所填表格的序数
  19056. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19057. var rowStart = tableOne.Rows[0]; //获取第1行
  19058. if (_dto.Language == 0)
  19059. {
  19060. //循环赋值
  19061. for (int i = 0; i < DcList.Count; i++)
  19062. {
  19063. EncryptionProcessor.DecryptProperties(DcList[i]);
  19064. builder.MoveToCell(0, i + 1, 0, 0);
  19065. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19066. builder.MoveToCell(0, i + 1, 1, 0);
  19067. int sex = DcList[i].Sex;
  19068. string sexStr = string.Empty;
  19069. if (sex == 0) sexStr = "男";
  19070. else if (sex == 1) sexStr = "女";
  19071. else sexStr = "未设置";
  19072. builder.Write(sexStr);
  19073. builder.MoveToCell(0, i + 1, 2, 0);
  19074. string birthDay = DcList[i].BirthDay;
  19075. string birthDayStr = string.Empty;
  19076. if (!string.IsNullOrEmpty(birthDay))
  19077. {
  19078. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19079. }
  19080. builder.Write(birthDayStr);
  19081. builder.MoveToCell(0, i + 1, 3, 0);
  19082. string company = "";
  19083. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19084. {
  19085. company = DcList[i].CompanyFullName.ToString();
  19086. }
  19087. builder.Write(company);
  19088. builder.MoveToCell(0, i + 1, 4, 0);
  19089. builder.Write(DcList[i].Job);
  19090. }
  19091. }
  19092. else if (_dto.Language == 1)
  19093. {
  19094. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19095. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19096. List<string> transArrayStr = new List<string>();
  19097. string transStrRes1 = "";
  19098. for (int i = 0; i < DcList.Count; i++)
  19099. {
  19100. var dc = DcList[i];
  19101. EncryptionProcessor.DecryptProperties(dc);
  19102. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19103. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19104. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19105. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19106. else transStrRes1 += $"{str1}|";
  19107. }
  19108. #region AI转英文
  19109. string jsonValue = JsonConvert.SerializeObject(DcList);
  19110. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19111. List<SeedMessages> messages = new List<SeedMessages>()
  19112. {
  19113. new SeedMessages
  19114. {
  19115. Role = KimiRole.user,
  19116. Content = jsonValue + text
  19117. }
  19118. };
  19119. KiMiApiClient client = new KiMiApiClient();
  19120. var kimiApiResult = await client.SeedMessage(messages);
  19121. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19122. string clients = kimiApiResult_JObject["content"].ToString();
  19123. string startStr = "```json", endStr = "```";
  19124. // 判断并清除开头部分
  19125. if (clients.StartsWith(startStr))
  19126. {
  19127. clients = clients.Remove(0, startStr.Length);
  19128. }
  19129. // 判断并清除结尾部分
  19130. if (clients.EndsWith(endStr))
  19131. {
  19132. clients = clients.Remove(clients.Length - endStr.Length);
  19133. }
  19134. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19135. //循环赋值
  19136. for (int i = 0; i < en_Json.Count; i++)
  19137. {
  19138. var dc = en_Json[i];
  19139. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19140. string PYName = dc.FirstName + " " + dc.LastName;
  19141. builder.MoveToCell(0, i + 1, 0, 0);
  19142. builder.Write(PYName);
  19143. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19144. builder.MoveToCell(0, i + 1, 1, 0);
  19145. builder.Write(sex);
  19146. DateTime birthDt;
  19147. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19148. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19149. builder.MoveToCell(0, i + 1, 2, 0);
  19150. builder.Write(birthday);
  19151. string company = string.Empty, job = string.Empty;
  19152. company = dc.CompanyFullName;
  19153. job = dc.Job;
  19154. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName) )
  19155. {
  19156. //查询对照表
  19157. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19158. if (tempCec != null)
  19159. {
  19160. company = tempCec.enName;
  19161. }
  19162. }
  19163. builder.MoveToCell(0, i + 1, 3, 0);
  19164. builder.Write(company);
  19165. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19166. {
  19167. //查询对照表
  19168. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19169. if (tempPec != null)
  19170. {
  19171. job = tempPec.enName;
  19172. }
  19173. }
  19174. builder.MoveToCell(0, i + 1, 4, 0);
  19175. builder.Write(job);
  19176. }
  19177. #endregion
  19178. #region 旧翻译英文处理
  19179. ////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";
  19180. //string transStrRes = "";
  19181. //if (transStrRes1.Length > 0)
  19182. //{
  19183. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19184. //}
  19185. ////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
  19186. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19187. ////List<string> transArray = new List<string> { };
  19188. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19189. //if (transStrRes.Contains("|"))
  19190. //{
  19191. // string[] transArray1 = transStrRes.Split('|');
  19192. // if (transArray1.Length > 0)
  19193. // {
  19194. // foreach (var item in transArray1)
  19195. // {
  19196. // if (item.Contains("&"))
  19197. // {
  19198. // string[] transArray2 = item.Split('&');
  19199. // int index = 0;
  19200. // string companyName = "", job = "";
  19201. // if (transArray2.Length > 0)
  19202. // {
  19203. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19204. // if (1 < transArray2.Length) companyName = transArray2[1];
  19205. // if (2 < transArray2.Length) job = transArray2[2];
  19206. // }
  19207. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19208. // }
  19209. // }
  19210. // }
  19211. //}
  19212. ////循环赋值
  19213. //for (int i = 0; i < DcList.Count; i++)
  19214. //{
  19215. // string PYName = "";
  19216. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19217. // {
  19218. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19219. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19220. // PYName = PY_First + " " + PY_Last;
  19221. // }
  19222. // else
  19223. // {
  19224. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19225. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19226. // PYName = PY_First + " " + PY_Last;
  19227. // }
  19228. // builder.MoveToCell(0, i + 1, 0, 0);
  19229. // builder.Write(PYName);
  19230. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19231. // builder.MoveToCell(0, i + 1, 1, 0);
  19232. // builder.Write(sex);
  19233. // DateTime birthDt;
  19234. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19235. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19236. // builder.MoveToCell(0, i + 1, 2, 0);
  19237. // builder.Write(birthday);
  19238. // string company = string.Empty, job = string.Empty;
  19239. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19240. // if (dcTransInfo != null)
  19241. // {
  19242. // company = dcTransInfo.CompanyName;
  19243. // job = dcTransInfo.Job;
  19244. // }
  19245. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19246. // {
  19247. // //查询对照表
  19248. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19249. // if (tempCec != null)
  19250. // {
  19251. // company = tempCec.enName;
  19252. // }
  19253. // //翻译
  19254. // else
  19255. // {
  19256. // }
  19257. // }
  19258. // builder.MoveToCell(0, i + 1, 3, 0);
  19259. // builder.Write(company);
  19260. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19261. // {
  19262. // //查询对照表
  19263. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19264. // if (tempPec != null)
  19265. // {
  19266. // job = tempPec.enName;
  19267. // }
  19268. // //翻译
  19269. // else
  19270. // {
  19271. // }
  19272. // }
  19273. // builder.MoveToCell(0, i + 1, 4, 0);
  19274. // builder.Write(job);
  19275. //}
  19276. #endregion
  19277. }
  19278. //删除多余行
  19279. while (tableOne.Rows.Count > DcList.Count + 1)
  19280. {
  19281. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19282. }
  19283. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19284. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19285. doc.Save(fileDir);
  19286. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19287. return Ok(JsonView(true, "操作成功!", Url));
  19288. }
  19289. private class TranslateInfo
  19290. {
  19291. public int Index { get; set; }
  19292. public string CompanyName { get; set; }
  19293. public string Job { get; set; }
  19294. }
  19295. [HttpPost]
  19296. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19297. {
  19298. if (files.Count == 0)
  19299. {
  19300. return Ok(JsonView(false, "文件为空"));
  19301. }
  19302. KiMiApiClient KiMiApi = new KiMiApiClient();
  19303. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19304. if (seedConter.Count == 0)
  19305. {
  19306. return Ok(JsonView(false, "上传结果为空!"));
  19307. }
  19308. var messages = new List<SeedMessages>
  19309. {
  19310. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19311. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19312. };
  19313. messages.InsertRange(1, seedConter);
  19314. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19315. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19316. string clients = kimiApiResult_JObject["content"].ToString();
  19317. string startStr = "```json", endStr = "```";
  19318. // 判断并清除开头部分
  19319. if (clients.StartsWith(startStr))
  19320. {
  19321. clients = clients.Remove(0, startStr.Length);
  19322. }
  19323. // 判断并清除结尾部分
  19324. if (clients.EndsWith(endStr))
  19325. {
  19326. clients = clients.Remove(clients.Length - endStr.Length);
  19327. }
  19328. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19329. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19330. {
  19331. {"姓", "LastName" },
  19332. {"名", "FirstName" },
  19333. {"姓名拼音", "Pinyin" },
  19334. {"性别", "Sex" },
  19335. {"单位", "CompanyFullName" },
  19336. {"职务", "Job" },
  19337. {"出生日期", "Birthday" },
  19338. };
  19339. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19340. foreach (var item in clients_JObject)
  19341. {
  19342. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19343. foreach (var field in clientFieldMap.Keys)
  19344. {
  19345. if (item.TryGetValue(field, out JToken value))
  19346. {
  19347. var getValue = value.ToString();
  19348. System.Type type = cdc.GetType();
  19349. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19350. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19351. propertyInfo.SetValue(cdc, propertyValue);
  19352. }
  19353. }
  19354. crmClients.Add(cdc);
  19355. }
  19356. return Ok(JsonView(new
  19357. {
  19358. fileCount = files.Count,
  19359. UploadCount = seedConter.Count,
  19360. ApiResult = clients,
  19361. CrmClients = crmClients
  19362. }));
  19363. }
  19364. #endregion
  19365. #region 团组倒推表
  19366. /// <summary>
  19367. /// 倒推表基础数据
  19368. /// Init
  19369. /// </summary>
  19370. /// <returns></returns>
  19371. [HttpPost]
  19372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19373. public async Task<IActionResult> PostInvertedListInit()
  19374. {
  19375. var viewData = await _invertedListRep._Init();
  19376. if (viewData.Code != 0)
  19377. {
  19378. return Ok(JsonView(false, viewData.Msg));
  19379. }
  19380. return Ok(JsonView(viewData.Data));
  19381. }
  19382. /// <summary>
  19383. /// 倒推表
  19384. /// Info
  19385. /// </summary>
  19386. /// <param name="dto"></param>
  19387. /// <returns></returns>
  19388. [HttpPost]
  19389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19390. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19391. {
  19392. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19393. if (viewData.Code != 0)
  19394. {
  19395. return Ok(JsonView(false, viewData.Msg));
  19396. }
  19397. return Ok(JsonView(viewData.Data));
  19398. }
  19399. /// <summary>
  19400. /// 倒推表
  19401. /// Create
  19402. /// </summary>
  19403. /// <param name="dto"></param>
  19404. /// <returns></returns>
  19405. [HttpPost]
  19406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19407. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19408. {
  19409. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19410. if (viewData.Code != 0)
  19411. {
  19412. return Ok(JsonView(false, viewData.Msg));
  19413. }
  19414. return Ok(JsonView(viewData.Data));
  19415. }
  19416. /// <summary>
  19417. /// 倒推表
  19418. /// Update
  19419. /// </summary>
  19420. /// <param name="dto"></param>
  19421. /// <returns></returns>
  19422. [HttpPost]
  19423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19424. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19425. {
  19426. var viewData = await _invertedListRep._Update(dto);
  19427. if (viewData.Code != 0)
  19428. {
  19429. return Ok(JsonView(false, viewData.Msg));
  19430. }
  19431. return Ok(JsonView(viewData.Data));
  19432. }
  19433. /// <summary>
  19434. /// 倒推表
  19435. /// File Download
  19436. /// </summary>
  19437. /// <param name="dto"></param>
  19438. /// <returns></returns>
  19439. [HttpPost]
  19440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19441. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19442. {
  19443. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19444. if (info2.Code != 0)
  19445. {
  19446. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19447. }
  19448. var info1 = info2.Data as InvertedListInfoView;
  19449. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19450. string teamName = "";
  19451. if (info != null) teamName = info.TeamName;
  19452. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19453. var doc = new Document();
  19454. var builder = new DocumentBuilder(doc);
  19455. #region old insert
  19456. ////载入模板
  19457. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19458. //Document doc = new Document(tempPath);
  19459. //DocumentBuilder builder = new DocumentBuilder(doc);
  19460. //利用键值对存放数据
  19461. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19462. //dic.Add("TeamName", teamName);
  19463. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19464. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19465. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19466. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19467. //dic.Add("SQRemark", info1.ApprovalRemark);
  19468. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19469. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19470. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19471. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19472. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19473. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19474. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19475. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19476. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19477. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19478. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19479. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19480. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19481. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19482. //#region 填充word模板书签内容
  19483. //foreach (var key in dic.Keys)
  19484. //{
  19485. // builder.MoveToBookmark(key);
  19486. // builder.Write(dic[key]);
  19487. //}
  19488. //#endregion
  19489. #endregion
  19490. #region New Insert
  19491. string titleFont = $"仿宋",
  19492. contentFont = $"仿宋";
  19493. var fontColor = Color.FromArgb(64, 64, 64);
  19494. //设置标题 团组名称
  19495. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19496. builder.Font.Name = titleFont;
  19497. builder.Font.Color = fontColor;
  19498. builder.Font.Size = 12;
  19499. builder.Font.Bold = true;
  19500. builder.Writeln(teamName);
  19501. //设置副标题 团组出访时间
  19502. builder.Font.Size = 12;
  19503. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19504. builder.Writeln();
  19505. var backgroundColor = Color.FromArgb(199, 199, 199);
  19506. var table = builder.StartTable();
  19507. builder.InsertCell();
  19508. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19509. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19510. builder.CellFormat.Borders.LineWidth = 1;
  19511. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19512. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19513. builder.RowFormat.Height = 40;
  19514. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19515. builder.Font.Name = contentFont;
  19516. builder.Font.Size = 12;
  19517. builder.Font.Bold = true;
  19518. builder.Font.Color = fontColor;
  19519. builder.Write("时间");
  19520. builder.InsertCell();
  19521. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19522. builder.Write("流程");
  19523. builder.InsertCell();
  19524. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19525. builder.Write("说明");
  19526. builder.EndRow();
  19527. //报批资料准备
  19528. if (info1.IsSelectedAirportd)
  19529. {
  19530. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19531. }
  19532. //报批/提供送签资料
  19533. if (info1.IsSelectedApprovalData)
  19534. {
  19535. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19536. }
  19537. //出批件护照办理
  19538. if (info1.IsSelectedIssueApproval)
  19539. {
  19540. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19541. }
  19542. //签证资料准备
  19543. if (info1.IsSelectedVisaInfo)
  19544. {
  19545. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19546. }
  19547. //送签
  19548. if (info1.IsSelectedSendVisa)
  19549. {
  19550. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19551. }
  19552. //出签
  19553. if (info1.IsSelectedIssueVisa)
  19554. {
  19555. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19556. }
  19557. //机票
  19558. if (info1.IsSelectedAirTicket)
  19559. {
  19560. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19561. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19562. }
  19563. //酒店
  19564. if (info1.IsSelectedHotel)
  19565. {
  19566. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19567. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19568. }
  19569. //开行前会
  19570. if (info1.IsSelectedPreTripMeeting)
  19571. {
  19572. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19573. }
  19574. //送机
  19575. if (info1.IsSelectedAirportdDropOff)
  19576. {
  19577. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19578. }
  19579. builder.EndTable();
  19580. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19581. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19582. for (int i = 0; i < table.Rows.Count; i++)
  19583. {
  19584. var row = table.Rows[i];
  19585. //设置宽度
  19586. row.Cells[0].CellFormat.Width = 20.00;
  19587. row.Cells[1].CellFormat.Width = 30.00;
  19588. row.Cells[2].CellFormat.Width = 50.00;
  19589. if (i != 0)
  19590. {
  19591. //边框设置
  19592. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19593. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19594. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19595. }
  19596. }
  19597. #region 页脚插入图片
  19598. // 创建页脚
  19599. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19600. doc.FirstSection.HeadersFooters.Add(footer);
  19601. Paragraph para = new Paragraph(doc);
  19602. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19603. footer.AppendChild(para);
  19604. builder.MoveTo(para);
  19605. string imagePath = "./Images/FMGJ_Log.png";
  19606. builder.InsertImage(imagePath);
  19607. #endregion
  19608. #endregion
  19609. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19610. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19611. string filePath = fileDir + $@"InvertedList/{fileName}";
  19612. doc.Save(filePath);
  19613. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19614. return Ok(JsonView(true, "操作成功!", Url));
  19615. }
  19616. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19617. {
  19618. var fontColor = Color.FromArgb(64, 64, 64);
  19619. builder.InsertCell();
  19620. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19621. builder.RowFormat.Height = 40;
  19622. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19623. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19624. builder.Font.Name = fontName;
  19625. builder.Font.Size = 8;
  19626. builder.Font.Bold = true;
  19627. builder.Font.Color = fontColor;
  19628. builder.Write(dateTime);
  19629. builder.InsertCell();
  19630. builder.Font.Size = 9;
  19631. builder.Font.Bold = true;
  19632. builder.Font.Color = fontColor;
  19633. builder.Write(content);
  19634. builder.InsertCell();
  19635. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19636. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19637. builder.Font.Size = 9;
  19638. builder.Font.Bold = false;
  19639. builder.Font.Color = fontColor;
  19640. builder.Write(reamrk);
  19641. builder.EndRow();
  19642. }
  19643. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19644. {
  19645. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19646. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19647. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19648. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19649. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19650. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19651. }
  19652. #endregion
  19653. #region 会务倒推表
  19654. /// <summary>
  19655. /// 会务倒推表
  19656. /// Init
  19657. /// </summary>
  19658. /// <returns></returns>
  19659. [HttpPost]
  19660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19661. public async Task<IActionResult> InforRetrogressTableInit()
  19662. {
  19663. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19664. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19665. return Ok(JsonView(false, groupData.Msg));
  19666. }
  19667. /// <summary>
  19668. /// 会务倒推表
  19669. /// ExcelDownload
  19670. /// </summary>
  19671. /// <param name="dto"></param>
  19672. /// <returns></returns>
  19673. [HttpPost]
  19674. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19676. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19677. {
  19678. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19679. var validatorRes = await validator.ValidateAsync(dto);
  19680. if (!validatorRes.IsValid)
  19681. {
  19682. StringBuilder sb = new StringBuilder();
  19683. foreach (var item in validatorRes.Errors)
  19684. {
  19685. sb.AppendLine(item.ErrorMessage);
  19686. }
  19687. return Ok(JsonView(false, sb.ToString()));
  19688. }
  19689. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  19690. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  19691. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  19692. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  19693. #region Excel
  19694. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  19695. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  19696. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  19697. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  19698. var fileNamePrefix = string.Empty;
  19699. if (days >= 30)
  19700. {
  19701. tempPath += $"会务工作倒推进度表(30天).xlsx";
  19702. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  19703. }
  19704. else if (days < 30 && days > 7)
  19705. {
  19706. tempPath += $"会务工作倒推进度表(15天).xlsx";
  19707. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  19708. }
  19709. else if (days <= 7)
  19710. {
  19711. tempPath += $"会务工作倒推进度表(7天).xlsx";
  19712. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  19713. }
  19714. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  19715. fileName = CommonFun.ValidFileName(fileName);
  19716. //载入模板
  19717. WorkbookDesigner designer = new WorkbookDesigner();
  19718. designer.Workbook = new Workbook(tempPath);
  19719. designer.Process();
  19720. if (!Directory.Exists(savePath))
  19721. {
  19722. Directory.CreateDirectory(savePath);
  19723. }
  19724. string serverPath = $"{savePath}{fileName}";
  19725. designer.Workbook.Save(serverPath);
  19726. string rst = $"{servicePath}{ftpPath}{fileName}";
  19727. #endregion
  19728. return Ok(JsonView(new { url = rst }));
  19729. }
  19730. #endregion
  19731. #region 三公签证费用(签证费、代办费)
  19732. /// <summary>
  19733. /// 三公签证费用(签证费、代办费)
  19734. /// List
  19735. /// </summary>
  19736. /// <returns></returns>
  19737. [HttpPost]
  19738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19739. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  19740. {
  19741. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  19742. if (_view.Code != 0)
  19743. {
  19744. return Ok(JsonView(false, _view.Msg));
  19745. }
  19746. return Ok(JsonView(true, "操作成功!", _view.Data));
  19747. }
  19748. /// <summary>
  19749. /// 三公签证费用(签证费、代办费)
  19750. /// Add Or Update
  19751. /// </summary>
  19752. /// <returns></returns>
  19753. [HttpPost]
  19754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19755. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  19756. {
  19757. var _view = await _visaFeeInfoRep._Update(_dto);
  19758. if (_view.Code != 0)
  19759. {
  19760. return Ok(JsonView(false, _view.Msg));
  19761. }
  19762. return Ok(JsonView(true, _view.Msg));
  19763. }
  19764. #endregion
  19765. #region 酒店询价
  19766. /// <summary>
  19767. /// 酒店询价
  19768. /// Init
  19769. /// </summary>
  19770. /// <returns></returns>
  19771. [HttpPost]
  19772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19773. public async Task<IActionResult> PostHotelInquiryInit()
  19774. {
  19775. var res = await _hotelInquiryRep._Init();
  19776. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19777. return Ok(JsonView(true, res.Msg, res.Data));
  19778. }
  19779. /// <summary>
  19780. /// 酒店询价
  19781. /// page Item
  19782. /// </summary>
  19783. /// <param name="_dto"></param>
  19784. /// <returns></returns>
  19785. [HttpPost]
  19786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19787. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  19788. {
  19789. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  19790. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19791. var view = res.Data as PageDataViewBase;
  19792. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  19793. }
  19794. /// <summary>
  19795. /// 酒店询价
  19796. /// info
  19797. /// </summary>
  19798. /// <param name="_dto"></param>
  19799. /// <returns></returns>
  19800. [HttpPost]
  19801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19802. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  19803. {
  19804. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  19805. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19806. return Ok(JsonView(true, res.Msg, res.Data));
  19807. }
  19808. /// <summary>
  19809. /// 酒店询价
  19810. /// Add Or Edit
  19811. /// </summary>
  19812. /// <param name="_dto"></param>
  19813. /// <returns></returns>
  19814. [HttpPost]
  19815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19816. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  19817. {
  19818. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  19819. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19820. return Ok(JsonView(true, res.Msg, res.Data));
  19821. }
  19822. /// <summary>
  19823. /// 酒店询价
  19824. /// Del
  19825. /// </summary>
  19826. /// <param name="_dto"></param>
  19827. /// <returns></returns>
  19828. [HttpPost]
  19829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19830. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  19831. {
  19832. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  19833. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19834. return Ok(JsonView(true, res.Msg, res.Data));
  19835. }
  19836. #endregion
  19837. #region 下载匹配op行程单
  19838. /// <summary>
  19839. /// 匹配op行程单
  19840. /// Init
  19841. /// </summary>
  19842. /// <param name="dto">团组列表请求dto</param>
  19843. /// <returns></returns>
  19844. [HttpPost]
  19845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19846. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  19847. {
  19848. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19849. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19850. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  19851. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  19852. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  19853. .Where(it => it.IsDel == 0)
  19854. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  19855. .OrderByDescending(it => it.VisitStartDate)
  19856. .ToList();
  19857. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  19858. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  19859. var diids = groupInfos.Select(it => it.Id).ToList();
  19860. List<string> countrys = new List<string>();
  19861. foreach (var item in country)
  19862. {
  19863. var data = _groupRepository.FormartTeamName(item);
  19864. var dataArray = _groupRepository.GroupSplitCountry(data);
  19865. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  19866. }
  19867. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  19868. List<string> areaArray = new List<string>(); //GetGroupCityLine
  19869. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  19870. foreach (var item in areaItem)
  19871. {
  19872. string areaStr = item.Value;
  19873. if (!string.IsNullOrEmpty(areaStr))
  19874. {
  19875. string[] str1 = areaStr.Split("-");
  19876. if (str1.Length > 0)
  19877. {
  19878. areaArray.AddRange(str1);
  19879. }
  19880. }
  19881. }
  19882. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  19883. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  19884. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  19885. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  19886. .ToList();
  19887. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  19888. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  19889. .Where(it => countriesIds.Contains(it.Id))
  19890. .Select(it => new { it.Id, Name = it.Name_CN })
  19891. .ToList();
  19892. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  19893. .Select(it => it.TeamName).ToList();
  19894. stopwatch.Stop();
  19895. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  19896. }
  19897. ///// <summary>
  19898. ///// 匹配op行程单
  19899. ///// Init 查询区域数据
  19900. ///// </summary>
  19901. ///// <param name="dto">团组列表请求dto</param>
  19902. ///// <returns></returns>
  19903. //[HttpPost]
  19904. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19905. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  19906. //{
  19907. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19908. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  19909. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  19910. // if (string.IsNullOrEmpty(countriesDataStr))
  19911. // {
  19912. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  19913. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  19914. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  19915. // }
  19916. // else
  19917. // {
  19918. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  19919. // }
  19920. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  19921. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  19922. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  19923. // List<dynamic> childList = new List<dynamic>();
  19924. // int parentId = dto.CountriesId;
  19925. // if (provinceData.Count > 1)
  19926. // {
  19927. // foreach (var item1 in provinceData)
  19928. // {
  19929. // List<dynamic> childList1 = new List<dynamic>();
  19930. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  19931. // foreach (var item2 in citiesData1)
  19932. // {
  19933. // List<dynamic> childList2 = new List<dynamic>();
  19934. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19935. // foreach (var item3 in countiesData1)
  19936. // {
  19937. // childList2.Add(new
  19938. // {
  19939. // id = item3.Id,
  19940. // parentId = item2.Id,
  19941. // level = "district",
  19942. // name = item3.Name_CN,
  19943. // });
  19944. // }
  19945. // childList1.Add(new
  19946. // {
  19947. // id = item2.Id,
  19948. // parentId = item1.Id,
  19949. // level = "city",
  19950. // name = item2.Name_CN,
  19951. // childList = childList2
  19952. // });
  19953. // }
  19954. // childList.Add(new
  19955. // {
  19956. // id = item1.Id,
  19957. // parentId = parentId,
  19958. // level = "province",
  19959. // name = item1.Name_CN,
  19960. // childList = childList1
  19961. // });
  19962. // }
  19963. // //城市
  19964. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  19965. // foreach (var item2 in citiesData2)
  19966. // {
  19967. // List<dynamic> childList22 = new List<dynamic>();
  19968. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19969. // foreach (var item3 in countiesData1)
  19970. // {
  19971. // childList22.Add(new
  19972. // {
  19973. // id = item3.Id,
  19974. // parentId = item2.Id,
  19975. // level = "district",
  19976. // name = item3.Name_CN,
  19977. // });
  19978. // }
  19979. // childList.Add(new
  19980. // {
  19981. // id = item2.Id,
  19982. // parentId = parentId,
  19983. // level = "city",
  19984. // name = item2.Name_CN,
  19985. // childList = childList22
  19986. // });
  19987. // }
  19988. // }
  19989. // else
  19990. // {
  19991. // foreach (var item2 in citiesData)
  19992. // {
  19993. // string cname = item2.Name_CN;
  19994. // List<dynamic> childList1 = new List<dynamic>();
  19995. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19996. // foreach (var item3 in countiesData1)
  19997. // {
  19998. // childList1.Add(new
  19999. // {
  20000. // Id = item3.Id,
  20001. // parentId = item2.Id,
  20002. // level = "district",
  20003. // name = item3.Name_CN
  20004. // });
  20005. // }
  20006. // childList.Add(new
  20007. // {
  20008. // id = item2.Id,
  20009. // parentId = parentId,
  20010. // level = "city",
  20011. // name = item2.Name_CN,
  20012. // childList = childList1
  20013. // });
  20014. // }
  20015. // }
  20016. // stopwatch.Stop();
  20017. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20018. //}
  20019. /// <summary>
  20020. /// 匹配op行程单
  20021. /// 接团信息列表 Page
  20022. /// </summary>
  20023. /// <param name="dto">团组列表请求dto</param>
  20024. /// <returns></returns>
  20025. [HttpPost]
  20026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20027. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20028. {
  20029. var swatch = new Stopwatch();
  20030. swatch.Start();
  20031. #region 参数验证
  20032. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20033. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20034. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20035. #region 页面操作权限验证
  20036. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20037. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20038. #endregion
  20039. #endregion
  20040. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20041. {
  20042. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20043. //string sqlWhere = "";
  20044. if (!string.IsNullOrEmpty(dto.Country))
  20045. {
  20046. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20047. }
  20048. if (!string.IsNullOrEmpty(dto.Area))
  20049. {
  20050. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20051. }
  20052. if (!string.IsNullOrEmpty(dto.TeamName))
  20053. {
  20054. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20055. }
  20056. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20057. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20058. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20059. swatch.Stop();
  20060. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20061. }
  20062. else
  20063. {
  20064. return Ok(JsonView(false, "查询失败"));
  20065. }
  20066. }
  20067. /// <summary>
  20068. /// 匹配op行程单
  20069. /// 行程单下载
  20070. /// </summary>
  20071. /// <param name="dto">团组列表请求dto</param>
  20072. /// <returns></returns>
  20073. [HttpPost]
  20074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20075. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20076. {
  20077. #region 参数验证
  20078. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20079. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20080. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20081. #region 页面操作权限验证
  20082. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20083. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20084. #endregion
  20085. #endregion
  20086. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20087. {
  20088. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20089. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20090. }
  20091. else
  20092. {
  20093. return Ok(JsonView(false, "下载失败!"));
  20094. }
  20095. }
  20096. #endregion
  20097. #region 国家信息 数据 注释
  20098. //[HttpPost]
  20099. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20100. //{
  20101. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20102. // foreach (var item in dto)
  20103. // {
  20104. // infos.Add(new Grp_GroupsTaskAssignment()
  20105. // {
  20106. // DIId = item,
  20107. // CTId = 82,
  20108. // UId = 248,
  20109. // IsEnable = 1,
  20110. // CreateUserId = 233,
  20111. // CreateTime = DateTime.Now,
  20112. // IsDel = 0
  20113. // });
  20114. // infos.Add(new Grp_GroupsTaskAssignment()
  20115. // {
  20116. // DIId = item,
  20117. // CTId = 82,
  20118. // UId = 286,
  20119. // IsEnable = 1,
  20120. // CreateUserId = 233,
  20121. // CreateTime = DateTime.Now,
  20122. // IsDel = 0
  20123. // });
  20124. // }
  20125. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20126. // return Ok("操作成功");
  20127. //}
  20128. //public class paramJsonDto
  20129. //{
  20130. // public List<CountriesInfo> str { get; set; }
  20131. //}
  20132. //[HttpPost]
  20133. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20134. //{
  20135. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20136. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20137. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20138. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20139. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20140. // _sqlSugar.BeginTran();
  20141. // int countitiesIndex = 0;
  20142. // foreach (var item in dto.str)
  20143. // {
  20144. // dynamic data = item.c;
  20145. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20146. // if (data != null)
  20147. // {
  20148. // countitiesIndex++;
  20149. // foreach (var item1 in data)
  20150. // {
  20151. // string cnname = item1.cn;
  20152. // string enname = item1.en;
  20153. // Sys_Cities provinceInfo = new Sys_Cities()
  20154. // {
  20155. // CountriesId = countriesId,
  20156. // Name_CN = cnname,
  20157. // Name_EN = enname,
  20158. // ParentId = 0,
  20159. // IsCapital = 1,
  20160. // CreateUserId = 208,
  20161. // CreateTime = DateTime.Now,
  20162. // IsDel = 0
  20163. // };
  20164. // if (item1.lv == "province") //省份
  20165. // {
  20166. // provinceInfo.Level = 1;
  20167. // int provinceId = 0;
  20168. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20169. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20170. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20171. // var data1 = item1.c;
  20172. // foreach (var item2 in data1)
  20173. // {
  20174. // if (item2.lv == "city")
  20175. // {
  20176. // string citycnname = item2.cn;
  20177. // string cityenname = item2.en;
  20178. // Sys_Cities cityInfo = new Sys_Cities()
  20179. // {
  20180. // CountriesId = countriesId,
  20181. // ParentId = provinceId,
  20182. // Level = 2,
  20183. // Name_CN = citycnname,
  20184. // Name_EN = cityenname,
  20185. // IsCapital = 1,
  20186. // CreateUserId = 208,
  20187. // CreateTime = DateTime.Now,
  20188. // IsDel = 0
  20189. // };
  20190. // if (item2.c != null)
  20191. // {
  20192. // int cityId = 0;
  20193. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20194. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20195. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20196. // foreach (var item3 in item2.c)
  20197. // {
  20198. // if (item3.lv == "district")
  20199. // {
  20200. // var districtInfo = new Sys_Cities()
  20201. // {
  20202. // CountriesId = countriesId,
  20203. // Name_CN = item3.cn,
  20204. // Name_EN = item3.en,
  20205. // Level = 3,
  20206. // ParentId = cityId,
  20207. // IsCapital = 1,
  20208. // CreateUserId = 208,
  20209. // CreateTime = DateTime.Now,
  20210. // IsDel = 0
  20211. // };
  20212. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20213. // //{
  20214. // districts.Add(districtInfo);
  20215. // //}
  20216. // }
  20217. // }
  20218. // }
  20219. // else
  20220. // {
  20221. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20222. // //{
  20223. // cities.Add(cityInfo);
  20224. // //}
  20225. // }
  20226. // }
  20227. // }
  20228. // }
  20229. // else if (item1.lv == "city")//城市
  20230. // {
  20231. // provinceInfo.Level = 2;
  20232. // if (item1.c != null)
  20233. // {
  20234. // int cityId = 0;
  20235. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20236. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20237. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20238. // foreach (var item3 in item1.c)
  20239. // {
  20240. // if (item3.lv == "district")
  20241. // {
  20242. // var districtInfo = new Sys_Cities()
  20243. // {
  20244. // CountriesId = countriesId,
  20245. // Name_CN = item3.cn,
  20246. // Name_EN = item3.en,
  20247. // Level = 3,
  20248. // ParentId = cityId,
  20249. // IsCapital = 1,
  20250. // CreateUserId = 208,
  20251. // CreateTime = DateTime.Now,
  20252. // IsDel = 0
  20253. // };
  20254. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20255. // //{
  20256. // districts.Add(districtInfo);
  20257. // //}
  20258. // }
  20259. // }
  20260. // }
  20261. // else
  20262. // {
  20263. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20264. // //{
  20265. // cities.Add(provinceInfo);
  20266. // //}
  20267. // }
  20268. // }
  20269. // }
  20270. // }
  20271. // }
  20272. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20273. // cities = cities.Distinct().ToList();
  20274. // districts = districts.Distinct().ToList();
  20275. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20276. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20277. // cities.AddRange(districts);
  20278. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20279. // //_sqlSugar.RollbackTran();
  20280. // _sqlSugar.CommitTran();
  20281. // return Ok(JsonView(false, "操作成功!"));
  20282. //}
  20283. //[HttpPost]
  20284. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20285. //{
  20286. // List<CountitiesInfo> infos = dto.MyProperty;
  20287. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20288. // _sqlSugar.BeginTran();
  20289. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20290. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20291. // foreach (var item in infos)
  20292. // {
  20293. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20294. // if (countryInfo != null)
  20295. // {
  20296. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20297. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20298. // if (cityInfo1 != null)
  20299. // {
  20300. // cityInfo1.IsCapital = 0;
  20301. // cityInfos.Add(cityInfo1);
  20302. // }
  20303. // }
  20304. // }
  20305. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20306. // .UpdateColumns(it => it.IsCapital)
  20307. // .WhereColumns(it => it.Id)
  20308. // .ExecuteCommand();
  20309. // //_sqlSugar.RollbackTran();
  20310. // _sqlSugar.CommitTran();
  20311. // return Ok(JsonView(false, "操作成功!"));
  20312. //}
  20313. //public class CounrtiesDto
  20314. //{
  20315. // public List<CountitiesInfo> MyProperty { get; set; }
  20316. //}
  20317. //public class CountitiesInfo
  20318. //{
  20319. // /// <summary>
  20320. // /// 圣约翰
  20321. // /// </summary>
  20322. // public string capital_name_chinese { get; set; }
  20323. // /// <summary>
  20324. // ///
  20325. // /// </summary>
  20326. // public string capital_name { get; set; }
  20327. // /// <summary>
  20328. // ///
  20329. // /// </summary>
  20330. // public string country_type { get; set; }
  20331. // /// <summary>
  20332. // /// 安提瓜和巴布达
  20333. // /// </summary>
  20334. // public string country_name_chinese { get; set; }
  20335. // /// <summary>
  20336. // /// 安提瓜和巴布达
  20337. // /// </summary>
  20338. // public string country_name_chinese_short { get; set; }
  20339. // /// <summary>
  20340. // /// 安提瓜和巴布达
  20341. // /// </summary>
  20342. // public string country_name_chinese_UN { get; set; }
  20343. // /// <summary>
  20344. // ///
  20345. // /// </summary>
  20346. // public string country_name_english_abbreviation { get; set; }
  20347. // /// <summary>
  20348. // ///
  20349. // /// </summary>
  20350. // public string country_name_english_formal { get; set; }
  20351. // /// <summary>
  20352. // ///
  20353. // /// </summary>
  20354. // public string country_name_english_UN { get; set; }
  20355. // /// <summary>
  20356. // ///
  20357. // /// </summary>
  20358. // public string continent_name { get; set; }
  20359. // /// <summary>
  20360. // ///
  20361. // /// </summary>
  20362. // public string subregion_name { get; set; }
  20363. // /// <summary>
  20364. // ///
  20365. // /// </summary>
  20366. // public string country_code2 { get; set; }
  20367. // /// <summary>
  20368. // ///
  20369. // /// </summary>
  20370. // public string country_code3 { get; set; }
  20371. // /// <summary>
  20372. // ///
  20373. // /// </summary>
  20374. // public string phone_code { get; set; }
  20375. //}
  20376. //public class CountriesInfo : BasicInfo
  20377. //{
  20378. // public List<CitiesInfo> c { get; set; }
  20379. //}
  20380. //public class CitiesInfo : BasicInfo
  20381. //{
  20382. // public List<AreaInfo> c { get; set; }
  20383. //}
  20384. //public class AreaInfo : BasicInfo
  20385. //{
  20386. // public List<AreaInfo> c { get; set; }
  20387. //}
  20388. //public class BasicInfo
  20389. //{
  20390. // public string code { get; set; }
  20391. // public string cn { get; set; }
  20392. // public string lv { get; set; }
  20393. // public string en { get; set; }
  20394. //}
  20395. #endregion
  20396. #region 查看邀请方
  20397. /// <summary>
  20398. /// 查看邀请方
  20399. /// 邀请方信息 Init
  20400. /// </summary>
  20401. /// <param name="dto"></param>
  20402. /// <returns></returns>
  20403. [HttpPost]
  20404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20405. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20406. {
  20407. string sqlWhere = string.Empty;
  20408. if (!string.IsNullOrEmpty(dto.Search))
  20409. {
  20410. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20411. }
  20412. string sql = string.Format($@"Select
  20413. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20414. Id,
  20415. UnitName
  20416. From Res_InvitationOfficialActivityData
  20417. Where IsDel = 0
  20418. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20419. RefAsync<int> total = 0;
  20420. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20421. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20422. }
  20423. /// <summary>
  20424. /// 查看邀请方
  20425. /// 国家信息 Init
  20426. /// </summary>
  20427. /// <param name="dto"></param>
  20428. /// <returns></returns>
  20429. [HttpPost]
  20430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20431. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20432. {
  20433. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20434. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20435. var diids = groupInfos.Select(it => it.Id).ToList();
  20436. List<string> countrys = new List<string>();
  20437. foreach (var item in country)
  20438. {
  20439. var data = _groupRepository.FormartTeamName(item);
  20440. var dataArray = _groupRepository.GroupSplitCountry(data);
  20441. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20442. }
  20443. countrys = countrys.Distinct().ToList();
  20444. for (int i = 0; i < countrys.Count; i++)
  20445. {
  20446. string item = countrys[i];
  20447. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20448. {
  20449. countrys.Remove(item);
  20450. i--;
  20451. }
  20452. }
  20453. RefAsync<int> total = 0;
  20454. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20455. .Where(it => countrys.Contains(it.Name_CN))
  20456. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20457. .Select(it => new { id = it.Id, name = it.Name_CN })
  20458. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20459. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20460. }
  20461. /// <summary>
  20462. /// 查看邀请方
  20463. /// 城市信息 Init
  20464. /// </summary>
  20465. /// <param name="dto"></param>
  20466. /// <returns></returns>
  20467. [HttpPost]
  20468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20469. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20470. {
  20471. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20472. RefAsync<int> total = 0;
  20473. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20474. .Where(it => it.CountriesId == dto.CountiesId)
  20475. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20476. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20477. .Select(it => new { id = it.Id, name = it.Name_CN })
  20478. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20479. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20480. }
  20481. /// <summary>
  20482. /// 查看邀请方
  20483. /// 团组名称 Init
  20484. /// </summary>
  20485. /// <param name="dto"></param>
  20486. /// <returns></returns>
  20487. [HttpPost]
  20488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20489. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20490. {
  20491. var watch = new Stopwatch();
  20492. watch.Start();
  20493. RefAsync<int> total = 0;
  20494. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20495. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20496. .Where((oa, di) => oa.IsDel == 0)
  20497. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20498. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20499. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20500. .Distinct()
  20501. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20502. watch.Stop();
  20503. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20504. }
  20505. /// <summary>
  20506. /// 查看邀请方
  20507. /// 团组 & 邀请方信息
  20508. /// </summary>
  20509. /// <param name="dto"></param>
  20510. /// <returns></returns>
  20511. [HttpPost]
  20512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20513. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20514. {
  20515. var watch = new Stopwatch();
  20516. watch.Start();
  20517. RefAsync<int> total = 0;
  20518. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20519. .AS("Grp_DelegationInfo")
  20520. .Includes(x => x.InvitingInfos)
  20521. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20522. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20523. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20524. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20525. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20526. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20527. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20528. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20529. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20530. infos.ForEach(x =>
  20531. {
  20532. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20533. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20534. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20535. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20536. });
  20537. watch.Stop();
  20538. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20539. }
  20540. #endregion
  20541. #region 报批行程
  20542. /// <summary>
  20543. /// 报批行程初始化
  20544. /// </summary>
  20545. /// <param name="dto"></param>
  20546. /// <returns></returns>
  20547. [HttpPost]
  20548. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20549. {
  20550. const int chiNumber = 5;
  20551. var jw = JsonView(false);
  20552. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20553. var group = groupList.First();
  20554. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20555. group = groupList.First(x => x.Id == diid);
  20556. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20557. .Where(x => x.DiId == diid && x.IsDel == 0)
  20558. .ToArray();
  20559. var count = 1;
  20560. foreach (var item in blackCodeList)
  20561. {
  20562. if (string.IsNullOrWhiteSpace(item.Title))
  20563. {
  20564. item.Title = "未设置名称数据" + count;
  20565. }
  20566. count++;
  20567. };
  20568. if (group == null)
  20569. {
  20570. jw.Msg = "暂无团组!";
  20571. return Ok(jw);
  20572. }
  20573. var data = new
  20574. {
  20575. groupList = groupList.Select(x => new
  20576. {
  20577. x.TeamName,
  20578. x.Id
  20579. }),
  20580. content = new ArrayList(),
  20581. groupInfo = new
  20582. {
  20583. group.VisitDays,
  20584. group.TourCode,
  20585. group.VisitPNumber,
  20586. group.TeamName,
  20587. group.Id,
  20588. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20589. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  20590. },
  20591. blackCodeList = blackCodeList.Select(x => new
  20592. {
  20593. x.Title,
  20594. x.Id
  20595. }),
  20596. FileTempList = new ArrayList()
  20597. {
  20598. new { Index = 1,FileName = "旧模板" },
  20599. new { Index = 2,FileName = "省外办" },
  20600. new { Index = 3,FileName = "市外办" },
  20601. }
  20602. };
  20603. var resultArr = new ArrayList();
  20604. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20605. #region 默认不生成行程
  20606. //if (content.Count == 0)
  20607. //{
  20608. // var stay = "-";
  20609. // var cityPath = "-";
  20610. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20611. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20612. // .ToList();
  20613. // //添加城市路径以及住宿地
  20614. // //黑屏代码数据
  20615. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20616. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20617. // {
  20618. // jw = JsonView(true, "黑屏代码有误!", data);
  20619. // return Ok(jw);
  20620. // }
  20621. // data = data with
  20622. // {
  20623. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20624. // {
  20625. // x.Title,
  20626. // x.Id,
  20627. // }).ToArray())
  20628. // };
  20629. // foreach (DataRow row in dtBlack.Rows)
  20630. // {
  20631. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20632. // {
  20633. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20634. // return Ok(jw);
  20635. // }
  20636. // }
  20637. // //黑屏代码获取时间区间
  20638. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20639. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20640. // _sqlSugar.BeginTran();
  20641. // for (int i = 0; i < timeArr.Count; i++)
  20642. // {
  20643. // stay = "-";
  20644. // cityPath = "-";
  20645. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20646. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20647. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20648. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20649. // if (tbSelect.Length > 0)
  20650. // {
  20651. // List<string> threeCodeStr = new List<string>();
  20652. // foreach (var item in tbSelect)
  20653. // {
  20654. // var threeCode = item["Three"].ToString() ?? "";
  20655. // if (threeCode.Length == 6)
  20656. // {
  20657. // var start = threeCode.Substring(0, 3);
  20658. // var end = threeCode.Substring(3, 3);
  20659. // if (threeCodeStr.Count == 0)
  20660. // {
  20661. // threeCodeStr.Add(start);
  20662. // threeCodeStr.Add(end);
  20663. // }
  20664. // else
  20665. // {
  20666. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20667. // {
  20668. // threeCodeStr.Add(end);
  20669. // }
  20670. // else
  20671. // {
  20672. // threeCodeStr.Add(start);
  20673. // threeCodeStr.Add(end);
  20674. // }
  20675. // }
  20676. // }
  20677. // }
  20678. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20679. // var last = threeCodeStr.Last();
  20680. // foreach (var item in threeCodeStr)
  20681. // {
  20682. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20683. // if (item.Equals(last))
  20684. // {
  20685. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20686. // }
  20687. // }
  20688. // cityPath = cityPath.Trim('-');
  20689. // }
  20690. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  20691. // appro.Diid = diid ?? -1;
  20692. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20693. // appro.Id = thisId;
  20694. // appro.CreateUserId = dto.UserId;
  20695. // appro.CreateTime = DateTime.Now;
  20696. // content.Add(appro);
  20697. // }
  20698. // _sqlSugar.CommitTran();
  20699. //}
  20700. #endregion
  20701. foreach (var x in content)
  20702. {
  20703. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  20704. if (chiList.Count < chiNumber)
  20705. {
  20706. for (int i = chiList.Count; i < chiNumber; i++)
  20707. {
  20708. chiList.Add(new Grp_ApprovalTravelDetails());
  20709. }
  20710. }
  20711. resultArr.Add(new
  20712. {
  20713. x.Id,
  20714. x.Date,
  20715. x.Diid,
  20716. chiList = chiList.Select(x1 => new
  20717. {
  20718. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20719. x1.Details,
  20720. x1.ParentId,
  20721. x1.Id
  20722. })
  20723. });
  20724. }
  20725. data = data with
  20726. {
  20727. content = resultArr,
  20728. };
  20729. jw = JsonView(true, "获取成功!", data);
  20730. return Ok(jw);
  20731. }
  20732. /// <summary>
  20733. /// 报批行程删除
  20734. /// </summary>
  20735. /// <param name="dto"></param>
  20736. /// <returns></returns>
  20737. [HttpPost]
  20738. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  20739. {
  20740. var jw = JsonView(false);
  20741. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20742. if (group == null)
  20743. {
  20744. jw.Msg = "团组参数有误!";
  20745. return Ok(jw);
  20746. }
  20747. try
  20748. {
  20749. _sqlSugar.BeginTran();
  20750. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  20751. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  20752. {
  20753. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20754. DeleteUserId = dto.uesrId,
  20755. IsDel = 1
  20756. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  20757. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  20758. {
  20759. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20760. DeleteUserId = dto.uesrId,
  20761. IsDel = 1
  20762. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  20763. _sqlSugar.CommitTran();
  20764. jw = JsonView(true, "删除成功");
  20765. }
  20766. catch (Exception ex)
  20767. {
  20768. jw = JsonView(false, ex.Message);
  20769. }
  20770. return Ok(jw);
  20771. }
  20772. /// <summary>
  20773. /// 报批行程保存
  20774. /// </summary>
  20775. /// <param name="dto"></param>
  20776. /// <returns></returns>
  20777. [HttpPost]
  20778. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  20779. {
  20780. var jw = JsonView(false);
  20781. var Find = dto.Arr.Find(x => x.id == 0);
  20782. if (Find != null)
  20783. {
  20784. jw.Msg = "生成的ID为0!";
  20785. return Ok(jw);
  20786. }
  20787. foreach (var item in dto.Arr)
  20788. {
  20789. foreach (var chi in item.chiList)
  20790. {
  20791. if (chi.parentId == 0)
  20792. {
  20793. chi.parentId = item.id;
  20794. }
  20795. }
  20796. }
  20797. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  20798. _sqlSugar.BeginTran();
  20799. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  20800. {
  20801. var parentIds = dto.Arr.Select(x => x.id).ToList();
  20802. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  20803. {
  20804. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20805. DeleteUserId = dto.UserId,
  20806. IsDel = 1
  20807. }).ExecuteCommand();
  20808. }
  20809. try
  20810. {
  20811. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  20812. {
  20813. CreateTime = DateTime.Now,
  20814. CreateUserId = dto.UserId,
  20815. Details = x.details,
  20816. ParentId = x.parentId,
  20817. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20818. Remark = "",
  20819. IsDel = 0
  20820. }).ToList()).ExecuteCommand();
  20821. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  20822. {
  20823. Id = x.id,
  20824. Details = x.details,
  20825. ParentId = x.parentId,
  20826. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20827. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  20828. {
  20829. Details = x.Details,
  20830. ParentId = x.ParentId,
  20831. Time = x.Time
  20832. }).ExecuteCommand();
  20833. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  20834. {
  20835. Id = x.id,
  20836. Date = x.date,
  20837. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  20838. {
  20839. Date = x.Date
  20840. }).ExecuteCommand();
  20841. _sqlSugar.CommitTran();
  20842. jw = JsonView(true, "保存成功!");
  20843. }
  20844. catch (Exception ex)
  20845. {
  20846. _sqlSugar.RollbackTran();
  20847. jw = JsonView(false, "保存失败!" + ex.Message);
  20848. }
  20849. return Ok(jw);
  20850. }
  20851. /// <summary>
  20852. /// 报批行程生成
  20853. /// </summary>
  20854. /// <param name="dto"></param>
  20855. /// <returns></returns>
  20856. [HttpPost]
  20857. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  20858. {
  20859. var jw = JsonView(false);
  20860. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20861. if (group == null)
  20862. {
  20863. jw.Msg = "暂无该团组!";
  20864. return Ok(jw);
  20865. }
  20866. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  20867. //黑屏代码数据
  20868. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  20869. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20870. {
  20871. jw.Msg = "黑屏代码有误!";
  20872. return Ok(jw);
  20873. }
  20874. foreach (DataRow row in dtBlack.Rows)
  20875. {
  20876. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20877. {
  20878. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  20879. return Ok(jw);
  20880. }
  20881. }
  20882. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  20883. var resultArr = new ArrayList();
  20884. //if (officialActivitiesArr.Count == 0)
  20885. //{
  20886. // jw.Msg = "暂无公务出访信息!";
  20887. // return Ok(jw);
  20888. //}
  20889. try
  20890. {
  20891. _sqlSugar.BeginTran();
  20892. DeleteApprovalJourney(new
  20893. Domain.Dtos.Groups.DeleteApprovalJourney
  20894. {
  20895. Diid = dto.Diid,
  20896. uesrId = dto.Userid
  20897. });
  20898. var stay = "-";
  20899. var cityPath = "-";
  20900. var arriveCountry = string.Empty;
  20901. //添加城市路径以及住宿地
  20902. //黑屏代码获取时间区间
  20903. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20904. var empty = "【未收入该三字码!请机票同事录入】";
  20905. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20906. #region 配置公务活动时间
  20907. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  20908. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  20909. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  20910. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  20911. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  20912. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20913. {
  20914. 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" }),
  20915. 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"}),
  20916. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20917. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  20918. };
  20919. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20920. {
  20921. 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" }),
  20922. 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"}),
  20923. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20924. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  20925. };
  20926. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  20927. {
  20928. 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" }),
  20929. 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"}),
  20930. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  20931. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  20932. };
  20933. #endregion
  20934. var nextDayNum = 0;
  20935. for (int i = 0; i < timeArr.Count; i++)
  20936. {
  20937. stay = "-";
  20938. cityPath = "-";
  20939. var chiarr = new List<Grp_ApprovalTravelDetails>();
  20940. DateTime NewData = DateTime.Parse(timeArr[i]);
  20941. //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();
  20942. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20943. if (nextDayNum > 0)
  20944. {
  20945. nextDayNum--;
  20946. }
  20947. if (tbSelect.Length > 0)
  20948. {
  20949. List<string> threeCodeStr = new List<string>();
  20950. bool isTrade = false;
  20951. string trip = string.Empty;
  20952. foreach (var item in tbSelect)
  20953. {
  20954. if (nextDayNum == 0)
  20955. {
  20956. nextDayNum = Convert.ToInt32(item["Sign"]);
  20957. }
  20958. var airStartTime = item["StartTime"].ToString() ?? "0000";
  20959. var airEndTime = item["EndTime"].ToString() ?? "0000";
  20960. var takeOffTime = DateTime.Parse(timeArr[i]);
  20961. var fallToTime = DateTime.Parse(timeArr[i]);
  20962. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  20963. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  20964. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  20965. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  20966. if (nextDayNum > 0)
  20967. {
  20968. fallToTime = fallToTime.AddDays(nextDayNum);
  20969. }
  20970. trip = string.Empty;
  20971. var start = string.Empty;
  20972. var end = string.Empty;
  20973. var threeCode = item["Three"].ToString() ?? "";
  20974. if (threeCode.Length == 6)
  20975. {
  20976. start = threeCode.Substring(0, 3);
  20977. end = threeCode.Substring(3, 3);
  20978. if (threeCodeStr.Count == 0)
  20979. {
  20980. threeCodeStr.Add(start);
  20981. threeCodeStr.Add(end);
  20982. }
  20983. else
  20984. {
  20985. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20986. {
  20987. threeCodeStr.Add(end);
  20988. }
  20989. else
  20990. {
  20991. threeCodeStr.Add(start);
  20992. threeCodeStr.Add(end);
  20993. }
  20994. }
  20995. }
  20996. //处理机票信息
  20997. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  20998. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  20999. if (start_Object == null)
  21000. {
  21001. start_Object = new Res_ThreeCode()
  21002. {
  21003. AirPort = empty,
  21004. AirPort_En = empty,
  21005. City = empty,
  21006. Country = empty,
  21007. Four = empty,
  21008. Three = empty,
  21009. };
  21010. }
  21011. if (end_Object == null)
  21012. {
  21013. end_Object = new Res_ThreeCode()
  21014. {
  21015. AirPort = empty,
  21016. AirPort_En = empty,
  21017. City = empty,
  21018. Country = empty,
  21019. Four = empty,
  21020. Three = empty,
  21021. };
  21022. }
  21023. //机型判断
  21024. string airModel = item["AirModel"].ToString();
  21025. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21026. string flightTime = item["FlightTime"].ToString();
  21027. flightTime = ParseBlackTime(flightTime);
  21028. //航班号
  21029. string flightcode = item["Fliagtcode"].ToString();
  21030. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21031. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21032. if (aircompany == null)
  21033. {
  21034. aircompany = new Res_AirCompany
  21035. {
  21036. CnName = hsEmpty,
  21037. EnName = hsEmpty,
  21038. ShortCode = hsEmpty,
  21039. };
  21040. }
  21041. //航班前公务安排
  21042. if (tbSelect.First().Equals(item) && i != 0)
  21043. {
  21044. foreach (var takeoff in takeoffTimes)
  21045. {
  21046. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21047. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21048. {
  21049. foreach (var addTime in takeoff.Item2)
  21050. {
  21051. chiarr.Add(new Grp_ApprovalTravelDetails
  21052. {
  21053. Time = addTime,
  21054. CreateTime = DateTime.Now,
  21055. CreateUserId = dto.Userid,
  21056. ParentId = 0,
  21057. Details = "公务活动"
  21058. });
  21059. }
  21060. break;
  21061. }
  21062. }
  21063. }
  21064. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21065. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21066. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21067. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21068. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21069. if (isTrade)
  21070. {
  21071. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21072. trip += "(转机不出机场)。";
  21073. }
  21074. //else
  21075. //{
  21076. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21077. //}
  21078. chiarr.Add(new Grp_ApprovalTravelDetails
  21079. {
  21080. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21081. CreateTime = DateTime.Now,
  21082. CreateUserId = dto.Userid,
  21083. ParentId = 0,
  21084. Details = trip
  21085. });
  21086. //最后一条到达的时间安排公务
  21087. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21088. {
  21089. bool isCheckCountry = false;
  21090. if (end_Object.Country != arriveCountry)
  21091. {
  21092. arriveCountry = end_Object.Country;
  21093. isCheckCountry = true;
  21094. }
  21095. if (nextDayNum == 0)
  21096. {
  21097. //需要入境的情况
  21098. if (isCheckCountry)
  21099. {
  21100. foreach (var fallTime in fallTimesCheckCountry)
  21101. {
  21102. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21103. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21104. {
  21105. foreach (var addTime in fallTime.Item2)
  21106. {
  21107. chiarr.Add(new Grp_ApprovalTravelDetails
  21108. {
  21109. Time = addTime,
  21110. CreateTime = DateTime.Now,
  21111. CreateUserId = dto.Userid,
  21112. ParentId = 0,
  21113. Details = "公务活动"
  21114. });
  21115. }
  21116. break;
  21117. }
  21118. }
  21119. }
  21120. else
  21121. {
  21122. foreach (var fallTime in fallTimesNotCheckCountry)
  21123. {
  21124. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21125. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21126. {
  21127. foreach (var addTime in fallTime.Item2)
  21128. {
  21129. chiarr.Add(new Grp_ApprovalTravelDetails
  21130. {
  21131. Time = addTime,
  21132. CreateTime = DateTime.Now,
  21133. CreateUserId = dto.Userid,
  21134. ParentId = 0,
  21135. Details = "公务活动"
  21136. });
  21137. }
  21138. break;
  21139. }
  21140. }
  21141. }
  21142. }
  21143. }
  21144. }
  21145. //添加乘车语句
  21146. //chiarr.Add(new Grp_ApprovalTravelDetails
  21147. //{
  21148. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21149. // CreateTime = DateTime.Now,
  21150. // CreateUserId = dto.Userid,
  21151. // ParentId = 0,
  21152. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21153. //});
  21154. //if (i != timeArr.Count - 1)
  21155. //{
  21156. // fallToTime = fallToTime.AddHours(2.5);
  21157. // foreach (var item in Times)
  21158. // {
  21159. // //排列公务时间
  21160. // if (fallToTime.Hour < item.Item1)
  21161. // {
  21162. // chiarr.Add(new Grp_ApprovalTravelDetails
  21163. // {
  21164. // Time = $"{item.Item2} - {item.Item3}",
  21165. // CreateTime = DateTime.Now,
  21166. // CreateUserId = dto.Userid,
  21167. // ParentId = 0,
  21168. // Details = "公务活动"
  21169. // });
  21170. // }
  21171. // }
  21172. //}
  21173. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21174. var last = threeCodeStr.Last();
  21175. foreach (var item in threeCodeStr)
  21176. {
  21177. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21178. if (item.Equals(last))
  21179. {
  21180. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21181. }
  21182. }
  21183. cityPath = cityPath.Trim('-');
  21184. }
  21185. else
  21186. {
  21187. foreach (var item in Times)
  21188. {
  21189. chiarr.Add(new Grp_ApprovalTravelDetails
  21190. {
  21191. Time = $"{item.Item2} - {item.Item3}",
  21192. CreateTime = DateTime.Now,
  21193. CreateUserId = dto.Userid,
  21194. ParentId = 0,
  21195. Details = "公务活动"
  21196. });
  21197. }
  21198. }
  21199. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21200. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21201. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21202. appro.Diid = dto.Diid;
  21203. appro.CreateUserId = dto.Userid;
  21204. appro.CreateTime = DateTime.Now;
  21205. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21206. appro.Id = thisId;
  21207. //foreach (var item in gwinfo)
  21208. //{
  21209. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21210. // chi.Details = "拜访" + item.Client;
  21211. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21212. // {
  21213. // chi.Details += "," + item.ReqSample;
  21214. // }
  21215. // chi.ParentId = thisId;
  21216. // chi.Time = item.Time;
  21217. // chiarr.Add(chi);
  21218. //}
  21219. if (chiarr.Count < 6)
  21220. {
  21221. for (int j = chiarr.Count; j < 6; j++)
  21222. {
  21223. chiarr.Add(new
  21224. Grp_ApprovalTravelDetails());
  21225. }
  21226. }
  21227. resultArr.Add(new
  21228. {
  21229. appro.Id,
  21230. appro.Date,
  21231. appro.Diid,
  21232. chiList = chiarr.Select(x1 => new
  21233. {
  21234. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21235. x1.Details,
  21236. x1.ParentId,
  21237. x1.Id
  21238. })
  21239. });
  21240. }
  21241. _sqlSugar.CommitTran();
  21242. jw = JsonView(true, "生成成功!", resultArr);
  21243. }
  21244. catch (Exception ex)
  21245. {
  21246. jw.Code = 400;
  21247. jw.Msg = "生成失败!" + ex.Message;
  21248. }
  21249. return Ok(jw);
  21250. }
  21251. /// <summary>
  21252. /// 报批行程word导出
  21253. /// </summary>
  21254. /// <param name="dto"></param>
  21255. /// <returns></returns>
  21256. [HttpPost]
  21257. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21258. {
  21259. var jw = JsonView(false);
  21260. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21261. if (group == null)
  21262. {
  21263. jw.Msg = "暂无该团组!";
  21264. return Ok(jw);
  21265. }
  21266. //模板路径
  21267. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21268. var fileName = string.Empty;
  21269. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21270. bool bold = false;
  21271. if (dto.FileIndex == 1)
  21272. {
  21273. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21274. }
  21275. else if (dto.FileIndex == 2)
  21276. {
  21277. fileName = "省外办-报批.docx";
  21278. bold = false;
  21279. titleFont = "方正黑体简体";
  21280. timeFont = "Times New Roman";
  21281. contentFont = "方正仿宋_GBK";
  21282. }
  21283. else if (dto.FileIndex == 3)
  21284. {
  21285. fileName = "市外办-报批.docx";
  21286. titleFont = "方正黑体简体";
  21287. timeFont = "Times New Roman";
  21288. contentFont = "方正仿宋简体";
  21289. }
  21290. tempPath = tempPath + fileName;
  21291. //载入模板
  21292. Document doc = new Document(tempPath);
  21293. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21294. //获取所填表格的序数
  21295. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21296. Aspose.Words.Tables.Row titleRowClone = null;
  21297. Aspose.Words.Tables.Row CenterRowClone = null;
  21298. int index = 0;
  21299. int indexChi = 0;
  21300. int SetIndex = 0;
  21301. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21302. //获取数据,放到datatable
  21303. foreach (var item in ApprovalTravelArr)
  21304. {
  21305. if (index > 0)
  21306. {
  21307. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21308. tableOne.AppendChild(titleRowClone);
  21309. }
  21310. var textTime = item.Date;
  21311. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21312. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21313. SetIndex++;
  21314. if (ChiRep.Count > 0)
  21315. {
  21316. foreach (var itemChi in ChiRep)
  21317. {
  21318. var txtTime = itemChi.Time;
  21319. var txtDetail = itemChi.Details;
  21320. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21321. {
  21322. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21323. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21324. //indexChi++;
  21325. //SetIndex++;
  21326. break;
  21327. }
  21328. if (indexChi > 0)
  21329. {
  21330. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21331. tableOne.AppendChild(CenterRowClone);
  21332. }
  21333. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21334. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21335. indexChi++;
  21336. SetIndex++;
  21337. }
  21338. }
  21339. //else
  21340. //{
  21341. // if (indexChi > 0)
  21342. // {
  21343. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21344. // tableOne.AppendChild(CenterRowClone);
  21345. // }
  21346. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21347. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21348. // indexChi++;
  21349. // SetIndex++;
  21350. //}
  21351. index++;
  21352. }
  21353. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21354. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21355. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21356. jw.Code = 200;
  21357. jw.Msg = "";
  21358. return Ok(jw);
  21359. }
  21360. private string ParseBlackTime(string time)
  21361. {
  21362. // 匹配可能只有分钟的情况
  21363. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21364. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21365. if (match.Success)
  21366. {
  21367. string hours = match.Groups[1].Value;
  21368. string minutes = match.Groups[2].Value;
  21369. // 如果小时部分为空,则只显示分钟
  21370. if (string.IsNullOrEmpty(hours))
  21371. {
  21372. return $"{minutes}分钟";
  21373. }
  21374. // 如果分钟部分为空,则只显示小时
  21375. else if (string.IsNullOrEmpty(minutes))
  21376. {
  21377. return $"{hours}小时";
  21378. }
  21379. // 否则显示完整格式
  21380. else
  21381. {
  21382. return $"{hours}小时{minutes}分钟";
  21383. }
  21384. }
  21385. else
  21386. {
  21387. return "未知时长";
  21388. }
  21389. }
  21390. private string intToString(int numberVal)
  21391. {
  21392. string numberval = numberVal.ToString();
  21393. Dictionary<char, string> Number = new Dictionary<char, string>();
  21394. Number.Add('1', "一");
  21395. Number.Add('2', "二");
  21396. Number.Add('3', "三");
  21397. Number.Add('4', "四");
  21398. Number.Add('5', "五");
  21399. Number.Add('6', "六");
  21400. Number.Add('7', "七");
  21401. Number.Add('8', "八");
  21402. Number.Add('9', "九");
  21403. string stringNumberVal = string.Empty;
  21404. for (int i = 0; i < numberval.Length; i++)
  21405. {
  21406. if (i == 0)
  21407. {
  21408. stringNumberVal += Number[numberval[i]];
  21409. }
  21410. else if (i >= 1)
  21411. {
  21412. if (numberval[i] == '0')
  21413. {
  21414. stringNumberVal = "十";
  21415. }
  21416. else
  21417. {
  21418. stringNumberVal += "十" + Number[numberval[i]];
  21419. }
  21420. }
  21421. }
  21422. return stringNumberVal;
  21423. }
  21424. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21425. {
  21426. //获取table中的某个单元格,从0开始
  21427. Cell lshCell = table.Rows[rows].Cells[cells];
  21428. //将单元格中段落移除
  21429. foreach (Paragraph item in lshCell.Paragraphs)
  21430. {
  21431. lshCell.Paragraphs.Remove(item);
  21432. }
  21433. if (val.Contains("\r\n"))
  21434. {
  21435. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21436. foreach (var item in spArr)
  21437. {
  21438. //新建一个段落
  21439. Paragraph p = new Paragraph(doc);
  21440. var r = new Run(doc, item);
  21441. //设置字体
  21442. if (!string.IsNullOrEmpty(font))
  21443. {
  21444. r.Font.Name = font;
  21445. }
  21446. r.Font.Bold = bold;
  21447. //把设置的值赋给之前新建的段落
  21448. p.AppendChild(r);
  21449. //将此段落加到单元格内
  21450. lshCell.AppendChild(p);
  21451. }
  21452. }
  21453. else
  21454. {
  21455. //新建一个段落
  21456. Paragraph p = new Paragraph(doc);
  21457. var r = new Run(doc, val);
  21458. //设置字体
  21459. if (!string.IsNullOrEmpty(font))
  21460. {
  21461. r.Font.Name = font;
  21462. }
  21463. r.Font.Bold = bold;
  21464. //把设置的值赋给之前新建的段落
  21465. p.AppendChild(r);
  21466. //将此段落加到单元格内
  21467. lshCell.AppendChild(p);
  21468. }
  21469. }
  21470. //[HttpPost]
  21471. //public async Task<IActionResult> ServerHttp(string paramStr)
  21472. //{
  21473. // paramStr = paramStr.TrimEnd('\'');
  21474. // paramStr = paramStr.TrimStart('\'');
  21475. // JsonView jw = JsonView(false);
  21476. // JObject param = JObject.Parse(paramStr);
  21477. // if (!param.ContainsKey("url"))
  21478. // {
  21479. // jw.Msg = "url null";
  21480. // return Ok(jw);
  21481. // }
  21482. // string url = param["url"]!.ToString();
  21483. // var methon = "get";
  21484. // Dictionary<string, string> headValues = null;
  21485. // string bodyStr = string.Empty;
  21486. // if (param.ContainsKey("methon"))
  21487. // {
  21488. // methon = param["methon"]!.ToString().ToLower();
  21489. // }
  21490. // if (param.ContainsKey("header"))
  21491. // {
  21492. // var header = param["header"]!.ToString();
  21493. // JObject headerJobject = JObject.Parse(header);
  21494. // headValues = new Dictionary<string, string>();
  21495. // foreach (JProperty item in headerJobject.Properties())
  21496. // {
  21497. // var value = item.Value.ToString();
  21498. // var head = item.Path;
  21499. // headValues.Add(head, value);
  21500. // }
  21501. // }
  21502. // HttpClient client = new HttpClient();
  21503. // string responseString = string.Empty;
  21504. // StringContent content = null;
  21505. // if (headValues != null)
  21506. // {
  21507. // foreach (var item in headValues.Keys)
  21508. // {
  21509. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  21510. // {
  21511. // if (param.ContainsKey("body"))
  21512. // {
  21513. // bodyStr = param["body"]!.ToString();
  21514. // }
  21515. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  21516. // }
  21517. // else
  21518. // {
  21519. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  21520. // }
  21521. // }
  21522. // }
  21523. // try
  21524. // {
  21525. // if (methon == "get")
  21526. // {
  21527. // responseString = await client.GetStringAsync(url);
  21528. // }
  21529. // else if (methon == "post")
  21530. // {
  21531. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  21532. // {
  21533. // Content = content
  21534. // };
  21535. // var response = await client.SendAsync(request);
  21536. // try
  21537. // {
  21538. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  21539. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  21540. // {
  21541. // using (StreamReader reader = new StreamReader(gzipStream))
  21542. // {
  21543. // responseString = await reader.ReadToEndAsync();
  21544. // }
  21545. // }
  21546. // }
  21547. // catch (Exception)
  21548. // {
  21549. // responseString = await response.Content.ReadAsStringAsync();
  21550. // }
  21551. // }
  21552. // else
  21553. // {
  21554. // responseString = "methon error";
  21555. // }
  21556. // jw = JsonView(true, "success", responseString);
  21557. // }
  21558. // catch (Exception ex)
  21559. // {
  21560. // jw.Msg = "error " + ex.Message;
  21561. // jw.Data = ex.StackTrace;
  21562. // }
  21563. // finally
  21564. // {
  21565. // client.Dispose();
  21566. // }
  21567. // return Ok(jw);
  21568. //}
  21569. #endregion
  21570. #region 团组接待意见调查
  21571. /// <summary>
  21572. /// 团组接待意见调查 - 信息管理
  21573. /// 基础数据(团组)
  21574. /// </summary>
  21575. /// <returns></returns>
  21576. [HttpGet]
  21577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21578. public async Task<IActionResult> OpinionaireInit()
  21579. {
  21580. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21581. .Select(x => new
  21582. {
  21583. x.Id,
  21584. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21585. })
  21586. .OrderByDescending(x => x.Id)
  21587. .ToListAsync();
  21588. return Ok(JsonView(groupData, groupData.Count));
  21589. }
  21590. /// <summary>
  21591. /// 团组接待意见调查 - 信息管理
  21592. /// 列表
  21593. /// </summary>
  21594. /// <param name="groupId"></param>
  21595. /// <returns></returns>
  21596. [HttpGet("{groupId}")]
  21597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21598. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21599. {
  21600. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21601. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21602. .Select(x => new
  21603. {
  21604. x.Id,
  21605. x.TourGuideName,
  21606. x.CityName,
  21607. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21608. x.CreateTime
  21609. })
  21610. .OrderBy(x => x.Id)
  21611. .ToListAsync();
  21612. return Ok(JsonView(data));
  21613. }
  21614. /// <summary>
  21615. /// 团组接待意见调查 - 信息管理
  21616. /// 保存
  21617. /// </summary>
  21618. /// <param name="dto"></param>
  21619. /// <returns></returns>
  21620. [HttpPost]
  21621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21622. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21623. {
  21624. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21625. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21626. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21627. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21628. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21629. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21630. _opinionaireRep.BeginTran();
  21631. if (addData != null && addData.Count > 0)
  21632. {
  21633. foreach (var item in addData)
  21634. {
  21635. item.CreateUserId = currUserInfo.UserId;
  21636. item.DiId = dto.DiId;
  21637. }
  21638. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21639. }
  21640. if (updData != null && updData.Count > 0)
  21641. {
  21642. var upd = await _opinionaireRep._sqlSugar
  21643. .Updateable(updData)
  21644. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21645. .WhereColumns(x => new { x.Id })
  21646. .ExecuteCommandAsync();
  21647. }
  21648. _opinionaireRep.CommitTran();
  21649. return Ok(JsonView("操作成功!"));
  21650. }
  21651. /// <summary>
  21652. /// 团组接待意见调查 - 信息管理
  21653. /// 删除
  21654. /// </summary>
  21655. /// <param name="id"></param>
  21656. /// <returns></returns>
  21657. [HttpDelete("{id}")]
  21658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21659. public async Task<IActionResult> OpinionaireManageDel(int id)
  21660. {
  21661. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21662. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21663. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21664. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21665. if (!del) return Ok(JsonView("操作失败!"));
  21666. return Ok(JsonView("操作成功!"));
  21667. }
  21668. /// <summary>
  21669. /// 团组接待意见调查 - 用户
  21670. /// 列表
  21671. /// </summary>
  21672. /// <param name="diId"></param>
  21673. /// <returns></returns>
  21674. [HttpGet("{diId}")]
  21675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21676. public async Task<IActionResult> OpinionaireUserList(int diId)
  21677. {
  21678. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21679. var sql = string.Format(@"
  21680. SELECT
  21681. o.Id,
  21682. o.DiId,
  21683. di.TeamName AS 'GroupName',
  21684. di.VisitPNumber AS 'PeopleNumber',
  21685. di.ClientName AS 'LeadGroup',
  21686. di.VisitCountry AS 'Travel',
  21687. di.VisitDays AS 'Days',
  21688. o.CityName,
  21689. o.TourGuideName,
  21690. o.Catering,
  21691. o.CateringReason,
  21692. o.Stay,
  21693. o.StayReason,
  21694. o.[Route],
  21695. o.RouteReason,
  21696. o.OfficialActivity,
  21697. o.OfficialActivityReason,
  21698. o.TourGuide,
  21699. o.TourGuideReason,
  21700. o.[Translate],
  21701. o.TranslateReason,
  21702. o.Trip,
  21703. o.TripReason,
  21704. o.ESFileName,
  21705. o.SignatureDate,
  21706. o.Remark
  21707. FROM
  21708. Grp_Opinionaire o
  21709. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21710. WHERE
  21711. o.IsDel = 0
  21712. AND o.DiId = {0}
  21713. ORDER BY
  21714. o.Id ASC", diId);
  21715. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21716. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21717. return Ok(JsonView(data));
  21718. }
  21719. /// <summary>
  21720. /// 团组接待意见调查 - 用户
  21721. /// 保存
  21722. /// </summary>
  21723. /// <param name="dto"></param>
  21724. /// <returns></returns>
  21725. [HttpPost]
  21726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21727. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21728. {
  21729. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21730. foreach (var item in dto)
  21731. {
  21732. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21733. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21734. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21735. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21736. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21737. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21738. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21739. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21740. }
  21741. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21742. if (!Directory.Exists(filePathBase))
  21743. {
  21744. Directory.CreateDirectory(filePathBase);
  21745. }
  21746. #region 上传文件
  21747. var filePaths = new List<string>();
  21748. foreach (var item in dto)
  21749. {
  21750. var file = item.File;
  21751. // 将文件保存到指定位置
  21752. var filePath = Path.Combine(filePathBase, file.FileName);
  21753. using (var stream = new FileStream(filePath, FileMode.Create))
  21754. {
  21755. await file.CopyToAsync(stream);
  21756. }
  21757. //验证文件是否上传成功
  21758. if (!System.IO.File.Exists(filePath))
  21759. {
  21760. foreach (var filePathStr in filePaths)
  21761. {
  21762. System.IO.File.Delete(filePathStr);
  21763. }
  21764. return Ok(JsonView(false, "文件上传失败!"));
  21765. }
  21766. item.ESFileName = file.FileName;
  21767. }
  21768. #endregion
  21769. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  21770. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  21771. .UpdateColumns(x => new
  21772. {
  21773. x.Catering,
  21774. x.CateringReason,
  21775. x.Stay,
  21776. x.StayReason,
  21777. x.Route,
  21778. x.RouteReason,
  21779. x.OfficialActivity,
  21780. x.OfficialActivityReason,
  21781. x.TourGuide,
  21782. x.TourGuideReason,
  21783. x.Translate,
  21784. x.TranslateReason,
  21785. x.Trip,
  21786. x.TripReason,
  21787. x.ESFileName,
  21788. x.SignatureDate,
  21789. x.Remark
  21790. })
  21791. .WhereColumns(x => new { x.Id })
  21792. .ExecuteCommandAsync();
  21793. if (upd < 1)
  21794. {
  21795. foreach (var filePathStr in filePaths)
  21796. {
  21797. System.IO.File.Delete(filePathStr);
  21798. }
  21799. return Ok(JsonView(false));
  21800. }
  21801. return Ok(JsonView(true));
  21802. }
  21803. #endregion
  21804. #region 团组餐厅相关信息
  21805. /// <summary>
  21806. /// 团组相关餐厅信息
  21807. /// 基础数据(团组)
  21808. /// </summary>
  21809. /// <returns></returns>
  21810. [HttpGet]
  21811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21812. public async Task<IActionResult> RestaurantInit()
  21813. {
  21814. return Ok(await _restaurantRep.InitAsync());
  21815. }
  21816. /// <summary>
  21817. /// 团组相关餐厅信息
  21818. /// Item
  21819. /// </summary>
  21820. /// <param name="dto"></param>
  21821. /// <returns></returns>
  21822. [HttpPost]
  21823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21824. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  21825. {
  21826. int portType = dto.PortType,
  21827. groupId = dto.GroupId;
  21828. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21829. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21830. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  21831. }
  21832. /// <summary>
  21833. /// 团组相关餐厅信息
  21834. /// List
  21835. /// </summary>
  21836. /// <param name="dto"></param>
  21837. /// <returns></returns>
  21838. [HttpPost]
  21839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21840. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  21841. {
  21842. int portType = dto.PortType,
  21843. groupId = dto.GroupId;
  21844. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21845. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21846. var sql = string.Format(@" SELECT
  21847. ri.Id,
  21848. ri.GroupId,
  21849. ri.Date,
  21850. ri.StartTime,
  21851. ri.EndTime,
  21852. CASE WHEN ri.Type = 1 THEN '早餐'
  21853. WHEN ri.Type = 2 THEN '午餐'
  21854. WHEN ri.Type = 3 THEN '晚餐'
  21855. ELSE '其他'
  21856. END AS 'Type',
  21857. ri.Name,
  21858. ri.Address,
  21859. ri.Tel,
  21860. ri.Remark,
  21861. ri.CreateTime,
  21862. u.CnName AS CreateUserName
  21863. FROM
  21864. Grp_RestaurantInfo ri
  21865. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  21866. WHERE
  21867. ri.IsDel = 0
  21868. AND ri.GroupId = {0}
  21869. ORDER BY
  21870. ri.Date ASC
  21871. ", groupId);
  21872. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  21873. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  21874. return Ok(JsonView(infos));
  21875. }
  21876. /// <summary>
  21877. /// 团组相关餐厅信息
  21878. /// Info
  21879. /// </summary>
  21880. /// <param name="dto"></param>
  21881. /// <returns></returns>
  21882. [HttpPost]
  21883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21884. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  21885. {
  21886. int portType = dto.PortType,
  21887. id = dto.Id;
  21888. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21889. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21890. return Ok(await _restaurantRep.InfoAsync(portType, id));
  21891. }
  21892. /// <summary>
  21893. /// 团组相关餐厅信息
  21894. /// Op
  21895. /// </summary>
  21896. /// <param name="dto"></param>
  21897. /// <returns></returns>
  21898. [HttpPost]
  21899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21900. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  21901. {
  21902. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21903. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21904. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  21905. return Ok(await _restaurantRep.OpAsync(dto));
  21906. }
  21907. /// <summary>
  21908. /// 团组相关餐厅信息
  21909. /// Del
  21910. /// </summary>
  21911. /// <param name="dto"></param>
  21912. /// <returns></returns>
  21913. [HttpPost]
  21914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21915. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  21916. {
  21917. int userId = dto.DeleteUserId;
  21918. var id = dto.Id;
  21919. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21920. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21921. return Ok(await _restaurantRep.DelAsync(dto));
  21922. }
  21923. #endregion
  21924. // /// <summary>
  21925. // ///
  21926. // /// </summary>
  21927. // /// <param name="_dto"></param>
  21928. // /// <returns></returns>
  21929. // [HttpPost]
  21930. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21931. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21932. // {
  21933. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21934. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  21935. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  21936. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21937. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  21938. // dic_psg.Add("客人", 974);
  21939. // dic_psg.Add("司机", 975);
  21940. // dic_psg.Add("导游", 976);
  21941. // dic_psg.Add("公司内部人员", 977);
  21942. // dic_psg.Add("司机/导游/公司内部人员", 978);
  21943. // foreach (var item in list_visa)
  21944. // {
  21945. // Grp_VisaInfo temp = new Grp_VisaInfo();
  21946. // temp.Id = item.Id;
  21947. // temp.DIId = item.DIId;
  21948. // temp.VisaClient = item.VisaClient;
  21949. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  21950. // temp.VisaCurrency = item.VisaCurrency;
  21951. // temp.IsThird = item.IsThird;
  21952. // if (dic_psg.ContainsKey(item.PassengerType))
  21953. // {
  21954. // temp.PassengerType = dic_psg[item.PassengerType];
  21955. // }
  21956. // else {
  21957. // temp.PassengerType = -1;
  21958. // }
  21959. // temp.VisaNumber = item.VisaNumber;
  21960. // temp.VisaFreeNumber = item.VisaFreeNumber;
  21961. // temp.CreateUserId = item.Operators;
  21962. // DateTime dt_ct;
  21963. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  21964. // if (b_ct)
  21965. // {
  21966. // temp.CreateTime = dt_ct;
  21967. // }
  21968. // else
  21969. // {
  21970. // temp.CreateTime = DateTime.Now;
  21971. // }
  21972. // temp.DeleteTime = "";
  21973. // temp.DeleteUserId = 0;
  21974. // temp.Remark = item.Remark;
  21975. // if (string.IsNullOrEmpty(temp.Remark)) {
  21976. // temp.Remark = "";
  21977. // }
  21978. // temp.IsDel = item.IsDel;
  21979. // temp.VisaDescription = item.VisaAttachment;
  21980. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  21981. //([Id]
  21982. // ,[DIId]
  21983. // ,[VisaClient]
  21984. // ,[VisaPrice]
  21985. // ,[VisaCurrency]
  21986. // ,[IsThird]
  21987. // ,[PassengerType]
  21988. // ,[VisaNumber]
  21989. // ,[VisaFreeNumber]
  21990. // ,[CreateUserId]
  21991. // ,[CreateTime]
  21992. // ,[DeleteTime]
  21993. // ,[DeleteUserId]
  21994. // ,[Remark]
  21995. // ,[IsDel]
  21996. // ,[visaDescription])
  21997. // VALUES
  21998. // ({0},{1},'{2}',{3},{4}
  21999. //,{5},{6},{7},{8},{9}
  22000. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  22001. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  22002. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  22003. //);
  22004. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  22005. // }
  22006. // return Ok(JsonView(true, "操作成功!"));
  22007. // }
  22008. /// <summary>
  22009. /// 123132123
  22010. /// </summary>
  22011. /// <param name="_dto"></param>
  22012. /// <returns></returns>
  22013. [HttpPost]
  22014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22015. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22016. {
  22017. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22018. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22019. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22020. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22021. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22022. dicDetail.Add(789, 1034);
  22023. dicDetail.Add(790, 1035);
  22024. dicDetail.Add(791, 1036);
  22025. dicDetail.Add(792, 1037);
  22026. dicDetail.Add(793, 1038);
  22027. dicDetail.Add(794, 1039);
  22028. dicDetail.Add(795, 1040);
  22029. dicDetail.Add(796, 1041);
  22030. dicDetail.Add(797, 1042);
  22031. dicDetail.Add(798, 1043);
  22032. dicDetail.Add(801, 1044);
  22033. dicDetail.Add(802, 1045);
  22034. dicDetail.Add(803, 1046);
  22035. Dictionary<int, int> dic = new Dictionary<int, int>();
  22036. dic.Add(806, 1027);
  22037. dic.Add(807, 1028);
  22038. dic.Add(808, 1029);
  22039. dic.Add(809, 1030);
  22040. dic.Add(810, 1031);
  22041. dic.Add(811, 1032);
  22042. dic.Add(812, 1033);
  22043. foreach (var item in list_visa)
  22044. {
  22045. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22046. temp.Coefficient = item.coefficient;
  22047. DateTime dtCrt;
  22048. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22049. if (b1)
  22050. {
  22051. temp.CreateTime = dtCrt;
  22052. }
  22053. else
  22054. {
  22055. temp.CreateTime = DateTime.Now;
  22056. }
  22057. temp.CreateUserId = item.Operators;
  22058. temp.DeleteTime = "";
  22059. temp.DeleteUserId = 0;
  22060. temp.DiId = int.Parse(item.DIID);
  22061. temp.FilePath = item.FilePath;
  22062. temp.IsDel = item.IsDel;
  22063. temp.Price = item.Price;
  22064. temp.PriceCount = 1;
  22065. temp.PriceCurrency = item.Currency;
  22066. int detailId = 0;
  22067. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22068. {
  22069. detailId = dicDetail[item.PriceTypeDetail];
  22070. }
  22071. temp.PriceDetailType = detailId;
  22072. temp.PriceDt = DateTime.Now;
  22073. temp.PriceName = item.PriceName;
  22074. temp.PriceSum = item.Price;
  22075. int tid = 0;
  22076. if (dic.ContainsKey(item.PriceType))
  22077. {
  22078. tid = dic[item.PriceType];
  22079. }
  22080. temp.PriceType = tid;
  22081. temp.Remark = item.Remark;
  22082. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22083. }
  22084. return Ok(JsonView(true, "操作成功!"));
  22085. }
  22086. [HttpPost]
  22087. public IActionResult TimeTest()
  22088. {
  22089. var jw = JsonView(false, "error");
  22090. _sqlSugar.BeginTran();
  22091. try
  22092. {
  22093. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22094. .Select(x => new Crm_NewClientData
  22095. {
  22096. Id = x.Id,
  22097. Client = x.Client,
  22098. Contact = x.Contact,
  22099. Location = x.Location,
  22100. })
  22101. .ToList();
  22102. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22103. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22104. Stopwatch stopwatch = new Stopwatch();
  22105. // 开始计时
  22106. stopwatch.Start();
  22107. foreach (var item in clientList)
  22108. {
  22109. EncryptionProcessor.DecryptProperties(item);
  22110. }
  22111. stopwatch.Stop();
  22112. jw.Code = 200;
  22113. jw.Data = stopwatch.ElapsedMilliseconds;
  22114. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22115. }
  22116. catch (Exception ex)
  22117. {
  22118. jw.Code = 400;
  22119. jw.Msg = ex.Message;
  22120. }
  22121. return Ok(jw);
  22122. }
  22123. }
  22124. }